Skip to content

Commit becbc87

Browse files
committed
Add Timer support (PWM, OC, IC) for stmhal and teensy
1 parent 2842945 commit becbc87

23 files changed

+2055
-86
lines changed

stmhal/pin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *self, mp_uint_t n_args, con
413413
STATIC mp_obj_t pin_obj_init(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
414414
return pin_obj_init_helper(args[0], n_args - 1, args + 1, kw_args);
415415
}
416-
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pin_init_obj, 1, pin_obj_init);
416+
MP_DEFINE_CONST_FUN_OBJ_KW(pin_init_obj, 1, pin_obj_init);
417417

418418
/// \method value([value])
419419
/// Get or set the digital logic level of the pin:

stmhal/pin.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ extern const mp_obj_type_t pin_cpu_pins_obj_type;
8282
extern const mp_obj_dict_t pin_cpu_pins_locals_dict;
8383
extern const mp_obj_dict_t pin_board_pins_locals_dict;
8484

85+
MP_DECLARE_CONST_FUN_OBJ(pin_init_obj);
86+
8587
void pin_init0(void);
8688
uint32_t pin_get_mode(const pin_obj_t *pin);
8789
uint32_t pin_get_pull(const pin_obj_t *pin);
8890
uint32_t pin_get_af(const pin_obj_t *pin);
8991
const pin_obj_t *pin_find(mp_obj_t user_obj);
9092
const pin_obj_t *pin_find_named_pin(const mp_obj_dict_t *named_pins, mp_obj_t name);
91-
const pin_af_obj_t *pin_find_af(const pin_obj_t *pin, uint8_t fn, uint8_t unit, uint8_t pin_type);
93+
const pin_af_obj_t *pin_find_af(const pin_obj_t *pin, uint8_t fn, uint8_t unit);
9294
const pin_af_obj_t *pin_find_af_by_index(const pin_obj_t *pin, mp_uint_t af_idx);
9395
const pin_af_obj_t *pin_find_af_by_name(const pin_obj_t *pin, const char *name);

stmhal/pin_named_pins.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,15 @@ const pin_obj_t *pin_find_named_pin(const mp_obj_dict_t *named_pins, mp_obj_t na
6464
return NULL;
6565
}
6666

67-
/* unused
68-
const pin_af_obj_t *pin_find_af(const pin_obj_t *pin, uint8_t fn, uint8_t unit, uint8_t type) {
67+
const pin_af_obj_t *pin_find_af(const pin_obj_t *pin, uint8_t fn, uint8_t unit) {
6968
const pin_af_obj_t *af = pin->af;
7069
for (mp_uint_t i = 0; i < pin->num_af; i++, af++) {
71-
if (af->fn == fn && af->unit == unit && af->type == type) {
70+
if (af->fn == fn && af->unit == unit) {
7271
return af;
7372
}
7473
}
7574
return NULL;
7675
}
77-
*/
7876

7977
const pin_af_obj_t *pin_find_af_by_index(const pin_obj_t *pin, mp_uint_t af_idx) {
8078
const pin_af_obj_t *af = pin->af;

stmhal/qstrdefsport.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,40 @@ Q(recv)
144144

145145
// for Timer class
146146
Q(Timer)
147+
Q(init)
148+
Q(deinit)
149+
Q(channel)
147150
Q(counter)
148151
Q(prescaler)
149152
Q(period)
150153
Q(callback)
151154
Q(freq)
152155
Q(mode)
153156
Q(div)
157+
Q(UP)
158+
Q(DOWN)
159+
Q(CENTER)
160+
Q(IC)
161+
Q(PWM)
162+
Q(PWM_INVERTED)
163+
Q(OC_TIMING)
164+
Q(OC_ACTIVE)
165+
Q(OC_INACTIVE)
166+
Q(OC_TOGGLE)
167+
Q(OC_FORCED_ACTIVE)
168+
Q(OC_FORCED_INACTIVE)
169+
Q(HIGH)
170+
Q(LOW)
171+
Q(RISING)
172+
Q(FALLING)
173+
Q(BOTH)
174+
175+
// for TimerChannel class
176+
Q(TimerChannel)
177+
Q(pulse_width)
178+
Q(compare)
179+
Q(capture)
180+
Q(polarity)
154181

155182
// for ExtInt class
156183
Q(ExtInt)

0 commit comments

Comments
 (0)