增加了大量注释

This commit is contained in:
NeoZng
2023-01-01 17:32:22 +08:00
parent c2f8b5c8c3
commit c05513587c
56 changed files with 773 additions and 598 deletions

View File

@@ -0,0 +1,25 @@
#include "bsp_buzzer.h"
#include "main.h"
extern TIM_HandleTypeDef htim4;
static uint8_t tmp_warning_level = 0;
void BuzzerInit()
{
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_3);
}
void BuzzerOn(uint16_t psc, uint16_t pwm, uint8_t level)
{
if (level > tmp_warning_level)
{
tmp_warning_level = level;
__HAL_TIM_PRESCALER(&htim4, psc);
__HAL_TIM_SetCompare(&htim4, TIM_CHANNEL_3, pwm);
}
}
void BuzzerOff(void)
{
__HAL_TIM_SetCompare(&htim4, TIM_CHANNEL_3, 0);
tmp_warning_level = 0;
}

View File

@@ -0,0 +1,10 @@
#ifndef BSP_BUZZER_H
#define BSP_BUZZER_H
#include <stdint.h>
void BuzzerInit();
extern void BuzzerOn(uint16_t psc, uint16_t pwm, uint8_t level);
extern void BuzzerOff(void);
#endif

View File

@@ -0,0 +1,27 @@
#include "bsp_led.h"
#include "main.h"
extern TIM_HandleTypeDef htim5;
static uint8_t tmp_output_level = 0;
void LEDInit()
{
HAL_TIM_PWM_Start(&htim5, TIM_CHANNEL_1);
HAL_TIM_PWM_Start(&htim5, TIM_CHANNEL_2);
HAL_TIM_PWM_Start(&htim5, TIM_CHANNEL_3);
}
void FlowRGBShow(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;
__HAL_TIM_SetCompare(&htim5, TIM_CHANNEL_1, blue);
__HAL_TIM_SetCompare(&htim5, TIM_CHANNEL_2, green);
__HAL_TIM_SetCompare(&htim5, TIM_CHANNEL_3, red);
}

View File

@@ -0,0 +1,9 @@
#ifndef BSP_LED_H
#define BSP_LED_H
#include <stdint.h>
void LEDInit();
extern void FlowRGBShow(uint32_t aRGB);
#endif

View File

@@ -0,0 +1,13 @@
#include "bsp_temperature.h"
extern TIM_HandleTypeDef htim10;
void IMUTempInit()
{
HAL_TIM_PWM_Start(&htim10, TIM_CHANNEL_1);
}
void IMUPWMSet(uint16_t pwm)
{
__HAL_TIM_SetCompare(&htim10, TIM_CHANNEL_1, pwm);
}

View File

@@ -0,0 +1,10 @@
#ifndef __BSP_IMU_PWM_H
#define __BSP_IMU_PWM_H
#include "stdint.h"
#include "tim.h"
void IMUTempInit();
extern void IMUPWMSet(uint16_t pwm);
#endif

View File

@@ -0,0 +1,3 @@
# legacy bsp
这些bsp实现将在v0.1删除,因为他们实际上都是用pwm实现的,应当放在module层,以彻底隔离bsp和CubeMX的初始化代码.之后在修改CubeMX的初始化配置之后就不再需要修改bsp的内容了,所有的修改都会通过app层的初始化配置`xxx_Init_Config_s`来实现.