/****************************************************************************
|
* 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);
|
}
|