diff options
author | Dave Hylands <dhylands@gmail.com> | 2014-06-15 22:33:14 -0700 |
---|---|---|
committer | Dave Hylands <dhylands@gmail.com> | 2014-06-15 22:48:05 -0700 |
commit | 4f1b7fec9f103c92de40875e9a06b7decc4923f4 (patch) | |
tree | d9e0f1b0e7dd290a728c065960500ecf30967997 /stmhal/pin.c | |
parent | 2547928148aefcf163953057979e14f46bef1170 (diff) | |
download | micropython-4f1b7fec9f103c92de40875e9a06b7decc4923f4.tar.gz micropython-4f1b7fec9f103c92de40875e9a06b7decc4923f4.zip |
Updated teensy to build.
Refactored some stmhal files which are shared with teensy.
Diffstat (limited to 'stmhal/pin.c')
-rw-r--r-- | stmhal/pin.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/stmhal/pin.c b/stmhal/pin.c index 9806a8c49a..6ee5fa564e 100644 --- a/stmhal/pin.c +++ b/stmhal/pin.c @@ -28,9 +28,8 @@ #include <stdint.h> #include <string.h> -#include "stm32f4xx_hal.h" - #include "mpconfig.h" +#include HAL_H #include "nlr.h" #include "misc.h" #include "qstr.h" @@ -310,13 +309,13 @@ STATIC mp_obj_t pin_value(uint n_args, mp_obj_t *args) { pin_obj_t *self = args[0]; if (n_args == 1) { // get pin - return MP_OBJ_NEW_SMALL_INT((self->gpio->IDR >> self->pin) & 1); + return MP_OBJ_NEW_SMALL_INT(GPIO_read_pin(self->gpio, self->pin)); } else { // set pin if (mp_obj_is_true(args[1])) { - self->gpio->BSRRL = self->pin_mask; + GPIO_set_pin(self->gpio, self->pin_mask); } else { - self->gpio->BSRRH = self->pin_mask; + GPIO_clear_pin(self->gpio, self->pin_mask); } return mp_const_none; } @@ -327,7 +326,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pin_value_obj, 1, 2, pin_value); /// Set the pin to a low logic level. STATIC mp_obj_t pin_low(mp_obj_t self_in) { pin_obj_t *self = self_in; - self->gpio->BSRRH = self->pin_mask; + GPIO_clear_pin(self->gpio, self->pin_mask);; return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(pin_low_obj, pin_low); @@ -336,7 +335,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pin_low_obj, pin_low); /// Set the pin to a high logic level. STATIC mp_obj_t pin_high(mp_obj_t self_in) { pin_obj_t *self = self_in; - self->gpio->BSRRL = self->pin_mask; + GPIO_set_pin(self->gpio, self->pin_mask);; return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(pin_high_obj, pin_high); |