Skip to content

Commit 4a5c52f

Browse files
committed
starting on adafruit#1046 rtc for nRF
1 parent 367f658 commit 4a5c52f

File tree

6 files changed

+96
-2
lines changed

6 files changed

+96
-2
lines changed

ports/nrf/common-hal/rtc/RTC.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 Nick Moore for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include <stdlib.h>
28+
29+
#include "py/obj.h"
30+
#include "py/runtime.h"
31+
#include "lib/timeutils/timeutils.h"
32+
#include "shared-bindings/rtc/__init__.h"
33+
#include "supervisor/shared/translate.h"
34+
35+
void rtc_init(void) {
36+
}
37+
38+
void common_hal_rtc_get_time(timeutils_struct_time_t *tm) {
39+
tm->tm_year = 2000;
40+
tm->tm_mon = 1;
41+
tm->tm_mday = 2;
42+
tm->tm_hour = 3;
43+
tm->tm_min = 4;
44+
tm->tm_sec = 5;
45+
tm->tm_wday = 6;
46+
tm->tm_yday = 2;
47+
}
48+
49+
void common_hal_rtc_set_time(timeutils_struct_time_t *tm) {
50+
}
51+
52+
// A positive value speeds up the clock by removing clock cycles.
53+
int common_hal_rtc_get_calibration(void) {
54+
return 0;
55+
}
56+
57+
void common_hal_rtc_set_calibration(int calibration) {
58+
}

ports/nrf/common-hal/rtc/RTC.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2018 Noralf Trønnes
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_RTC_RTC_H
28+
#define MICROPY_INCLUDED_NRF_COMMON_HAL_RTC_RTC_H
29+
30+
extern void rtc_init(void);
31+
32+
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_RTC_RTC_H

ports/nrf/common-hal/rtc/__init__.c

Whitespace-only changes.

ports/nrf/mpconfigport.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,4 @@
5757
CIRCUITPY_COMMON_ROOT_POINTERS \
5858
ble_drv_evt_handler_entry_t* ble_drv_evt_handler_entries; \
5959

60-
6160
#endif // NRF5_MPCONFIGPORT_H__

ports/nrf/mpconfigport.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ CIRCUITPY_I2CSLAVE = 0
2323
CIRCUITPY_NVM = 0
2424

2525
# rtc not yet implemented
26-
CIRCUITPY_RTC = 0
26+
CIRCUITPY_RTC = 1
2727

2828
# frequencyio not yet implemented
2929
CIRCUITPY_FREQUENCYIO = 0

ports/nrf/supervisor/port.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@
4545
#include "common-hal/pulseio/PWMOut.h"
4646
#include "common-hal/pulseio/PulseOut.h"
4747
#include "common-hal/pulseio/PulseIn.h"
48+
#include "common-hal/rtc/RTC.h"
4849
#include "tick.h"
4950

51+
#include "shared-bindings/rtc/__init__.h"
52+
5053
static void power_warning_handler(void) {
5154
reset_into_safe_mode(BROWNOUT);
5255
}
@@ -71,6 +74,7 @@ safe_mode_t port_init(void) {
7174

7275
// Configure millisecond timer initialization.
7376
tick_init();
77+
rtc_init();
7478

7579
// Will do usb_init() if chip supports USB.
7680
board_init();
@@ -90,6 +94,7 @@ void reset_port(void) {
9094
pulseout_reset();
9195
pulsein_reset();
9296
timers_reset();
97+
rtc_reset();
9398

9499
bleio_reset();
95100

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy