清除所有的legacy support,增加编译时的内存使用预测和Werror选项,统一命名。

This commit is contained in:
NeoZng
2023-07-14 17:24:44 +08:00
parent 8943bdfe5c
commit 3faa9f1f8f
24 changed files with 94 additions and 234 deletions

View File

@@ -2,6 +2,7 @@
#include "buzzer.h"
#include "bsp_dwt.h"
#include "string.h"
static PWMInstance *buzzer;
static uint8_t idx;
static BuzzzerInstance *buzzer_list[BUZZER_DEVICE_CNT] = {0};
@@ -10,13 +11,13 @@ static BuzzzerInstance *buzzer_list[BUZZER_DEVICE_CNT] = {0};
* @brief 蜂鸣器初始化
*
*/
void buzzer_init()
void BuzzerInit()
{
PWM_Init_Config_s buzzer_config = {
.htim = &htim4,
.channel= TIM_CHANNEL_3,
.dutyratio = 0,
.period = 0.001,
.htim = &htim4,
.channel = TIM_CHANNEL_3,
.dutyratio = 0,
.period = 0.001,
};
buzzer = PWMRegister(&buzzer_config);
}
@@ -36,7 +37,6 @@ BuzzzerInstance *BuzzerRegister(Buzzer_config_s *config)
buzzer_list[config->alarm_level] = buzzer_temp;
return buzzer_temp;
}
void AlarmSetStatus(BuzzzerInstance *buzzer, AlarmState_e state)
@@ -50,11 +50,11 @@ void BuzzerTask()
for (size_t i = 0; i < BUZZER_DEVICE_CNT; ++i)
{
buzz = buzzer_list[i];
if(buzz->alarm_level > ALARM_LEVEL_LOW)
if (buzz->alarm_level > ALARM_LEVEL_LOW)
{
continue;
}
if(buzz->alarm_state == ALARM_OFF)
if (buzz->alarm_state == ALARM_OFF)
{
PWMSetDutyRatio(buzzer, 0);
}
@@ -63,35 +63,29 @@ void BuzzerTask()
PWMSetDutyRatio(buzzer, buzz->loudness);
switch (buzz->octave)
{
case OCTAVE_1:
PWMSetPeriod(buzzer, (float)1/DoFreq);
break;
case OCTAVE_2:
PWMSetPeriod(buzzer, (float)1/ReFreq);
break;
case OCTAVE_3:
PWMSetPeriod(buzzer, (float)1/MiFreq);
break;
case OCTAVE_4:
PWMSetPeriod(buzzer, (float)1/FaFreq);
break;
case OCTAVE_5:
PWMSetPeriod(buzzer, (float)1/SoFreq);
break;
case OCTAVE_6:
PWMSetPeriod(buzzer, (float)1/LaFreq);
break;
case OCTAVE_7:
PWMSetPeriod(buzzer, (float)1/SiFreq);
break;
case OCTAVE_1:
PWMSetPeriod(buzzer, (float)1 / DoFreq);
break;
case OCTAVE_2:
PWMSetPeriod(buzzer, (float)1 / ReFreq);
break;
case OCTAVE_3:
PWMSetPeriod(buzzer, (float)1 / MiFreq);
break;
case OCTAVE_4:
PWMSetPeriod(buzzer, (float)1 / FaFreq);
break;
case OCTAVE_5:
PWMSetPeriod(buzzer, (float)1 / SoFreq);
break;
case OCTAVE_6:
PWMSetPeriod(buzzer, (float)1 / LaFreq);
break;
case OCTAVE_7:
PWMSetPeriod(buzzer, (float)1 / SiFreq);
break;
}
break;
}
}
}

View File

@@ -53,7 +53,7 @@ typedef struct
}BuzzzerInstance;
void buzzer_init();
void BuzzerInit();
void BuzzerTask();
BuzzzerInstance *BuzzerRegister(Buzzer_config_s *config);
void AlarmSetStatus(BuzzzerInstance *buzzer, AlarmState_e state);

View File

@@ -5,7 +5,7 @@
#include "bsp_log.h"
#include <math.h>
#warning this is a legacy support. test the new BMI088 module as soon as possible.
#pragma message "this is a legacy support. test the new BMI088 module as soon as possible."
float BMI088_ACCEL_SEN = BMI088_ACCEL_6G_SEN;
float BMI088_GYRO_SEN = BMI088_GYRO_2000_SEN;

View File

@@ -14,8 +14,8 @@
#include "ins_task.h"
#include "controller.h"
#include "QuaternionEKF.h"
#include "bsp_temperature.h"
#include "spi.h"
#include "tim.h"
#include "user_lib.h"
#include "general_def.h"
#include "master_process.h"
@@ -35,6 +35,11 @@ static float RefTemp = 40; // 恒温设定温度
static void IMU_Param_Correction(IMU_Param_t *param, float gyro[3], float accel[3]);
static void IMUPWMSet(uint16_t pwm)
{
__HAL_TIM_SetCompare(&htim10, TIM_CHANNEL_1, pwm);
}
/**
* @brief 温度控制
*
@@ -79,6 +84,8 @@ attitude_t *INS_Init(void)
else
return (attitude_t *)&INS.Gyro;
HAL_TIM_PWM_Start(&htim10, TIM_CHANNEL_1);
while (BMI088Init(&hspi1, 1) != BMI088_NO_ERROR)
;
IMU_Param.scale[X] = 1;

View File

@@ -34,6 +34,13 @@ void LEDSwitch(LEDInstance *_led, uint8_t led_switch)
}
}
void LEDShow()
void LEDShow(uint32_t aRGB)
{
static uint8_t alpha;
static uint16_t red, green, blue;
alpha = (aRGB & 0xFF000000) >> 24;
red = ((aRGB & 0x00FF0000) >> 16) * alpha;
green = ((aRGB & 0x0000FF00) >> 8) * alpha;
blue = ((aRGB & 0x000000FF) >> 0) * alpha;
}

3
modules/led/led.md Normal file
View File

@@ -0,0 +1,3 @@
TO BE DONE
请勿使用

View File

@@ -1,8 +0,0 @@
# led_task
<p align='right'>neozng1@hnu.edu.cn</p>
> TODO:
> 1. 预计添加不同错误标志,将错误类型和灯的闪烁频率或颜色等对应起来,方便调试
这是legacy support,后续将使用bsp_pwm进行重构

View File

@@ -1,59 +0,0 @@
/**
* @file led_task.c
* @author DJI RM
* @author modified by NeoZeng neozng1@hnu.edu.cn
* @brief 流水灯效
* @version 0.1
* @date 2022-11-30
*
* @copyright Copyright (c) 2022
*
*/
#warning this is a legacy support file, please build the new 'led' module as soon as possible
#include "led_task.h"
#include <stdint.h>
#include "bsp_led.h"
#include "main.h"
#define RGB_FLOW_COLOR_CHANGE_TIME 1000
#define RGB_FLOW_COLOR_LENGHT 6
// 蓝 -> 绿(灭) -> 红 -> 蓝(灭) -> 绿 -> 红(灭) -> 蓝
uint32_t RGB_flow_color[RGB_FLOW_COLOR_LENGHT + 1] = {0xFF0000FF, 0x0000FF00, 0xFFFF0000, 0x000000FF, 0xFF00FF00, 0x00FF0000, 0xFF0000FF};
void led_RGB_flow_task()
{
static float delta_alpha, delta_red, delta_green, delta_blue;
static float alpha, red, green, blue;
static uint32_t aRGB;
for (size_t 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 /= 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 (size_t 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;
FlowRGBShow(aRGB);
}
}
}

View File

@@ -1,7 +0,0 @@
#ifndef LED_TRIGGER_TASK_H
#define LED_TRIGGER_TASK_H
void led_RGB_flow_task();
#endif