samd/modmachine: Add machine.time_pulse_us.

Software based. Resolution:
- +/-2 microseconds on SAMD51.
- +/-4 microseconds on SAMD21.
This commit is contained in:
robert-hh 2022-06-07 21:52:03 +02:00 committed by Damien George
parent f5da77b5ce
commit 029e9af457
2 changed files with 5 additions and 2 deletions

View File

@ -26,10 +26,11 @@
#include "py/runtime.h" #include "py/runtime.h"
#include "extmod/machine_mem.h" #include "extmod/machine_mem.h"
#include "samd_soc.h" #include "extmod/machine_pulse.h"
#include "modmachine.h"
#include "extmod/machine_i2c.h" #include "extmod/machine_i2c.h"
#include "extmod/machine_spi.h" #include "extmod/machine_spi.h"
#include "modmachine.h"
#include "samd_soc.h"
// ASF 4 // ASF 4
#include "hal_flash.h" #include "hal_flash.h"
@ -165,6 +166,7 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_idle), MP_ROM_PTR(&machine_idle_obj) }, { MP_ROM_QSTR(MP_QSTR_idle), MP_ROM_PTR(&machine_idle_obj) },
{ MP_ROM_QSTR(MP_QSTR_disable_irq), MP_ROM_PTR(&machine_disable_irq_obj) }, { MP_ROM_QSTR(MP_QSTR_disable_irq), MP_ROM_PTR(&machine_disable_irq_obj) },
{ MP_ROM_QSTR(MP_QSTR_enable_irq), MP_ROM_PTR(&machine_enable_irq_obj) }, { MP_ROM_QSTR(MP_QSTR_enable_irq), MP_ROM_PTR(&machine_enable_irq_obj) },
{ MP_ROM_QSTR(MP_QSTR_time_pulse_us), MP_ROM_PTR(&machine_time_pulse_us_obj) },
}; };
STATIC MP_DEFINE_CONST_DICT(machine_module_globals, machine_module_globals_table); STATIC MP_DEFINE_CONST_DICT(machine_module_globals, machine_module_globals_table);

View File

@ -111,6 +111,7 @@
#define MICROPY_PY_MACHINE_SPI (1) #define MICROPY_PY_MACHINE_SPI (1)
#define MICROPY_PY_MACHINE_SOFTSPI (1) #define MICROPY_PY_MACHINE_SOFTSPI (1)
#define MICROPY_PY_OS_DUPTERM (3) #define MICROPY_PY_OS_DUPTERM (3)
#define MICROPY_PY_MACHINE_PULSE (1)
#define MICROPY_PY_MACHINE_PWM (1) #define MICROPY_PY_MACHINE_PWM (1)
#define MICROPY_PY_MACHINE_PWM_INIT (0) #define MICROPY_PY_MACHINE_PWM_INIT (0)
#define MICROPY_PY_MACHINE_PWM_DUTY_U16_NS (1) #define MICROPY_PY_MACHINE_PWM_DUTY_U16_NS (1)