diff options
| author | Dan Halbert <halbert@halwitz.org> | 2019-03-29 16:41:29 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-29 16:41:29 -0400 |
| commit | 0653bca3239e9e00ad744523188f181b315d479f (patch) | |
| tree | 1d6154931764b9dba5588d4a9c67547253b27c0f /ports/nrf | |
| parent | aca74a5394a25ed5cd80bcb7d5050383681304c8 (diff) | |
Revert "Circuitpython nickzoic 1046 nrf rtc"
Diffstat (limited to 'ports/nrf')
| -rwxr-xr-x | ports/nrf/Makefile | 1 | ||||
| -rw-r--r-- | ports/nrf/common-hal/rtc/RTC.c | 81 | ||||
| -rw-r--r-- | ports/nrf/common-hal/rtc/RTC.h | 32 | ||||
| -rw-r--r-- | ports/nrf/common-hal/rtc/__init__.c | 0 | ||||
| -rw-r--r-- | ports/nrf/mpconfigport.h | 1 | ||||
| -rw-r--r-- | ports/nrf/mpconfigport.mk | 4 | ||||
| -rw-r--r-- | ports/nrf/nrfx_config.h | 3 | ||||
| -rw-r--r-- | ports/nrf/supervisor/port.c | 5 |
8 files changed, 3 insertions, 124 deletions
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 3cb4b52aa..3681ac49e 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -140,7 +140,6 @@ SRC_NRFX = $(addprefix nrfx/,\ drivers/src/nrfx_twim.c \ drivers/src/nrfx_uarte.c \ drivers/src/nrfx_gpiote.c \ - drivers/src/nrfx_rtc.c \ ) ifdef EXTERNAL_FLASH_DEVICES diff --git a/ports/nrf/common-hal/rtc/RTC.c b/ports/nrf/common-hal/rtc/RTC.c deleted file mode 100644 index d807d7b03..000000000 --- a/ports/nrf/common-hal/rtc/RTC.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Nick Moore for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include <stdlib.h> - -#include "py/obj.h" -#include "py/runtime.h" -#include "lib/timeutils/timeutils.h" -#include "shared-bindings/rtc/__init__.h" -#include "supervisor/shared/translate.h" - -#include "nrfx_rtc.h" -#include "nrf_clock.h" - -// We clock the RTC very slowly (8Hz) so that it won't overflow often. -// But the counter is only 24 bits, so overflow is about every 24 days ... -// For testing, set this to 32768 and it'll overflow every few minutes - -#define RTC_CLOCK_HZ (8) - -volatile static uint32_t rtc_offset = 0; - -const nrfx_rtc_t rtc_instance = NRFX_RTC_INSTANCE(0); - -const nrfx_rtc_config_t rtc_config = { - .prescaler = RTC_FREQ_TO_PRESCALER(RTC_CLOCK_HZ), - .reliable = 0, - .tick_latency = 0, - .interrupt_priority = 6 -}; - -void rtc_handler(nrfx_rtc_int_type_t int_type) { - if (int_type == NRFX_RTC_INT_OVERFLOW) { - rtc_offset += (1L<<24) / RTC_CLOCK_HZ; - } -} - -void rtc_init(void) { - if (!nrf_clock_lf_is_running()) { - nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART); - } - nrfx_rtc_counter_clear(&rtc_instance); - nrfx_rtc_init(&rtc_instance, &rtc_config, rtc_handler); - nrfx_rtc_enable(&rtc_instance); - nrfx_rtc_overflow_enable(&rtc_instance, 1); -} - -void common_hal_rtc_get_time(timeutils_struct_time_t *tm) { - uint32_t t = rtc_offset + (nrfx_rtc_counter_get(&rtc_instance) / RTC_CLOCK_HZ ); - timeutils_seconds_since_2000_to_struct_time(t, tm); -} - -void common_hal_rtc_set_time(timeutils_struct_time_t *tm) { - rtc_offset = timeutils_seconds_since_2000( - tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec - ); - nrfx_rtc_counter_clear(&rtc_instance); -} diff --git a/ports/nrf/common-hal/rtc/RTC.h b/ports/nrf/common-hal/rtc/RTC.h deleted file mode 100644 index 5374fa2c8..000000000 --- a/ports/nrf/common-hal/rtc/RTC.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2018 Noralf Trønnes - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_RTC_RTC_H -#define MICROPY_INCLUDED_NRF_COMMON_HAL_RTC_RTC_H - -extern void rtc_init(void); - -#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_RTC_RTC_H diff --git a/ports/nrf/common-hal/rtc/__init__.c b/ports/nrf/common-hal/rtc/__init__.c deleted file mode 100644 index e69de29bb..000000000 --- a/ports/nrf/common-hal/rtc/__init__.c +++ /dev/null diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 5ed521e85..1b2d8ea12 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -57,4 +57,5 @@ CIRCUITPY_COMMON_ROOT_POINTERS \ ble_drv_evt_handler_entry_t* ble_drv_evt_handler_entries; \ + #endif // NRF5_MPCONFIGPORT_H__ diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk index fdeb1bbbe..badfb6735 100644 --- a/ports/nrf/mpconfigport.mk +++ b/ports/nrf/mpconfigport.mk @@ -22,8 +22,8 @@ CIRCUITPY_I2CSLAVE = 0 # nvm not yet implemented CIRCUITPY_NVM = 0 -# enable RTC -CIRCUITPY_RTC = 1 +# rtc not yet implemented +CIRCUITPY_RTC = 0 # frequencyio not yet implemented CIRCUITPY_FREQUENCYIO = 0 diff --git a/ports/nrf/nrfx_config.h b/ports/nrf/nrfx_config.h index b8a0a7f60..57a2727aa 100644 --- a/ports/nrf/nrfx_config.h +++ b/ports/nrf/nrfx_config.h @@ -70,9 +70,6 @@ #define NRFX_PWM3_ENABLED 0 #endif -#define NRFX_RTC_ENABLED 1 -#define NRFX_RTC0_ENABLED 1 - // TIMERS #define NRFX_TIMER_ENABLED 1 // Don't enable TIMER0: it's used by the SoftDevice. diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index 3d20e94ae..fd077a46a 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -45,11 +45,8 @@ #include "common-hal/pulseio/PWMOut.h" #include "common-hal/pulseio/PulseOut.h" #include "common-hal/pulseio/PulseIn.h" -#include "common-hal/rtc/RTC.h" #include "tick.h" -#include "shared-bindings/rtc/__init__.h" - static void power_warning_handler(void) { reset_into_safe_mode(BROWNOUT); } @@ -74,7 +71,6 @@ safe_mode_t port_init(void) { // Configure millisecond timer initialization. tick_init(); - rtc_init(); // Will do usb_init() if chip supports USB. board_init(); @@ -94,7 +90,6 @@ void reset_port(void) { pulseout_reset(); pulsein_reset(); timers_reset(); - rtc_reset(); bleio_reset(); |
