copy from src/bare_test/stm32_key/board/stm32v5_led.c
copy to src/bare_test/4.Systick/user/stm32v5_led.c
File was copied from src/bare_test/stm32_key/board/stm32v5_led.c |
| | |
| | | /****************************************************************************
|
| | | * Copyright: (C)2014 Î人ÁèÔÆÇ¶ÈëʽʵÑéÊÒ www.emblinux.com
|
| | | * Author: GuoWenxue<guowenxue@gmail.com> QQ: 281143292
|
| | | * Description: ·Ü¶·STM32v5¿ª·¢°åcontiki²Ù×÷ϵͳLEDÉ豸²Ù×÷º¯Êý½Ó¿Ú
|
| | | * |
| | | * ChangeLog:
|
| | | * °æ±¾ºÅ ÈÕÆÚ ×÷Õß ËµÃ÷
|
| | | * V1.0.0 2014.08.25 GuoWenxue ·¢²¼¸Ã°æ±¾
|
| | | ****************************************************************************/
|
| | |
|
| | | #include "stm32v5_led.h"
|
| | |
|
| | | static led_gpio_t leds_gpio[MAX_LED] =
|
| | | {
|
| | | {LED1, GPIOB, GPIO_Pin_5}, /* LED1 ÓõÄGPB5 */
|
| | | {LED2, GPIOD, GPIO_Pin_6}, /* LED2 ÓõÄGPD6 */
|
| | | {LED3, GPIOD, GPIO_Pin_3}, /* LED3 ÓõÄGPD3 */ |
| | | };
|
| | |
|
| | |
|
| | | void init_led_gpio(void)
|
| | | {
|
| | | int i;
|
| | | GPIO_InitTypeDef GPIO_InitStructure;
|
| | |
|
| | | /* ʹÄÜPBºÍPD×é GPIOµÄʱÖÓ */
|
| | | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOD , ENABLE); |
| | | |
| | | /*ÉèÖà PB5(LED1), PD6(LED2), PD3(LED3)Ϊ GPIO Êä³öÍÆÃâģʽ£¬¿ÚÏ߷תËÙ¶ÈΪ50MHz */
|
| | | for(i=0; i<MAX_LED; i++)
|
| | | {
|
| | | /*ÉèÖà PB5(LED1)Ϊ GPIO Êä³öÍÆÃâģʽ£¬¿ÚÏ߷תËÙ¶ÈΪ50MHz */
|
| | | GPIO_InitStructure.GPIO_Pin = leds_gpio[i].pin; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
| | | GPIO_Init(leds_gpio[i].group, &GPIO_InitStructure); |
| | | }
|
| | | }
|
| | |
|
| | | void turn_led(int which, int cmd)
|
| | | {
|
| | | if(which<0 || which> MAX_LED )
|
| | | return;
|
| | | |
| | | if(OFF == cmd)
|
| | | GPIO_ResetBits(leds_gpio[which].group, leds_gpio[which].pin);
|
| | | else
|
| | | GPIO_SetBits(leds_gpio[which].group, leds_gpio[which].pin);
|
| | | }
|
| | | /**************************************************************************** |
| | | * Copyright: (C)2018 Î人ÁèÔÆÎïÍøÖÇ¿ÆÊµÑéÊÒ www.iot-yun.com |
| | | * Author: GuoWenxue<guowenxue@gmail.com> QQ: 281143292 |
| | | * Description: ·Ü¶·STM32v5¿ª·¢°å LEDÉ豸²Ù×÷º¯Êý½Ó¿Ú |
| | | * |
| | | * ChangeLog: |
| | | * °æ±¾ºÅ ÈÕÆÚ ×÷Õß ËµÃ÷ |
| | | * V1.0.0 2018.05.10 GuoWenxue ·¢²¼¸Ã°æ±¾ |
| | | ****************************************************************************/ |
| | | |
| | | #include "stm32f10x.h" |
| | | #include "stm32v5_led.h" |
| | | |
| | | /* STM32v5 Èý¸öLED·Ö±ðÁ¬½Ó GPIO¿ÚµÄ PB5(LED1)¡¢PD6(LED2)¡¢PD3(LED3) */ |
| | | led_gpio_t leds_gpio[MAX_LED] = |
| | | { |
| | | {LED1, GPIOB, GPIO_Pin_5}, /* LED1 ÓõÄGPB5 */ |
| | | {LED2, GPIOD, GPIO_Pin_6}, /* LED2 ÓõÄGPD6 */ |
| | | {LED3, GPIOD, GPIO_Pin_3}, /* LED3 ÓõÄGPD3 */ |
| | | }; |
| | | |
| | | /* º¯Êý˵Ã÷: ÅäÖà LED GPIO¿ÚºÍʱÖÓ£» |
| | | * ²ÎÊý˵Ã÷: ÎÞ |
| | | * ·µ»ØÖµ: ÎÞ |
| | | */ |
| | | void init_led_gpio(void) |
| | | { |
| | | int i; |
| | | GPIO_InitTypeDef GPIO_InitStructure; |
| | | |
| | | /* ʹÄÜPBºÍPD×é GPIOµÄʱÖÓ */ |
| | | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOD , ENABLE); |
| | | |
| | | /*ÉèÖà PB5(LED1), PD6(LED2), PD3(LED3)Ϊ GPIO Êä³öÍÆÃâģʽ£¬¿ÚÏ߷תËÙ¶ÈΪ50MHz */ |
| | | for(i=0; i<MAX_LED; i++) |
| | | { |
| | | /*ÉèÖà PB5(LED1)Ϊ GPIO Êä³öÍÆÃâģʽ£¬¿ÚÏ߷תËÙ¶ÈΪ50MHz */ |
| | | GPIO_InitStructure.GPIO_Pin = leds_gpio[i].pin; |
| | | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
| | | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| | | GPIO_Init(leds_gpio[i].group, &GPIO_InitStructure); |
| | | } |
| | | } |
| | | |
| | | |
| | | /* º¯Êý˵Ã÷: µãÁÁ»òÃðµôÏàÓ¦LED |
| | | * ²ÎÊý˵Ã÷: which: Òª²Ù×÷ÄĸöLED,ÆäÖµÓ¦¸ÃΪ LED1¡¢LED2 »ò LED3£ |
| | | * cmd: ÒªÁÁ»¹ÊÇÃð, ÆäÖµ¶ÔӦΪ ON »ò OFF |
| | | * ·µ»ØÖµ: ÎÞ |
| | | */ |
| | | void turn_led(int which, int cmd) |
| | | { |
| | | if(which<0 || which> MAX_LED ) |
| | | return; |
| | | |
| | | if(OFF == cmd) |
| | | GPIO_ResetBits(leds_gpio[which].group, leds_gpio[which].pin); |
| | | else |
| | | GPIO_SetBits(leds_gpio[which].group, leds_gpio[which].pin); |
| | | } |