Embedded System Design 2 - Project
delay.h
Go to the documentation of this file.
1 /***************************************************************************//**
2  * @file delay.h
3  * @brief Delay functionality.
4  * @version 3.2
5  * @author Brecht Van Eeckhoudt
6  *
7  * ******************************************************************************
8  *
9  * @section License
10  *
11  * **Copyright (C) 2019 - Brecht Van Eeckhoudt**
12  *
13  * This program is free software: you can redistribute it and/or modify
14  * it under the terms of the **GNU General Public License** as published by
15  * the Free Software Foundation, either **version 3** of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * *A copy of the GNU General Public License can be found in the `LICENSE`
24  * file along with this source code.*
25  *
26  * @n
27  *
28  * Some methods use code obtained from examples from [Silicon Labs' GitHub](https://github.com/SiliconLabs/peripheral_examples).
29  * These sections are licensed under the Silabs License Agreement. See the file
30  * "Silabs_License_Agreement.txt" for details. Before using this software for
31  * any purpose, you must agree to the terms of that agreement.
32  *
33  ******************************************************************************/
34 
35 
36 /* Include guards prevent multiple inclusions of the same header */
37 #ifndef _DELAY_H_
38 #define _DELAY_H_
39 
40 
41 /* Includes necessary for this header file */
42 #include <stdint.h> /* (u)intXX_t */
43 
44 
45 /** Public definition to select which delay to use
46  * @li `1` - Use SysTick delays.
47  * @li `0` - Use EM2/3 RTC compare delays. */
48 #define SYSTICKDELAY 0
49 
50 
51 /** Public definition to select the use of the crystal or the oscillator
52  * @li `0` - Use the low-frequency crystal oscillator (LFXO), EM2 sleep is used.
53  * @li `1` - Use the ultra low-frequency RC oscillator (ULFRCO), EM3 sleep is used but delays are less precise timing-wise.
54  * ** EM3: All unwanted oscillators are disabled, they don't need to manually disabled before `EMU_EnterEM3`.** */
55 #define ULFRCO 1
56 
57 
58 /* Public prototypes */
59 void delay (uint32_t msDelay);
60 void sleep (uint32_t sSleep);
61 bool RTC_checkWakeup (void);
62 void RTC_clearWakeup (void);
63 uint32_t RTC_getPassedSleeptime (void);
64 
65 
66 #endif /* _DELAY_H_ */
uint32_t RTC_getPassedSleeptime(void)
Method to get the time spend sleeping (in seconds) in the case of GPIO wake-up.
Definition: delay.c:428
void RTC_clearWakeup(void)
Method to clear RTC_sleep_wakeup.
Definition: delay.c:414
void delay(uint32_t msDelay)
Wait for a certain amount of milliseconds in EM2/3.
Definition: delay.c:124
bool RTC_checkWakeup(void)
Method to check if the wakeup was caused by the RTC.
Definition: delay.c:404
void sleep(uint32_t sSleep)
Sleep for a certain amount of seconds in EM2/3.
Definition: delay.c:276