Commit 1a3dfad3 authored by Rahix's avatar Rahix

fix(bhi160): Fix interrupt behavior during initialization

As discussed in issue #133, the BHI160 changes its
interrupt behavior during initialization.  In commit 2f56ff36
("fix(bhi160): Call bhy_mapping_matrix_set twice for the first time")
a quick workaround for this issue was added.  Replace this hack with
a proper fix by reconfiguring the interrupt on the host side according
to the specification.

(Finally) fixes #133.

Fixes: 2f56ff36 ("fix(bhi160): Call bhy_mapping_matrix_set twice for the first time")
Link: #133 (comment 5894)Signed-off-by: Rahix's avatarRahix <>
parent 713a76b2
Pipeline #4403 passed with stages
in 1 minute and 4 seconds
......@@ -405,12 +405,20 @@ void vBhi160Task(void *pvParameters)
memset(bhi160_streams, 0x00, sizeof(bhi160_streams));
/* Install interrupt callback */
* The BHI160, coming out of power-on-reset will hold its interrupt line
* high until a firmware image is loaded. Once that firmware is loaded
* and running, the interrupt line is deasserted and from then on,
* interrupts are signaled using a rising edge.
* So, initially we need to configure the IRQ for a falling edge, load
* the firmware and then reconfigure for a rising edge.
&bhi160_interrupt_pin, bhi160_interrupt_callback, NULL
GPIO_IntConfig(&bhi160_interrupt_pin, GPIO_INT_EDGE, GPIO_INT_RISING);
GPIO_IntConfig(&bhi160_interrupt_pin, GPIO_INT_EDGE, GPIO_INT_FALLING);
(IRQn_Type)MXC_GPIO_GET_IRQ(bhi160_interrupt_pin.port), 2
......@@ -424,17 +432,18 @@ void vBhi160Task(void *pvParameters)
/* Wait for first interrupt */
/* Wait for first interrupt, a falling edge */
ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(100));
* The firmware is now loaded; as stated above, we now need to
* reconfigure the IRQ for a rising edge.
GPIO_IntConfig(&bhi160_interrupt_pin, GPIO_INT_EDGE, GPIO_INT_RISING);
/* Remap axes to match card10 layout */
/* Due to a known issue (#133) the first call to
* bhy_mapping_matrix_set might fail. */
PHYSICAL_SENSOR_INDEX_ACC, bhi160_mapping_matrix
PHYSICAL_SENSOR_INDEX_ACC, bhi160_mapping_matrix
Markdown is supported
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