0,0 → 1,78 |
#include "stm32_eval.h" |
|
GPIO_TypeDef* GPIO_PORT[LEDn] = {LED1_GPIO_PORT, LED2_GPIO_PORT, LED3_GPIO_PORT, |
LED4_GPIO_PORT}; |
const uint16_t GPIO_PIN[LEDn] = {LED1_GPIO_PIN, LED2_GPIO_PIN, LED3_GPIO_PIN, |
LED4_GPIO_PIN}; |
const uint32_t GPIO_CLK[LEDn] = {LED1_GPIO_CLK, LED2_GPIO_CLK, LED3_GPIO_CLK, |
LED4_GPIO_CLK}; |
|
/** |
* @brief Configures LED GPIO. |
* @param Led: Specifies the Led to be configured. |
* This parameter can be one of following parameters: |
* @arg LED1 |
* @arg LED2 |
* @arg LED3 |
* @arg LED4 |
* @retval None |
*/ |
void STM_EVAL_LEDInit(Led_TypeDef Led) |
{ |
GPIO_InitTypeDef GPIO_InitStructure; |
|
/* Enable the GPIO_LED Clock */ |
RCC_APB2PeriphClockCmd(GPIO_CLK[Led], ENABLE); |
|
/* Configure the GPIO_LED pin */ |
GPIO_InitStructure.GPIO_Pin = GPIO_PIN[Led]; |
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
|
GPIO_Init(GPIO_PORT[Led], &GPIO_InitStructure); |
} |
|
/** |
* @brief Turns selected LED On. |
* @param Led: Specifies the Led to be set on. |
* This parameter can be one of following parameters: |
* @arg LED1 |
* @arg LED2 |
* @arg LED3 |
* @arg LED4 |
* @retval None |
*/ |
void STM_EVAL_LEDOn(Led_TypeDef Led) |
{ |
GPIO_PORT[Led]->BSRR = 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 LED1 |
* @arg LED2 |
* @arg LED3 |
* @arg LED4 |
* @retval None |
*/ |
void STM_EVAL_LEDOff(Led_TypeDef Led) |
{ |
GPIO_PORT[Led]->BRR = GPIO_PIN[Led]; |
} |
|
/** |
* @brief Toggles the selected LED. |
* @param Led: Specifies the Led to be toggled. |
* This parameter can be one of following parameters: |
* @arg LED1 |
* @arg LED2 |
* @arg LED3 |
* @arg LED4 |
* @retval None |
*/ |
void STM_EVAL_LEDToggle(Led_TypeDef Led) |
{ |
GPIO_PORT[Led]->ODR ^= GPIO_PIN[Led]; |
} |