| BlueNRG-1 Peripherals drivers Examples

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

RTC_TimeBase_main.c
Go to the documentation of this file.
1
2 /******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
3 * File Name : RTC_TimeBase_main.c
4 * Author : VMA DIVISION
5 * Version : 1.0.0
6 * Date : 21-September-2015
7 * Description : Code demostrating the RTC timer periodic 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
161 /* Includes ------------------------------------------------------------------*/
162 #include "BlueNRG1.h"
163 #include "BlueNRG1_conf.h"
164 #include "SDK_EVAL_Config.h"
165
178 /* Private typedef -----------------------------------------------------------*/
179 /* Private define ------------------------------------------------------------*/
180 #define RTC_PERIOD_1s (32767)
181
182 /* Private macro -------------------------------------------------------------*/
183 /* Private variables ---------------------------------------------------------*/
184 /* Private function prototypes -----------------------------------------------*/
185 void RTC_Configuration(void);
186
187 /* Private functions ---------------------------------------------------------*/
188
189
195 int main(void)
196 {
197 /* System initialization function */
198 SystemInit();
199
200 /* Identify BlueNRG1 platform */
201 SdkEvalIdentification();
202
203 /* LED initialization */
204 SdkEvalLedInit(LED1);
205
206 /* RTC configuration */
207 RTC_Configuration();
208
209 /* Infinite loop */
210 while(1);
211 }
212
213
219 void RTC_Configuration(void)
220 {
221 RTC_InitType RTC_Init_struct;
222 NVIC_InitType NVIC_InitStructure;
223
224 SysCtrl_PeripheralClockCmd(CLOCK_PERIPH_RTC, ENABLE);
225
226 /* RTC configuration */
227 RTC_Init_struct.RTC_operatingMode = RTC_TIMER_PERIODIC;
228 RTC_Init_struct.RTC_PATTERN_SIZE = 1 - 1;
229 RTC_Init_struct.RTC_TLR1 = RTC_PERIOD_1s;
230 RTC_Init_struct.RTC_TLR2 = 0;
231 RTC_Init_struct.RTC_PATTERN1 = 0x00;
232 RTC_Init_struct.RTC_PATTERN2 = 0x00;
233 RTC_Init_struct.RTC_PATTERN3 = 0x00;
234 RTC_Init_struct.RTC_PATTERN4 = 0x00;
235 RTC_Init(&RTC_Init_struct);
236
237 /* Enable RTC Timer interrupt*/
238 RTC_IT_Config(RTC_IT_TIMER, ENABLE);
239 RTC_IT_Clear(RTC_IT_TIMER);
240
245 for (volatile uint32_t i=0; i<300; i++) {
246 __asm("NOP");
247 }
248
249 /* Set the RTC_IRQn interrupt priority and enable it */
250 NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn;
251 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = LOW_PRIORITY;
252 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
253 NVIC_Init(&NVIC_InitStructure);
254
255 /* Enable RTC */
256 RTC_Cmd(ENABLE);
257
258 }
259
260
261
262 #ifdef USE_FULL_ASSERT
263
270 void assert_failed(uint8_t* file, uint32_t line)
271 {
272 /* User can add his own implementation to report the file name and line number,
273 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
274
275 /* Infinite loop */
276 while (1)
277 {
278 }
279 }
280
281 #endif
282
295 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/
RTC_Configuration
void RTC_Configuration(void)
RTC Configuration.
Definition: RTC_TimeBase_main.c:219
RTC_PERIOD_1s
#define RTC_PERIOD_1s
Definition: RTC_TimeBase_main.c:180
main
int main(void)
Main program code.
Definition: RTC_TimeBase_main.c:195