compiles; maybe ready to test, or almost

This commit is contained in:
Dan Halbert 2020-11-22 21:52:37 -05:00
parent 25591a3f8a
commit 3abee9b256
4 changed files with 39 additions and 4 deletions

View File

@ -26,17 +26,19 @@
*/ */
#include "py/objtuple.h" #include "py/objtuple.h"
#include "py/runtime.h"
#include "shared-bindings/alarm/__init__.h" #include "shared-bindings/alarm/__init__.h"
#include "shared-bindings/alarm/pin/PinAlarm.h" #include "shared-bindings/alarm/pin/PinAlarm.h"
#include "shared-bindings/alarm/time/DurationAlarm.h" #include "shared-bindings/alarm/time/DurationAlarm.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "esp_sleep.h" #include "esp_sleep.h"
STATIC mp_obj_tuple_t *_deep_sleep_alarms; STATIC mp_obj_tuple_t *_deep_sleep_alarms;
void alarm_reset(void) { void alarm_reset(void) {
_deep_sleep_alarms = &mp_const_empty_tuple; _deep_sleep_alarms = mp_const_empty_tuple;
} }
void common_hal_alarm_disable_all(void) { void common_hal_alarm_disable_all(void) {
@ -94,8 +96,8 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala
} }
void common_hal_deep_sleep_with_alarms(void) { void common_hal_deep_sleep_with_alarms(void) {
for (size_t i = 0; i < _deep_sleep_alarms.len; i++) { for (size_t i = 0; i < _deep_sleep_alarms->len; i++) {
mp_obj_t alarm = _deep_sleep_alarms.items[i] mp_obj_t alarm = _deep_sleep_alarms->items[i];
if (MP_OBJ_IS_TYPE(alarm, &alarm_time_duration_alarm_type)) { if (MP_OBJ_IS_TYPE(alarm, &alarm_time_duration_alarm_type)) {
alarm_time_duration_alarm_obj_t *duration_alarm = MP_OBJ_TO_PTR(alarm); alarm_time_duration_alarm_obj_t *duration_alarm = MP_OBJ_TO_PTR(alarm);
esp_sleep_enable_timer_wakeup( esp_sleep_enable_timer_wakeup(

View File

@ -0,0 +1,32 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2020 Dan Halbert 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.
*/
#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_ALARM__INIT__H
#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_ALARM__INIT__H
void alarm_reset(void);
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_ALARM__INIT__H

View File

@ -42,6 +42,7 @@
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "esp_sleep.h" #include "esp_sleep.h"
#include "esp_wifi.h"
void common_hal_mcu_delay_us(uint32_t delay) { void common_hal_mcu_delay_us(uint32_t delay) {
mp_hal_delay_us(delay); mp_hal_delay_us(delay);

View File

@ -30,7 +30,7 @@
#include "py/obj.h" #include "py/obj.h"
extern mp_obj_t common_hal_alarm_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); extern mp_obj_t common_hal_alarm_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms);
extern mp_obj_t common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms); extern void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms);
// Used by wake-up code. // Used by wake-up code.
extern void common_hal_alarm_set_wake_alarm(mp_obj_t alarm); extern void common_hal_alarm_set_wake_alarm(mp_obj_t alarm);