diff options
author | Damien <damien.p.george@gmail.com> | 2013-11-03 18:30:57 +0000 |
---|---|---|
committer | Damien <damien.p.george@gmail.com> | 2013-11-03 18:30:57 +0000 |
commit | 0c70f887340bbf39ac4fcaeef57fa359aa20d6f7 (patch) | |
tree | 46484d77e89d839b80e2018847ddbfd8b0973a01 | |
parent | e8674399f11dd0ad5edcf1dfc961fb41f0dd4b68 (diff) | |
download | micropython-0c70f887340bbf39ac4fcaeef57fa359aa20d6f7.tar.gz micropython-0c70f887340bbf39ac4fcaeef57fa359aa20d6f7.zip |
Add simple PWM control command to STM code.
-rw-r--r-- | stm/main.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/stm/main.c b/stm/main.c index def515e48b..f8f1105c1c 100644 --- a/stm/main.c +++ b/stm/main.c @@ -514,6 +514,14 @@ py_obj_t pyb_servo_set(py_obj_t value) { return py_const_none; } +py_obj_t pyb_pwm_set(py_obj_t period, py_obj_t pulse) { + int pe = py_obj_get_int(period); + int pu = py_obj_get_int(pulse); + TIM2->ARR = pe; + TIM2->CCR3 = pu; + return py_const_none; +} + #define MMA_ADDR (0x4c) py_obj_t pyb_mma_read() { @@ -749,6 +757,7 @@ soft_reset: rt_store_attr(m, qstr_from_str_static("led"), rt_make_function_1(pyb_led)); rt_store_attr(m, qstr_from_str_static("sw"), rt_make_function_0(pyb_sw)); rt_store_attr(m, qstr_from_str_static("servo"), rt_make_function_1(pyb_servo_set)); + rt_store_attr(m, qstr_from_str_static("pwm"), rt_make_function_2(pyb_pwm_set)); rt_store_attr(m, qstr_from_str_static("mma"), rt_make_function_0(pyb_mma_read)); rt_store_attr(m, qstr_from_str_static("hid"), rt_make_function_1(pyb_hid_send_report)); rt_store_attr(m, qstr_from_str_static("time"), rt_make_function_0(pyb_rtc_read)); |