Rev Author Line No. Line
3328 povik 1 #include "stm32_eval.h"
2  
3 GPIO_TypeDef* GPIO_PORT[LEDn] = {LED1_GPIO_PORT, LED2_GPIO_PORT, LED3_GPIO_PORT,
4 LED4_GPIO_PORT};
5 const uint16_t GPIO_PIN[LEDn] = {LED1_GPIO_PIN, LED2_GPIO_PIN, LED3_GPIO_PIN,
6 LED4_GPIO_PIN};
7 const uint32_t GPIO_CLK[LEDn] = {LED1_GPIO_CLK, LED2_GPIO_CLK, LED3_GPIO_CLK,
8 LED4_GPIO_CLK};
9  
10 /**
11 * @brief Configures LED GPIO.
12 * @param Led: Specifies the Led to be configured.
13 * This parameter can be one of following parameters:
14 * @arg LED1
15 * @arg LED2
16 * @arg LED3
17 * @arg LED4
18 * @retval None
19 */
20 void STM_EVAL_LEDInit(Led_TypeDef Led)
21 {
22 GPIO_InitTypeDef GPIO_InitStructure;
23  
24 /* Enable the GPIO_LED Clock */
25 RCC_APB2PeriphClockCmd(GPIO_CLK[Led], ENABLE);
26  
27 /* Configure the GPIO_LED pin */
28 GPIO_InitStructure.GPIO_Pin = GPIO_PIN[Led];
29 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
30 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
31  
32 GPIO_Init(GPIO_PORT[Led], &GPIO_InitStructure);
33 }
34  
35 /**
36 * @brief Turns selected LED On.
37 * @param Led: Specifies the Led to be set on.
38 * This parameter can be one of following parameters:
39 * @arg LED1
40 * @arg LED2
41 * @arg LED3
42 * @arg LED4
43 * @retval None
44 */
45 void STM_EVAL_LEDOn(Led_TypeDef Led)
46 {
47 GPIO_PORT[Led]->BSRR = GPIO_PIN[Led];
48 }
49  
50 /**
51 * @brief Turns selected LED Off.
52 * @param Led: Specifies the Led to be set off.
53 * This parameter can be one of following parameters:
54 * @arg LED1
55 * @arg LED2
56 * @arg LED3
57 * @arg LED4
58 * @retval None
59 */
60 void STM_EVAL_LEDOff(Led_TypeDef Led)
61 {
62 GPIO_PORT[Led]->BRR = GPIO_PIN[Led];
63 }
64  
65 /**
66 * @brief Toggles the selected LED.
67 * @param Led: Specifies the Led to be toggled.
68 * This parameter can be one of following parameters:
69 * @arg LED1
70 * @arg LED2
71 * @arg LED3
72 * @arg LED4
73 * @retval None
74 */
75 void STM_EVAL_LEDToggle(Led_TypeDef Led)
76 {
77 GPIO_PORT[Led]->ODR ^= GPIO_PIN[Led];
78 }