mirror of
https://gitee.com/dlmu-cone/bf_original_balance_chassis
synced 2026-07-24 19:47:44 +08:00
增加了大量注释
This commit is contained in:
25
bsp/bsp_legacy_support/bsp_buzzer.c
Normal file
25
bsp/bsp_legacy_support/bsp_buzzer.c
Normal 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;
|
||||
}
|
||||
10
bsp/bsp_legacy_support/bsp_buzzer.h
Normal file
10
bsp/bsp_legacy_support/bsp_buzzer.h
Normal 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
|
||||
27
bsp/bsp_legacy_support/bsp_led.c
Normal file
27
bsp/bsp_legacy_support/bsp_led.c
Normal 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);
|
||||
}
|
||||
9
bsp/bsp_legacy_support/bsp_led.h
Normal file
9
bsp/bsp_legacy_support/bsp_led.h
Normal 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
|
||||
13
bsp/bsp_legacy_support/bsp_temperature.c
Normal file
13
bsp/bsp_legacy_support/bsp_temperature.c
Normal 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);
|
||||
}
|
||||
10
bsp/bsp_legacy_support/bsp_temperature.h
Normal file
10
bsp/bsp_legacy_support/bsp_temperature.h
Normal 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
|
||||
3
bsp/bsp_legacy_support/legacy.md
Normal file
3
bsp/bsp_legacy_support/legacy.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# legacy bsp
|
||||
|
||||
这些bsp实现将在v0.1删除,因为他们实际上都是用pwm实现的,应当放在module层,以彻底隔离bsp和CubeMX的初始化代码.之后在修改CubeMX的初始化配置之后就不再需要修改bsp的内容了,所有的修改都会通过app层的初始化配置`xxx_Init_Config_s`来实现.
|
||||
Reference in New Issue
Block a user