87 lines
1.9 KiB
C
87 lines
1.9 KiB
C
#include "bsp_led.h"
|
|
|
|
gpio_type *led_gpio_port[LED_NUM] =
|
|
{
|
|
LED2_GPIO,
|
|
LED3_GPIO,
|
|
LED4_GPIO
|
|
};
|
|
uint16_t led_gpio_pin[LED_NUM] =
|
|
{
|
|
LED2_PIN,
|
|
LED3_PIN,
|
|
LED4_PIN
|
|
};
|
|
crm_periph_clock_type led_gpio_crm_clk[LED_NUM] =
|
|
{
|
|
LED2_GPIO_CRM_CLK,
|
|
LED3_GPIO_CRM_CLK,
|
|
LED4_GPIO_CRM_CLK
|
|
};
|
|
|
|
|
|
void bsp_led_init(led_type led)
|
|
{
|
|
gpio_init_type gpio_init_struct;
|
|
|
|
/* enable the led clock */
|
|
crm_periph_clock_enable(led_gpio_crm_clk[led], TRUE);
|
|
|
|
/* set default parameter */
|
|
gpio_default_para_init(&gpio_init_struct);
|
|
|
|
/* configure the led gpio */
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_OUTPUT;
|
|
gpio_init_struct.gpio_pins = led_gpio_pin[led];
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
gpio_init(led_gpio_port[led], &gpio_init_struct);
|
|
gpio_bits_set(GPIOB, GPIO_PINS_7);
|
|
gpio_bits_reset(GPIOB, GPIO_PINS_7);
|
|
gpio_bits_set(GPIOB, GPIO_PINS_7);
|
|
gpio_bits_reset(GPIOB, GPIO_PINS_7);
|
|
}
|
|
|
|
void bsp_led_on(led_type led)
|
|
{
|
|
if(led > (LED_NUM - 1))
|
|
return;
|
|
if(led_gpio_pin[led])
|
|
led_gpio_port[led]->clr = led_gpio_pin[led];
|
|
}
|
|
|
|
/**
|
|
* @brief turns selected led off.
|
|
* @param led: specifies the led to be set off.
|
|
* this parameter can be one of following parameters:
|
|
* @arg LED2
|
|
* @arg LED3
|
|
* @arg LED4
|
|
* @retval none
|
|
*/
|
|
void bsp_led_off(led_type led)
|
|
{
|
|
if(led > (LED_NUM - 1))
|
|
return;
|
|
if(led_gpio_pin[led])
|
|
led_gpio_port[led]->scr = led_gpio_pin[led];
|
|
}
|
|
|
|
/**
|
|
* @brief turns selected led toggle.
|
|
* @param led: specifies the led to be set off.
|
|
* this parameter can be one of following parameters:
|
|
* @arg LED2
|
|
* @arg LED3
|
|
* @arg LED4
|
|
* @retval none
|
|
*/
|
|
void bsp_led_toggle(led_type led)
|
|
{
|
|
if(led > (LED_NUM - 1))
|
|
return;
|
|
if(led_gpio_pin[led])
|
|
led_gpio_port[led]->odt ^= led_gpio_pin[led];
|
|
}
|