Skip to content

Commit

Permalink
ports/psoc6: Machine class refactor according to upstream.
Browse files Browse the repository at this point in the history
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
  • Loading branch information
jaenrig-ifx authored and actions-user committed Nov 6, 2023
1 parent 64cb8ee commit ce897b1
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ports/psoc6/drivers/machine/psoc6_pwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion ports/psoc6/modules/machine/machine_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


// mpy includes
#include "extmod/machine_i2c.h"
#include "extmod/modmachine.h"
#include "py/runtime.h"
#include "py/mphal.h"

Expand Down
6 changes: 2 additions & 4 deletions ports/psoc6/modules/machine/machine_pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions ports/psoc6/modules/machine/machine_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 1 addition & 7 deletions ports/psoc6/modules/machine/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ce897b1

Please sign in to comment.