fix can rx fifo bug

This commit is contained in:
NeoZeng
2022-11-23 22:10:44 +08:00
parent 62b1783b59
commit 490b957045
11 changed files with 123 additions and 73 deletions

View File

@@ -25,7 +25,8 @@
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "ins_task.h"
#include "motor_task.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@@ -51,6 +52,9 @@ osThreadId defaultTaskHandle;
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */
void StartINSTASK(void const * argument);
void StartMOTORTASK(void const * argument);
/* USER CODE END FunctionPrototypes */
@@ -106,6 +110,12 @@ void MX_FREERTOS_Init(void) {
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
osThreadDef(instask, StartINSTASK, osPriorityNormal, 0, 1024);
defaultTaskHandle = osThreadCreate(osThread(instask), NULL);
osThreadDef(motortask, StartMOTORTASK, osPriorityNormal, 0, 256);
defaultTaskHandle = osThreadCreate(osThread(motortask), NULL);
/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
/* USER CODE END RTOS_THREADS */
@@ -134,5 +144,24 @@ void StartDefaultTask(void const * argument)
/* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */
void StartINSTASK(void const * argument)
{
while (1)
{
INS_Task();
osDelay(1);
}
}
void StartMOTORTASK(void const * argument)
{
while (1)
{
MotorControlTask();
osDelay(1);
}
}
/* USER CODE END Application */

View File

@@ -77,8 +77,7 @@ void MX_FREERTOS_Init(void);
* @brief The application entry point.
* @retval int
*/
int main(void)
{
int main(void){
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
@@ -119,12 +118,12 @@ int main(void)
RC_init(&huart3);
DWT_Init(168);
Motor_Init_Config_s config = {
.motor_type = M2006,
.motor_type = M3508,
.can_init_config = {
.can_handle = &hcan1,
.tx_id = 1},
.controller_setting_init_config = {.angle_feedback_source = MOTOR_FEED, .close_loop_type = SPEED_LOOP | CURRENT_LOOP, .speed_feedback_source = MOTOR_FEED, .reverse_flag = MOTOR_DIRECTION_NORMAL},
.controller_param_init_config = {.current_PID = {.Improve = 0, .Kp = 1, .Ki = 0, .Kd = 0, .DeadBand = 0, .MaxOut = 4000}, .speed_PID = {.Improve = 0, .Kp = 1, .Ki = 0, .Kd = 0, .DeadBand = 0, .MaxOut = 4000}}};
.tx_id = 2},
.controller_setting_init_config = {.angle_feedback_source = MOTOR_FEED, .close_loop_type = SPEED_LOOP | ANGLE_LOOP, .speed_feedback_source = MOTOR_FEED, .reverse_flag = MOTOR_DIRECTION_NORMAL},
.controller_param_init_config = {.angle_PID = {.Improve = 0, .Kp = 1, .Ki = 0, .Kd = 0, .DeadBand = 0, .MaxOut = 4000}, .speed_PID = {.Improve = 0, .Kp = 1, .Ki = 0, .Kd = 0, .DeadBand = 0, .MaxOut = 4000}}};
dji_motor_instance *djimotor = DJIMotorInit(config);
RefereeInit(&huart6);
@@ -143,7 +142,7 @@ int main(void)
{
/* USER CODE END WHILE */
DJIMotorSetRef(djimotor, get_remote_control_point()->rc.ch[0]);
DJIMotorSetRef(djimotor, 10);
MotorControlTask();
HAL_Delay(100);
/* USER CODE BEGIN 3 */