Hello adrianwongCPI,
In your application code, there was no configuration code for BMA400 auto wakeup. You could refer the following BMA400 auto wakeup code, it run on STM32. Auto wakeup interrupt was mapped to INT1.
main()
{
...//Initialize BMA400
Open_BMA400_Auto_Wakeup(dev); Config_BMA400_INT1(dev); Enable_MCU_INT1_Pin();
bma400_set_power_mode(BMA400_MODE_LOW_POWER, dev);
...
}
int8_t Open_BMA400_Auto_Wakeup(struct bma400_dev *dev) { int16_t rslt = BMA400_OK; struct bma400_device_conf dev_conf; struct bma400_int_enable int_en;
dev_conf.type = BMA400_AUTOWAKEUP_INT; dev_conf.param.wakeup.wakeup_ref_update = BMA400_UPDATE_EVERY_TIME; dev_conf.param.wakeup.sample_count = BMA400_SAMPLE_COUNT_1; dev_conf.param.wakeup.wakeup_axes_en = BMA400_AXIS_XYZ_EN; dev_conf.param.wakeup.int_wkup_threshold = 4;//63mg----2g range dev_conf.param.wakeup.int_chan = BMA400_INT_CHANNEL_1; rslt = bma400_set_device_conf(&dev_conf, 1, dev); if(rslt != BMA400_OK) { PDEBUG("bma400_set_device_conf set BMA400_AUTOWAKEUP_INT failed\r\n"); }
int_en.type = BMA400_AUTO_WAKEUP_EN; int_en.conf = BMA400_ENABLE;
rslt = bma400_enable_interrupt(&int_en, 1, dev); if(rslt != BMA400_OK) { PDEBUG("bma400_enable_interrupt set BMA400_AUTO_WAKEUP_EN failed\r\n"); }
return rslt; }
int8_t Config_BMA400_INT1(struct bma400_dev *dev) { int16_t rslt = BMA400_OK; struct bma400_device_conf dev_conf;
dev_conf.type = BMA400_INT_PIN_CONF; dev_conf.param.int_conf.int_chan = BMA400_INT_CHANNEL_1; dev_conf.param.int_conf.pin_conf = BMA400_INT_PUSH_PULL_ACTIVE_1;
rslt = bma400_set_device_conf(&dev_conf, 1, dev); if(rslt != BMA400_OK) { PDEBUG("Config_BMA400_INT1 bma400_set_device_conf set BMA400_INT_PIN_CONF failed\r\n"); }
return rslt; }
void Enable_MCU_INT1_Pin(void) { GPIO_InitTypeDef GPIO_InitStruct = {0};
__HAL_RCC_GPIOA_CLK_ENABLE(); /*Configure GPIO pin : INT1_Pin */ GPIO_InitStruct.Pin = INT1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(INT1_GPIO_Port, &GPIO_InitStruct);
/* EXTI interrupt init*/ HAL_NVIC_SetPriority(EXTI15_10_IRQn, 5, 0); HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); }
... View more