diff --git a/Code/.vscode/extensions.json b/Code/.vscode/extensions.json new file mode 100644 index 0000000..b610f74 --- /dev/null +++ b/Code/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "cschlosser.doxdocgen" + ] +} \ No newline at end of file diff --git a/Code/bsp/src/bsp_led.c b/Code/bsp/src/bsp_led.c deleted file mode 100644 index 8fc3275..0000000 --- a/Code/bsp/src/bsp_led.c +++ /dev/null @@ -1,253 +0,0 @@ -/* -********************************************************************************************************* -* -* 模块名称 : LED指示灯驱动模块 -* 文件名称 : bsp_led.c -* 版 本 : V1.0 -* 说 明 : 驱动LED指示灯 -* -* 修改记录 : -* 版本号 日期 作者 说明 -* V1.0 2013-02-01 armfly 正式发布 -* -* Copyright (C), 2013-2014, 安富莱电子 www.armfly.com -* -********************************************************************************************************* -*/ - -#include "bsp.h" - -/* - 该程序适用于安富莱STM32-X4、STM32-F4开发板 - - 如果用于其它硬件,请修改GPIO定义和 IsKeyDown1 - IsKeyDown8 函数 - - 如果用户的LED指示灯个数小于4个,可以将多余的LED全部定义为和第1个LED一样,并不影响程序功能 -*/ - -#ifdef STM32F103C8T6 /* STM32F103C8T6 开发板 */ - /* - STM32F103C8 LED口线分配: - LED1 : PC13 (低电平点亮,高电平熄灭) - LED2 : - LED3 : - LED4 : - */ - /* 按键口对应的RCC时钟 */ - #define RCC_ALL_LED (RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOB) - - #define GPIO_PORT_LED1 GPIOC - #define GPIO_PIN_LED1 GPIO_Pin_13 - - #define GPIO_PORT_LED2 GPIOB - #define GPIO_PIN_LED2 GPIO_Pin_9 - - // #define GPIO_PORT_LED2 GPIOE - // #define GPIO_PIN_LED2 GPIO_Pin_3 - - // #define GPIO_PORT_LED3 GPIOE - // #define GPIO_PIN_LED3 GPIO_Pin_4 - - // #define GPIO_PORT_LED4 GPIOE - // #define GPIO_PIN_LED4 GPIO_Pin_5 - -#endif - -#ifdef STM32_F4 - /* STM32_F4 */ - /* - 安富莱STM32-V5 开发板LED口线分配: - LD1 : PI10/TP_NCS (低电平点亮,高电平熄灭) - LD2 : PF7/NRF24L01_CSN (低电平点亮,高电平熄灭) - LD3 : PF8/SF_CS (低电平点亮,高电平熄灭) - LD4 : PC2/NRF905_CSN/VS1053_XCS (低电平点亮,高电平熄灭) - */ - - /* 按键口对应的RCC时钟 */ - #define RCC_ALL_LED (RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_GPIOI) - - #define GPIO_PORT_LED1 GPIOI - #define GPIO_PIN_LED1 GPIO_Pin_10 - - #define GPIO_PORT_LED2 GPIOF - #define GPIO_PIN_LED2 GPIO_Pin_7 - - #define GPIO_PORT_LED3 GPIOF - #define GPIO_PIN_LED3 GPIO_Pin_8 - - #define GPIO_PORT_LED4 GPIOC - #define GPIO_PIN_LED4 GPIO_Pin_2 -#endif - -/* -********************************************************************************************************* -* 函 数 名: bsp_InitLed -* 功能说明: 配置LED指示灯相关的GPIO, 该函数被 bsp_Init() 调用。 -* 形 参: 无 -* 返 回 值: 无 -********************************************************************************************************* -*/ -void bsp_InitLed(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - /* 打开GPIO时钟 */ - RCC_APB2PeriphClockCmd(RCC_ALL_LED, ENABLE); - - /* - 配置所有的LED指示灯GPIO为推挽输出模式 - 由于将GPIO设置为输出时,GPIO输出寄存器的值缺省是0,因此会驱动LED点亮. - 这是我不希望的,因此在改变GPIO为输出前,先关闭LED指示灯 - */ - bsp_LedOff(LED1); - bsp_LedOff(LED2); - - /* LED 1*/ - GPIO_InitStructure.GPIO_Pin = GPIO_PIN_LED1; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; /* 设为 输出推挽模式 */ - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; /* IO口最大速度 */ - GPIO_Init(GPIO_PORT_LED1, &GPIO_InitStructure); - /* LED 2*/ - GPIO_InitStructure.GPIO_Pin = GPIO_PIN_LED2; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; /* 设为 输出推挽模式 */ - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; /* IO口最大速度 */ - GPIO_Init(GPIO_PORT_LED2, &GPIO_InitStructure); -} - -/* -********************************************************************************************************* -* 函 数 名: bsp_LedOn -* 功能说明: 点亮指定的LED指示灯。 -* 形 参: _no : 指示灯序号,范围 1 - 4 -* 返 回 值: 无 -********************************************************************************************************* -*/ -void bsp_LedOn(uint8_t _no) -{ - _no--; - - if (_no == (LED1-1)) - { - // STM32F103C8T6开发板 1是亮,0是灭 - // GPIO_PORT_LED1->BRR = GPIO_PIN_LED1; - GPIO_PORT_LED1->BSRR |= GPIO_PIN_LED1; - } - // else if (_no == 1) - // { - // GPIO_PORT_LED2->BSRRH = GPIO_PIN_LED2; - // } - // else if (_no == 2) - // { - // GPIO_PORT_LED3->BSRRH = GPIO_PIN_LED3; - // } - // else if (_no == 3) - // { - // GPIO_PORT_LED4->BSRRH = GPIO_PIN_LED4; - // } -} - -/* -********************************************************************************************************* -* 函 数 名: bsp_LedOff -* 功能说明: 熄灭指定的LED指示灯。 -* 形 参: _no : 指示灯序号,范围 1 - 4 -* 返 回 值: 无 -********************************************************************************************************* -*/ -void bsp_LedOff(uint8_t _no) -{ - _no--; - - if (_no == (LED1-1)) - { - // STM32F103C8T6开发板 1是亮,0是灭 - GPIO_PORT_LED1->BRR = GPIO_PIN_LED1; - } - // else if (_no == 1) - // { - // GPIO_PORT_LED2->BSRRL = GPIO_PIN_LED2; - // } - // else if (_no == 2) - // { - // GPIO_PORT_LED3->BSRRL = GPIO_PIN_LED3; - // } - // else if (_no == 3) - // { - // GPIO_PORT_LED4->BSRRL = GPIO_PIN_LED4; - // } -} - -/* -********************************************************************************************************* -* 函 数 名: bsp_LedToggle -* 功能说明: 翻转指定的LED指示灯。 -* 形 参: _no : 指示灯序号,范围 1 - 4 -* 返 回 值: 按键代码 -********************************************************************************************************* -*/ -void bsp_LedToggle(uint8_t _no) -{ - if (_no == (LED1)) - { - GPIO_PORT_LED1->ODR ^= GPIO_PIN_LED1; - } - else if (_no == 2) - { - GPIO_PORT_LED2->ODR ^= GPIO_PIN_LED2; - } - // else if (_no == 3) - // { - // GPIO_PORT_LED3->ODR ^= GPIO_PIN_LED3; - // } - // else if (_no == 4) - // { - // GPIO_PORT_LED4->ODR ^= GPIO_PIN_LED4; - // } -} - -/* -********************************************************************************************************* -* 函 数 名: bsp_IsLedOn -* 功能说明: 判断LED指示灯是否已经点亮。 -* 形 参: _no : 指示灯序号,范围 1 - 4 -* 返 回 值: 1表示已经点亮,0表示未点亮 -********************************************************************************************************* -*/ -uint8_t bsp_IsLedOn(uint8_t _no) -{ - if (_no == (LED1-1)) - { - if ((GPIO_PORT_LED1->ODR & GPIO_PIN_LED1) == 0) - { - return 1; - } - return 0; - } - // else if (_no == 2) - // { - // if ((GPIO_PORT_LED2->ODR & GPIO_PIN_LED2) == 0) - // { - // return 1; - // } - // return 0; - // } - // else if (_no == 3) - // { - // if ((GPIO_PORT_LED3->ODR & GPIO_PIN_LED3) == 0) - // { - // return 1; - // } - // return 0; - // } - // else if (_no == 4) - // { - // if ((GPIO_PORT_LED4->ODR & GPIO_PIN_LED4) == 0) - // { - // return 1; - // } - // return 0; - // } - - return 0; -} - -/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/ diff --git a/Code/middleware/Led/mw_led.c b/Code/middleware/Led/mw_led.c index 2f01aa5..3ce118c 100644 --- a/Code/middleware/Led/mw_led.c +++ b/Code/middleware/Led/mw_led.c @@ -51,7 +51,14 @@ void mw_led1_off(void) bsp_led_off(LED1); } /* led2 基础函数包 */ - +void mw_led2_on(void) +{ + bsp_led_on(LED2); +} +void mw_led2_off(void) +{ + bsp_led_off(LED2); +} /************************************************************************************* * @brief Led driver installation. * @@ -62,10 +69,9 @@ void mw_led_drv_init(void) { led_type_enum e_val; /* led0 installation */ - led_drv_buf[Led0].led_drv = Led0; - led_drv_buf[Led0].init = mw_led0_init; - led_drv_buf[Led0].on = mw_led0_on; - led_drv_buf[Led0].off = mw_led0_off; + led_drv_buf[Led1].led_drv = LED1; + led_drv_buf[Led1].on = mw_led0_on; + led_drv_buf[Led1].off = mw_led0_off; /* init all led peripherals */ for(e_val = Led0; e_val < led_num; e_val++) { diff --git a/Code/middleware/Led/mw_led.h b/Code/middleware/Led/mw_led.h index 1a4bc11..829da34 100644 --- a/Code/middleware/Led/mw_led.h +++ b/Code/middleware/Led/mw_led.h @@ -12,8 +12,8 @@ typedef struct { - uint8_t led_drv; - void (*init)(void); + led_type_enum led_drv; + // void (*init)(void); void (*on)(void); void (*off)(void); }mw_led_t;