diff options
author | Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> | 2020-08-25 10:29:54 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-09-27 08:16:05 +0000 |
commit | d916b6002b7b5cf508208946fa871e7f2ecf1681 (patch) | |
tree | d93cc18ee2e4c2ff781c6f9517f203ebca32b10f | |
parent | 93a0e931610955f48e4ecbf51511f50af0e6be10 (diff) | |
download | chrome-ec-d916b6002b7b5cf508208946fa871e7f2ecf1681.tar.gz |
board: nucleo-f411re: create icm426xx development platform
Use icm426xx chip instead of bmi.
Add SPI slave + interrupt to interface with AP (SPI1 + PA1).
Add SPI master interface using SPI2 for the sensor (optional).
Fix board init hook priority to be run after motionsense init.
Increase task stack sizes.
Conflicts:
board/nucleo-f411re/board.c: Just change i2c address,
SPI and frequency support not in this branch.
board/nucleo-f411re/board.h: CONFIG_ACCEL_FIFO_SIZE
does not exist.
BUG=chromium:1117541, b:192817920
BRANCH=rammus
TEST=ectool && tast run hardware.SensorRing
Cq-Depend: chromium:3099546, chromium:3121867
Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Change-Id: I860b669fd3d2ee196a66e5c80cdc0835b4e5bc73
(cherry picked from commit a4b8af57d15111440893759acd5d90bfc21d8c58)
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3121866
Reviewed-by: JuHyun Kim <jkim@invensense.com>
Reviewed-by: Zhuohao Lee <zhuohao@chromium.org>
Commit-Queue: JuHyun Kim <jkim@invensense.com>
Commit-Queue: Zhuohao Lee <zhuohao@chromium.org>
Auto-Submit: JuHyun Kim <jkim@invensense.com>
Tested-by: JuHyun Kim <jkim@invensense.com>
-rw-r--r-- | board/nucleo-f411re/board.c | 27 | ||||
-rw-r--r-- | board/nucleo-f411re/board.h | 12 | ||||
-rw-r--r-- | board/nucleo-f411re/ec.tasklist | 6 | ||||
-rw-r--r-- | board/nucleo-f411re/gpio.inc | 3 |
4 files changed, 30 insertions, 18 deletions
diff --git a/board/nucleo-f411re/board.c b/board/nucleo-f411re/board.c index 0f7c57f1e3..d0a84638fd 100644 --- a/board/nucleo-f411re/board.c +++ b/board/nucleo-f411re/board.c @@ -8,7 +8,8 @@ #include "adc_chip.h" #include "common.h" #include "console.h" -#include "driver/accelgyro_bmi160.h" +#include "driver/accelgyro_icm_common.h" +#include "driver/accelgyro_icm426xx.h" #include "ec_version.h" #include "gpio.h" #include "hooks.h" @@ -31,6 +32,7 @@ void user_button_evt(enum gpio_signal signal) static void board_init(void) { gpio_enable_interrupt(GPIO_USER_BUTTON_L); + gpio_enable_interrupt(GPIO_ICM426XX_INT1_L); /* No power control yet */ /* Go to S3 state */ @@ -39,7 +41,7 @@ static void board_init(void) /* Go to S0 state */ hook_notify(HOOK_CHIPSET_RESUME); } -DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_LAST); /* ADC channels */ const struct adc_t adc_channels[] = { @@ -53,29 +55,28 @@ BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); /* I2C ports */ const struct i2c_port_t i2c_ports[] = { - {"master", I2C_PORT_MASTER, 100, + {"master", I2C_PORT_MASTER, 400, GPIO_MASTER_I2C_SCL, GPIO_MASTER_I2C_SDA}, }; - const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /* Base Sensor mutex */ static struct mutex g_base_mutex; -static struct bmi160_drv_data_t g_bmi160_data; +static struct icm_drv_data_t g_icm426xx_data; struct motion_sensor_t motion_sensors[] = { [BASE_ACCEL] = { .name = "Base Accel", .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_BMI160, + .chip = MOTIONSENSE_CHIP_ICM426XX, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_BASE, - .drv = &bmi160_drv, + .drv = &icm426xx_drv, .mutex = &g_base_mutex, - .drv_data = &g_bmi160_data, + .drv_data = &g_icm426xx_data, .port = I2C_PORT_ACCEL, - .addr = BMI160_ADDR0, + .addr = ICM426XX_ADDR0_FLAGS, .rot_standard_ref = NULL, .default_range = 2, /* g, enough for laptop. */ .config = { @@ -95,14 +96,14 @@ struct motion_sensor_t motion_sensors[] = { [BASE_GYRO] = { .name = "Base Gyro", .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_BMI160, + .chip = MOTIONSENSE_CHIP_ICM426XX, .type = MOTIONSENSE_TYPE_GYRO, .location = MOTIONSENSE_LOC_BASE, - .drv = &bmi160_drv, + .drv = &icm426xx_drv, .mutex = &g_base_mutex, - .drv_data = &g_bmi160_data, + .drv_data = &g_icm426xx_data, .port = I2C_PORT_ACCEL, - .addr = BMI160_ADDR0, + .addr = ICM426XX_ADDR0_FLAGS, .default_range = 1000, /* dps */ .rot_standard_ref = NULL, }, diff --git a/board/nucleo-f411re/board.h b/board/nucleo-f411re/board.h index 7ffa0b0f07..9c2380948b 100644 --- a/board/nucleo-f411re/board.h +++ b/board/nucleo-f411re/board.h @@ -34,7 +34,17 @@ #define CONFIG_UART_TX_REQ_CH STM32_REQ_USART2_TX #define CONFIG_UART_RX_REQ_CH STM32_REQ_USART2_RX -#define CONFIG_ACCELGYRO_BMI160 +#define CONFIG_ACCELGYRO_ICM426XX +#define CONFIG_ACCEL_INTERRUPTS +#define CONFIG_ACCELGYRO_ICM426XX_INT_EVENT TASK_EVENT_CUSTOM(4) + +#define CONFIG_MKBP_EVENT +/* Enable sensor fifo, must also define the _SIZE and _THRES */ +/* FIFO size is in power of 2. */ +#define CONFIG_ACCEL_FIFO 512 +/* Depends on how fast the AP boots and typical ODRs */ +#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3) + #define CONFIG_CMD_ACCELS #define CONFIG_CMD_ACCEL_INFO #define CONFIG_CMD_FLASH diff --git a/board/nucleo-f411re/ec.tasklist b/board/nucleo-f411re/ec.tasklist index 52135d97f8..847b82695c 100644 --- a/board/nucleo-f411re/ec.tasklist +++ b/board/nucleo-f411re/ec.tasklist @@ -17,7 +17,7 @@ * 's' is the stack size in bytes; must be a multiple of 8 */ #define CONFIG_TASK_LIST \ - TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_NOTEST(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \ - TASK_NOTEST(MOTIONSENSE, motion_sense_task, NULL, TASK_STACK_SIZE) \ + TASK_ALWAYS(HOOKS, hook_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_NOTEST(HOSTCMD, host_command_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_NOTEST(MOTIONSENSE, motion_sense_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE) diff --git a/board/nucleo-f411re/gpio.inc b/board/nucleo-f411re/gpio.inc index 83a9e51a08..3ad0a0ff69 100644 --- a/board/nucleo-f411re/gpio.inc +++ b/board/nucleo-f411re/gpio.inc @@ -7,11 +7,12 @@ /* Interrupts */ GPIO_INT(USER_BUTTON_L, PIN(C, 13), GPIO_INT_BOTH, user_button_evt) +GPIO_INT(ICM426XX_INT1_L, PIN(C, 10), GPIO_INT_FALLING, icm426xx_interrupt) /* User LED */ GPIO(USER_LED, PIN(A, 5), GPIO_OUT_LOW) +GPIO(EC_INT_L, PIN(A, 1), GPIO_OUT_HIGH) -GPIO(BMI160_INT2_L, PIN(C, 10), GPIO_OUT_LOW) /* * I2C pins should be configured as inputs until I2C module is * initialized. This will avoid driving the lines unintentionally. |