修改编译器的类型支持,将老旧的struct_typedef替换为新的stdint-gcc.h
This commit is contained in:
parent
6c56d4d19f
commit
1dc8622f53
|
@ -1,6 +1,8 @@
|
|||
{
|
||||
"files.associations": {
|
||||
"memory.h": "c"
|
||||
"memory.h": "c",
|
||||
"stdint-gcc.h": "c",
|
||||
"led_task.h": "c",
|
||||
"stdint.h": "c"
|
||||
},
|
||||
"C_Cpp.errorSquiggles": "Disabled"
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
#ifndef BSP_BUZZER_H
|
||||
#define BSP_BUZZER_H
|
||||
|
||||
#include "struct_typedef.h"
|
||||
#include <stdint-gcc.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void buzzer_init();
|
||||
extern void buzzer_on(uint16_t psc, uint16_t pwm,uint8_t level);
|
||||
extern void buzzer_on(uint16_t psc, uint16_t pwm, uint8_t level);
|
||||
extern void buzzer_off(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef BSP_CAN_H
|
||||
#define BSP_CAN_H
|
||||
|
||||
#include "struct_typedef.h"
|
||||
#include <stdint-gcc.h>
|
||||
#include "can.h"
|
||||
|
||||
#define MX_REGISTER_DEVICE_CNT 12 // maximum number of device can be registered to CAN service
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#ifndef BSP_LED_H
|
||||
#define BSP_LED_H
|
||||
|
||||
#include "struct_typedef.h"
|
||||
|
||||
#include <stdint-gcc.h>
|
||||
|
||||
void LED_init();
|
||||
extern void aRGB_led_show(uint32_t aRGB);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef BSP_RC_H
|
||||
#define BSP_RC_H
|
||||
|
||||
#include "struct_typedef.h"
|
||||
#include <stdint-gcc.h>
|
||||
#include "main.h"
|
||||
|
||||
#define DEVICE_USART_CNT 3 // C板至多分配3个串口
|
||||
|
|
|
@ -22,10 +22,7 @@ typedef unsigned int uint32_t;
|
|||
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef unsigned char bool_t;
|
||||
typedef float fp32;
|
||||
typedef float float;
|
||||
typedef double fp64;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
****************************(C) COPYRIGHT 2019 DJI****************************
|
||||
* @file led_trigger_task.c/h
|
||||
* @brief led RGB show.led RGB灯效。
|
||||
* @note
|
||||
* @note
|
||||
* @history
|
||||
* Version Date Author Modification
|
||||
* V1.0.0 Nov-11-2019 RM 1. rgb led
|
||||
|
@ -19,62 +19,59 @@
|
|||
#include "cmsis_os.h"
|
||||
#include "main.h"
|
||||
|
||||
|
||||
#define RGB_FLOW_COLOR_CHANGE_TIME 1000
|
||||
#define RGB_FLOW_COLOR_LENGHT 6
|
||||
//blue-> green(dark)-> red -> blue(dark) -> green(dark) -> red(dark) -> blue
|
||||
//蓝 -> 绿(灭) -> 红 -> 蓝(灭) -> 绿 -> 红(灭) -> 蓝
|
||||
#define RGB_FLOW_COLOR_CHANGE_TIME 1000
|
||||
#define RGB_FLOW_COLOR_LENGHT 6
|
||||
// blue-> green(dark)-> red -> blue(dark) -> green(dark) -> red(dark) -> blue
|
||||
// 蓝 -> 绿(灭) -> 红 -> 蓝(灭) -> 绿 -> 红(灭) -> 蓝
|
||||
uint32_t RGB_flow_color[RGB_FLOW_COLOR_LENGHT + 1] = {0xFF0000FF, 0x0000FF00, 0xFFFF0000, 0x000000FF, 0xFF00FF00, 0x00FF0000, 0xFF0000FF};
|
||||
|
||||
/**
|
||||
* @brief led rgb task
|
||||
* @param[in] pvParameters: NULL
|
||||
* @retval none
|
||||
*/
|
||||
* @brief led rgb task
|
||||
* @param[in] pvParameters: NULL
|
||||
* @retval none
|
||||
*/
|
||||
/**
|
||||
* @brief led RGB任务
|
||||
* @param[in] pvParameters: NULL
|
||||
* @retval none
|
||||
*/
|
||||
* @brief led RGB任务
|
||||
* @param[in] pvParameters: NULL
|
||||
* @retval none
|
||||
*/
|
||||
void led_RGB_flow_task()
|
||||
{
|
||||
uint16_t i, j;
|
||||
fp32 delta_alpha, delta_red, delta_green, delta_blue;
|
||||
fp32 alpha,red,green,blue;
|
||||
uint32_t aRGB;
|
||||
uint16_t i, j;
|
||||
float delta_alpha, delta_red, delta_green, delta_blue;
|
||||
float alpha, red, green, blue;
|
||||
uint32_t aRGB;
|
||||
|
||||
while(1)
|
||||
while (1)
|
||||
{
|
||||
|
||||
for (i = 0; i < RGB_FLOW_COLOR_LENGHT; i++)
|
||||
{
|
||||
alpha = (RGB_flow_color[i] & 0xFF000000) >> 24;
|
||||
red = ((RGB_flow_color[i] & 0x00FF0000) >> 16);
|
||||
green = ((RGB_flow_color[i] & 0x0000FF00) >> 8);
|
||||
blue = ((RGB_flow_color[i] & 0x000000FF) >> 0);
|
||||
|
||||
for(i = 0; i < RGB_FLOW_COLOR_LENGHT; i++)
|
||||
{
|
||||
alpha = (RGB_flow_color[i] & 0xFF000000) >> 24;
|
||||
red = ((RGB_flow_color[i] & 0x00FF0000) >> 16);
|
||||
green = ((RGB_flow_color[i] & 0x0000FF00) >> 8);
|
||||
blue = ((RGB_flow_color[i] & 0x000000FF) >> 0);
|
||||
delta_alpha = (float)((RGB_flow_color[i + 1] & 0xFF000000) >> 24) - (float)((RGB_flow_color[i] & 0xFF000000) >> 24);
|
||||
delta_red = (float)((RGB_flow_color[i + 1] & 0x00FF0000) >> 16) - (float)((RGB_flow_color[i] & 0x00FF0000) >> 16);
|
||||
delta_green = (float)((RGB_flow_color[i + 1] & 0x0000FF00) >> 8) - (float)((RGB_flow_color[i] & 0x0000FF00) >> 8);
|
||||
delta_blue = (float)((RGB_flow_color[i + 1] & 0x000000FF) >> 0) - (float)((RGB_flow_color[i] & 0x000000FF) >> 0);
|
||||
|
||||
delta_alpha = (fp32)((RGB_flow_color[i + 1] & 0xFF000000) >> 24) - (fp32)((RGB_flow_color[i] & 0xFF000000) >> 24);
|
||||
delta_red = (fp32)((RGB_flow_color[i + 1] & 0x00FF0000) >> 16) - (fp32)((RGB_flow_color[i] & 0x00FF0000) >> 16);
|
||||
delta_green = (fp32)((RGB_flow_color[i + 1] & 0x0000FF00) >> 8) - (fp32)((RGB_flow_color[i] & 0x0000FF00) >> 8);
|
||||
delta_blue = (fp32)((RGB_flow_color[i + 1] & 0x000000FF) >> 0) - (fp32)((RGB_flow_color[i] & 0x000000FF) >> 0);
|
||||
delta_alpha /= RGB_FLOW_COLOR_CHANGE_TIME;
|
||||
delta_red /= RGB_FLOW_COLOR_CHANGE_TIME;
|
||||
delta_green /= RGB_FLOW_COLOR_CHANGE_TIME;
|
||||
delta_blue /= RGB_FLOW_COLOR_CHANGE_TIME;
|
||||
for (j = 0; j < RGB_FLOW_COLOR_CHANGE_TIME; j++)
|
||||
{
|
||||
alpha += delta_alpha;
|
||||
red += delta_red;
|
||||
green += delta_green;
|
||||
blue += delta_blue;
|
||||
|
||||
delta_alpha /= RGB_FLOW_COLOR_CHANGE_TIME;
|
||||
delta_red /= RGB_FLOW_COLOR_CHANGE_TIME;
|
||||
delta_green /= RGB_FLOW_COLOR_CHANGE_TIME;
|
||||
delta_blue /= RGB_FLOW_COLOR_CHANGE_TIME;
|
||||
for(j = 0; j < RGB_FLOW_COLOR_CHANGE_TIME; j++)
|
||||
{
|
||||
alpha += delta_alpha;
|
||||
red += delta_red;
|
||||
green += delta_green;
|
||||
blue += delta_blue;
|
||||
|
||||
aRGB = ((uint32_t)(alpha)) << 24 | ((uint32_t)(red)) << 16 | ((uint32_t)(green)) << 8 | ((uint32_t)(blue)) << 0;
|
||||
aRGB_led_show(aRGB);
|
||||
osDelay(1);
|
||||
}
|
||||
}
|
||||
aRGB = ((uint32_t)(alpha)) << 24 | ((uint32_t)(red)) << 16 | ((uint32_t)(green)) << 8 | ((uint32_t)(blue)) << 0;
|
||||
aRGB_led_show(aRGB);
|
||||
osDelay(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
****************************(C) COPYRIGHT 2019 DJI****************************
|
||||
* @file led_trigger_task.c/h
|
||||
* @brief led RGB show.led RGB<EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>
|
||||
* @note
|
||||
* @note
|
||||
* @history
|
||||
* Version Date Author Modification
|
||||
* V1.0.0 Nov-11-2019 RM 1. rgb led
|
||||
|
@ -17,22 +17,18 @@
|
|||
#ifndef LED_TRIGGER_TASK_H
|
||||
#define LED_TRIGGER_TASK_H
|
||||
|
||||
|
||||
#include "struct_typedef.h"
|
||||
#include <stdint-gcc.h>
|
||||
|
||||
/**
|
||||
* @brief led rgb task
|
||||
* @param[in] pvParameters: NULL
|
||||
* @retval none
|
||||
*/
|
||||
* @brief led rgb task
|
||||
* @param[in] pvParameters: NULL
|
||||
* @retval none
|
||||
*/
|
||||
/**
|
||||
* @brief led RGB<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param[in] pvParameters: NULL
|
||||
* @retval none
|
||||
*/
|
||||
* @brief led RGB<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param[in] pvParameters: NULL
|
||||
* @retval none
|
||||
*/
|
||||
extern void led_RGB_flow_task();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef HT04_H
|
||||
#define HT04_H
|
||||
|
||||
#include "struct_typedef.h"
|
||||
#include <stdint-gcc.h>
|
||||
#include "bsp_can.h"
|
||||
#include "controller.h"
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef LK9025_H
|
||||
#define LK9025_H
|
||||
|
||||
#include "struct_typedef.h"
|
||||
#include <stdint-gcc.h>
|
||||
#include "bsp_can.h"
|
||||
#include "controller.h"
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
#ifndef __CRC_H_
|
||||
#define __CRC_H_
|
||||
|
||||
#include "struct_typedef.h"
|
||||
#include <stdint-gcc.h>
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
// CRC8
|
||||
void Append_CRC8_Check_Sum( uint8_t *pchMessage, uint16_t dwLength);
|
||||
uint32_t Verify_CRC8_Check_Sum( uint8_t *pchMessage, uint16_t dwLength);
|
||||
uint8_t Get_CRC8_Check_Sum( uint8_t *pchMessage, uint16_t dwLength, uint8_t ucCRC8 );
|
||||
void Append_CRC8_Check_Sum(uint8_t *pchMessage, uint16_t dwLength);
|
||||
uint32_t Verify_CRC8_Check_Sum(uint8_t *pchMessage, uint16_t dwLength);
|
||||
uint8_t Get_CRC8_Check_Sum(uint8_t *pchMessage, uint16_t dwLength, uint8_t ucCRC8);
|
||||
|
||||
// CRC16
|
||||
void Append_CRC16_Check_Sum(uint8_t * pchMessage,uint32_t dwLength);
|
||||
void Append_CRC16_Check_Sum(uint8_t *pchMessage, uint32_t dwLength);
|
||||
uint32_t Verify_CRC16_Check_Sum(uint8_t *pchMessage, uint32_t dwLength);
|
||||
uint16_t Get_CRC16_Check_Sum(uint8_t *pchMessage,uint32_t dwLength,uint16_t wCRC);
|
||||
uint16_t Get_CRC16_Check_Sum(uint8_t *pchMessage, uint32_t dwLength, uint16_t wCRC);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,7 +13,6 @@ usart_instance referee_usart_instance;
|
|||
|
||||
/**************裁判系统数据******************/
|
||||
referee_info_t referee_info;
|
||||
bool_t Judge_Data_TF = FALSE; //裁判数据是否可用,辅助函数调用
|
||||
uint8_t Judge_Self_ID; //当前机器人的ID
|
||||
uint16_t Judge_SelfClient_ID; //发送者机器人对应的客户端ID
|
||||
|
||||
|
@ -21,7 +20,7 @@ uint16_t Judge_SelfClient_ID; //发送者机器人对应的客户端ID
|
|||
|
||||
static void ReceiveCallback()
|
||||
{
|
||||
Judge_Data_TF=Judge_Read_Data(referee_usart_instance.recv_buff);
|
||||
Judge_Read_Data(referee_usart_instance.recv_buff);
|
||||
}
|
||||
|
||||
void referee_init(UART_HandleTypeDef *referee_usart_handle)
|
||||
|
@ -39,9 +38,8 @@ void referee_init(UART_HandleTypeDef *referee_usart_handle)
|
|||
* @retval 是否对正误判断做处理
|
||||
* @attention 在此判断帧头和CRC校验,无误再写入数据,不重复判断帧头
|
||||
*/
|
||||
bool_t Judge_Read_Data(uint8_t *ReadFromUsart)
|
||||
void Judge_Read_Data(uint8_t *ReadFromUsart)
|
||||
{
|
||||
bool_t retval_tf = FALSE; //数据正确与否标志,每次调用读取裁判系统数据函数都先默认为错误
|
||||
uint16_t judge_length; //统计一帧数据长度
|
||||
// referee_info.CmdID = 0; //数据命令码解析
|
||||
//空数据包,则不作任何处理
|
||||
|
@ -64,7 +62,6 @@ bool_t Judge_Read_Data(uint8_t *ReadFromUsart)
|
|||
//帧尾CRC16校验
|
||||
if (Verify_CRC16_Check_Sum(ReadFromUsart, judge_length) == TRUE)
|
||||
{
|
||||
retval_tf = TRUE; //都校验过了则说明数据可用
|
||||
// 2个8位拼成16位int
|
||||
referee_info.CmdID = (ReadFromUsart[6] << 8 | ReadFromUsart[5]);
|
||||
//解析数据命令码,将数据拷贝到相应结构体中(注意拷贝数据的长度)
|
||||
|
@ -129,21 +126,8 @@ bool_t Judge_Read_Data(uint8_t *ReadFromUsart)
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
return retval_tf; //返回此次接收到的数据是否时有效的
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 数据是否可用
|
||||
* @param void
|
||||
* @retval TRUE可用 FALSE不可用
|
||||
* @attention 在裁判读取函数中实时改变返回值
|
||||
*/
|
||||
bool_t JUDGE_sGetDataState(void)
|
||||
{
|
||||
return Judge_Data_TF;
|
||||
}
|
||||
/**
|
||||
* @brief 读取瞬时功率
|
||||
* @param void
|
||||
|
|
|
@ -342,9 +342,7 @@ typedef struct
|
|||
extern referee_info_t referee_info;
|
||||
|
||||
void referee_init(UART_HandleTypeDef *referee_usart_handle);
|
||||
bool_t Judge_Read_Data(uint8_t *ReadFromUsart);
|
||||
|
||||
bool_t JUDGE_sGetDataState(void);
|
||||
void Judge_Read_Data(uint8_t *ReadFromUsart);
|
||||
float JUDGE_fGetChassisPower(void);
|
||||
|
||||
#endif // !REFEREE_H
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#ifndef REMOTE_CONTROL_H
|
||||
#define REMOTE_CONTROL_H
|
||||
|
||||
#include "struct_typedef.h"
|
||||
#include <stdint-gcc.h>
|
||||
#include "main.h"
|
||||
|
||||
#define RC_CH_VALUE_MIN ((uint16_t)364)
|
||||
|
|
Loading…
Reference in New Issue