summaryrefslogtreecommitdiff
path: root/stmhal/accel.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-10-29 22:40:42 +0000
committerDamien George <damien.p.george@gmail.com>2015-10-29 22:40:42 +0000
commit6f70283909a718ca4eab4efcdd1a2d74939c7193 (patch)
tree882c4c9920818b98b95011768b03cfd0adca6bcd /stmhal/accel.c
parent98b6d35c4ffa8ad40fb7aead3b9025c5e0471c27 (diff)
stmhal: Make accel AVDD pin configurable via mpconfigboard.h.
Diffstat (limited to 'stmhal/accel.c')
-rw-r--r--stmhal/accel.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/stmhal/accel.c b/stmhal/accel.c
index 64ac85266..59d83bfb5 100644
--- a/stmhal/accel.c
+++ b/stmhal/accel.c
@@ -31,6 +31,8 @@
#include "py/nlr.h"
#include "py/runtime.h"
+#include "pin.h"
+#include "genhdr/pins.h"
#include "i2c.h"
#include "accel.h"
@@ -59,12 +61,12 @@ void accel_init(void) {
GPIO_InitTypeDef GPIO_InitStructure;
// PB5 is connected to AVDD; pull high to enable MMA accel device
- GPIOB->BSRRH = GPIO_PIN_5; // turn off AVDD
- GPIO_InitStructure.Pin = GPIO_PIN_5;
+ MICROPY_HW_MMA_AVDD_PIN.gpio->BSRRH = MICROPY_HW_MMA_AVDD_PIN.pin_mask; // turn off AVDD
+ GPIO_InitStructure.Pin = MICROPY_HW_MMA_AVDD_PIN.pin_mask;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
GPIO_InitStructure.Pull = GPIO_NOPULL;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
+ HAL_GPIO_Init(MICROPY_HW_MMA_AVDD_PIN.gpio, &GPIO_InitStructure);
}
STATIC void accel_start(void) {
@@ -80,9 +82,9 @@ STATIC void accel_start(void) {
i2c_init(&I2CHandle1);
// turn off AVDD, wait 30ms, turn on AVDD, wait 30ms again
- GPIOB->BSRRH = GPIO_PIN_5; // turn off
+ MICROPY_HW_MMA_AVDD_PIN.gpio->BSRRH = MICROPY_HW_MMA_AVDD_PIN.pin_mask; // turn off
HAL_Delay(30);
- GPIOB->BSRRL = GPIO_PIN_5; // turn on
+ MICROPY_HW_MMA_AVDD_PIN.gpio->BSRRL = MICROPY_HW_MMA_AVDD_PIN.pin_mask; // turn on
HAL_Delay(30);
HAL_StatusTypeDef status;