summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/pin.c
diff options
context:
space:
mode:
Diffstat (limited to 'stmhal/pin.c')
-rw-r--r--stmhal/pin.c13
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);