| BlueNRG-1 Peripherals drivers Examples

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

RTC_TimeBasePattern_main.c
Go to the documentation of this file.
1
2 /******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
3 * File Name : RTC_TimeBasePattern_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 with pattern usage
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
165 /* Includes ------------------------------------------------------------------*/
166 #include "BlueNRG1.h"
167 #include "BlueNRG1_conf.h"
168 #include "SDK_EVAL_Config.h"
169
182 /* Private typedef -----------------------------------------------------------*/
183 /* Private define ------------------------------------------------------------*/
184 #define RTC_PERIOD_1s (32767)
185 #define RTC_PERIOD_100ms ((32767)/10)
187 /* Private macro -------------------------------------------------------------*/
188 /* Private variables ---------------------------------------------------------*/
189 /* Private function prototypes -----------------------------------------------*/
190 void RTC_Configuration(void);
191
192 /* Private functions ---------------------------------------------------------*/
193
199 int main(void)
200 {
201 /* System initialization function */
202 SystemInit();
203
204 /* Identify BlueNRG1 platform */
205 SdkEvalIdentification();
206
207 /* LED initialization */
208 SdkEvalLedInit(LED1);
209
210 /* RTC initialization */
211 RTC_Configuration();
212
213 /* Infinite loop */
214 while(1);
215 }
216
217
218
224 void RTC_Configuration(void)
225 {
226 RTC_InitType RTC_Init_struct;
227 NVIC_InitType NVIC_InitStructure;
228
229 SysCtrl_PeripheralClockCmd(CLOCK_PERIPH_RTC, ENABLE);
230
232 RTC_Init_struct.RTC_operatingMode = RTC_TIMER_PERIODIC;
233 RTC_Init_struct.RTC_PATTERN_SIZE = 8-1;
234 RTC_Init_struct.RTC_TLR1 = RTC_PERIOD_1s;
235 RTC_Init_struct.RTC_TLR2 = RTC_PERIOD_100ms;
242 RTC_Init_struct.RTC_PATTERN1 = 0xF2;
243 RTC_Init_struct.RTC_PATTERN2 = 0;
244 RTC_Init_struct.RTC_PATTERN3 = 0;
245 RTC_Init_struct.RTC_PATTERN4 = 0;
246 RTC_Init(&RTC_Init_struct);
247
249 RTC_IT_Config(RTC_IT_TIMER, ENABLE);
250 RTC_IT_Clear(RTC_IT_TIMER);
251
256 for (volatile uint32_t i=0; i<300; i++) {
257 __asm("NOP");
258 }
259
260 /* Set the RTC_IRQn interrupt priority and enable it */
261 NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn;
262 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = LOW_PRIORITY;
263 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
264 NVIC_Init(&NVIC_InitStructure);
265
266 /* Enable RTC */
267 RTC_Cmd(ENABLE);
268 }
269
270
271 #ifdef USE_FULL_ASSERT
272
279 void assert_failed(uint8_t* file, uint32_t line)
280 {
281 /* User can add his own implementation to report the file name and line number,
282 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
283
284 /* Infinite loop */
285 while (1)
286 {
287 }
288 }
289
290 #endif
291
304 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/
main
int main(void)
Main program code.
Definition: RTC_TimeBasePattern_main.c:199
RTC_Configuration
void RTC_Configuration(void)
RTC0 Configuration.
Definition: RTC_TimeBasePattern_main.c:224
RTC_PERIOD_1s
#define RTC_PERIOD_1s
Definition: RTC_TimeBasePattern_main.c:184
RTC_PERIOD_100ms
#define RTC_PERIOD_100ms
Definition: RTC_TimeBasePattern_main.c:185