drivers/sensors/bmi270: Enable to select config memory
Allow to transfer the BMI270 configuration data directly, and provide an option to use the heap memory if it cannot transfer directly.
This commit is contained in:
parent
a015aa4fca
commit
60364d7c72
@ -232,6 +232,14 @@ config SENSORS_BMI270_SPI
|
||||
|
||||
endchoice
|
||||
|
||||
config SENSORS_BMI270_LOAD_FROM_HEAP
|
||||
bool "BMI270 config loading from heap memory"
|
||||
default n
|
||||
---help---
|
||||
Enable support to load the configuration data from heap memory.
|
||||
Some chips can not do DMA transfer from FLASH and therefore
|
||||
it is necessary to transfer the configuration file to RAM.
|
||||
|
||||
endif
|
||||
|
||||
config SENSORS_BMP180
|
||||
|
@ -1258,9 +1258,11 @@ static int bmi270_init_seq(FAR struct bmi270_dev_s *priv)
|
||||
|
||||
bmi270_putreg8(priv, BMI270_INIT_CTRL, 0);
|
||||
|
||||
#ifdef CONFIG_SENSORS_BMI270_LOAD_FROM_HEAP
|
||||
|
||||
/* Copy configuration to RAM */
|
||||
|
||||
tmp = malloc(sizeof(g_bmi270_config_file));
|
||||
tmp = kmm_malloc(sizeof(g_bmi270_config_file));
|
||||
if (tmp == NULL)
|
||||
{
|
||||
snerr("Failed to allocate memory for configuration file\n");
|
||||
@ -1269,12 +1271,24 @@ static int bmi270_init_seq(FAR struct bmi270_dev_s *priv)
|
||||
|
||||
memcpy(tmp, g_bmi270_config_file, sizeof(g_bmi270_config_file));
|
||||
|
||||
#else
|
||||
|
||||
/* Transfer directly from const data memory */
|
||||
|
||||
tmp = (FAR uint8_t *)&g_bmi270_config_file;
|
||||
|
||||
#endif
|
||||
|
||||
/* Load configuration - start with byte 0 */
|
||||
|
||||
bmi270_putregs(priv, BMI270_INIT_DATA,
|
||||
tmp,
|
||||
sizeof(g_bmi270_config_file));
|
||||
|
||||
#ifdef CONFIG_SENSORS_BMI270_LOAD_FROM_HEAP
|
||||
kmm_free(tmp);
|
||||
#endif
|
||||
|
||||
/* Complete config load INIT_CTRL=0x01 */
|
||||
|
||||
bmi270_putreg8(priv, BMI270_INIT_CTRL, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user