generated from Template/H563ZI-HAL-CMake-Template
Compare commits
4 Commits
develop
...
8b51db6587
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b51db6587 | |||
| 47d3432695 | |||
| 7092525208 | |||
| 3d456a334c |
@@ -34,11 +34,10 @@ Mcu.IP10=TIM1
|
||||
Mcu.IP11=TIM2
|
||||
Mcu.IP12=TIM3
|
||||
Mcu.IP13=TIM4
|
||||
Mcu.IP14=TIM5
|
||||
Mcu.IP15=TIM8
|
||||
Mcu.IP16=UART4
|
||||
Mcu.IP17=USART2
|
||||
Mcu.IP18=USART3
|
||||
Mcu.IP14=TIM8
|
||||
Mcu.IP15=UART4
|
||||
Mcu.IP16=USART2
|
||||
Mcu.IP17=USART3
|
||||
Mcu.IP2=DEBUG
|
||||
Mcu.IP3=GPDMA1
|
||||
Mcu.IP4=MEMORYMAP
|
||||
@@ -47,18 +46,18 @@ Mcu.IP6=PWR
|
||||
Mcu.IP7=RCC
|
||||
Mcu.IP8=SYS
|
||||
Mcu.IP9=THREADX
|
||||
Mcu.IPNb=19
|
||||
Mcu.IPNb=18
|
||||
Mcu.Name=STM32H563ZITx
|
||||
Mcu.Package=LQFP144
|
||||
Mcu.Pin0=PH0-OSC_IN(PH0)
|
||||
Mcu.Pin1=PH1-OSC_OUT(PH1)
|
||||
Mcu.Pin10=PG2
|
||||
Mcu.Pin11=PG3
|
||||
Mcu.Pin12=PC6
|
||||
Mcu.Pin13=PC7
|
||||
Mcu.Pin14=PC9
|
||||
Mcu.Pin15=PA13(JTMS/SWDIO)
|
||||
Mcu.Pin16=PA14(JTCK/SWCLK)
|
||||
Mcu.Pin10=PC6
|
||||
Mcu.Pin11=PC7
|
||||
Mcu.Pin12=PC8
|
||||
Mcu.Pin13=PC9
|
||||
Mcu.Pin14=PA13(JTMS/SWDIO)
|
||||
Mcu.Pin15=PA14(JTCK/SWCLK)
|
||||
Mcu.Pin16=PC10
|
||||
Mcu.Pin17=PC11
|
||||
Mcu.Pin18=PC12
|
||||
Mcu.Pin19=PD2
|
||||
@@ -73,22 +72,21 @@ Mcu.Pin26=VP_GPDMA1_VS_GPDMACH4
|
||||
Mcu.Pin27=VP_GPDMA1_VS_GPDMACH5
|
||||
Mcu.Pin28=VP_PWR_VS_SECSignals
|
||||
Mcu.Pin29=VP_PWR_VS_LPOM
|
||||
Mcu.Pin3=PA0
|
||||
Mcu.Pin3=PB1
|
||||
Mcu.Pin30=VP_SYS_VS_tim6
|
||||
Mcu.Pin31=VP_THREADX_VS_RTOSJjThreadXJjCoreJjDefault
|
||||
Mcu.Pin32=VP_TIM2_VS_ClockSourceINT
|
||||
Mcu.Pin33=VP_TIM3_VS_ClockSourceINT
|
||||
Mcu.Pin34=VP_TIM4_VS_ClockSourceINT
|
||||
Mcu.Pin35=VP_TIM5_VS_ClockSourceINT
|
||||
Mcu.Pin36=VP_BOOTPATH_VS_BOOTPATH
|
||||
Mcu.Pin37=VP_MEMORYMAP_VS_MEMORYMAP
|
||||
Mcu.Pin4=PB1
|
||||
Mcu.Pin5=PG0
|
||||
Mcu.Pin6=PG1
|
||||
Mcu.Pin7=PE9
|
||||
Mcu.Pin8=PE11
|
||||
Mcu.Pin9=PB10
|
||||
Mcu.PinsNb=38
|
||||
Mcu.Pin35=VP_BOOTPATH_VS_BOOTPATH
|
||||
Mcu.Pin36=VP_MEMORYMAP_VS_MEMORYMAP
|
||||
Mcu.Pin4=PG0
|
||||
Mcu.Pin5=PG1
|
||||
Mcu.Pin6=PE9
|
||||
Mcu.Pin7=PE11
|
||||
Mcu.Pin8=PG2
|
||||
Mcu.Pin9=PG3
|
||||
Mcu.PinsNb=37
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32H563ZITx
|
||||
@@ -112,7 +110,6 @@ NVIC.SavedSystickIrqHandlerGenerated=true
|
||||
NVIC.SysTick_IRQn=true\:14\:0\:false\:false\:false\:false\:false\:true\:false
|
||||
NVIC.TIM2_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true\:true
|
||||
NVIC.TIM3_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true\:true
|
||||
NVIC.TIM5_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true\:true
|
||||
NVIC.TIM6_IRQn=true\:15\:0\:false\:false\:true\:false\:false\:true\:true
|
||||
NVIC.TimeBase=TIM6_IRQn
|
||||
NVIC.TimeBaseIP=TIM6
|
||||
@@ -120,9 +117,6 @@ NVIC.UART4_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true\:true
|
||||
NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true\:true
|
||||
NVIC.USART3_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true\:true
|
||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||
PA0.GPIOParameters=GPIO_Label
|
||||
PA0.GPIO_Label=HC_Echo
|
||||
PA0.Signal=S_TIM5_CH1
|
||||
PA13(JTMS/SWDIO).Mode=Serial_Wire
|
||||
PA13(JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO
|
||||
PA14(JTCK/SWCLK).Mode=Serial_Wire
|
||||
@@ -131,15 +125,15 @@ PB1.GPIOParameters=GPIO_Label
|
||||
PB1.GPIO_Label=PWMB
|
||||
PB1.Locked=true
|
||||
PB1.Signal=S_TIM3_CH4
|
||||
PB10.Locked=true
|
||||
PB10.Mode=Asynchronous
|
||||
PB10.Signal=USART3_TX
|
||||
PB8.Locked=true
|
||||
PB8.Mode=Asynchronous
|
||||
PB8.Signal=UART4_RX
|
||||
PB9.Locked=true
|
||||
PB9.Mode=Asynchronous
|
||||
PB9.Signal=UART4_TX
|
||||
PC10.Locked=true
|
||||
PC10.Mode=Asynchronous
|
||||
PC10.Signal=USART3_TX
|
||||
PC11.Locked=true
|
||||
PC11.Mode=Asynchronous
|
||||
PC11.Signal=USART3_RX
|
||||
@@ -152,16 +146,18 @@ PC2.GPIOParameters=GPIO_Label
|
||||
PC2.GPIO_Label=PWMA
|
||||
PC2.Locked=true
|
||||
PC2.Signal=S_TIM4_CH4
|
||||
PC6.GPIOParameters=GPIO_PuPd,GPIO_Label
|
||||
PC6.GPIOParameters=GPIO_Label
|
||||
PC6.GPIO_Label=E2A
|
||||
PC6.GPIO_PuPd=GPIO_PULLUP
|
||||
PC6.Locked=true
|
||||
PC6.Signal=S_TIM8_CH1
|
||||
PC7.GPIOParameters=GPIO_PuPd,GPIO_Label
|
||||
PC7.GPIOParameters=GPIO_Label
|
||||
PC7.GPIO_Label=E2B
|
||||
PC7.GPIO_PuPd=GPIO_PULLUP
|
||||
PC7.Locked=true
|
||||
PC7.Signal=S_TIM8_CH2
|
||||
PC8.GPIOParameters=GPIO_Label
|
||||
PC8.GPIO_Label=HC_Echo
|
||||
PC8.Locked=true
|
||||
PC8.Signal=S_TIM3_CH3
|
||||
PC9.GPIOParameters=GPIO_PuPd,GPIO_Label
|
||||
PC9.GPIO_Label=HC_Trig
|
||||
PC9.GPIO_PuPd=GPIO_NOPULL
|
||||
@@ -178,14 +174,12 @@ PD5.Signal=USART2_TX
|
||||
PD6.Locked=true
|
||||
PD6.Mode=Asynchronous
|
||||
PD6.Signal=USART2_RX
|
||||
PE11.GPIOParameters=GPIO_PuPd,GPIO_Label
|
||||
PE11.GPIOParameters=GPIO_Label
|
||||
PE11.GPIO_Label=E1B
|
||||
PE11.GPIO_PuPd=GPIO_PULLUP
|
||||
PE11.Locked=true
|
||||
PE11.Signal=S_TIM1_CH2
|
||||
PE9.GPIOParameters=GPIO_PuPd,GPIO_Label
|
||||
PE9.GPIOParameters=GPIO_Label
|
||||
PE9.GPIO_Label=E1A
|
||||
PE9.GPIO_PuPd=GPIO_PULLUP
|
||||
PE9.Locked=true
|
||||
PE9.Signal=S_TIM1_CH1
|
||||
PG0.GPIOParameters=GPIO_Label
|
||||
@@ -330,12 +324,12 @@ SH.S_TIM1_CH1.0=TIM1_CH1,Encoder_Interface
|
||||
SH.S_TIM1_CH1.ConfNb=1
|
||||
SH.S_TIM1_CH2.0=TIM1_CH2,Encoder_Interface
|
||||
SH.S_TIM1_CH2.ConfNb=1
|
||||
SH.S_TIM3_CH3.0=TIM3_CH3,Input_Capture3_from_TI3
|
||||
SH.S_TIM3_CH3.ConfNb=1
|
||||
SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4
|
||||
SH.S_TIM3_CH4.ConfNb=1
|
||||
SH.S_TIM4_CH4.0=TIM4_CH4,PWM Generation4 CH4
|
||||
SH.S_TIM4_CH4.ConfNb=1
|
||||
SH.S_TIM5_CH1.0=TIM5_CH1,Input_Capture1_from_TI1
|
||||
SH.S_TIM5_CH1.ConfNb=1
|
||||
SH.S_TIM8_CH1.0=TIM8_CH1,Encoder_Interface
|
||||
SH.S_TIM8_CH1.ConfNb=1
|
||||
SH.S_TIM8_CH2.0=TIM8_CH2,Encoder_Interface
|
||||
@@ -343,29 +337,20 @@ SH.S_TIM8_CH2.ConfNb=1
|
||||
THREADX.IPParameters=TX_APP_GENERATE_INIT_CODE,TX_MINIMUM_STACK
|
||||
THREADX.TX_APP_GENERATE_INIT_CODE=false
|
||||
THREADX.TX_MINIMUM_STACK=400
|
||||
TIM1.EncoderMode=TIM_ENCODERMODE_TI12
|
||||
TIM1.IPParameters=EncoderMode
|
||||
TIM2.IPParameters=Prescaler
|
||||
TIM2.Prescaler=250 - 1
|
||||
TIM3.Channel-Input_Capture3_from_TI3=TIM_CHANNEL_3
|
||||
TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
|
||||
TIM3.IPParameters=Prescaler,Channel-PWM Generation4 CH4,PeriodNoDither
|
||||
TIM3.PeriodNoDither=255
|
||||
TIM3.Prescaler=48
|
||||
TIM3.IPParameters=Prescaler,Channel-PWM Generation4 CH4,Channel-Input_Capture3_from_TI3
|
||||
TIM3.Prescaler=250 - 1
|
||||
TIM4.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
|
||||
TIM4.IPParameters=Channel-PWM Generation4 CH4,Prescaler,PeriodNoDither
|
||||
TIM4.PeriodNoDither=255
|
||||
TIM4.Prescaler=48
|
||||
TIM5.Channel-Input_Capture1_from_TI1=TIM_CHANNEL_1
|
||||
TIM5.IPParameters=Channel-Input_Capture1_from_TI1,Prescaler
|
||||
TIM5.Prescaler=250-1
|
||||
TIM8.EncoderMode=TIM_ENCODERMODE_TI12
|
||||
TIM8.IPParameters=EncoderMode
|
||||
TIM4.IPParameters=Channel-PWM Generation4 CH4
|
||||
UART4.BaudRate=9600
|
||||
UART4.IPParameters=BaudRate
|
||||
USART2.BaudRate=9600
|
||||
USART2.IPParameters=VirtualMode-Asynchronous,BaudRate
|
||||
USART2.VirtualMode-Asynchronous=VM_ASYNC
|
||||
USART3.BaudRate=115200
|
||||
USART3.BaudRate=9600
|
||||
USART3.IPParameters=VirtualMode-Asynchronous,BaudRate
|
||||
USART3.VirtualMode-Asynchronous=VM_ASYNC
|
||||
VP_BOOTPATH_VS_BOOTPATH.Mode=BP_Activate
|
||||
@@ -394,6 +379,4 @@ VP_TIM3_VS_ClockSourceINT.Mode=Internal
|
||||
VP_TIM3_VS_ClockSourceINT.Signal=TIM3_VS_ClockSourceINT
|
||||
VP_TIM4_VS_ClockSourceINT.Mode=Internal
|
||||
VP_TIM4_VS_ClockSourceINT.Signal=TIM4_VS_ClockSourceINT
|
||||
VP_TIM5_VS_ClockSourceINT.Mode=Internal
|
||||
VP_TIM5_VS_ClockSourceINT.Signal=TIM5_VS_ClockSourceINT
|
||||
board=custom
|
||||
|
||||
@@ -49,16 +49,16 @@ extern "C" {
|
||||
/* USER CODE BEGIN PD */
|
||||
// <20>¼<EFBFBD><C2BC><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
|
||||
#define EVENT_OBSTACLE_DETECTED 0x01
|
||||
#define EVENT_GPS_DATA_READY 0x02
|
||||
#define EVENT_BLE_COMMAND_RECEIVED 0x04
|
||||
#define IMU_UPDATE_EVENT 0x08
|
||||
#define EVENT_LOCATION_UPDATED 0x10
|
||||
|
||||
#define EVENT_IMU_DATA_READY 0x20 // <20><><EFBFBD><EFBFBD>IMU<4D><55><EFBFBD>ݾ<EFBFBD><DDBE><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
|
||||
#define TEST 1
|
||||
extern TX_QUEUE ble_tx_queue;
|
||||
extern TX_EVENT_FLAGS_GROUP system_events;
|
||||
extern TX_EVENT_FLAGS_GROUP sensor_events; //传感器事件组
|
||||
extern TX_EVENT_FLAGS_GROUP response_events; //避障
|
||||
|
||||
//typedef struct
|
||||
//{
|
||||
//// uint32_t msg_type; // 应该使用 int --- 4字节
|
||||
|
||||
@@ -59,8 +59,6 @@ void Error_Handler(void);
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
#define PWMA_Pin GPIO_PIN_2
|
||||
#define PWMA_GPIO_Port GPIOC
|
||||
#define HC_Echo_Pin GPIO_PIN_0
|
||||
#define HC_Echo_GPIO_Port GPIOA
|
||||
#define PWMB_Pin GPIO_PIN_1
|
||||
#define PWMB_GPIO_Port GPIOB
|
||||
#define AIN1_Pin GPIO_PIN_0
|
||||
@@ -79,6 +77,8 @@ void Error_Handler(void);
|
||||
#define E2A_GPIO_Port GPIOC
|
||||
#define E2B_Pin GPIO_PIN_7
|
||||
#define E2B_GPIO_Port GPIOC
|
||||
#define HC_Echo_Pin GPIO_PIN_8
|
||||
#define HC_Echo_GPIO_Port GPIOC
|
||||
#define HC_Trig_Pin GPIO_PIN_9
|
||||
#define HC_Trig_GPIO_Port GPIOC
|
||||
#define Shake_Motor_Pin GPIO_PIN_12
|
||||
|
||||
@@ -57,7 +57,6 @@ void GPDMA1_Channel4_IRQHandler(void);
|
||||
void GPDMA1_Channel5_IRQHandler(void);
|
||||
void TIM2_IRQHandler(void);
|
||||
void TIM3_IRQHandler(void);
|
||||
void TIM5_IRQHandler(void);
|
||||
void TIM6_IRQHandler(void);
|
||||
void USART2_IRQHandler(void);
|
||||
void USART3_IRQHandler(void);
|
||||
|
||||
@@ -40,8 +40,6 @@ extern TIM_HandleTypeDef htim3;
|
||||
|
||||
extern TIM_HandleTypeDef htim4;
|
||||
|
||||
extern TIM_HandleTypeDef htim5;
|
||||
|
||||
extern TIM_HandleTypeDef htim8;
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
@@ -52,7 +50,6 @@ void MX_TIM1_Init(void);
|
||||
void MX_TIM2_Init(void);
|
||||
void MX_TIM3_Init(void);
|
||||
void MX_TIM4_Init(void);
|
||||
void MX_TIM5_Init(void);
|
||||
void MX_TIM8_Init(void);
|
||||
|
||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
||||
|
||||
@@ -36,13 +36,10 @@
|
||||
|
||||
// BLE define
|
||||
#define BLE_RX_THREAD_STACK_SIZE 2048
|
||||
#define BLE_RX_THREAD_PRIORITY 9
|
||||
#define BLE_RX_THREAD_PRIORITY 10
|
||||
#define BLE_TX_THREAD_STACK_SIZE 2048
|
||||
#define BLE_TX_THREAD_PRIORITY 10
|
||||
// IMU thread config
|
||||
// IMU thread config
|
||||
#define IMU_ANGLE_THREAD_STACK_SIZE 1024
|
||||
#define IMU_ANGLE_THREAD_PRIORITY 11
|
||||
//
|
||||
|
||||
|
||||
|
||||
@@ -58,9 +55,6 @@
|
||||
/* ȫ<>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
|
||||
TX_EVENT_FLAGS_GROUP system_events;
|
||||
TX_EVENT_FLAGS_GROUP sensor_events;
|
||||
TX_EVENT_FLAGS_GROUP response_events; // 用于避障事件实现
|
||||
|
||||
MotorCommand current_motor_cmd = {0,0};
|
||||
_GPSData gps_data;
|
||||
|
||||
@@ -80,29 +74,13 @@ TX_QUEUE ble_tx_queue;
|
||||
__attribute__((aligned(4)))
|
||||
ULONG ble_tx_queue_buffer[BLE_TX_QUEUE_LEN * ((BLE_TX_MSG_LEN + sizeof(ULONG) - 1) / sizeof(ULONG))];
|
||||
|
||||
// imu
|
||||
TX_THREAD imu_angle_thread;
|
||||
UCHAR imu_angle_stack[IMU_ANGLE_THREAD_STACK_SIZE];
|
||||
//
|
||||
|
||||
#define IM948_RX_QUEUE_SIZE 64
|
||||
ULONG im948_rx_queue_buffer[IM948_RX_QUEUE_SIZE];
|
||||
TX_QUEUE im948_uart_rx_queue;
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
#define GPS_TASK_STACK_SIZE 2048
|
||||
#define GPS_TASK_PRIORITY 11
|
||||
|
||||
TX_THREAD gps_task;
|
||||
ULONG gps_task_stack[GPS_TASK_STACK_SIZE / sizeof(ULONG)];
|
||||
|
||||
static TX_THREAD obstacle_thread;
|
||||
static UCHAR obstacle_stack[512];
|
||||
//超声波
|
||||
static UCHAR ultrasonic_stack[512];
|
||||
static void obstacle_thread_entry(ULONG);
|
||||
TX_THREAD ultrasonic_task_thread;
|
||||
|
||||
/* USER CODE END 1 */
|
||||
/* USER CODE END 1 */
|
||||
@@ -156,81 +134,8 @@ UINT App_ThreadX_Init(VOID *memory_ptr)
|
||||
return status;
|
||||
}
|
||||
|
||||
status = tx_thread_create(&imu_angle_thread, "IMU Angle Thread",
|
||||
imu_angle_ble_task_entry, 0,
|
||||
imu_angle_stack, IMU_ANGLE_THREAD_STACK_SIZE,
|
||||
IMU_ANGLE_THREAD_PRIORITY, IMU_ANGLE_THREAD_PRIORITY,
|
||||
TX_NO_TIME_SLICE, TX_AUTO_START);
|
||||
|
||||
if (status != TX_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
status = tx_queue_create(&im948_uart_rx_queue, "IM948_RX_QUEUE",
|
||||
TX_1_ULONG, // sizeof(ULONG) bytes per entry
|
||||
im948_rx_queue_buffer,
|
||||
IM948_RX_QUEUE_SIZE * sizeof(ULONG));
|
||||
if(status != TX_SUCCESS)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
status = tx_thread_create(&gps_task,
|
||||
"GPS Task",
|
||||
gps_thread_entry,
|
||||
0,
|
||||
gps_task_stack,
|
||||
GPS_TASK_STACK_SIZE,
|
||||
GPS_TASK_PRIORITY,
|
||||
GPS_TASK_PRIORITY,
|
||||
TX_NO_TIME_SLICE,
|
||||
TX_AUTO_START);
|
||||
|
||||
if(status != TX_SUCCESS)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
// obstacle_thread create
|
||||
status = tx_thread_create(&obstacle_thread,
|
||||
"obstacle",
|
||||
obstacle_thread_entry,
|
||||
0,obstacle_stack,sizeof(obstacle_stack),8,8,TX_NO_TIME_SLICE,TX_AUTO_START);
|
||||
|
||||
if(status != TX_SUCCESS)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
status = tx_thread_create(&ultrasonic_task_thread,
|
||||
"Ultrasonic",
|
||||
ultrasonic_task_entry,
|
||||
0,
|
||||
ultrasonic_stack,
|
||||
sizeof(ultrasonic_stack),
|
||||
7, 7, // 这里的优先级
|
||||
TX_NO_TIME_SLICE,
|
||||
TX_AUTO_START);
|
||||
|
||||
if(status != TX_SUCCESS)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
//
|
||||
// HCBle_SendData("✅ BLE RX/TX 线程和队列初始化完成\r\n");
|
||||
|
||||
// status = ControlThreadCreate();
|
||||
// if(status != TX_SUCCESS)
|
||||
// {
|
||||
// return status;
|
||||
// }
|
||||
// status = Encoder_ThreadCreate();
|
||||
// if(status != TX_SUCCESS)
|
||||
// {
|
||||
// return status;
|
||||
// }
|
||||
HCBle_SendData("✅ BLE RX/TX 线程和队列初始化完成\r\n");
|
||||
|
||||
return TX_SUCCESS;
|
||||
}
|
||||
@@ -246,6 +151,7 @@ void MX_ThreadX_Init(void)
|
||||
/* USER CODE BEGIN Before_Kernel_Start */
|
||||
HCBle_InitEventFlags(); // 这必须在任何使用前调用一次
|
||||
/* USER CODE END Before_Kernel_Start */
|
||||
|
||||
tx_kernel_enter();
|
||||
|
||||
/* USER CODE BEGIN Kernel_Start_Error */
|
||||
@@ -254,48 +160,45 @@ void MX_ThreadX_Init(void)
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
//新加入的 obstacle
|
||||
static void obstacle_thread_entry(ULONG arg)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
ULONG evt; // 这个应该是用来接收数据的
|
||||
tx_event_flags_get(&response_events,EVENT_OBSTACLE_DETECTED,TX_OR_CLEAR,&evt,TX_WAIT_FOREVER);
|
||||
|
||||
switch(obstacle_level)
|
||||
{
|
||||
case 1: // 远
|
||||
Buzzer_Open();
|
||||
Shake_Motor_Open();
|
||||
tx_thread_sleep(30);
|
||||
Buzzer_Close();
|
||||
Shake_Motor_Close();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for(int i = 0; i < 2;i++)
|
||||
{
|
||||
Buzzer_Open();
|
||||
Shake_Motor_Open();
|
||||
tx_thread_sleep(50);
|
||||
Buzzer_Close();
|
||||
Shake_Motor_Close();
|
||||
tx_thread_sleep(30);
|
||||
}
|
||||
break;
|
||||
|
||||
case 3: // 近
|
||||
Buzzer_Open();
|
||||
Shake_Motor_Open();
|
||||
tx_thread_sleep(150);
|
||||
Buzzer_Close();
|
||||
Shake_Motor_Close();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
tx_thread_sleep(20);
|
||||
}
|
||||
}
|
||||
#ifdef TEST //Ŀǰ<C4BF><C7B0><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>
|
||||
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
void main_control_thread_entry(ULONG thread_input)
|
||||
{
|
||||
ULONG events;
|
||||
MotorCommand motor_cmd = {0, 0};
|
||||
|
||||
while(1)
|
||||
{
|
||||
// 等待事件发生
|
||||
tx_event_flags_get(&system_events,
|
||||
EVENT_OBSTACLE_DETECTED | EVENT_BLE_COMMAND_RECEIVED,
|
||||
TX_OR_CLEAR, &events, TX_WAIT_FOREVER);
|
||||
|
||||
// 处理障碍物事件
|
||||
if(events & EVENT_OBSTACLE_DETECTED)
|
||||
{
|
||||
// 触发蜂鸣器和振动提示
|
||||
Buzzer_Open();
|
||||
Shake_Motor_Open();
|
||||
tx_thread_sleep(100); // 振动100ms
|
||||
Buzzer_Close();
|
||||
Shake_Motor_Close();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 处理蓝牙控制指令
|
||||
if(events & EVENT_BLE_COMMAND_RECEIVED)
|
||||
{
|
||||
// 从队列获取电机命令
|
||||
// tx_queue_receive(&ble_rx_queue, &motor_cmd, TX_WAIT_FOREVER);
|
||||
|
||||
// 实际控制电机 (伪代码)
|
||||
// set_motor_speed(motor_cmd.leftSpeed, motor_cmd.rightSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* USER CODE END 1 */
|
||||
|
||||
@@ -46,10 +46,10 @@ void MX_GPIO_Init(void)
|
||||
/* GPIO Ports Clock Enable */
|
||||
__HAL_RCC_GPIOH_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOG_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
uint8_t rx_byte; // imu_<75><5F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
@@ -100,15 +100,7 @@ int main(void)
|
||||
MX_UART4_Init();
|
||||
MX_TIM1_Init();
|
||||
MX_TIM8_Init();
|
||||
MX_TIM5_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
imu600_init();
|
||||
GPS_Init();
|
||||
DWT_Init();
|
||||
PWM_GPIO_TIM_Init();
|
||||
HAL_TIM_IC_Start_IT(&htim5,TIM_CHANNEL_1);
|
||||
// Buzzer_Open();
|
||||
// HCBle_InitDMAReception();
|
||||
// HAL_Delay(200);
|
||||
// GPS_Init();
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
/* External variables --------------------------------------------------------*/
|
||||
extern TIM_HandleTypeDef htim2;
|
||||
extern TIM_HandleTypeDef htim3;
|
||||
extern TIM_HandleTypeDef htim5;
|
||||
extern DMA_NodeTypeDef Node_GPDMA1_Channel5;
|
||||
extern DMA_QListTypeDef List_GPDMA1_Channel5;
|
||||
extern DMA_HandleTypeDef handle_GPDMA1_Channel5;
|
||||
@@ -243,20 +242,6 @@ void TIM3_IRQHandler(void)
|
||||
/* USER CODE END TIM3_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles TIM5 global interrupt.
|
||||
*/
|
||||
void TIM5_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN TIM5_IRQn 0 */
|
||||
|
||||
/* USER CODE END TIM5_IRQn 0 */
|
||||
HAL_TIM_IRQHandler(&htim5);
|
||||
/* USER CODE BEGIN TIM5_IRQn 1 */
|
||||
|
||||
/* USER CODE END TIM5_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles TIM6 global interrupt.
|
||||
*/
|
||||
|
||||
147
Core/Src/tim.c
147
Core/Src/tim.c
@@ -28,7 +28,6 @@ TIM_HandleTypeDef htim1;
|
||||
TIM_HandleTypeDef htim2;
|
||||
TIM_HandleTypeDef htim3;
|
||||
TIM_HandleTypeDef htim4;
|
||||
TIM_HandleTypeDef htim5;
|
||||
TIM_HandleTypeDef htim8;
|
||||
|
||||
/* TIM1 init function */
|
||||
@@ -52,7 +51,7 @@ void MX_TIM1_Init(void)
|
||||
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim1.Init.RepetitionCounter = 0;
|
||||
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
sConfig.EncoderMode = TIM_ENCODERMODE_TI12;
|
||||
sConfig.EncoderMode = TIM_ENCODERMODE_TI1;
|
||||
sConfig.IC1Polarity = TIM_ICPOLARITY_RISING;
|
||||
sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI;
|
||||
sConfig.IC1Prescaler = TIM_ICPSC_DIV1;
|
||||
@@ -127,15 +126,16 @@ void MX_TIM3_Init(void)
|
||||
|
||||
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
|
||||
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||
TIM_IC_InitTypeDef sConfigIC = {0};
|
||||
TIM_OC_InitTypeDef sConfigOC = {0};
|
||||
|
||||
/* USER CODE BEGIN TIM3_Init 1 */
|
||||
|
||||
/* USER CODE END TIM3_Init 1 */
|
||||
htim3.Instance = TIM3;
|
||||
htim3.Init.Prescaler = 48;
|
||||
htim3.Init.Prescaler = 250 - 1;
|
||||
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim3.Init.Period = 255;
|
||||
htim3.Init.Period = 65535;
|
||||
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
|
||||
@@ -147,6 +147,10 @@ void MX_TIM3_Init(void)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_TIM_IC_Init(&htim3) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
@@ -157,6 +161,14 @@ void MX_TIM3_Init(void)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_RISING;
|
||||
sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI;
|
||||
sConfigIC.ICPrescaler = TIM_ICPSC_DIV1;
|
||||
sConfigIC.ICFilter = 0;
|
||||
if (HAL_TIM_IC_ConfigChannel(&htim3, &sConfigIC, TIM_CHANNEL_3) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
||||
sConfigOC.Pulse = 0;
|
||||
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||
@@ -187,9 +199,9 @@ void MX_TIM4_Init(void)
|
||||
|
||||
/* USER CODE END TIM4_Init 1 */
|
||||
htim4.Instance = TIM4;
|
||||
htim4.Init.Prescaler = 48;
|
||||
htim4.Init.Prescaler = 0;
|
||||
htim4.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim4.Init.Period = 255;
|
||||
htim4.Init.Period = 65535;
|
||||
htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_Base_Init(&htim4) != HAL_OK)
|
||||
@@ -224,59 +236,6 @@ void MX_TIM4_Init(void)
|
||||
/* USER CODE END TIM4_Init 2 */
|
||||
HAL_TIM_MspPostInit(&htim4);
|
||||
|
||||
}
|
||||
/* TIM5 init function */
|
||||
void MX_TIM5_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN TIM5_Init 0 */
|
||||
|
||||
/* USER CODE END TIM5_Init 0 */
|
||||
|
||||
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
|
||||
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||
TIM_IC_InitTypeDef sConfigIC = {0};
|
||||
|
||||
/* USER CODE BEGIN TIM5_Init 1 */
|
||||
|
||||
/* USER CODE END TIM5_Init 1 */
|
||||
htim5.Instance = TIM5;
|
||||
htim5.Init.Prescaler = 250-1;
|
||||
htim5.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim5.Init.Period = 4294967295;
|
||||
htim5.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim5.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_Base_Init(&htim5) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||
if (HAL_TIM_ConfigClockSource(&htim5, &sClockSourceConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_TIM_IC_Init(&htim5) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_RISING;
|
||||
sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI;
|
||||
sConfigIC.ICPrescaler = TIM_ICPSC_DIV1;
|
||||
sConfigIC.ICFilter = 0;
|
||||
if (HAL_TIM_IC_ConfigChannel(&htim5, &sConfigIC, TIM_CHANNEL_1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN TIM5_Init 2 */
|
||||
|
||||
/* USER CODE END TIM5_Init 2 */
|
||||
|
||||
}
|
||||
/* TIM8 init function */
|
||||
void MX_TIM8_Init(void)
|
||||
@@ -299,7 +258,7 @@ void MX_TIM8_Init(void)
|
||||
htim8.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim8.Init.RepetitionCounter = 0;
|
||||
htim8.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
sConfig.EncoderMode = TIM_ENCODERMODE_TI12;
|
||||
sConfig.EncoderMode = TIM_ENCODERMODE_TI1;
|
||||
sConfig.IC1Polarity = TIM_ICPOLARITY_RISING;
|
||||
sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI;
|
||||
sConfig.IC1Prescaler = TIM_ICPSC_DIV1;
|
||||
@@ -344,7 +303,7 @@ void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* tim_encoderHandle)
|
||||
*/
|
||||
GPIO_InitStruct.Pin = E1A_Pin|E1B_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
|
||||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||
@@ -368,7 +327,7 @@ void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* tim_encoderHandle)
|
||||
*/
|
||||
GPIO_InitStruct.Pin = E2A_Pin|E2B_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF3_TIM8;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
@@ -406,6 +365,17 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||
/* TIM3 clock enable */
|
||||
__HAL_RCC_TIM3_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
/**TIM3 GPIO Configuration
|
||||
PC8 ------> TIM3_CH3
|
||||
*/
|
||||
GPIO_InitStruct.Pin = HC_Echo_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
|
||||
HAL_GPIO_Init(HC_Echo_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* TIM3 interrupt Init */
|
||||
HAL_NVIC_SetPriority(TIM3_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM3_IRQn);
|
||||
@@ -424,32 +394,6 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||
|
||||
/* USER CODE END TIM4_MspInit 1 */
|
||||
}
|
||||
else if(tim_baseHandle->Instance==TIM5)
|
||||
{
|
||||
/* USER CODE BEGIN TIM5_MspInit 0 */
|
||||
|
||||
/* USER CODE END TIM5_MspInit 0 */
|
||||
/* TIM5 clock enable */
|
||||
__HAL_RCC_TIM5_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
/**TIM5 GPIO Configuration
|
||||
PA0 ------> TIM5_CH1
|
||||
*/
|
||||
GPIO_InitStruct.Pin = HC_Echo_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF2_TIM5;
|
||||
HAL_GPIO_Init(HC_Echo_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* TIM5 interrupt Init */
|
||||
HAL_NVIC_SetPriority(TIM5_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM5_IRQn);
|
||||
/* USER CODE BEGIN TIM5_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM5_MspInit 1 */
|
||||
}
|
||||
}
|
||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
|
||||
{
|
||||
@@ -565,6 +509,14 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_TIM3_CLK_DISABLE();
|
||||
|
||||
/**TIM3 GPIO Configuration
|
||||
PB1 ------> TIM3_CH4
|
||||
PC8 ------> TIM3_CH3
|
||||
*/
|
||||
HAL_GPIO_DeInit(PWMB_GPIO_Port, PWMB_Pin);
|
||||
|
||||
HAL_GPIO_DeInit(HC_Echo_GPIO_Port, HC_Echo_Pin);
|
||||
|
||||
/* TIM3 interrupt Deinit */
|
||||
HAL_NVIC_DisableIRQ(TIM3_IRQn);
|
||||
/* USER CODE BEGIN TIM3_MspDeInit 1 */
|
||||
@@ -582,25 +534,6 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||
|
||||
/* USER CODE END TIM4_MspDeInit 1 */
|
||||
}
|
||||
else if(tim_baseHandle->Instance==TIM5)
|
||||
{
|
||||
/* USER CODE BEGIN TIM5_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END TIM5_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_TIM5_CLK_DISABLE();
|
||||
|
||||
/**TIM5 GPIO Configuration
|
||||
PA0 ------> TIM5_CH1
|
||||
*/
|
||||
HAL_GPIO_DeInit(HC_Echo_GPIO_Port, HC_Echo_Pin);
|
||||
|
||||
/* TIM5 interrupt Deinit */
|
||||
HAL_NVIC_DisableIRQ(TIM5_IRQn);
|
||||
/* USER CODE BEGIN TIM5_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END TIM5_MspDeInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
@@ -135,7 +135,7 @@ void MX_USART3_UART_Init(void)
|
||||
|
||||
/* USER CODE END USART3_Init 1 */
|
||||
huart3.Instance = USART3;
|
||||
huart3.Init.BaudRate = 115200;
|
||||
huart3.Init.BaudRate = 9600;
|
||||
huart3.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
huart3.Init.StopBits = UART_STOPBITS_1;
|
||||
huart3.Init.Parity = UART_PARITY_NONE;
|
||||
@@ -404,20 +404,12 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||
/* USART3 clock enable */
|
||||
__HAL_RCC_USART3_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
/**USART3 GPIO Configuration
|
||||
PB10 ------> USART3_TX
|
||||
PC10 ------> USART3_TX
|
||||
PC11 ------> USART3_RX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_10;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_11;
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
@@ -492,12 +484,10 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
|
||||
__HAL_RCC_USART3_CLK_DISABLE();
|
||||
|
||||
/**USART3 GPIO Configuration
|
||||
PB10 ------> USART3_TX
|
||||
PC10 ------> USART3_TX
|
||||
PC11 ------> USART3_RX
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10);
|
||||
|
||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_11);
|
||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10|GPIO_PIN_11);
|
||||
|
||||
/* USART3 interrupt Deinit */
|
||||
HAL_NVIC_DisableIRQ(USART3_IRQn);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -152,18 +152,18 @@
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>110</LineNumber>
|
||||
<LineNumber>162</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134265834</Address>
|
||||
<Address>134296028</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>..\fun\Ultrasound.c</Filename>
|
||||
<Filename>..\fun\HCBle.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\AutoGuideStick\../fun/Ultrasound.c\110</Expression>
|
||||
<Expression>\\AutoGuideStick\../fun/HCBle.c\162</Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<WatchWindow1>
|
||||
@@ -227,26 +227,6 @@
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>status</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>12</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>UartFifo</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>13</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>temp</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>14</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>isNewData</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>15</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>current_location</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<WatchWindow2>
|
||||
<Ww>
|
||||
@@ -254,46 +234,6 @@
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>json_buf[128]</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>1</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>x</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>2</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>rx_byte</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>3</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>buf[5+CmdPacketMaxDatSizeRx]</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>4</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>AngleZ</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>5</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>GPS_DMA_RX_BUF[GPS_DMA_RX_BUF_LEN]</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>6</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>msg</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>7</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>status</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>8</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>distance_cm</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow2>
|
||||
<Tracepoint>
|
||||
<THDelay>0</THDelay>
|
||||
@@ -2897,90 +2837,6 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>209</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\fun\Motor.c</PathWithFileName>
|
||||
<FilenameWithoutPath>Motor.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>210</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\fun\Motor.h</PathWithFileName>
|
||||
<FilenameWithoutPath>Motor.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>211</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\fun\imu948.c</PathWithFileName>
|
||||
<FilenameWithoutPath>imu948.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>212</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\fun\imu948.h</PathWithFileName>
|
||||
<FilenameWithoutPath>imu948.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>213</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\fun\value.h</PathWithFileName>
|
||||
<FilenameWithoutPath>value.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>214</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\fun\encoder.c</PathWithFileName>
|
||||
<FilenameWithoutPath>encoder.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>215</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\fun\encoder.h</PathWithFileName>
|
||||
<FilenameWithoutPath>encoder.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
|
||||
@@ -190,7 +190,7 @@
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
<useUlib>1</useUlib>
|
||||
<useUlib>0</useUlib>
|
||||
<EndSel>0</EndSel>
|
||||
<uLtcg>0</uLtcg>
|
||||
<nSecure>0</nSecure>
|
||||
@@ -1709,41 +1709,6 @@
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\fun\IMU.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>Motor.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\fun\Motor.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>Motor.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\fun\Motor.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>imu948.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\fun\imu948.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>imu948.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\fun\imu948.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>value.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\fun\value.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>encoder.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\fun\encoder.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>encoder.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\fun\encoder.h</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
||||
Binary file not shown.
@@ -22,12 +22,20 @@ Dialog DLL: TCM.DLL V1.56.4.0
|
||||
|
||||
<h2>Project:</h2>
|
||||
D:\advance_stick\AutoGuideStick\MDK-ARM\AutoGuideStick.uvprojx
|
||||
Project File Date: 07/02/2025
|
||||
Project File Date: 06/26/2025
|
||||
|
||||
<h2>Output:</h2>
|
||||
*** Using Compiler 'V6.21', folder: 'D:\keil5\ARM\ARMCLANG\Bin'
|
||||
Build target 'AutoGuideStick'
|
||||
"AutoGuideStick\AutoGuideStick.axf" - 0 Error(s), 0 Warning(s).
|
||||
../fun/HCBle.c(124): warning: illegal character encoding in string literal [-Winvalid-source-encoding]
|
||||
124 | HCBle_SendData("? <BD><E2><CE><F6>ʧ<B0><DC>: %s\r\n", frame);
|
||||
| ^~~~~~~~~~~~~~~~ ~~~~~~~~
|
||||
1 warning generated.
|
||||
compiling HCBle.c...
|
||||
linking...
|
||||
Program Size: Code=83284 RO-data=1592 RW-data=16 ZI-data=11480
|
||||
FromELF: creating hex file...
|
||||
"AutoGuideStick\AutoGuideStick.axf" - 0 Error(s), 1 Warning(s).
|
||||
|
||||
<h2>Software Packages used:</h2>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -200,10 +200,7 @@
|
||||
"autoguidestick\shake_motor.o"
|
||||
"autoguidestick\ultrasound.o"
|
||||
"autoguidestick\imu.o"
|
||||
"autoguidestick\motor.o"
|
||||
"autoguidestick\imu948.o"
|
||||
"autoguidestick\encoder.o"
|
||||
--library_type=microlib --strict --scatter "AutoGuideStick\AutoGuideStick.sct"
|
||||
--strict --scatter "AutoGuideStick\AutoGuideStick.sct"
|
||||
--summary_stderr --info summarysizes --map --load_addr_map_info --xref --callgraph --symbols
|
||||
--info sizes --info totals --info unused --info veneers
|
||||
--list "AutoGuideStick.map" -o AutoGuideStick\AutoGuideStick.axf
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -40,5 +40,4 @@ autoguidestick/app_azure_rtos.o: ..\AZURE_RTOS\App\app_azure_rtos.c \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdio.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdarg.h ..\fun\HCBle.h ..\fun\gps.h \
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Buzzer.h \
|
||||
..\fun\Motor.h ..\fun\IMU.h ..\fun\imu948.h ..\fun\encoder.h \
|
||||
..\fun\value.h ..\AZURE_RTOS\App\app_azure_rtos_config.h
|
||||
..\AZURE_RTOS\App\app_azure_rtos_config.h
|
||||
|
||||
@@ -39,6 +39,4 @@ autoguidestick/app_threadx.o: ..\Core\Src\app_threadx.c \
|
||||
..\Core\Inc\gpdma.h ..\Core\Inc\tim.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdio.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdarg.h ..\fun\HCBle.h ..\fun\gps.h \
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Buzzer.h \
|
||||
..\fun\Motor.h ..\fun\IMU.h ..\fun\imu948.h ..\fun\encoder.h \
|
||||
..\fun\value.h
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Buzzer.h
|
||||
|
||||
Binary file not shown.
@@ -39,5 +39,4 @@ autoguidestick/buzzer.o: ..\fun\Buzzer.c ..\fun\Buzzer.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\string.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdio.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdarg.h ..\fun\HCBle.h ..\fun\gps.h \
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Motor.h ..\fun\IMU.h \
|
||||
..\fun\imu948.h ..\fun\encoder.h ..\fun\value.h
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
autoguidestick/encoder.o: ..\fun\encoder.c ..\fun\encoder.h \
|
||||
..\fun\headfile.h ..\Core\Inc\main.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal.h \
|
||||
..\Core\Inc\stm32h5xx_hal_conf.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_rcc.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_def.h \
|
||||
..\Drivers\CMSIS\Device\ST\STM32H5xx\Include\stm32h5xx.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\math.h \
|
||||
..\Drivers\CMSIS\Device\ST\STM32H5xx\Include\stm32h563xx.h \
|
||||
..\Drivers\CMSIS\Include\core_cm33.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdint.h \
|
||||
D:\advance_stick\AutoGuideStick\Drivers\CMSIS\Include\cmsis_version.h \
|
||||
D:\advance_stick\AutoGuideStick\Drivers\CMSIS\Include\cmsis_compiler.h \
|
||||
D:\advance_stick\AutoGuideStick\Drivers\CMSIS\Include\cmsis_armclang.h \
|
||||
D:\advance_stick\AutoGuideStick\Drivers\CMSIS\Include\mpu_armv8.h \
|
||||
..\Drivers\CMSIS\Device\ST\STM32H5xx\Include\system_stm32h5xx.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stddef.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_rcc_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_gpio.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_gpio_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_dma.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_dma_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_cortex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_flash.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_flash_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pwr.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pwr_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_tim.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_tim_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_uart.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_uart_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_exti.h \
|
||||
..\Core\Inc\memorymap.h ..\Core\Inc\usart.h ..\Core\Inc\gpio.h \
|
||||
..\Core\Inc\gpdma.h ..\Core\Inc\tim.h ..\Core\Inc\app_threadx.h \
|
||||
..\Middlewares\ST\threadx\common\inc\tx_api.h \
|
||||
..\Middlewares\ST\threadx\ports\cortex_m33\ac6\inc\tx_port.h \
|
||||
..\Core\Inc\tx_user.h D:\keil5\ARM\ARMCLANG\include\stdlib.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\string.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdio.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdarg.h ..\fun\HCBle.h ..\fun\gps.h \
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Buzzer.h \
|
||||
..\fun\Motor.h ..\fun\IMU.h ..\fun\imu948.h ..\fun\value.h
|
||||
Binary file not shown.
Binary file not shown.
@@ -38,6 +38,4 @@ autoguidestick/gps.o: ..\fun\gps.c ..\fun\gps.h ..\fun\headfile.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\string.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdio.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdarg.h ..\fun\HCBle.h \
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Buzzer.h \
|
||||
..\fun\Motor.h ..\fun\IMU.h ..\fun\imu948.h ..\fun\encoder.h \
|
||||
..\fun\value.h
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Buzzer.h
|
||||
|
||||
Binary file not shown.
@@ -38,6 +38,4 @@ autoguidestick/hcble.o: ..\fun\HCBle.c ..\fun\HCBle.h ..\fun\headfile.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\string.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdio.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdarg.h ..\fun\gps.h \
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Buzzer.h \
|
||||
..\fun\Motor.h ..\fun\IMU.h ..\fun\imu948.h ..\fun\encoder.h \
|
||||
..\fun\value.h
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Buzzer.h
|
||||
|
||||
Binary file not shown.
@@ -38,5 +38,4 @@ autoguidestick/imu.o: ..\fun\IMU.c ..\fun\IMU.h ..\fun\headfile.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\string.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdio.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdarg.h ..\fun\HCBle.h ..\fun\gps.h \
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Buzzer.h \
|
||||
..\fun\Motor.h ..\fun\imu948.h ..\fun\encoder.h ..\fun\value.h
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Buzzer.h
|
||||
|
||||
Binary file not shown.
@@ -1,43 +0,0 @@
|
||||
autoguidestick/imu948.o: ..\fun\imu948.c ..\fun\imu948.h \
|
||||
..\fun\headfile.h ..\Core\Inc\main.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal.h \
|
||||
..\Core\Inc\stm32h5xx_hal_conf.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_rcc.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_def.h \
|
||||
..\Drivers\CMSIS\Device\ST\STM32H5xx\Include\stm32h5xx.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\math.h \
|
||||
..\Drivers\CMSIS\Device\ST\STM32H5xx\Include\stm32h563xx.h \
|
||||
..\Drivers\CMSIS\Include\core_cm33.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdint.h \
|
||||
D:\advance_stick\AutoGuideStick\Drivers\CMSIS\Include\cmsis_version.h \
|
||||
D:\advance_stick\AutoGuideStick\Drivers\CMSIS\Include\cmsis_compiler.h \
|
||||
D:\advance_stick\AutoGuideStick\Drivers\CMSIS\Include\cmsis_armclang.h \
|
||||
D:\advance_stick\AutoGuideStick\Drivers\CMSIS\Include\mpu_armv8.h \
|
||||
..\Drivers\CMSIS\Device\ST\STM32H5xx\Include\system_stm32h5xx.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stddef.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_rcc_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_gpio.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_gpio_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_dma.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_dma_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_cortex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_flash.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_flash_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pwr.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pwr_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_tim.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_tim_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_uart.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_uart_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_exti.h \
|
||||
..\Core\Inc\memorymap.h ..\Core\Inc\usart.h ..\Core\Inc\gpio.h \
|
||||
..\Core\Inc\gpdma.h ..\Core\Inc\tim.h ..\Core\Inc\app_threadx.h \
|
||||
..\Middlewares\ST\threadx\common\inc\tx_api.h \
|
||||
..\Middlewares\ST\threadx\ports\cortex_m33\ac6\inc\tx_port.h \
|
||||
..\Core\Inc\tx_user.h D:\keil5\ARM\ARMCLANG\include\stdlib.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\string.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdio.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdarg.h ..\fun\HCBle.h ..\fun\gps.h \
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Buzzer.h \
|
||||
..\fun\Motor.h ..\fun\IMU.h ..\fun\encoder.h ..\fun\value.h
|
||||
Binary file not shown.
@@ -38,6 +38,4 @@ autoguidestick/main.o: ..\Core\Src\main.c ..\Core\Inc\app_threadx.h \
|
||||
..\Core\Inc\gpdma.h ..\Core\Inc\tim.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdio.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdarg.h ..\fun\HCBle.h ..\fun\gps.h \
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Buzzer.h \
|
||||
..\fun\Motor.h ..\fun\IMU.h ..\fun\imu948.h ..\fun\encoder.h \
|
||||
..\fun\value.h
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Buzzer.h
|
||||
|
||||
Binary file not shown.
@@ -1,42 +0,0 @@
|
||||
autoguidestick/motor.o: ..\fun\Motor.c ..\fun\Motor.h ..\fun\headfile.h \
|
||||
..\Core\Inc\main.h ..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal.h \
|
||||
..\Core\Inc\stm32h5xx_hal_conf.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_rcc.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_def.h \
|
||||
..\Drivers\CMSIS\Device\ST\STM32H5xx\Include\stm32h5xx.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\math.h \
|
||||
..\Drivers\CMSIS\Device\ST\STM32H5xx\Include\stm32h563xx.h \
|
||||
..\Drivers\CMSIS\Include\core_cm33.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdint.h \
|
||||
D:\advance_stick\AutoGuideStick\Drivers\CMSIS\Include\cmsis_version.h \
|
||||
D:\advance_stick\AutoGuideStick\Drivers\CMSIS\Include\cmsis_compiler.h \
|
||||
D:\advance_stick\AutoGuideStick\Drivers\CMSIS\Include\cmsis_armclang.h \
|
||||
D:\advance_stick\AutoGuideStick\Drivers\CMSIS\Include\mpu_armv8.h \
|
||||
..\Drivers\CMSIS\Device\ST\STM32H5xx\Include\system_stm32h5xx.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stddef.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_rcc_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_gpio.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_gpio_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_dma.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_dma_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_cortex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_flash.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_flash_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pwr.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_pwr_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_tim.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_tim_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_uart.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_uart_ex.h \
|
||||
..\Drivers\STM32H5xx_HAL_Driver\Inc\stm32h5xx_hal_exti.h \
|
||||
..\Core\Inc\memorymap.h ..\Core\Inc\usart.h ..\Core\Inc\gpio.h \
|
||||
..\Core\Inc\gpdma.h ..\Core\Inc\tim.h ..\Core\Inc\app_threadx.h \
|
||||
..\Middlewares\ST\threadx\common\inc\tx_api.h \
|
||||
..\Middlewares\ST\threadx\ports\cortex_m33\ac6\inc\tx_port.h \
|
||||
..\Core\Inc\tx_user.h D:\keil5\ARM\ARMCLANG\include\stdlib.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\string.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdio.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdarg.h ..\fun\HCBle.h ..\fun\gps.h \
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Buzzer.h ..\fun\IMU.h \
|
||||
..\fun\imu948.h ..\fun\encoder.h ..\fun\value.h
|
||||
Binary file not shown.
@@ -39,5 +39,4 @@ autoguidestick/shake_motor.o: ..\fun\Shake_Motor.c ..\fun\Shake_Motor.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\string.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdio.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdarg.h ..\fun\HCBle.h ..\fun\gps.h \
|
||||
..\fun\Ultrasound.h ..\fun\Buzzer.h ..\fun\Motor.h ..\fun\IMU.h \
|
||||
..\fun\imu948.h ..\fun\encoder.h ..\fun\value.h
|
||||
..\fun\Ultrasound.h ..\fun\Buzzer.h
|
||||
|
||||
Binary file not shown.
@@ -39,6 +39,4 @@ autoguidestick/stm32h5xx_it.o: ..\Core\Src\stm32h5xx_it.c \
|
||||
D:\keil5\ARM\ARMCLANG\include\string.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdio.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdarg.h ..\fun\HCBle.h ..\fun\gps.h \
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Buzzer.h \
|
||||
..\fun\Motor.h ..\fun\IMU.h ..\fun\imu948.h ..\fun\encoder.h \
|
||||
..\fun\value.h
|
||||
..\fun\Shake_Motor.h ..\fun\Ultrasound.h ..\fun\Buzzer.h
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -39,5 +39,4 @@ autoguidestick/ultrasound.o: ..\fun\Ultrasound.c ..\fun\Ultrasound.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\string.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdio.h \
|
||||
D:\keil5\ARM\ARMCLANG\include\stdarg.h ..\fun\HCBle.h ..\fun\gps.h \
|
||||
..\fun\Shake_Motor.h ..\fun\Buzzer.h ..\fun\Motor.h ..\fun\IMU.h \
|
||||
..\fun\imu948.h ..\fun\encoder.h ..\fun\value.h
|
||||
..\fun\Shake_Motor.h ..\fun\Buzzer.h
|
||||
|
||||
Binary file not shown.
Binary file not shown.
48
fun/HCBle.c
48
fun/HCBle.c
@@ -33,7 +33,7 @@ uint8_t rx_data; //
|
||||
uint8_t uart_dma_rx_buf[UART_DMA_RX_BUF_SIZE];
|
||||
RingBuffer ble_rx_ring = {0}; //<2F><>ʼ<EFBFBD><CABC>
|
||||
MotorCommand cmd;
|
||||
BleMessage current_location = {0};
|
||||
LocationData current_location = {0};
|
||||
float imu_angle = 0.0f;
|
||||
|
||||
TX_EVENT_FLAGS_GROUP ble_event_flags;
|
||||
@@ -41,10 +41,7 @@ TX_EVENT_FLAGS_GROUP ble_event_flags;
|
||||
|
||||
|
||||
void HCBle_InitEventFlags(void)
|
||||
{ tx_event_flags_create(&ble_event_flags, "BLE Events");
|
||||
tx_event_flags_create(&system_events,"gps Events");
|
||||
// tx_event_flags_create(&sensor_events,"Sensor Events");
|
||||
}
|
||||
{ tx_event_flags_create(&ble_event_flags, "BLE Events");}
|
||||
|
||||
//<2F><>ʼ<EFBFBD><CABC>DMA<4D><41><EFBFBD>պ<EFBFBD><D5BA><EFBFBD>
|
||||
void HCBle_InitDMAReception(void)
|
||||
@@ -100,21 +97,6 @@ void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
|
||||
tx_event_flags_set(&ble_event_flags, BLE_EVENT_DATA_READY, TX_OR);
|
||||
HAL_UARTEx_ReceiveToIdle_IT(&huart4, uart_dma_rx_buf, UART_DMA_RX_BUF_SIZE);
|
||||
}
|
||||
else if(huart->Instance == USART2) // gps<70>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
|
||||
// // <20><><EFBFBD><EFBFBD> Size <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
memcpy(GPS.GPS_Buffer,GPS_DMA_RX_BUF,Size);
|
||||
GPS.GPS_Buffer[Size] = '\0';
|
||||
GPS.isGetData = 1; //<2F><><EFBFBD>ݽ<EFBFBD><DDBD>ձ<EFBFBD>־λ<D6BE><CEBB>Ϊ1
|
||||
|
||||
tx_event_flags_set(&system_events, EVENT_GPS_DATA_READY, TX_OR);
|
||||
|
||||
//<2F><><EFBFBD>¿<EFBFBD><C2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
HAL_UARTEx_ReceiveToIdle_IT(&huart2,GPS_DMA_RX_BUF,GPS_DMA_RX_BUF_LEN);
|
||||
// HAL_UARTEx_ReceiveToIdle_DMA(&huart2,GPS_DMA_RX_BUF,GPS_DMA_RX_BUF_LEN);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -128,19 +110,16 @@ void HCBle_ParseAndHandleFrame(const char *frame)
|
||||
if (sscanf(frame, "#{\"leftSpeed\":%d,\"rightSpeed\":%d}$", &left, &right) == 2) {
|
||||
cmd.LeftSpeed = left;
|
||||
cmd.RightSpeed = right;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>
|
||||
target_rpm_L = map_speed_to_rpm(cmd.LeftSpeed);
|
||||
target_rpm_R = map_speed_to_rpm(cmd.RightSpeed);
|
||||
|
||||
HCBle_SendData("left=%d, right=%d\r\n", cmd.LeftSpeed, cmd.RightSpeed);
|
||||
// HCBle_SendData("left=%d, right=%d\r\n", left, right);
|
||||
DriveBOTH(cmd.LeftSpeed,cmd.RightSpeed); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// DriveBOTH(cmd.LeftSpeed,cmd.RightSpeed);
|
||||
HCBle_SendData("left=%d, right=%d\r\n", left, right);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// if (sscanf(frame, "%*[^0-9]%d%*[^0-9]%d", &left, &right) == 2) {
|
||||
// cmd.LeftSpeed = left;
|
||||
// cmd.RightSpeed = right;
|
||||
// HCBle_SendData("? <20><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>: <20><>=%d, <20><>=%d\r\n", left, right);
|
||||
// return;
|
||||
// }
|
||||
|
||||
HCBle_SendData("? <20><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>: %s\r\n", frame);
|
||||
}
|
||||
@@ -199,18 +178,15 @@ void ble_rx_task_entry(ULONG thread_input)
|
||||
// HCBle_SendData("#{\"lat\":%.6f,\"lon\":%.6f,\"angle\":%.2f}\n",
|
||||
// current_location.lat, current_location.lon, current_location.angle);
|
||||
void ble_tx_task_entry(ULONG thread_input) {
|
||||
BleMessage msg;
|
||||
char recv_msg[128];
|
||||
while(1) {
|
||||
|
||||
// HCBle_SendData("#{\"lat\":%.6f,\"lon\":%.6f,\"angle\":%.2f}\n",23.123456, 113.654321, 95.0);
|
||||
// tx_thread_sleep(500);
|
||||
if(tx_queue_receive(&ble_tx_queue,&msg,TX_WAIT_FOREVER) == TX_SUCCESS)
|
||||
if(tx_queue_receive(&ble_tx_queue,&recv_msg,TX_WAIT_FOREVER) == TX_SUCCESS)
|
||||
{
|
||||
HCBle_SendData("#{\"lat\":%.6f,\"lon\":%.6f,\"angle\":%.1f}\n",
|
||||
msg.lat, msg.lon,msg.angle);
|
||||
|
||||
HCBle_SendData("%s",recv_msg);
|
||||
}
|
||||
tx_thread_sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,17 +30,12 @@ typedef struct
|
||||
}RingBuffer;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float lat;
|
||||
float lon;
|
||||
float angle;
|
||||
}BleMessage;
|
||||
|
||||
|
||||
extern uint8_t rx_data;
|
||||
extern RingBuffer ble_rx_ring; //<2F><>ʼ<EFBFBD><CABC>
|
||||
extern uint8_t uart_dma_rx_buf[UART_DMA_RX_BUF_SIZE];
|
||||
extern BleMessage current_location;
|
||||
extern LocationData current_location;
|
||||
|
||||
extern uint8_t flag;
|
||||
|
||||
|
||||
255
fun/IMU.h
255
fun/IMU.h
@@ -1,258 +1,7 @@
|
||||
/******************************************************************************
|
||||
<20>豸<EFBFBD><E8B1B8>IM948ģ<38><C4A3>֮<EFBFBD><D6AE><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ͨ<EFBFBD>ſ<EFBFBD>
|
||||
<EFBFBD>汾: V1.05
|
||||
<EFBFBD><EFBFBD>¼: 1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ټƺ<D9BC><C6BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̿<EFBFBD><CCBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
2<><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ų<EFBFBD>У<D0A3><D7BC>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
||||
3<><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD>
|
||||
4<><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>þ<EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>ģʽ<C4A3>Ĵ<EFBFBD><C4B4><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
5<><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>Ȧ<EFBFBD><C8A6><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><CDB8>
|
||||
6<><36><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>z<EFBFBD>Ƕ<EFBFBD>Ϊָ<CEAA><D6B8>ֵ
|
||||
*******************************************************************************/
|
||||
#ifndef __IMU_H__
|
||||
#define __IMU_H__
|
||||
|
||||
#include "headfile.h"
|
||||
|
||||
typedef signed char S8;
|
||||
typedef unsigned char U8;
|
||||
typedef signed short S16;
|
||||
typedef unsigned short U16;
|
||||
typedef signed long S32;
|
||||
typedef unsigned long U32;
|
||||
typedef float F32;
|
||||
#define pow2(x) ((x)*(x)) // <20><>ƽ<EFBFBD><C6BD>
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>ʱת<CAB1><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--------------
|
||||
#define scaleAccel 0.00478515625f // <20><><EFBFBD>ٶ<EFBFBD> [-16g~+16g] 9.8*16/32768
|
||||
#define scaleQuat 0.000030517578125f // <20><>Ԫ<EFBFBD><D4AA> [-1~+1] 1/32768
|
||||
#define scaleAngle 0.0054931640625f // <20>Ƕ<EFBFBD> [-180~+180] 180/32768
|
||||
#define scaleAngleSpeed 0.06103515625f // <20><><EFBFBD>ٶ<EFBFBD> [-2000~+2000] 2000/32768
|
||||
#define scaleMag 0.15106201171875f // <20>ų<EFBFBD> [-4950~+4950] 4950/32768
|
||||
#define scaleTemperature 0.01f // <20>¶<EFBFBD>
|
||||
#define scaleAirPressure 0.0002384185791f // <20><>ѹ [-2000~+2000] 2000/8388608
|
||||
#define scaleHeight 0.0010728836f // <20>߶<EFBFBD> [-9000~+9000] 9000/8388608
|
||||
|
||||
#define CmdPacket_Begin 0x49 // <20><>ʼ<EFBFBD><CABC>
|
||||
#define CmdPacket_End 0x4D // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define CmdPacketMaxDatSizeRx 73 // ģ<>鷢<EFBFBD><E9B7A2><EFBFBD><EFBFBD> <20><><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define CmdPacketMaxDatSizeTx 31 // <20><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD> <20><><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
#define FifoSize 200 // <20><><EFBFBD><EFBFBD>3<EFBFBD><33>fifo<66><6F>С <20>ֽ<EFBFBD><D6BD><EFBFBD>
|
||||
typedef struct // <20><><EFBFBD><EFBFBD> Fifo<66><6F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
U8 RxBuf[FifoSize];
|
||||
volatile U8 In;
|
||||
volatile U8 Out;
|
||||
volatile U8 Cnt;
|
||||
}struct_UartFifo;
|
||||
extern struct_UartFifo UartFifo;
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB>浽fifo<66><6F>, Ȼ<><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>
|
||||
#define Fifo_in(RxByte) if (FifoSize > UartFifo.Cnt)\
|
||||
{\
|
||||
UartFifo.RxBuf[UartFifo.In] = (RxByte);\
|
||||
if(++UartFifo.In >= FifoSize)\
|
||||
{\
|
||||
UartFifo.In = 0;\
|
||||
}\
|
||||
++UartFifo.Cnt;\
|
||||
}
|
||||
|
||||
|
||||
// ===============================<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>====================================
|
||||
// #define __Debug // ʹ<>õ<EFBFBD><C3B5>Կ<EFBFBD><D4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ,<2C><>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>α<EFBFBD><CEB1>伴<EFBFBD><E4BCB4>
|
||||
#ifdef __Debug
|
||||
#define Dbp(fmt, args...) printf(fmt, ##args) // <20><><EFBFBD><EFBFBD>Ҫʹ<D2AA>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>Ϣ, <20>û<EFBFBD><C3BB>Խ<EFBFBD>Dbp<62><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
extern void Dbp_U8_buf(char *sBeginInfo, char *sEndInfo, char *sFormat, const U8 *Buf, U32 Len);
|
||||
#else
|
||||
#define Dbp(fmt, args...)
|
||||
#define Dbp_U8_buf(sBeginInfo, sEndInfo, sFormat, Buf, Len)
|
||||
#endif
|
||||
|
||||
|
||||
// =================================<3D><>ֲ<EFBFBD>ӿ<EFBFBD>======================================
|
||||
/**
|
||||
* <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>, <20>û<EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD>ѽ<EFBFBD><D1BD>յ<EFBFBD><D5B5><EFBFBD>ÿ<EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param byte <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD>ÿ<EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @return U8 1=<3D><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>, 0δ<30><CEB4>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
|
||||
*/
|
||||
extern U8 Cmd_GetPkt(U8 byte);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD>뵽 Cmd_RxUnpack(U8 *buf, U8 DLen) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ڸú<DAB8><C3BA><EFBFBD><EFBFBD>ﴦ<EFBFBD><EFB4A6><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD>Ǹ<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>һ<EFBFBD>е<EFBFBD>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
|
||||
extern F32 AngleX,AngleY,AngleZ;// <20><>Cmd_RxUnpack<63>л<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8>µ<EFBFBD>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>û<EFBFBD><C3BB>Լ<EFBFBD><D4BC><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3>ɲο<C9B2><CEBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD>
|
||||
extern U8 isNewData;// 1=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>ݵ<EFBFBD>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
extern void im948_test(void); // <20><><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE> <20><><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>ָ<EFBFBD>Ȼ<EEA3AC><C8BB><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD>T<EFBFBD><EFBCB4>
|
||||
|
||||
// ================================ģ<><C4A3><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>ָ<EFBFBD><D6B8>=================================
|
||||
extern U8 targetDeviceAddress; // ͨ<>ŵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ϊ0-254ָ<34><D6B8><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ϊ255<35><35><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>豸(<28><><EFBFBD>㲥), <20><><EFBFBD><EFBFBD>Ҫʹ<D2AA><CAB9>485<38><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽͨ<CABD><CDA8>ʱͨ<CAB1><CDA8><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>ѡ<EFBFBD><D1A1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD><C7B4><EFBFBD>1<EFBFBD><31>1ͨ<31><CDA8><EFBFBD><EFBFBD>Ϊ<EFBFBD>㲥<EFBFBD><E3B2A5>ַ255<35><35><EFBFBD><EFBFBD>
|
||||
extern void Cmd_02(void);// ˯<>ߴ<EFBFBD><DFB4><EFBFBD><EFBFBD><EFBFBD>
|
||||
extern void Cmd_03(void);// <20><><EFBFBD>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD><EFBFBD>
|
||||
extern void Cmd_18(void);// <20>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>
|
||||
extern void Cmd_19(void);// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>
|
||||
extern void Cmd_11(void);// <20><>ȡ1<C8A1>ζ<EFBFBD><CEB6>ĵĹ<C4B5><C4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
extern void Cmd_10(void);// <20><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD>Ժ<EFBFBD>״̬
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
* @param accStill <20>ߵ<EFBFBD>-<2D><>ֹ״̬<D7B4><CCAC><EFBFBD>ٶȷ<D9B6>ֵ <20><>λdm/s?
|
||||
* @param stillToZero <20>ߵ<EFBFBD>-<2D><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>(<28><>λcm/s) 0:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 255:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param moveToZero <20>ߵ<EFBFBD>-<2D><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>(<28><>λcm/s) 0:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param isCompassOn 1=<3D><><EFBFBD>ںϴų<CFB4> 0=<3D><><EFBFBD>ںϴų<CFB4>
|
||||
* @param barometerFilter <20><>ѹ<EFBFBD>Ƶ<EFBFBD><C6B5>˲<EFBFBD><CBB2>ȼ<EFBFBD>[ȡֵ0-3],<2C><>ֵԽ<D6B5><D4BD>Խƽ<D4BD>ȵ<EFBFBD>ʵʱ<CAB5><CAB1>Խ<EFBFBD><D4BD>
|
||||
* @param reportHz <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1>Ĵ<EFBFBD><C4B4><EFBFBD>֡<EFBFBD><D6A1>[ȡֵ0-250HZ], 0<><30>ʾ0.5HZ
|
||||
* @param gyroFilter <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>ϵ<EFBFBD><CFB5>[ȡֵ0-2],<2C><>ֵԽ<D6B5><D4BD>Խƽ<D4BD>ȵ<EFBFBD>ʵʱ<CAB5><CAB1>Խ<EFBFBD><D4BD>
|
||||
* @param accFilter <20><><EFBFBD>ټ<EFBFBD><D9BC>˲<EFBFBD>ϵ<EFBFBD><CFB5>[ȡֵ0-4],<2C><>ֵԽ<D6B5><D4BD>Խƽ<D4BD>ȵ<EFBFBD>ʵʱ<CAB5><CAB1>Խ<EFBFBD><D4BD>
|
||||
* @param compassFilter <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>ϵ<EFBFBD><CFB5>[ȡֵ0-9],<2C><>ֵԽ<D6B5><D4BD>Խƽ<D4BD>ȵ<EFBFBD>ʵʱ<CAB5><CAB1>Խ<EFBFBD><D4BD>
|
||||
* @param Cmd_ReportTag <20><><EFBFBD>ܶ<EFBFBD><DCB6>ı<EFBFBD>ʶ
|
||||
*/
|
||||
extern void Cmd_12(U8 accStill, U8 stillToZero, U8 moveToZero, U8 isCompassOn, U8 barometerFilter, U8 reportHz, U8 gyroFilter, U8 accFilter, U8 compassFilter, U16 Cmd_ReportTag);
|
||||
extern void Cmd_13(void);// <20>ߵ<EFBFBD><DFB5><EFBFBD>ά<EFBFBD>ռ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
extern void Cmd_16(void);// <20>Ʋ<EFBFBD><C6B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
extern void Cmd_14(void);// <20>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>У<D0A3><D7BC><EFBFBD><EFBFBD>
|
||||
extern void Cmd_15(void);// <20><><EFBFBD>浱ǰУ<D0A3><D7BC><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>У<D0A3><D7BC><EFBFBD><EFBFBD>
|
||||
extern void Cmd_07(void);// <20><><EFBFBD>ټƼ<D9BC><C6BC><EFBFBD>У ģ<>龲ֹ<E9BEB2><D6B9>ˮƽ<CBAE><C6BD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>յ<EFBFBD><D5B5>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD>ȴ<EFBFBD>5<EFBFBD>뼴<EFBFBD><EBBCB4>
|
||||
/**
|
||||
* <20><><EFBFBD>ټƸ߾<C6B8><DFBE><EFBFBD>У
|
||||
* @param flag <20><>ģ<EFBFBD><C4A3>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>У״̬ʱ<CCAC><CAB1>
|
||||
* ֵ0 <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼһ<CABC><D2BB>У<D0A3><D7BC><EFBFBD>ɼ<EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* ֵ255 <20><>ʾѯ<CABE><D1AF><EFBFBD>豸<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>У
|
||||
* <20><>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<D0A3><D7BC>:
|
||||
* ֵ1 <20><>ʾҪ<CABE>ɼ<EFBFBD><C9BC><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* ֵ255 <20><>ʾҪ<CABE>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
extern void Cmd_17(U8 flag);
|
||||
|
||||
extern void Cmd_32(void);// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У
|
||||
extern void Cmd_04(void);// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У
|
||||
extern void Cmd_05(void);// z<><7A><EFBFBD>ǹ<EFBFBD><C7B9><EFBFBD>
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD> Z<><5A><EFBFBD>Ƕ<EFBFBD>Ϊָ<CEAA><D6B8>ֵ
|
||||
* @param val Ҫ<><D2AA><EFBFBD>õĽǶ<C4BD>ֵ(<28><>λ0.001<EFBFBD><EFBFBD>)<29>з<EFBFBD><D0B7><EFBFBD>32λ<32><CEBB>
|
||||
*/
|
||||
extern void Cmd_28(S32 val);
|
||||
extern void Cmd_06(void);// xyz<79><7A><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>
|
||||
extern void Cmd_08(void);// <20>ָ<EFBFBD>Ĭ<EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵZ<CFB5><5A>ָ<EFBFBD>ָ<F2BCB0BB>Ĭ<EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD>PCB<43><42>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param accMatrix <20><><EFBFBD>ټƷ<D9BC><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param comMatrix <20><><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
extern void Cmd_20(S8 *accMatrix, S8 *comMatrix);
|
||||
extern void Cmd_21(void);// <20><>ȡPCB<43><42>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㲥<EFBFBD><E3B2A5><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param bleName <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>15<31><35><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>,<2C><>֧<EFBFBD><D6A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||
*/
|
||||
extern void Cmd_22(U8 *bleName);
|
||||
extern void Cmd_23(void);// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>㲥<EFBFBD><E3B2A5><EFBFBD><EFBFBD>
|
||||
/**
|
||||
* <20><><EFBFBD>ùػ<C3B9><D8BB><EFBFBD>ѹ<EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param PowerDownVoltageFlag <20>ػ<EFBFBD><D8BB><EFBFBD>ѹѡ<D1B9><D1A1> 0=3.4V(﮵<><EFAEB5><EFBFBD><EFBFBD><EFBFBD>) 1=2.7V(<28><><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD><EFBFBD>)
|
||||
* @param charge_full_mV <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>ѹ 0:3962mv 1:4002mv 2:4044mv 3:4086mv 4:4130mv 5:4175mv 6:4222mv 7:4270mv 8:4308mv 9:4349mv 10:4391mv
|
||||
* @param charge_full_mA <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD> 0:2ma 1:5ma 2:7ma 3:10ma 4:15ma 5:20ma 6:25ma 7:30ma
|
||||
* @param charge_mA <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0:20ma 1:30ma 2:40ma 3:50ma 4:60ma 5:70ma 6:80ma 7:90ma 8:100ma 9:110ma 10:120ma 11:140ma 12:160ma 13:180ma 14:200ma 15:220ma
|
||||
*/
|
||||
extern void Cmd_24(U8 PowerDownVoltageFlag, U8 charge_full_mV, U8 charge_full_mA, U8 charge_mA);
|
||||
extern void Cmd_25(void);// <20><>ȡ <20>ػ<EFBFBD><D8BB><EFBFBD>ѹ<EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
extern void Cmd_26(void);// <20>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>GPIO<49><4F><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param M 0=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 1=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 2=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 3=<3D><><EFBFBD><EFBFBD>0, 4=<3D><><EFBFBD><EFBFBD>1
|
||||
*/
|
||||
extern void Cmd_27(U8 M);
|
||||
extern void Cmd_2A(void);// <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
extern void Cmd_2B(void);// <20>豸<EFBFBD>ػ<EFBFBD>
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>йػ<D0B9>ʱ<EFBFBD><CAB1>
|
||||
*
|
||||
* @param idleToPowerOffTime <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڹ㲥<DAB9>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ﵽ<EFBFBD><EFB5BD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD>10<31><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ػ<EFBFBD> 0=<3D><><EFBFBD>ػ<EFBFBD>
|
||||
*/
|
||||
extern void Cmd_2C(U8 idleToPowerOffTime);
|
||||
extern void Cmd_2D(void);// <20><>ȡ <20><><EFBFBD>йػ<D0B9>ʱ<EFBFBD><CAB1>
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD> <20><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƺͳ<C6BA><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ʶ
|
||||
*
|
||||
* @param DisableBleSetNameAndCahrge 1=<3D><>ֹͨ<D6B9><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0=<3D><><EFBFBD><EFBFBD>(Ĭ<><C4AC>) <20><><EFBFBD>ܿͻ<DCBF><CDBB>IJ<EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>Ϊ1<CEAA><31><EFBFBD><EFBFBD>
|
||||
*/
|
||||
extern void Cmd_2E(U8 DisableBleSetNameAndCahrge);
|
||||
extern void Cmd_2F(void);// <20><>ȡ <20><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƺͳ<C6BA><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ʶ
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ͨ<EFBFBD>ŵ<EFBFBD>ַ
|
||||
*
|
||||
* @param address <20>豸<EFBFBD><E8B1B8>ַֻ<D6B7><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0-254
|
||||
*/
|
||||
extern void Cmd_30(U8 address);
|
||||
extern void Cmd_31(void);// <20><>ȡ <20><><EFBFBD><EFBFBD>ͨ<EFBFBD>ŵ<EFBFBD>ַ
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ټƺ<D9BC><C6BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param AccRange Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD><D9B6><EFBFBD><EFBFBD><EFBFBD> 0=2g 1=4g 2=8g 3=16g
|
||||
* @param GyroRange Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0=256 1=512 2=1024 3=2048
|
||||
*/
|
||||
extern void Cmd_33(U8 AccRange, U8 GyroRange);
|
||||
extern void Cmd_34(void);// <20><>ȡ <20><><EFBFBD>ټƺ<D9BC><C6BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>ʶ
|
||||
*
|
||||
* @param GyroAutoFlag 1=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȿ<EFBFBD> 0=<3D><>
|
||||
*/
|
||||
extern void Cmd_35(U8 GyroAutoFlag);
|
||||
extern void Cmd_36(void);// <20><>ȡ <20><><EFBFBD>ټƺ<D9BC><C6BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD> <20><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>ģʽ<C4A3>Ĵ<EFBFBD><C4B4><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
*
|
||||
* @param EcoTime_10s <20><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ģʽ(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD>ߺ<EFBFBD><DFBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹEcoTime_10s<30><73>10<31><30><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD><CBB6><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>) 0=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
extern void Cmd_37(U8 EcoTime_10s);
|
||||
extern void Cmd_38(void);// <20><>ȡ <20><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>ģʽ<C4A3>Ĵ<EFBFBD><C4B4><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
*
|
||||
* @param Flag ȡֵ2=<3D><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD>1=<3D><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>, 0=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҵ<EFBFBD><D2B4>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>
|
||||
*/
|
||||
extern void Cmd_40(U8 Flag);
|
||||
// <20><>ȡ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
extern void Cmd_41(void);
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD> <20><>ǰ<EFBFBD>߶<EFBFBD>Ϊָ<CEAA><D6B8>ֵ
|
||||
*
|
||||
* @param val Ҫ<><D2AA><EFBFBD>õĸ߶<C4B8>ֵ <20><>λΪmm
|
||||
*/
|
||||
extern void Cmd_42(S32 val);
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD> <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߶ȱ<DFB6>ʶ
|
||||
*
|
||||
* @param OnOff 0=<3D>ر<EFBFBD> 1=<3D><><EFBFBD><EFBFBD>
|
||||
*/
|
||||
extern void Cmd_43(U8 OnOff);
|
||||
// <20><>ȡ <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߶ȱ<DFB6>ʶ
|
||||
extern void Cmd_44(void);
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param BaudRate Ŀ<>겨<EFBFBD><EAB2A8><EFBFBD><EFBFBD> 0=9600 1=115200 2=230400 3=460800
|
||||
*/
|
||||
extern void Cmd_47(U8 BaudRate);
|
||||
// <20><>ȡ <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>
|
||||
extern void Cmd_48(void);
|
||||
// <20><>˸<EFBFBD><CBB8><EFBFBD><EFBFBD>ledָʾ<D6B8><CABE>
|
||||
extern void Cmd_49(void);
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><CDB8>
|
||||
*
|
||||
* @param TxBuf Ҫ<D2AA><CDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param TxLen <20>ֽ<EFBFBD><D6BD><EFBFBD> <20><><EFBFBD><EFBFBD>С<EFBFBD><D0A1>CmdPacketMaxDatSizeTx
|
||||
*/
|
||||
extern void Cmd_50(U8 *TxBuf, U8 TxLen);
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD> <20>Ƿ<EFBFBD><C7B7>ϴ<EFBFBD><CFB4><EFBFBD>Ȧ<EFBFBD><C8A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param isReportCycle 0=<3D><><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 1=<3D><><EFBFBD><EFBFBD>Ȧ<EFBFBD><C8A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD>Ǵ<EFBFBD><C7B4><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȧ<EFBFBD><C8A6>
|
||||
*/
|
||||
extern void Cmd_51(U8 isReportCycle);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
void imu_thread_entry(ULONG thread_input);
|
||||
#endif
|
||||
131
fun/Motor.c
131
fun/Motor.c
@@ -1,131 +0,0 @@
|
||||
#include "Motor.h"
|
||||
|
||||
extern TIM_HandleTypeDef htim3;
|
||||
extern TIM_HandleTypeDef htim4;
|
||||
|
||||
/*******
|
||||
PWMA --- TIM4_CHANNEL4
|
||||
|
||||
PMWB --- TIM3_CHANNEL4
|
||||
|
||||
STBY --- 5V Ĭ<><C4AC>5V <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*******/
|
||||
void PWM_GPIO_TIM_Init(void)
|
||||
{
|
||||
HAL_TIM_PWM_Start(&htim3,TIM_CHANNEL_4);
|
||||
HAL_TIM_PWM_Start(&htim4,TIM_CHANNEL_4);
|
||||
}
|
||||
|
||||
|
||||
void MotorA_Dir(uint8_t dir)
|
||||
{
|
||||
if(0 == dir) // ǰ<><C7B0>
|
||||
{
|
||||
HAL_GPIO_WritePin(AIN1_GPIO_Port,AIN1_Pin,GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(AIN2_GPIO_Port,AIN2_Pin,GPIO_PIN_RESET);
|
||||
}
|
||||
else // <20><>ת
|
||||
{
|
||||
HAL_GPIO_WritePin(AIN1_GPIO_Port,AIN1_Pin,GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(AIN2_GPIO_Port,AIN2_Pin,GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MotorB_Dir(uint8_t dir)
|
||||
{
|
||||
if(0 == dir) // ǰ<><C7B0>
|
||||
{
|
||||
HAL_GPIO_WritePin(BIN1_GPIO_Port,BIN1_Pin,GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(BIN2_GPIO_Port,BIN2_Pin,GPIO_PIN_RESET);
|
||||
}
|
||||
else // <20><>ת
|
||||
{
|
||||
HAL_GPIO_WritePin(BIN1_GPIO_Port,BIN1_Pin,GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(BIN2_GPIO_Port,BIN2_Pin,GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>A<EFBFBD><41><EFBFBD>ٶ<EFBFBD>
|
||||
void MotorA_Speed(uint8_t speed)
|
||||
{
|
||||
__HAL_TIM_SET_COMPARE(&htim4,TIM_CHANNEL_4,speed);
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>B<EFBFBD><42><EFBFBD>ٶ<EFBFBD>
|
||||
void MotorB_Speed(uint8_t speed)
|
||||
{
|
||||
__HAL_TIM_SET_COMPARE(&htim3,TIM_CHANNEL_4,speed);
|
||||
}
|
||||
|
||||
|
||||
// ʾ<><CABE> ͬʱ<CDAC><CAB1><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>A/B
|
||||
// <20><>ʾ <20><><EFBFBD><EFBFBD> Dir 0 ---- ǰ<><C7B0> go forward
|
||||
// <20><><EFBFBD><EFBFBD> Dir 1 ---- <20><><EFBFBD><EFBFBD> go forward
|
||||
//void DriveBOTH(int16_t speedA,int16_t speedB)
|
||||
//{
|
||||
// // <20><><EFBFBD><EFBFBD> A
|
||||
// if (speedA >= 0) MotorA_Dir(0);
|
||||
// else
|
||||
// {
|
||||
// MotorA_Dir(1);
|
||||
// speedA = -speedA;
|
||||
// }
|
||||
// MotorA_Speed(speedA);
|
||||
//
|
||||
// // <20><><EFBFBD><EFBFBD> B
|
||||
// if (speedB >= 0) MotorB_Dir(0);
|
||||
// else
|
||||
// {
|
||||
// MotorB_Dir(1);
|
||||
// speedB = -speedB;
|
||||
// }
|
||||
// MotorB_Speed(speedB);
|
||||
//}
|
||||
|
||||
|
||||
// Motor.c <20><><EFBFBD>Ͻ<EFBFBD><CFBD>д<EFBFBD><D0B4><EFBFBD>
|
||||
void DriveBOTH(int16_t speedA, int16_t speedB)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A
|
||||
if(speedA == 0) {
|
||||
// <20>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>͵<EFBFBD>ƽ
|
||||
HAL_GPIO_WritePin(AIN1_GPIO_Port, AIN1_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(AIN2_GPIO_Port, AIN2_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
else if(speedA > 0) {
|
||||
HAL_GPIO_WritePin(AIN1_GPIO_Port, AIN1_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(AIN2_GPIO_Port, AIN2_Pin, GPIO_PIN_RESET);
|
||||
speedA = abs(speedA); // ȡ<><C8A1><EFBFBD><EFBFBD>ֵ
|
||||
}
|
||||
else {
|
||||
HAL_GPIO_WritePin(AIN1_GPIO_Port, AIN1_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(AIN2_GPIO_Port, AIN2_Pin, GPIO_PIN_SET);
|
||||
speedA = abs(speedA); // ȡ<><C8A1><EFBFBD><EFBFBD>ֵ
|
||||
}
|
||||
|
||||
|
||||
if(speedB == 0) {
|
||||
// <20>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>͵<EFBFBD>ƽ
|
||||
HAL_GPIO_WritePin(BIN1_GPIO_Port, BIN1_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(BIN2_GPIO_Port, BIN2_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
else if(speedB > 0) {
|
||||
HAL_GPIO_WritePin(BIN1_GPIO_Port, BIN1_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(BIN2_GPIO_Port, BIN2_Pin, GPIO_PIN_RESET);
|
||||
speedB = abs(speedB); // ȡ<><C8A1><EFBFBD><EFBFBD>ֵ
|
||||
}
|
||||
else {
|
||||
HAL_GPIO_WritePin(BIN1_GPIO_Port, BIN1_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(BIN2_GPIO_Port, BIN2_Pin, GPIO_PIN_SET);
|
||||
speedB = abs(speedB); // ȡ<><C8A1><EFBFBD><EFBFBD>ֵ
|
||||
}
|
||||
// ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B...
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>PWM
|
||||
__HAL_TIM_SET_COMPARE(&htim4, TIM_CHANNEL_4, speedA);
|
||||
__HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_4, speedB);
|
||||
}
|
||||
27
fun/Motor.h
27
fun/Motor.h
@@ -1,27 +0,0 @@
|
||||
#ifndef __MOTOR_H__
|
||||
#define __MOTOR_H__
|
||||
|
||||
#include "headfile.h"
|
||||
|
||||
|
||||
void PWM_GPIO_TIM_Init(void);
|
||||
|
||||
void MotorA_Dir(uint8_t dir);
|
||||
|
||||
|
||||
void MotorB_Dir(uint8_t dir);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>A<EFBFBD><41><EFBFBD>ٶ<EFBFBD>
|
||||
void MotorA_Speed(uint8_t speed);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>B<EFBFBD><42><EFBFBD>ٶ<EFBFBD>
|
||||
void MotorB_Speed(uint8_t speed);
|
||||
|
||||
// ʾ<><CABE> ͬʱ<CDAC><CAB1><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>A/B
|
||||
// <20><>ʾ <20><><EFBFBD><EFBFBD> Dir 0 ---- ǰ<><C7B0> go forward
|
||||
// <20><><EFBFBD><EFBFBD> Dir 1 ---- <20><><EFBFBD><EFBFBD> go forward
|
||||
void DriveBOTH(int16_t speedA,int16_t speedB);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,7 @@ volatile uint32_t ic_val1 = 0; //
|
||||
volatile uint32_t ic_val2 = 0; // <20><><EFBFBD><EFBFBD>ֵ2
|
||||
volatile uint8_t is_first_capture = 0; // <20>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA>һ<EFBFBD>β<EFBFBD><CEB2><EFBFBD>
|
||||
volatile uint32_t distance_cm = 0; // <20><><EFBFBD>밴<EFBFBD><EBB0B4> cm<63><6D><EFBFBD><EFBFBD>
|
||||
volatile uint8_t obstacle_level = 0; // 0 - <20><><EFBFBD>ϰ<EFBFBD> , 1 = Զ ,2 = <20><> , 3 = <20><>
|
||||
|
||||
/*******
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Psc: 250 - 1 <20>Դﵽ 1tick = 1us<75><73>Ч<EFBFBD><D0A7>
|
||||
@@ -64,7 +64,7 @@ void HCSR04_Trigger(void)
|
||||
|
||||
#ifdef TEST
|
||||
void ultrasonic_task_entry(ULONG thread_input) {
|
||||
HAL_TIM_IC_Start_IT(&htim5, TIM_CHANNEL_1);
|
||||
HAL_TIM_IC_Start_IT(&htim2, TIM_CHANNEL_2);
|
||||
DWT_Init();
|
||||
|
||||
while (1) {
|
||||
@@ -74,22 +74,9 @@ void ultrasonic_task_entry(ULONG thread_input) {
|
||||
if (tx_event_flags_get(&ultrasonic_event, EVENT_ECHO_DONE, TX_OR_CLEAR,
|
||||
&events, TX_WAIT_FOREVER) == TX_SUCCESS) {
|
||||
if (distance_cm < 30) {
|
||||
obstacle_level = 3; // <20>ܽ<EFBFBD>
|
||||
}else if(distance_cm > 30 && distance_cm < 50)
|
||||
{
|
||||
obstacle_level = 2; // <20><>
|
||||
}else if(distance_cm > 50 && distance_cm < 80)
|
||||
{
|
||||
obstacle_level = 1;
|
||||
}else
|
||||
{
|
||||
obstacle_level = 0; // <20><><EFBFBD>ϰ<EFBFBD>
|
||||
}
|
||||
|
||||
if(obstacle_level > 0)
|
||||
{
|
||||
tx_event_flags_set(&response_events,EVENT_OBSTACLE_DETECTED,TX_OR); // <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
}
|
||||
tx_event_flags_set(&system_events,EVENT_OBSTACLE_DETECTED,TX_OR);// ִ<EFBFBD>б<EFBFBD><EFBFBD>ϴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
tx_thread_sleep(50); // ÿ<>β<EFBFBD><CEB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 50 ticks 20Hz <20><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>
|
||||
@@ -107,14 +94,14 @@ Echo
|
||||
|
||||
******/
|
||||
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) {
|
||||
if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1) {
|
||||
if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_2) {
|
||||
if (is_first_capture == 0) {
|
||||
ic_val1 = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_1);
|
||||
__HAL_TIM_SET_CAPTUREPOLARITY(htim, TIM_CHANNEL_1, TIM_INPUTCHANNELPOLARITY_FALLING);
|
||||
ic_val1 = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_2);
|
||||
__HAL_TIM_SET_CAPTUREPOLARITY(htim, TIM_CHANNEL_2, TIM_INPUTCHANNELPOLARITY_FALLING);
|
||||
is_first_capture = 1;
|
||||
} else {
|
||||
ic_val2 = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_1);
|
||||
__HAL_TIM_SET_CAPTUREPOLARITY(htim, TIM_CHANNEL_1, TIM_INPUTCHANNELPOLARITY_RISING);
|
||||
ic_val2 = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_2);
|
||||
__HAL_TIM_SET_CAPTUREPOLARITY(htim, TIM_CHANNEL_2, TIM_INPUTCHANNELPOLARITY_RISING);
|
||||
is_first_capture = 0;
|
||||
|
||||
uint32_t delta = (ic_val2 > ic_val1) ? (ic_val2 - ic_val1) : (0xFFFF - ic_val1 + ic_val2);
|
||||
@@ -123,7 +110,6 @@ void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) {
|
||||
// ֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD> ȡ<><C8A1>ע<EFBFBD><D7A2><EFBFBD>Ի<EFBFBD><D4BB>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
tx_event_flags_set(&ultrasonic_event, EVENT_ECHO_DONE, TX_OR);
|
||||
}
|
||||
HAL_TIM_IC_Start_IT(&htim5,TIM_CHANNEL_1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
#define HCSR_TEST 1
|
||||
#define EVENT_ECHO_DONE 0x01
|
||||
|
||||
extern volatile uint8_t obstacle_level;
|
||||
extern volatile uint32_t distance_cm;
|
||||
|
||||
void DWT_Init(void);
|
||||
/********
|
||||
delay_us() <20><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5> (ʹ<><CAB9>DWT) <20><>ȷ<EFBFBD><C8B7>
|
||||
|
||||
135
fun/encoder.c
135
fun/encoder.c
@@ -1,135 +0,0 @@
|
||||
#include "encoder.h"
|
||||
|
||||
volatile int32_t tick_L = 0,tick_R = 0;
|
||||
volatile int16_t rpm_L = 0,rpm_R = 0;
|
||||
|
||||
extern TIM_HandleTypeDef htim1;
|
||||
extern TIM_HandleTypeDef htim8;
|
||||
|
||||
static TX_THREAD enc_thread;
|
||||
static UCHAR enc_stack[512];
|
||||
|
||||
static void enc_thread_entry(ULONG);
|
||||
|
||||
UINT Encoder_ThreadCreate(void)
|
||||
{
|
||||
UINT status;
|
||||
|
||||
HAL_TIM_Encoder_Start(&htim1,TIM_CHANNEL_ALL);
|
||||
HAL_TIM_Encoder_Start(&htim8,TIM_CHANNEL_ALL);
|
||||
|
||||
__HAL_TIM_SET_COUNTER(&htim1,0);
|
||||
__HAL_TIM_SET_COUNTER(&htim8,0);
|
||||
|
||||
status = tx_thread_create(&enc_thread, "Encoder", enc_thread_entry, 0,
|
||||
enc_stack, sizeof(enc_stack),
|
||||
6, 6, TX_NO_TIME_SLICE, TX_AUTO_START);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
static void enc_thread_entry(ULONG arg)
|
||||
{
|
||||
const float msPerMin = 6000.0f;
|
||||
const float ticksPerRev = 1024.0f; // <20><><EFBFBD><EFBFBD> * 4
|
||||
uint16_t lastL = 0, lastR = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
uint16_t cntL = __HAL_TIM_GET_COUNTER(&htim1);
|
||||
uint16_t cntR = __HAL_TIM_GET_COUNTER(&htim8);
|
||||
|
||||
int16_t dL = (int16_t)(cntL - lastL);
|
||||
int16_t dR = (int16_t)(cntR - lastR);
|
||||
|
||||
lastL = cntL;
|
||||
lastR = cntR;
|
||||
|
||||
tick_L += dL;
|
||||
tick_R += dR;
|
||||
|
||||
rpm_L = (int16_t)(dL * msPerMin / (ticksPerRev * 10));
|
||||
rpm_R = (int16_t)(dR * msPerMin / (ticksPerRev * 10));
|
||||
|
||||
tx_thread_sleep(10);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
|
||||
//ControlThread
|
||||
//
|
||||
|
||||
static TX_THREAD control_thread;
|
||||
static UCHAR control_stack[512];
|
||||
|
||||
volatile int16_t target_rpm_L = 0;
|
||||
volatile int16_t target_rpm_R = 0;
|
||||
|
||||
static void control_thread_entry(ULONG arg);
|
||||
|
||||
|
||||
UINT ControlThreadCreate(void)
|
||||
{
|
||||
UINT status;
|
||||
status = tx_thread_create(&control_thread, "Control", control_thread_entry, 0,
|
||||
control_stack, sizeof(control_stack),
|
||||
7, 7, TX_NO_TIME_SLICE, TX_AUTO_START);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
static void control_thread_entry(ULONG arg)
|
||||
{
|
||||
static int16_t pwmL = 0, pwmR = 0;
|
||||
static float integralL = 0, integralR = 0;
|
||||
float Kp = 1.0f, Ki = 0.1f;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int16_t errorL = target_rpm_L - rpm_L;
|
||||
int16_t errorR = target_rpm_R - rpm_R;
|
||||
|
||||
integralL += errorL;
|
||||
integralR += errorR;
|
||||
|
||||
// <20>ڻ<EFBFBD><DABB><EFBFBD><EFBFBD>ۼӺ<DBBC><D3BA><EFBFBD><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (errorL == 0) integralL = 0;
|
||||
if (errorR == 0) integralR = 0;
|
||||
|
||||
const float max_integral = 1000.0f;
|
||||
if(integralL > max_integral) integralL = max_integral;
|
||||
if(integralL < -max_integral) integralL = -max_integral;
|
||||
|
||||
if(integralR > max_integral) integralR = max_integral;
|
||||
if(integralR < -max_integral) integralR = -max_integral;
|
||||
// ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>integralR...
|
||||
|
||||
pwmL += (int16_t)(Kp * errorL + Ki * integralL);
|
||||
pwmR += (int16_t)(Kp * errorR + Ki * integralR);
|
||||
|
||||
if (pwmL < 0) pwmL = 0;
|
||||
if (pwmL > 255) pwmL = 255;
|
||||
if (pwmR < 0) pwmR = 0;
|
||||
if (pwmR > 255) pwmR = 255;
|
||||
|
||||
DriveBOTH(pwmL, pwmR);
|
||||
|
||||
tx_thread_sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int16_t map_speed_to_rpm(int speed)
|
||||
{
|
||||
if (abs(speed) < 30) return 0;
|
||||
return (speed - 60) * 1.5; // <20><><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef __ENCODER_H__
|
||||
#define __ENCODER_H__
|
||||
|
||||
#include "headfile.h"
|
||||
|
||||
extern volatile int16_t target_rpm_L;
|
||||
extern volatile int16_t target_rpm_R;
|
||||
int16_t map_speed_to_rpm(int speed);
|
||||
UINT ControlThreadCreate(void);
|
||||
UINT Encoder_ThreadCreate(void);
|
||||
|
||||
#endif
|
||||
281
fun/gps.c
281
fun/gps.c
@@ -26,215 +26,68 @@ _GPSData GPS;
|
||||
void GPS_Init(void)
|
||||
{
|
||||
HAL_UARTEx_ReceiveToIdle_IT(&huart2, GPS_DMA_RX_BUF, GPS_DMA_RX_BUF_LEN);
|
||||
// HAL_UARTEx_ReceiveToIdle_DMA(&huart2,GPS_DMA_RX_BUF,GPS_DMA_RX_BUF_LEN);
|
||||
// __HAL_DMA_DISABLE_IT(&handle_GPDMA1_Channel3, DMA_IT_HT); // <20><><EFBFBD>ð봫<C3B0><EBB4AB>
|
||||
}
|
||||
|
||||
#ifdef parse
|
||||
// GPS<50><53><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD>
|
||||
//void parseGpsBuffer()
|
||||
//{
|
||||
// char *subString;
|
||||
// char *subStringNext;
|
||||
// char i = 0;
|
||||
//
|
||||
// if(GPS.isGetData)
|
||||
// {
|
||||
// GPS.isGetData = 0; // <20>ѱ<EFBFBD>־λ<D6BE><CEBB>Ϊ1
|
||||
//
|
||||
// char usefullBuffer[2] = {0};
|
||||
// for(i = 0; i <= 6; i++)
|
||||
// {
|
||||
// if(i == 0)
|
||||
// {
|
||||
//
|
||||
// subString = strstr(GPS.GPS_Buffer,",");
|
||||
// if(!subString)return;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// subString++;
|
||||
// subStringNext = strstr(subString,",");
|
||||
// if(!subStringNext)return;
|
||||
//
|
||||
// switch(i)
|
||||
// {
|
||||
// case 1:
|
||||
// memcpy(GPS.UTCTime,subString,subStringNext - subString);
|
||||
// break;
|
||||
// case 2:
|
||||
// memcpy(usefullBuffer,subString,subStringNext - subString);
|
||||
// break;
|
||||
// case 3:
|
||||
// memcpy(GPS.latitude,subString,subStringNext - subString);
|
||||
// break;
|
||||
// case 4:
|
||||
// memcpy(GPS.N_S,subString,subStringNext - subString);
|
||||
// break;
|
||||
// case 5:
|
||||
// memcpy(GPS.longitude,subString,subStringNext - subString);
|
||||
// break;
|
||||
// case 6:
|
||||
// memcpy(GPS.E_W,subString,subStringNext - subString);
|
||||
// break;
|
||||
// default:break;
|
||||
// }
|
||||
//
|
||||
// subString = subStringNext;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// GPS.isParseData = 1;
|
||||
// GPS.isUsefull = (usefullBuffer[0] == 'A') ? 1 : 0;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
|
||||
//void parseGpsBuffer(void)
|
||||
//{
|
||||
// if (!GPS.isGetData) return;
|
||||
// GPS.isGetData = 0;
|
||||
|
||||
// /* ----------- <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD> ------------ */
|
||||
// const char *p = GPS.GPS_Buffer;
|
||||
|
||||
// /* <20><> RMC ----------------------------------------------------- */
|
||||
// if (!strncmp(p, "$GNRMC", 6) || !strncmp(p, "$GPRMC", 6))
|
||||
// {
|
||||
// char status, lat[16], ns[3], lon[16], ew[3];
|
||||
// if (sscanf(p,
|
||||
// "$%*[^,],%*[^,],%c,%15[^,],%2[^,],%15[^,],%2[^,],",
|
||||
// &status, lat, ns, lon, ew) == 5)
|
||||
// {
|
||||
// if (status == 'A') /* <20><>λ<EFBFBD><CEBB>Ч */
|
||||
// {
|
||||
// strcpy(GPS.latitude, lat);
|
||||
// strcpy(GPS.N_S, ns);
|
||||
// strcpy(GPS.longitude, lon);
|
||||
// strcpy(GPS.E_W, ew);
|
||||
// GPS.isParseData = 1;
|
||||
// GPS.isUsefull = 1;
|
||||
// }
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
|
||||
// /* <20><> GGA ----------------------------------------------------- */
|
||||
// if (!strncmp(p, "$GNGGA", 6) || !strncmp(p, "$GPGGA", 6))
|
||||
// {
|
||||
// int q; char lat[16], ns[3], lon[16], ew[3];
|
||||
// if (sscanf(p,
|
||||
// "$%*[^,],%*[^,],%15[^,],%2[^,],%15[^,],%2[^,],%d,",
|
||||
// lat, ns, lon, ew, &q) == 5)
|
||||
// {
|
||||
// if (q > 0) /* q=0 <20><EFBFBD>λ */
|
||||
// {
|
||||
// strcpy(GPS.latitude, lat);
|
||||
// strcpy(GPS.N_S, ns);
|
||||
// strcpy(GPS.longitude, lon);
|
||||
// strcpy(GPS.E_W, ew);
|
||||
// GPS.isParseData = 1;
|
||||
// GPS.isUsefull = 1;
|
||||
// }
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
|
||||
// /* <20><> GLL ----------------------------------------------------- */
|
||||
// if (!strncmp(p, "$GNGLL", 6) || !strncmp(p, "$GPGLL", 6))
|
||||
// {
|
||||
// char status, lat[16], ns[3], lon[16], ew[3];
|
||||
// if (sscanf(p,
|
||||
// "$%*[^,],%15[^,],%2[^,],%15[^,],%2[^,],%*[^,],%c",
|
||||
// lat, ns, lon, ew, &status) == 5)
|
||||
// {
|
||||
// if (status == 'A')
|
||||
// {
|
||||
// strcpy(GPS.latitude, lat);
|
||||
// strcpy(GPS.N_S, ns);
|
||||
// strcpy(GPS.longitude, lon);
|
||||
// strcpy(GPS.E_W, ew);
|
||||
// GPS.isParseData = 1;
|
||||
// GPS.isUsefull = 1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
/* === <20><> <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD> & <20><><EFBFBD>ͺ<EFBFBD><CDBA><EFBFBD> === */
|
||||
static char line_buf[GPS_Buffer_Length];
|
||||
static uint16_t line_w = 0;
|
||||
|
||||
void GPS_LinePush(uint8_t ch)
|
||||
void parseGpsBuffer()
|
||||
{
|
||||
if (ch == '\n') { /* <20><><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><D0BD><EFBFBD> */
|
||||
line_buf[line_w] = '\0';
|
||||
|
||||
|
||||
/* A. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '$' <20><>ͷ<EFBFBD><CDB7>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD><EFBFBD><EFBFBD> <20><> ֱ<><D6B1>ƴ<EFBFBD><C6B4> */
|
||||
if (line_buf[0] != '$' && GPS.isGetData == 0 && GPS.GPS_Buffer[0] == '$')
|
||||
{
|
||||
strncat(GPS.GPS_Buffer, line_buf, GPS_Buffer_Length - strlen(GPS.GPS_Buffer) - 1);
|
||||
}
|
||||
else /* B. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¾<EFBFBD> */
|
||||
{
|
||||
strncpy(GPS.GPS_Buffer, line_buf, GPS_Buffer_Length);
|
||||
}
|
||||
|
||||
line_w = 0;
|
||||
GPS.isGetData = 1;
|
||||
tx_event_flags_set(&system_events, EVENT_GPS_DATA_READY, TX_OR);
|
||||
return;
|
||||
}
|
||||
char *subString;
|
||||
char *subStringNext;
|
||||
char i = 0;
|
||||
|
||||
if(GPS.isGetData)
|
||||
{
|
||||
GPS.isGetData = 0; // <20>ѱ<EFBFBD>־λ<D6BE><CEBB>Ϊ1
|
||||
|
||||
char usefullBuffer[2] = {0};
|
||||
for(i = 0; i <= 6; i++)
|
||||
{
|
||||
if(i == 0)
|
||||
{
|
||||
|
||||
subString = strstr(GPS.GPS_Buffer,",");
|
||||
if(!subString)return;
|
||||
}
|
||||
else
|
||||
{
|
||||
subString++;
|
||||
subStringNext = strstr(subString,",");
|
||||
if(!subStringNext)return;
|
||||
|
||||
switch(i)
|
||||
{
|
||||
case 1:
|
||||
memcpy(GPS.UTCTime,subString,subStringNext - subString);
|
||||
break;
|
||||
case 2:
|
||||
memcpy(usefullBuffer,subString,subStringNext - subString);
|
||||
break;
|
||||
case 3:
|
||||
memcpy(GPS.latitude,subString,subStringNext - subString);
|
||||
break;
|
||||
case 4:
|
||||
memcpy(GPS.N_S,subString,subStringNext - subString);
|
||||
break;
|
||||
case 5:
|
||||
memcpy(GPS.longitude,subString,subStringNext - subString);
|
||||
break;
|
||||
case 6:
|
||||
memcpy(GPS.E_W,subString,subStringNext - subString);
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
|
||||
subString = subStringNext;
|
||||
}
|
||||
|
||||
}
|
||||
GPS.isParseData = 1;
|
||||
GPS.isUsefull = (usefullBuffer[0] == 'A') ? 1 : 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* === <20><> <20>½<EFBFBD><C2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻҪ<D6BB><D2AA>γ<EFBFBD><CEB3> === */
|
||||
void parseGpsBuffer(void)
|
||||
{
|
||||
if (!GPS.isGetData) return;
|
||||
GPS.isGetData = 0;
|
||||
GPS.isParseData = 0;
|
||||
GPS.isUsefull = 0;
|
||||
|
||||
const char *p = GPS.GPS_Buffer;
|
||||
/* ---- $GxRMC ---- */
|
||||
if (!strncmp(p, "$GNRMC", 6) || !strncmp(p, "$GPRMC", 6)) {
|
||||
char s, lat[16], ns[3], lon[16], ew[3];
|
||||
if (sscanf(p,
|
||||
"$%*[^,],%*[^,],%c,%15[^,],%2[^,],%15[^,],%2[^,],",
|
||||
&s, lat, ns, lon, ew) == 5 && s == 'A') {
|
||||
strcpy(GPS.latitude, lat); strcpy(GPS.N_S, ns);
|
||||
strcpy(GPS.longitude, lon); strcpy(GPS.E_W, ew);
|
||||
GPS.isParseData = GPS.isUsefull = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
/* ---- $GxGGA ---- */
|
||||
if (!strncmp(p, "$GNGGA", 6) || !strncmp(p, "$GPGGA", 6)) {
|
||||
int q; char lat[16], ns[3], lon[16], ew[3];
|
||||
if (sscanf(p,
|
||||
"$%*[^,],%*[^,],%15[^,],%2[^,],%15[^,],%2[^,],%d,",
|
||||
lat, ns, lon, ew, &q) == 5 && q > 0) {
|
||||
strcpy(GPS.latitude, lat); strcpy(GPS.N_S, ns);
|
||||
strcpy(GPS.longitude, lon); strcpy(GPS.E_W, ew);
|
||||
GPS.isParseData = GPS.isUsefull = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
/* ---- $GxGLL ---- */
|
||||
if (!strncmp(p, "$GNGLL", 6) || !strncmp(p, "$GPGLL", 6)) {
|
||||
char s, lat[16], ns[3], lon[16], ew[3];
|
||||
if (sscanf(p,
|
||||
"$%*[^,],%15[^,],%2[^,],%15[^,],%2[^,],%*[^,],%c",
|
||||
lat, ns, lon, ew, &s) == 5 && s == 'A') {
|
||||
strcpy(GPS.latitude, lat); strcpy(GPS.N_S, ns);
|
||||
strcpy(GPS.longitude, lon); strcpy(GPS.E_W, ew);
|
||||
GPS.isParseData = GPS.isUsefull = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#else // <20><><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD><C7B6>ڸĽ<DAB8><C4BD><EFBFBD><EFBFBD><EFBFBD>parse <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>в<EFBFBD><D0B2><EFBFBD>
|
||||
void parseGpsBuffer()
|
||||
{
|
||||
@@ -319,7 +172,7 @@ void GPS_Data_CLR(void)
|
||||
//
|
||||
// tx_event_flags_set(&system_events, EVENT_GPS_DATA_READY, TX_OR);
|
||||
// //<2F><><EFBFBD>¿<EFBFBD><C2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// HAL_UARTEx_ReceiveToIdle_IT(&huart2,GPS_DMA_RX_BUF,GPS_DMA_RX_BUF_LEN);
|
||||
// HAL_UARTEx_ReceiveToIdle_DMA(&huart2,GPS_DMA_RX_BUF,GPS_DMA_RX_BUF_LEN);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -333,30 +186,26 @@ void gps_thread_entry(ULONG thread_input)
|
||||
{
|
||||
GPS_Init();
|
||||
static int gps_first_fix_sent = 0;
|
||||
BleMessage msg;
|
||||
|
||||
while (1)
|
||||
{
|
||||
ULONG events;
|
||||
tx_event_flags_get(&system_events, EVENT_GPS_DATA_READY, TX_OR_CLEAR, &events, TX_WAIT_FOREVER);
|
||||
|
||||
parseGpsBuffer();
|
||||
// HCBle_SendData("[GPS] isGetData=%d, isParseData=%d, isUsefull=%d, Buffer=%s\r\n",
|
||||
// GPS.isGetData, GPS.isParseData, GPS.isUsefull, GPS.GPS_Buffer);
|
||||
|
||||
if (GPS.isParseData && GPS.isUsefull)
|
||||
{
|
||||
current_location.lat = Convert_to_degrees(GPS.latitude);
|
||||
current_location.lon = Convert_to_degrees(GPS.longitude);
|
||||
tx_event_flags_set(&system_events, EVENT_LOCATION_UPDATED, TX_OR);
|
||||
|
||||
|
||||
// msg.lat = current_location.lat;
|
||||
// msg.lon = current_location.lon;
|
||||
// snprintf(msg, sizeof(msg), "#{\"lat\":%.6f,\"lon\":%.6f,\"angle\":%.2f}\n",
|
||||
// current_location.lat,
|
||||
// current_location.lon,
|
||||
// current_location.angle);
|
||||
BleMessage msg = current_location;
|
||||
tx_queue_send(&ble_tx_queue, &msg, TX_WAIT_FOREVER);
|
||||
char msg[128];
|
||||
snprintf(msg, sizeof(msg), "#{\"lat\":%.6f,\"lon\":%.6f,\"angle\":%.2f}\n",
|
||||
current_location.lat,
|
||||
current_location.lon,
|
||||
current_location.angle);
|
||||
tx_queue_send(&ble_tx_queue, &msg, TX_WAIT_FOREVER);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
#define USART_REC_LEN 200
|
||||
#define EN_USART2_RX 1 //ʹ<>ܽ<EFBFBD><DCBD><EFBFBD> --- 1 <20><>֮ 0
|
||||
|
||||
#define GPS_DMA_RX_BUF_LEN 220 //<2F>ɸ<EFBFBD><C9B8><EFBFBD>NMEA<45><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define GPS_DMA_RX_BUF_LEN 200 //<2F>ɸ<EFBFBD><C9B8><EFBFBD>NMEA<45><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>gps<70>ṹ<EFBFBD><E1B9B9>
|
||||
#define GPS_Buffer_Length 256
|
||||
#define GPS_Buffer_Length 80
|
||||
#define UTCTime_Length 11
|
||||
#define latitude_Length 11
|
||||
#define N_S_Length 2
|
||||
@@ -32,10 +32,8 @@ typedef struct GPSData
|
||||
|
||||
extern _GPSData GPS;
|
||||
extern uint8_t GPS_DMA_RX_BUF[GPS_DMA_RX_BUF_LEN];
|
||||
double Convert_to_degrees(char *data);
|
||||
void parseGpsBuffer();
|
||||
|
||||
void gps_thread_entry(ULONG thread_input);
|
||||
void GPS_Init(void);
|
||||
void GPS_LinePush(uint8_t ch);
|
||||
|
||||
#endif
|
||||
@@ -13,19 +13,11 @@
|
||||
#include "stdlib.h"
|
||||
#include "stdarg.h"
|
||||
#include "string.h"
|
||||
#include "math.h"
|
||||
|
||||
#include "HCBle.h"
|
||||
#include "gps.h"
|
||||
#include "Shake_Motor.h"
|
||||
#include "Ultrasound.h"
|
||||
#include "Buzzer.h"
|
||||
#include "Motor.h"
|
||||
#include "IMU.h"
|
||||
#include "imu948.h"
|
||||
#include "encoder.h"
|
||||
|
||||
|
||||
#include "value.h" // ȫ<>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
#endif
|
||||
130
fun/imu948.c
130
fun/imu948.c
@@ -1,130 +0,0 @@
|
||||
#include "imu948.h"
|
||||
|
||||
#define DECLINATION_DEG -3.0
|
||||
extern _GPSData gps_data;
|
||||
extern TX_QUEUE ble_tx_queue;
|
||||
extern uint8_t rx_byte;
|
||||
extern TX_EVENT_FLAGS_GROUP sensor_events;
|
||||
|
||||
void imu600_init(void)
|
||||
{
|
||||
|
||||
HAL_UART_Receive_IT(&huart3,&rx_byte,1);
|
||||
HAL_Delay(6000);
|
||||
|
||||
//------- <20><><EFBFBD>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>úô<C3BA><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>-----
|
||||
Cmd_03(); //<2F><><EFBFBD>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD><EFBFBD>
|
||||
HAL_Delay(500);
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
* @param accStill <20>ߵ<EFBFBD>-<2D><>ֹ״̬<D7B4><CCAC><EFBFBD>ٶȷ<D9B6>ֵ <20><>λdm/s?
|
||||
* @param stillToZero <20>ߵ<EFBFBD>-<2D><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>(<28><>λcm/s) 0:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 255:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param moveToZero <20>ߵ<EFBFBD>-<2D><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>(<28><>λcm/s) 0:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param isCompassOn 1=<3D>迪<EFBFBD><E8BFAA><EFBFBD>ų<EFBFBD> 0=<3D><><EFBFBD>رմų<D5B4>
|
||||
* @param barometerFilter <20><>ѹ<EFBFBD>Ƶ<EFBFBD><C6B5>˲<EFBFBD><CBB2>ȼ<EFBFBD>[ȡֵ0-3],<2C><>ֵԽ<D6B5><D4BD>Խƽ<D4BD>ȵ<EFBFBD>ʵʱ<CAB5><CAB1>Խ<EFBFBD><D4BD>
|
||||
* @param reportHz <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1>Ĵ<EFBFBD><C4B4><EFBFBD>֡<EFBFBD><D6A1>[ȡֵ0-250HZ], 0<><30>ʾ0.5HZ
|
||||
* @param gyroFilter <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>ϵ<EFBFBD><CFB5>[ȡֵ0-2],<2C><>ֵԽ<D6B5><D4BD>Խƽ<D4BD>ȵ<EFBFBD>ʵʱ<CAB5><CAB1>Խ<EFBFBD><D4BD>
|
||||
* @param accFilter <20><><EFBFBD>ټ<EFBFBD><D9BC>˲<EFBFBD>ϵ<EFBFBD><CFB5>[ȡֵ0-4],<2C><>ֵԽ<D6B5><D4BD>Խƽ<D4BD>ȵ<EFBFBD>ʵʱ<CAB5><CAB1>Խ<EFBFBD><D4BD>
|
||||
* @param compassFilter <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>ϵ<EFBFBD><CFB5>[ȡֵ0-9],<2C><>ֵԽ<D6B5><D4BD>Խƽ<D4BD>ȵ<EFBFBD>ʵʱ<CAB5><CAB1>Խ<EFBFBD><D4BD>
|
||||
* @param Cmd_ReportTag <20><><EFBFBD>ܶ<EFBFBD><DCB6>ı<EFBFBD>ʶ
|
||||
*/
|
||||
Cmd_12(5, 255, 0, 0, 3, 2, 2, 4, 9, 0xFFF);// 2 <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>1) ֻ<><D6BB><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD>
|
||||
HAL_Delay(500);
|
||||
Cmd_19();// 3 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ҾͲ<D2BE><CDB2><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
//void IM948_Init(void)
|
||||
//{
|
||||
// HAL_UART_Receive_IT(&huart3, &rx_byte, 1);
|
||||
|
||||
// // <20><>ģ<EFBFBD><C4A3><EFBFBD>ϵ<EFBFBD>
|
||||
// tx_thread_sleep( TX_TIMER_TICKS_PER_SECOND * 5 );
|
||||
|
||||
|
||||
// Cmd_03(); // <20><><EFBFBD><EFBFBD>
|
||||
// tx_thread_sleep( TX_TIMER_TICKS_PER_SECOND / 10 );
|
||||
|
||||
// // ֻ<><D6BB><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD>
|
||||
// Cmd_12(
|
||||
// 5, 255, 0,
|
||||
// 0, 3, 5,
|
||||
// 2, 2, 4,
|
||||
// 0x0040 // ֻҪŷ<D2AA><C5B7><EFBFBD><EFBFBD>
|
||||
// );
|
||||
// tx_thread_sleep( TX_TIMER_TICKS_PER_SECOND / 10 );
|
||||
|
||||
// Cmd_19(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>
|
||||
//}
|
||||
|
||||
|
||||
extern TX_QUEUE im948_uart_rx_queue;
|
||||
/***
|
||||
<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD> <20><>IMU.c<><63>Ϊ<EFBFBD>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD><EFBFBD> Base
|
||||
<EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD>дӦ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
***/
|
||||
|
||||
void imu_angle_ble_task_entry(ULONG thread_input)
|
||||
{
|
||||
ULONG rx_data;
|
||||
static uint8_t filtInit = 0;
|
||||
static float heading_filt = 0;
|
||||
const float alpha = 0.20f; // 20% һ<><EFBFBD>ͨ
|
||||
// <20><>ʼ<EFBFBD><CABC>ģ<EFBFBD><C4A3>
|
||||
// IM948_Init();
|
||||
// HCBle_SendData("halo");
|
||||
while(1)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD><C8B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ڽ<EFBFBD><DABD><EFBFBD>
|
||||
if (tx_queue_receive(&im948_uart_rx_queue, &rx_data, TX_WAIT_FOREVER) == TX_SUCCESS)
|
||||
{
|
||||
Cmd_GetPkt( (uint8_t)rx_data );
|
||||
}
|
||||
|
||||
// <20><><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>°<EFBFBD>
|
||||
if (isNewData)
|
||||
{
|
||||
isNewData = 0;
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>angle<6C><65>ä<EFBFBD>ȳ<EFBFBD><C8B3><EFBFBD><EFBFBD>ж<EFBFBD>
|
||||
/* <20><><EFBFBD><EFBFBD> <20><> IMU <20>Ĵ<EFBFBD><C4B4><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ں<EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> */
|
||||
float angleRaw = AngleZ; /* <20><><EFBFBD>Ƕ<EFBFBD><C7B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD><C5B1><EFBFBD> */
|
||||
|
||||
/* ת<>汱 <20><>ݸ<EFBFBD><DDB8><EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD><DAA1><EFBFBD><EFBFBD>ݴ<EFBFBD>ƫ<EFBFBD><C6AB>Ϊ-3.0<EFBFBD><EFBFBD>*/
|
||||
float heading = angleRaw + DECLINATION_DEG;
|
||||
if (heading > 180) heading -= 360;
|
||||
if (heading < -180) heading += 360;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> IIR */
|
||||
const float alpha = 0.2f;
|
||||
heading_filt += alpha * (heading - heading_filt);
|
||||
|
||||
current_location.angle = heading_filt;
|
||||
// current_location.angle = AngleZ * 0.0054931640625f;
|
||||
if(current_location.lat != 0 && current_location.lon != 0)
|
||||
{
|
||||
BleMessage msg = current_location; // <20>ṹ<EFBFBD><E1B9B9>ֱ<EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD>
|
||||
tx_queue_send(&ble_tx_queue,&msg,TX_NO_WAIT);
|
||||
}
|
||||
tx_thread_sleep(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>úý<C3BA><C3BD>պ<EFBFBD><D5BA><EFBFBD>
|
||||
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
||||
{
|
||||
if(huart->Instance == USART3)
|
||||
{
|
||||
// HCBle_SendData("RX USART3: 0x%02X (%c)\r\n", rx_byte, rx_byte);
|
||||
|
||||
// Fifo_in(rx_byte);
|
||||
ULONG rx_data = rx_byte;
|
||||
tx_queue_send(&im948_uart_rx_queue, &rx_data, TX_NO_WAIT);
|
||||
// tx_event_flags_set(&sensor_events, EVENT_IMU_DATA_READY, TX_OR);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6><CFA3>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
HAL_UART_Receive_IT(huart,&rx_byte,1);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
#ifndef __IMU948_H__
|
||||
#define __IMU948_H__
|
||||
|
||||
#include "headfile.h"
|
||||
|
||||
void imu_angle_ble_task_entry(ULONG thread_input);
|
||||
void imu600_init(void);
|
||||
|
||||
#endif
|
||||
15
fun/value.h
15
fun/value.h
@@ -1,15 +0,0 @@
|
||||
#ifndef __VALUE_H__
|
||||
#define __VALUE_H__
|
||||
|
||||
//typedef struct
|
||||
//{
|
||||
// float lat;
|
||||
// float lon;
|
||||
// float angle;
|
||||
//}BleMessage;
|
||||
|
||||
#define EVENT_GPS_DATA_READY (1U << 0)
|
||||
#define EVENT_IMU_DATA_READY (1U << 1)
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user