| BlueNRG-1 SDK drivers APIs

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

SDK_EVAL_Button.c
Go to the documentation of this file.
1
24 /* Includes ------------------------------------------------------------------*/
25 #include "SDK_EVAL_Button.h"
26
76 /* Buttons IRQ Pin */
77 static uint32_t Get_ButtonGpioPin(SdkEvalButton xButton)
78 {
79 uint32_t button_pin;
80 switch (xButton)
81 {
82 case(BUTTON_1):
83 button_pin = PUSH_BUTTON1_PIN;
84 break;
85 case(BUTTON_2):
86 button_pin = PUSH_BUTTON2_PIN;
87 break;
88 default:
89 button_pin = PUSH_BUTTON1_PIN;
90 break;
91 }
92 return (button_pin);
93 }
94
115 void SdkEvalPushButtonInit(SdkEvalButton xButton)
116 {
117 GPIO_InitType GPIO_InitStructure;
118
119 /* Enables the BUTTON Clock */
120 SysCtrl_PeripheralClockCmd(CLOCK_PERIPH_GPIO, ENABLE);
121
122 /* Configures Button pin as input */
123 GPIO_InitStructure.GPIO_Pin = Get_ButtonGpioPin(xButton);
124 GPIO_InitStructure.GPIO_Mode = GPIO_Input;
125 GPIO_InitStructure.GPIO_Pull = DISABLE;
126 GPIO_InitStructure.GPIO_HighPwr = DISABLE;
127 GPIO_Init(&GPIO_InitStructure);
128
129 }
130
131
145 void SdkEvalPushButtonIrq(SdkEvalButton xButton, SdkEvalButtonIrq xButtonIrq)
146 {
147 GPIO_EXTIConfigType GPIO_EXTIStructure;
148 NVIC_InitType NVIC_InitStructure;
149
150 /* Set the GPIO interrupt priority and enable it */
151 NVIC_InitStructure.NVIC_IRQChannel = GPIO_IRQn;
152 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = LOW_PRIORITY;
153 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
154 NVIC_Init(&NVIC_InitStructure);
155
156 /* Configures EXTI line */
157 GPIO_EXTIStructure.GPIO_Pin = Get_ButtonGpioPin(xButton);
158 GPIO_EXTIStructure.GPIO_IrqSense = GPIO_IrqSense_Edge;
159 GPIO_EXTIStructure.GPIO_Event = xButtonIrq;
160 GPIO_EXTIConfig(&GPIO_EXTIStructure);
161
162 /* Clear pending interrupt */
163 GPIO_ClearITPendingBit(Get_ButtonGpioPin(xButton));
164
165 /* Enable the interrupt */
166 GPIO_EXTICmd(Get_ButtonGpioPin(xButton), ENABLE);
167 }
168
169
179 FlagStatus SdkEvalPushButtonGetState(SdkEvalButton xButton)
180 {
181 if(GPIO_ReadBit(Get_ButtonGpioPin(xButton)))
182 return SET;
183 else
184 return RESET;
185 }
186
187
197 FlagStatus SdkEvalPushButtonGetITPendingBit(SdkEvalButton xButton)
198 {
199 return GPIO_GetITPendingBit(Get_ButtonGpioPin(xButton));
200 }
201
202
211 void SdkEvalPushButtonClearITPendingBit(SdkEvalButton xButton)
212 {
213 GPIO_ClearITPendingBit(Get_ButtonGpioPin(xButton));
214 }
215
216
232 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/
SdkEvalPushButtonIrq
void SdkEvalPushButtonIrq(SdkEvalButton xButton, SdkEvalButtonIrq xButtonIrq)
Configures buttons IRQ mode.
Definition: SDK_EVAL_Button.c:145
SdkEvalButton
SdkEvalButton
Enumeration of SDK EVAL Buttons.
Definition: SDK_EVAL_Button.h:53
PUSH_BUTTON1_PIN
#define PUSH_BUTTON1_PIN
BlueNRG1 Eval Board (STEVAL-IDB007Vx) Buttons definitions.
Definition: USER_Platform_Configuration.h:39
SdkEvalPushButtonGetState
FlagStatus SdkEvalPushButtonGetState(SdkEvalButton xButton)
Returns the selected Button state.
Definition: SDK_EVAL_Button.c:179
BUTTON_1
Definition: SDK_EVAL_Button.h:54
SDK_EVAL_Button.h
This file provides all the low level API to manage buttons for eval board.
SdkEvalPushButtonClearITPendingBit
void SdkEvalPushButtonClearITPendingBit(SdkEvalButton xButton)
Clear the pending bit state.
Definition: SDK_EVAL_Button.c:211
PUSH_BUTTON2_PIN
#define PUSH_BUTTON2_PIN
Definition: USER_Platform_Configuration.h:40
BUTTON_2
Definition: SDK_EVAL_Button.h:55
SdkEvalButtonIrq
SdkEvalButtonIrq
Enumeration of SDK EVAL Buttons IRQ mode.
Definition: SDK_EVAL_Button.h:62
SdkEvalPushButtonInit
void SdkEvalPushButtonInit(SdkEvalButton xButton)
Configures Buttons.
Definition: SDK_EVAL_Button.c:115
SdkEvalPushButtonGetITPendingBit
FlagStatus SdkEvalPushButtonGetITPendingBit(SdkEvalButton xButton)
Get the pending bit state.
Definition: SDK_EVAL_Button.c:197