Shared cross-core layout for the MAX78000 dual-core IMU example.
More...
#include <stdint.h>
#include "mxc_device.h"
#include "sema_regs.h"
Shared cross-core layout for the MAX78000 dual-core IMU example.
- Author
- Victor Pascu (victo.nosp@m.r.pa.nosp@m.scu@a.nosp@m.nalo.nosp@m.g.com)
Copyright 2026(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
◆ IMU_ADIS_CS_GPIO
| #define IMU_ADIS_CS_GPIO 11u |
◆ IMU_ADIS_PROD_ID
| #define IMU_ADIS_PROD_ID 16577u |
Expected ADIS16577 product id (decimal, as reported by register 0x72).
◆ IMU_ADXL_CS_GPIO
| #define IMU_ADXL_CS_GPIO 19u |
◆ IMU_DCNTR_STUCK_SAMPLES
| #define IMU_DCNTR_STUCK_SAMPLES 400u |
◆ IMU_FAULT_MAGIC
| #define IMU_FAULT_MAGIC 0xDEADFA17UL |
Written to imu_shared_t.fault_magic by the RISC-V trap handler so the ARM can distinguish a genuine fault report from zeroed/garbage memory before trusting the fault_cause / fault_epc fields.
◆ IMU_RV_LOOP_PERIOD_US
| #define IMU_RV_LOOP_PERIOD_US 500u |
◆ IMU_SHARED_ADDR
| #define IMU_SHARED_ADDR 0x20011000UL |
Fixed SRAM2 address of the shared table, reached by both cores through an identical fixed-address pointer (no linker section maps here). It sits in the gap in the RISC-V's SRAM2 map: above the RV .data/.bss (which end at ~0x20010480) and well below the RV stack (limit 0x2001B000). It must NOT be in SRAM3: when the RISC-V runs in place from flash, SRAM3 is inaccessible to it as data. This is the same address the doorbell example uses.
NOTE: this address lies inside the RV newlib heap range (__HeapBase..__StackLimit). That is safe only because the coprocessor's heap use is tiny and one-time – adis_init allocates its adis_dev + SPI descriptor (< 1 KB), ending well below 0x20011000. If the RV firmware ever allocates more than ~2 KB, move this table or raise __HeapBase in the RV linker script.
◆ IMU_SHARED_MAGIC
| #define IMU_SHARED_MAGIC 0xAD152016UL |
Validity marker written by the RISC-V once the shared table is initialized.
◆ IMU_SPI_MISO_GPIO
| #define IMU_SPI_MISO_GPIO 6u |
◆ IMU_SPI_MOSI_GPIO
| #define IMU_SPI_MOSI_GPIO 5u |
◆ IMU_SPI_SCLK_GPIO
| #define IMU_SPI_SCLK_GPIO 7u |
◆ IMU_SPI_SEMA
MXC_SEMA->semaphores[] index used as the SPI bus lock. Distinct from the doorbell path (irq0/irq1 + mail0/mail1), which does not touch the semaphore array, so there is no collision.
◆ IMU_STAGE_ADIS_DIAG
| #define IMU_STAGE_ADIS_DIAG 6u /* reading ADIS diagnostic status */ |
◆ IMU_STAGE_ADIS_RESET_CMD
| #define IMU_STAGE_ADIS_RESET_CMD 3u /* ADIS software reset SPI write */ |
◆ IMU_STAGE_ADIS_RESET_WAIT
| #define IMU_STAGE_ADIS_RESET_WAIT 4u /* ADIS software reset delay */ |
◆ IMU_STAGE_ADIS_SPI
◆ IMU_STAGE_ADIS_SYNC
| #define IMU_STAGE_ADIS_SYNC 7u /* writing ADIS sync mode */ |
◆ IMU_STAGE_ADIS_TEST
| #define IMU_STAGE_ADIS_TEST 5u /* ADIS self-test command/delay */ |
◆ IMU_STAGE_LOOP
| #define IMU_STAGE_LOOP 9u /* steady-state read loop */ |
◆ IMU_STAGE_LOOP_READ_ERROR
| #define IMU_STAGE_LOOP_READ_ERROR 30u /* steady-state ADIS read failed */ |
◆ IMU_STAGE_READ_ID
| #define IMU_STAGE_READ_ID 8u /* reading PROD_ID/DIAG */ |
◆ IMU_STAGE_SPI_INIT
◆ IMU_STAGE_START
| #define IMU_STAGE_START 0u |
Bring-up stage tag written to imu_shared_t.stage before each risky step, so a fault or hang can be localized to the last stage the RISC-V entered even if it never returns. Distinct from state (which only advances on success).
◆ IMU_STATE_BOOT
| #define IMU_STATE_BOOT 0u /* RISC-V started, nothing done yet */ |
RISC-V lifecycle milestones, published (monotonically) in imu_shared_t.state so the ARM can gate its own bring-up on the RISC-V's progress. These are ordered so the ARM can wait with state < IMU_STATE_x. Whether the ADIS is the right part is reported separately via imu_shared_t.prod_id (compared by the ARM), not encoded in the state, to avoid racing the IMU_DETECTED -> RUNNING transition.
◆ IMU_STATE_ERROR
| #define IMU_STATE_ERROR 0x80u /* fatal init failure (SPI/ADIS, ret in fault_info) */ |
◆ IMU_STATE_FAULT
| #define IMU_STATE_FAULT 0x81u /* CPU trap/exception (see fault_* fields) */ |
◆ IMU_STATE_IMU_DETECTED
| #define IMU_STATE_IMU_DETECTED 2u /* ADIS PROD_ID/DIAG read into the table */ |
◆ IMU_STATE_RUNNING
| #define IMU_STATE_RUNNING 3u /* integration loop live */ |
◆ IMU_STATE_SPI_OK
| #define IMU_STATE_SPI_OK 1u /* SPI peripheral configured */ |
◆ IMU_TRACE_ADIS_LOCK
| #define IMU_TRACE_ADIS_LOCK 0x0111 |
◆ IMU_TRACE_ADIS_UNLOCK
| #define IMU_TRACE_ADIS_UNLOCK 0x0112 |
◆ IMU_TRACE_FAULT
| #define IMU_TRACE_FAULT 0xF000 |
◆ IMU_TRACE_LOOP_PUBLISH
| #define IMU_TRACE_LOOP_PUBLISH 0x0210 |
◆ IMU_TRACE_LOOP_READ
| #define IMU_TRACE_LOOP_READ 0x0201 |
◆ IMU_TRACE_MAIN_ENTER
| #define IMU_TRACE_MAIN_ENTER 0x0001 |
◆ IMU_TRACE_SHARED_INIT
| #define IMU_TRACE_SHARED_INIT 0x0010 |
◆ IMU_TRACE_SPI_LOCK
| #define IMU_TRACE_SPI_LOCK 0x0101 |
◆ IMU_TRACE_SPI_UNLOCK
| #define IMU_TRACE_SPI_UNLOCK 0x0102 |