| BlueNRG-1 Peripherals drivers Examples

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

GPIO_IOToggle_main.c
Go to the documentation of this file.
1
2 /******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
3 * File Name : GPIO_IOToggle_main.c
4 * Author : VMA DIVISION
5 * Version : 1.0.0
6 * Date : 21-September-2015
7 * Description : Code demostrating the GPIO toggle functionality
8 ********************************************************************************
9 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
10 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
11 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
12 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
13 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
14 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
15 *******************************************************************************/
16
134 /* Includes ------------------------------------------------------------------*/
135 #include "BlueNRG1.h"
136 #include "BlueNRG1_conf.h"
137 #include "SDK_EVAL_Config.h"
138
151 /* Private typedef -----------------------------------------------------------*/
152 /* Private define ------------------------------------------------------------*/
153 #define SYST_CLOCK 16000000
154
155 /* Private macro -------------------------------------------------------------*/
156 /* Private variables ---------------------------------------------------------*/
157 volatile uint32_t lSystickCounter=0;
158
159 /* Private function prototypes -----------------------------------------------*/
160 void SdkDelayMs(volatile uint32_t lTimeMs);
161
162 /* Private functions ---------------------------------------------------------*/
163
169 int main(void)
170 {
171 /* System initialization function */
172 SystemInit();
173
174 /* Identify BlueNRG1 platform */
175 SdkEvalIdentification();
176
177 /* LEDS initialization */
178 SdkEvalLedInit(LED1);
179 SdkEvalLedInit(LED2);
180 SdkEvalLedInit(LED3);
181
182 /* Configure SysTick to generate interrupt */
183 SysTick_Config(SYST_CLOCK/1000 - 1);
184
185 /* Infinite loop */
186 while(1) {
187 SdkEvalLedToggle(LED1);
188 SdkDelayMs(250);
189 SdkEvalLedToggle(LED2);
190 SdkDelayMs(250);
191 SdkEvalLedToggle(LED3);
192 SdkDelayMs(250);
193 }
194 }
195
196
202 void SdkDelayMs(volatile uint32_t lTimeMs)
203 {
204 uint32_t nWaitPeriod = ~lSystickCounter;
205
206 if(nWaitPeriod<lTimeMs)
207 {
208 while( lSystickCounter != 0xFFFFFFFF);
209 nWaitPeriod = lTimeMs-nWaitPeriod;
210 }
211 else
212 nWaitPeriod = lTimeMs+ ~nWaitPeriod;
213
214 while( lSystickCounter != nWaitPeriod ) ;
215
216 }
217
218 #ifdef USE_FULL_ASSERT
219
226 void assert_failed(uint8_t* file, uint32_t line)
227 {
228 /* User can add his own implementation to report the file name and line number,
229 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
230
231 /* Infinite loop */
232 while (1)
233 {
234 }
235 }
236
237 #endif
238
252 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/
SYST_CLOCK
#define SYST_CLOCK
Definition: GPIO_IOToggle_main.c:153
main
int main(void)
Main program.
Definition: ADC_Polling_main.c:206
SdkDelayMs
void SdkDelayMs(volatile uint32_t lTimeMs)
Delay function.
Definition: GPIO_IOToggle_main.c:202
lSystickCounter
volatile uint32_t lSystickCounter
Definition: GPIO_IOToggle_main.c:157