加入大疆C板例程bsp
This commit is contained in:
30
bsp/boards/bsp_led.c
Normal file
30
bsp/boards/bsp_led.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "bsp_led.h"
|
||||
#include "main.h"
|
||||
|
||||
extern TIM_HandleTypeDef htim5;
|
||||
/**
|
||||
* @brief aRGB show
|
||||
* @param[in] aRGB: 0xaaRRGGBB, 'aa' is alpha, 'RR' is red, 'GG' is green, 'BB' is blue
|
||||
* @retval none
|
||||
*/
|
||||
/**
|
||||
* @brief <20><>ʾRGB
|
||||
* @param[in] aRGB:0xaaRRGGBB,'aa' <20><><EFBFBD><CDB8><EFBFBD><EFBFBD>,'RR'<27>Ǻ<EFBFBD>ɫ,'GG'<27><><EFBFBD><EFBFBD>ɫ,'BB'<27><><EFBFBD><EFBFBD>ɫ
|
||||
* @retval none
|
||||
*/
|
||||
void aRGB_led_show(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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user