There are currently 7 ports that implement machine.WDT and a lot of code is duplicated across these implementations. This commit factors the common parts of all these implementations to a single location in extmod/machine_wdt.c. This common code provides the top-level Python bindings (class and method wrappers), and then each port implements the back end specific to that port. With this refactor the ports remain functionally the same except for: - The esp8266 WDT constructor now takes keyword arguments, and accepts the "timeout" argument but raises an exception if it's not the default value (this port doesn't support changing the timeout). - The mimxrt and samd ports now interpret the argument to WDT.timeout_ms() as signed and if it's negative truncate it to the minimum timeout (rather than it being unsigned and a negative value truncating to the maximum timeout). Signed-off-by: Damien George <damien@micropython.org>
36 lines
1.1 KiB
C
36 lines
1.1 KiB
C
#ifndef MICROPY_INCLUDED_ESP32_MODMACHINE_H
|
|
#define MICROPY_INCLUDED_ESP32_MODMACHINE_H
|
|
|
|
#include "py/obj.h"
|
|
|
|
typedef enum {
|
|
// MACHINE_WAKE_IDLE=0x01,
|
|
MACHINE_WAKE_SLEEP=0x02,
|
|
MACHINE_WAKE_DEEPSLEEP=0x04
|
|
} wake_type_t;
|
|
|
|
extern const mp_obj_type_t machine_timer_type;
|
|
extern const mp_obj_type_t machine_pin_type;
|
|
extern const mp_obj_type_t machine_touchpad_type;
|
|
extern const mp_obj_type_t machine_adc_type;
|
|
extern const mp_obj_type_t machine_adcblock_type;
|
|
extern const mp_obj_type_t machine_dac_type;
|
|
extern const mp_obj_type_t machine_i2c_type;
|
|
extern const mp_obj_type_t machine_spi_type;
|
|
extern const mp_obj_type_t machine_i2s_type;
|
|
extern const mp_obj_type_t machine_uart_type;
|
|
extern const mp_obj_type_t machine_rtc_type;
|
|
extern const mp_obj_type_t machine_sdcard_type;
|
|
|
|
void machine_init(void);
|
|
void machine_deinit(void);
|
|
void machine_pins_init(void);
|
|
void machine_pins_deinit(void);
|
|
void machine_pwm_deinit_all(void);
|
|
// TODO: void machine_rmt_deinit_all(void);
|
|
void machine_timer_deinit_all(void);
|
|
void machine_i2s_init0();
|
|
NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args);
|
|
|
|
#endif // MICROPY_INCLUDED_ESP32_MODMACHINE_H
|