Commit d8da3d18 authored by NOUNAH Rabab's avatar NOUNAH Rabab
Browse files

Delete main.c

parent 2f598da2
#include "main.h"
#include <string.h>
// openocd -s /local/sdk_elec/openocd/share/openocd/scripts -f board/st_nucleo_f4.cfg -c init
extern TIM_HandleTypeDef TimHandle_period;
#define DYN_ID 1
#define DYN_ID2 2
//=====================================================================================
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> MAIN <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//=====================================================================================
int main(void)
{
HAL_Init(); // passage par stm32f4xx_hal_msp.c : configuration des broches
SystemClock_Config();
uart1_Init(); //zigbee
uart2_Init(); // CABLE
uart6_Init(); // dxlAMIXELS
tickTimer_Init(3000); // 3000 ms
i2c1_Init(); // Modifier stm32f4xx_hal_msp.c pour configurer les broches
spi1Init(); // Modifier stm32f4xx_hal_msp.c pour configurer les broches
HAL_Delay(500);
//------------------------------------------------------------
// TEST LIAISON SERIE
// ouvrir gtkterm ou minicom / /dev/ttyCAM0 baudrate : 115200-8-N-1
//------------------------------------------------------------
dxl_LED(DYN_ID, LED_ON);
HAL_Delay(500);
dxl_LED(DYN_ID, LED_OFF);
HAL_Delay(500);
dxl_LED(2, LED_ON);
HAL_Delay(500);
dxl_LED(2, LED_OFF);
HAL_Delay(500);
// dxl_LED(DYN_ID, LED_ON );
//
// HAL_Delay(500);
// dxl_LED(DYN_ID, LED_OFF);
// HAL_Delay(500);
// CHANGE BAUDRATE
/* dxl_setBaudrate(DYN_ID, 1);
dxl_factoryReset(DYN_ID);
*/
//dxl_torque(DYN_ID, TORQUE_OFF);
//dxl_torque(DYN_ID2, TORQUE_OFF);
//------------------------------------------------------------
// BLINK LED : PA5
//------------------------------------------------------------
while(1)
{
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, 1);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, 0);
//HAL_UART_Receive(&Uart1Handle,(uint8_t *)Rx_data,4,10);
// HAL_UART_Receive_IT(&Uart1Handle, (uint8_t *)rec_buf1,NB_CAR_TO_RECEIVE);
// term_printf(&rec_buf1);
term_printf_zigbee("a");
HAL_Delay(10); // 1000 ms
// int w = 1;
if(strcmp(rec_buf1,"a")==0){
dxl_setOperatingMode(DYN_ID, VELOCITY_MODE);
dxl_setOperatingMode(DYN_ID2, VELOCITY_MODE);
dxl_torque(DYN_ID, TORQUE_ON);
dxl_setGoalVelocity(DYN_ID, 210);
dxl_setOperatingMode(DYN_ID2, VELOCITY_MODE);
dxl_torque(DYN_ID2, TORQUE_ON);
dxl_setGoalVelocity(DYN_ID2, -210);
// HAL_Delay(2000);
}
if(strcmp(rec_buf1,"c")==0){
//--------------Rotation a droite -----------------
dxl_setOperatingMode(DYN_ID, VELOCITY_MODE);
dxl_setOperatingMode(DYN_ID2, VELOCITY_MODE);
dxl_torque(DYN_ID2, TORQUE_ON);
dxl_setGoalVelocity(DYN_ID2, 210);
//HAL_Delay(1000);
dxl_torque(DYN_ID, TORQUE_ON);
dxl_setGoalVelocity(DYN_ID, 210);
}
if(strcmp(rec_buf1,"b")==0){
//--------------Rotation a gauche -----------------
dxl_setOperatingMode(DYN_ID, VELOCITY_MODE);
dxl_setOperatingMode(DYN_ID2, VELOCITY_MODE);
dxl_torque(DYN_ID2, TORQUE_ON);
dxl_setGoalVelocity(DYN_ID2, -210);
dxl_torque(DYN_ID, TORQUE_ON);
dxl_setGoalVelocity(DYN_ID, -210);
}
if(strcmp(rec_buf1,"d")==0){
//---------- REtour en arriere --------------
dxl_setOperatingMode(DYN_ID, VELOCITY_MODE);
dxl_setOperatingMode(DYN_ID2, VELOCITY_MODE);
dxl_torque(DYN_ID, TORQUE_ON);
dxl_setGoalVelocity(DYN_ID, -210);
dxl_torque(DYN_ID2, TORQUE_ON);
dxl_setGoalVelocity(DYN_ID2, 210);
}
if(strcmp(rec_buf1,"e")==0){
//stop
dxl_setOperatingMode(DYN_ID, VELOCITY_MODE);
dxl_setOperatingMode(DYN_ID2, VELOCITY_MODE);
dxl_torque(DYN_ID, TORQUE_OFF);
//dxl_setGoalVelocity(DYN_ID, 210);
dxl_setOperatingMode(DYN_ID2, VELOCITY_MODE);
dxl_torque(DYN_ID2, TORQUE_OFF);
}
}
return 0;
}
//=====================================================================================
// GPIO EXTERNAL INTERRUPT CALLBACK
//=====================================================================================
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
switch(GPIO_Pin)
{
case GPIO_PIN_0 :
break;
case GPIO_PIN_13 : term_printf_zigbee("USER BUTTON PUSHED \n\r"); // USER BUTTON
break;
default : break;
}
}
//=====================================================================================
// TIMER INTERRUPT CALLBACK
//=====================================================================================
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if (htim==&TimHandle_period)
{
//term_printf_zigbee("Tick Timer period elapsed \n\r");
}
}
//=====================================================================================
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment