File tree Expand file tree Collapse file tree 2 files changed +32
-6
lines changed
libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F Expand file tree Collapse file tree 2 files changed +32
-6
lines changed Original file line number Diff line number Diff line change 22
22
extern "C" {
23
23
#endif
24
24
25
+ typedef enum {
26
+ OSC32KCLK = 0 ,
27
+ } RTCName ;
28
+
25
29
typedef enum {
26
30
UART_0 = (int )UART0_BASE ,
27
31
UART_1 = (int )UART1_BASE ,
Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
*/
16
16
#include "rtc_api.h"
17
+ #include "fsl_rtc_driver.h"
17
18
18
- static void init ( void ) {
19
-
20
- }
19
+ const PinMap PinMap_RTC [] = {
20
+ { NC , OSC32KCLK , 0 },
21
+ };
21
22
22
23
void rtc_init (void ) {
24
+ rtc_init_config_t config = {0 };
25
+ rtc_hal_init_config_t hal_config = {0 };
26
+
27
+ hal_config .disableClockOutToPeripheral = true;
28
+ if (PinMap_RTC [0 ].pin == NC ) {
29
+ hal_config .enable32kOscillator = true;
30
+ }
31
+ hal_config .startSecondsCounterAt = 1 ; /* TSR = 1 */
32
+ config .general_config = & hal_config ;
33
+ rtc_init (& config );
23
34
35
+ // select RTC clock source
36
+ SIM -> SOPT1 &= ~SIM_SOPT1_OSC32KSEL_MASK ;
37
+ SIM -> SOPT1 |= SIM_SOPT1_OSC32KSEL (PinMap_RTC [0 ].peripheral );
38
+
39
+ rtc_start_time_counter ();
24
40
}
25
41
26
42
void rtc_free (void ) {
@@ -32,13 +48,19 @@ void rtc_free(void) {
32
48
* 0 = Disabled, 1 = Enabled
33
49
*/
34
50
int rtc_isenabled (void ) {
35
- return 1 ;
51
+ clock_manager_set_gate (kClockModuleRTC , 0U , true);
52
+ return (int )rtc_hal_is_counter_enabled ();
36
53
}
37
54
38
55
time_t rtc_read (void ) {
39
- return 1 ;
56
+ return BR_RTC_TSR_TSR ;
40
57
}
41
58
42
59
void rtc_write (time_t t ) {
43
-
60
+ if (t == 0 ) {
61
+ t = 1 ;
62
+ }
63
+ rtc_hal_counter_enable (false);
64
+ BW_RTC_TSR_TSR (t );
65
+ rtc_hal_counter_enable (true);
44
66
}
You can’t perform that action at this time.
0 commit comments