From 076973f41ec71f3f5206793b4024da6f1b0a6c3d Mon Sep 17 00:00:00 2001 From: NeoZeng Date: Sat, 19 Nov 2022 15:40:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=B1=BB=E5=9E=8B=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E9=97=AE=E9=A2=98=E5=92=8C=E9=87=8D=E5=A4=8D=E5=AE=9A?= =?UTF-8?q?=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 10 ++-- bsp/bsp_buzzer.h | 4 +- bsp/bsp_can.h | 2 +- bsp/bsp_led.h | 3 +- bsp/bsp_usart.h | 2 +- bsp/struct_typedef.h | 36 ------------- modules/led_light/led_task.c | 91 ++++++++++++++++----------------- modules/led_light/led_task.h | 24 ++++----- modules/motor/HT04.h | 3 +- modules/motor/LK9025.h | 4 +- modules/motor/motor_def.h | 3 ++ modules/remote/remote_control.h | 2 +- 12 files changed, 71 insertions(+), 113 deletions(-) delete mode 100644 bsp/struct_typedef.h diff --git a/Makefile b/Makefile index af148d3..5b3867e 100644 --- a/Makefile +++ b/Makefile @@ -260,13 +260,13 @@ vpath %.s $(sort $(dir $(ASM_SOURCES))) # 以下是编译命令,命令之前被粉色高亮的@就是静默输出的指令.删除前面的@会将输出显示到命令行. # 如@$(CC) -c $(CFLAGS) ...... 去掉第一个@即可. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) - $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ + @$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) - $(AS) -c $(CFLAGS) $< -o $@ + @$(AS) -c $(CFLAGS) $< -o $@ $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile - $(CC) $(OBJECTS) $(LDFLAGS) -o $@ + @$(CC) $(OBJECTS) $(LDFLAGS) -o $@ $(SZ) $@ $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) @@ -276,13 +276,13 @@ $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) $(BIN) $< $@ $(BUILD_DIR): - mkdir $@ + @mkdir $@ ####################################### # clean up ####################################### clean: - -rm -r $(BUILD_DIR) + -rm -r -Force $(BUILD_DIR) ####################################### # dependencies diff --git a/bsp/bsp_buzzer.h b/bsp/bsp_buzzer.h index c238343..75e7c56 100644 --- a/bsp/bsp_buzzer.h +++ b/bsp/bsp_buzzer.h @@ -1,10 +1,10 @@ #ifndef BSP_BUZZER_H #define BSP_BUZZER_H -#include "struct_typedef.h" +#include 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 diff --git a/bsp/bsp_can.h b/bsp/bsp_can.h index e6faf21..a14ff09 100644 --- a/bsp/bsp_can.h +++ b/bsp/bsp_can.h @@ -1,7 +1,7 @@ #ifndef BSP_CAN_H #define BSP_CAN_H -#include "struct_typedef.h" +#include #include "can.h" #define MX_REGISTER_DEVICE_CNT 12 // maximum number of device can be registered to CAN service diff --git a/bsp/bsp_led.h b/bsp/bsp_led.h index 2e96943..01805fc 100644 --- a/bsp/bsp_led.h +++ b/bsp/bsp_led.h @@ -1,8 +1,7 @@ #ifndef BSP_LED_H #define BSP_LED_H -#include "struct_typedef.h" - +#include void LED_init(); extern void aRGB_led_show(uint32_t aRGB); diff --git a/bsp/bsp_usart.h b/bsp/bsp_usart.h index 9447fe8..ed4d2f1 100644 --- a/bsp/bsp_usart.h +++ b/bsp/bsp_usart.h @@ -1,7 +1,7 @@ #ifndef BSP_RC_H #define BSP_RC_H -#include "struct_typedef.h" +#include #include "main.h" #define DEVICE_USART_CNT 3 // C板至多分配3个串口 diff --git a/bsp/struct_typedef.h b/bsp/struct_typedef.h deleted file mode 100644 index 87e7917..0000000 --- a/bsp/struct_typedef.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef STRUCT_TYPEDEF_H -#define STRUCT_TYPEDEF_H - - -#ifndef __PACKED -#define __packed __attribute__((pakced)) -#endif // !__PACKED - -typedef signed char int8_t; -typedef signed short int int16_t; - -#ifndef _INT32_T_DECLARED -typedef signed int int32_t; -#define _INT32_T_DECLARED -#endif - -typedef signed long long int64_t; - -/* exact-width unsigned integer types */ -typedef unsigned char uint8_t; -typedef unsigned short int uint16_t; - -#ifndef _UINT32_T_DECLARED -typedef unsigned int uint32_t; -#define _UINT32_T_DECLARED -#endif - -typedef unsigned long long uint64_t; -typedef unsigned char bool_t; -typedef float fp32; -typedef double fp64; - -#endif - - - diff --git a/modules/led_light/led_task.c b/modules/led_light/led_task.c index 978986a..6f6ea1a 100644 --- a/modules/led_light/led_task.c +++ b/modules/led_light/led_task.c @@ -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); + } } + } } - - diff --git a/modules/led_light/led_task.h b/modules/led_light/led_task.h index a8325c7..512f65c 100644 --- a/modules/led_light/led_task.h +++ b/modules/led_light/led_task.h @@ -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 @@ -17,22 +17,18 @@ #ifndef LED_TRIGGER_TASK_H #define LED_TRIGGER_TASK_H - -#include "struct_typedef.h" +#include /** - * @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 + */ extern void led_RGB_flow_task(); #endif - - - diff --git a/modules/motor/HT04.h b/modules/motor/HT04.h index 5da5f1f..9766743 100644 --- a/modules/motor/HT04.h +++ b/modules/motor/HT04.h @@ -1,9 +1,10 @@ #ifndef HT04_H #define HT04_H -#include "struct_typedef.h" +#include #include "bsp_can.h" #include "controller.h" +#include "motor_def.h" #define HT_MOTOR_CNT 4 diff --git a/modules/motor/LK9025.h b/modules/motor/LK9025.h index e3092fc..e6086ba 100644 --- a/modules/motor/LK9025.h +++ b/modules/motor/LK9025.h @@ -1,16 +1,14 @@ #ifndef LK9025_H #define LK9025_H -#include "struct_typedef.h" #include "bsp_can.h" #include "controller.h" +#include "motor_def.h" #define LK_MOTOR_CNT 2 #define I_MIN -2000 #define I_MAX 2000 -#define LIMIT_MIN_MAX(x, min, max) (x) = (((x) <= (min)) ? (min) : (((x) >= (max)) ? (max) : (x))) - typedef struct // 9025 { uint16_t last_ecd; diff --git a/modules/motor/motor_def.h b/modules/motor/motor_def.h index a46073d..f2a9e8c 100644 --- a/modules/motor/motor_def.h +++ b/modules/motor/motor_def.h @@ -13,6 +13,9 @@ #define MOTOR_DEF_H #include "controller.h" +#include + +#define LIMIT_MIN_MAX(x, min, max) (x) = (((x) <= (min)) ? (min) : (((x) >= (max)) ? (max) : (x))) /** * @brief 闭环类型,如果需要多个闭环,则使用或运算 diff --git a/modules/remote/remote_control.h b/modules/remote/remote_control.h index f0cdc23..6235c02 100644 --- a/modules/remote/remote_control.h +++ b/modules/remote/remote_control.h @@ -13,7 +13,7 @@ #ifndef REMOTE_CONTROL_H #define REMOTE_CONTROL_H -#include "struct_typedef.h" +#include #include "main.h" #define RC_CH_VALUE_MIN ((uint16_t)364)