From ce897b1bb088c337e917d6f24972fd5f094f478f Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Mon, 6 Nov 2023 15:33:44 +0100 Subject: [PATCH] ports/psoc6: Machine class refactor according to upstream. Signed-off-by: enriquezgarc --- ports/psoc6/drivers/machine/psoc6_pwm.h | 2 +- ports/psoc6/modules/machine/machine_i2c.c | 2 +- ports/psoc6/modules/machine/machine_pwm.c | 6 ++---- ports/psoc6/modules/machine/machine_spi.c | 4 +--- ports/psoc6/modules/machine/modmachine.c | 8 +------- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/ports/psoc6/drivers/machine/psoc6_pwm.h b/ports/psoc6/drivers/machine/psoc6_pwm.h index c61e92484b1f8..dbda21ddd0152 100644 --- a/ports/psoc6/drivers/machine/psoc6_pwm.h +++ b/ports/psoc6/drivers/machine/psoc6_pwm.h @@ -14,7 +14,7 @@ typedef struct _machine_pwm_obj_t { uint8_t pin; uint32_t fz; uint8_t duty_type; - mp_float_t duty; + mp_int_t duty; bool invert; } machine_pwm_obj_t; diff --git a/ports/psoc6/modules/machine/machine_i2c.c b/ports/psoc6/modules/machine/machine_i2c.c index 9b08c15ffee5d..60e43f48ed86a 100644 --- a/ports/psoc6/modules/machine/machine_i2c.c +++ b/ports/psoc6/modules/machine/machine_i2c.c @@ -4,7 +4,7 @@ // mpy includes -#include "extmod/machine_i2c.h" +#include "extmod/modmachine.h" #include "py/runtime.h" #include "py/mphal.h" diff --git a/ports/psoc6/modules/machine/machine_pwm.c b/ports/psoc6/modules/machine/machine_pwm.c index dc464ebacbbd6..9c4c59c1766cb 100644 --- a/ports/psoc6/modules/machine/machine_pwm.c +++ b/ports/psoc6/modules/machine/machine_pwm.c @@ -18,8 +18,6 @@ enum { }; STATIC void mp_machine_pwm_freq_set(machine_pwm_obj_t *self, mp_int_t freq); -STATIC void mp_machine_pwm_duty_set_u16(machine_pwm_obj_t *self, mp_float_t duty_u16); -STATIC void mp_machine_pwm_duty_set_ns(machine_pwm_obj_t *self, mp_float_t duty_ns); // To check whether the PWM is active STATIC void pwm_is_active(machine_pwm_obj_t *self) { @@ -148,7 +146,7 @@ STATIC mp_obj_t mp_machine_pwm_duty_get_u16(machine_pwm_obj_t *self) { } // sets the duty cycle as a ratio duty_u16 / 65535. -STATIC void mp_machine_pwm_duty_set_u16(machine_pwm_obj_t *self, mp_float_t duty_u16) { +STATIC void mp_machine_pwm_duty_set_u16(machine_pwm_obj_t *self, mp_int_t duty_u16) { pwm_is_active(self); // Check the value is more than the max value self->duty = duty_u16 > 65535 ? 65535 : duty_u16; @@ -166,7 +164,7 @@ STATIC mp_obj_t mp_machine_pwm_duty_get_ns(machine_pwm_obj_t *self) { } // sets the pulse width in nanoseconds -STATIC void mp_machine_pwm_duty_set_ns(machine_pwm_obj_t *self, mp_float_t duty_ns) { +STATIC void mp_machine_pwm_duty_set_ns(machine_pwm_obj_t *self, mp_int_t duty_ns) { pwm_is_active(self); self->duty = duty_ns; self->duty_type = DUTY_NS; diff --git a/ports/psoc6/modules/machine/machine_spi.c b/ports/psoc6/modules/machine/machine_spi.c index 38cd001d1448e..fbb43a0a8b63e 100644 --- a/ports/psoc6/modules/machine/machine_spi.c +++ b/ports/psoc6/modules/machine/machine_spi.c @@ -4,10 +4,8 @@ // mpy includes #include "py/runtime.h" -#include "extmod/machine_spi.h" -#include "py/mphal.h" +#include "extmod/modmachine.h" #include "py/mperrno.h" -#include "extmod/machine_spi.h" // MTB includes #include "cybsp.h" diff --git a/ports/psoc6/modules/machine/modmachine.c b/ports/psoc6/modules/machine/modmachine.c index 72bb69040495a..570502f47c2df 100644 --- a/ports/psoc6/modules/machine/modmachine.c +++ b/ports/psoc6/modules/machine/modmachine.c @@ -7,13 +7,7 @@ #include "py/runtime.h" #include "py/mphal.h" #include "shared/runtime/pyexec.h" -#include "extmod/machine_bitstream.h" -#include "extmod/machine_i2c.h" -#include "extmod/machine_mem.h" -#include "extmod/machine_pulse.h" -#include "extmod/machine_pwm.h" -#include "extmod/machine_signal.h" -#include "extmod/machine_spi.h" +#include "extmod/modmachine.h" // MTB includes #include "cybsp.h"