Commit fa1ecda3 authored by Damien George's avatar Damien George
Browse files

stmhal, accel: Increase start-up times to 30ms; add extra 30ms delay.

For accel to start-up reliably, need to wait 30ms between on/off, and
30ms for it to enter active mode.  With this fix the accel can be read
immediately after initialising it.

Addresses issue #763.
parent 3c4db9f9
......@@ -83,11 +83,11 @@ STATIC void accel_start(void) {
I2CHandle1.Init.OwnAddress2 = 0xfe; // unused
// turn off AVDD, wait 20ms, turn on AVDD, wait 20ms again
// turn off AVDD, wait 30ms, turn on AVDD, wait 30ms again
GPIOB->BSRRH = GPIO_PIN_5; // turn off
GPIOB->BSRRL = GPIO_PIN_5; // turn on
HAL_StatusTypeDef status;
......@@ -100,11 +100,12 @@ STATIC void accel_start(void) {
uint8_t data[1];
data[0] = 1; // active mode
// set MMA to active mode
uint8_t data[1] = {1}; // active mode
status = HAL_I2C_Mem_Write(&I2CHandle1, MMA_ADDR, MMA_REG_MODE, I2C_MEMADD_SIZE_8BIT, data, 1, 200);
//printf(" got %d\n", status);
// wait for MMA to become active
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment