Skip to content

Commit 27904ae

Browse files
Gadgetoiddpgeorge
authored andcommitted
rp2/machine_pwm: Add RP2350 slices to machine.PWM.
Signed-off-by: Phil Howard <[email protected]>
1 parent 8cc7c64 commit 27904ae

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

ports/rp2/machine_pwm.c

+12-2
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,20 @@ static machine_pwm_obj_t machine_pwm_obj[] = {
6767
{{&machine_pwm_type}, 6, PWM_CHAN_B, 0, DUTY_NOT_SET, 0 },
6868
{{&machine_pwm_type}, 7, PWM_CHAN_A, 0, DUTY_NOT_SET, 0 },
6969
{{&machine_pwm_type}, 7, PWM_CHAN_B, 0, DUTY_NOT_SET, 0 },
70+
#if NUM_PWM_SLICES == 12
71+
{{&machine_pwm_type}, 8, PWM_CHAN_A, 0, DUTY_NOT_SET, 0 },
72+
{{&machine_pwm_type}, 8, PWM_CHAN_B, 0, DUTY_NOT_SET, 0 },
73+
{{&machine_pwm_type}, 9, PWM_CHAN_A, 0, DUTY_NOT_SET, 0 },
74+
{{&machine_pwm_type}, 9, PWM_CHAN_B, 0, DUTY_NOT_SET, 0 },
75+
{{&machine_pwm_type}, 10, PWM_CHAN_A, 0, DUTY_NOT_SET, 0 },
76+
{{&machine_pwm_type}, 10, PWM_CHAN_B, 0, DUTY_NOT_SET, 0 },
77+
{{&machine_pwm_type}, 11, PWM_CHAN_A, 0, DUTY_NOT_SET, 0 },
78+
{{&machine_pwm_type}, 11, PWM_CHAN_B, 0, DUTY_NOT_SET, 0 },
79+
#endif
7080
};
7181

7282
static bool defer_start;
73-
static bool slice_freq_set[8];
83+
static bool slice_freq_set[NUM_PWM_SLICES];
7484

7585
static void mp_machine_pwm_freq_set(machine_pwm_obj_t *self, mp_int_t freq);
7686
static void mp_machine_pwm_duty_set_u16(machine_pwm_obj_t *self, mp_int_t duty_u16);
@@ -155,7 +165,7 @@ static mp_obj_t mp_machine_pwm_make_new(const mp_obj_type_t *type, size_t n_args
155165

156166
// Stop all active slices.
157167
void machine_pwm_deinit_all(void) {
158-
for (int i = 0; i < 8; i++) {
168+
for (int i = 0; i < NUM_PWM_SLICES; i++) {
159169
slice_freq_set[i] = false;
160170
pwm_set_enabled(machine_pwm_obj[i].slice, false);
161171
}

0 commit comments

Comments
 (0)