 |
iSensor-SPI-Buffer
1.15
Firmware for the iSensor-SPI-Buffer board to enable full throughput buffered data capture on Analog Devices IMUs
|
Go to the documentation of this file.
19 #define REG_PER_PAGE 64
22 #define NUM_REG_PAGES 4
28 #define OUTPUT_PAGE 252
31 #define BUF_CONFIG_PAGE 253
34 #define BUF_CONFIG_REG 0x41
35 #define BUF_LEN_REG 0x42
36 #define BTN_CONFIG_REG 0x43
37 #define DIO_INPUT_CONFIG_REG 0x44
38 #define DIO_OUTPUT_CONFIG_REG 0x45
39 #define WATERMARK_INT_CONFIG_REG 0x46
40 #define ERROR_INT_CONFIG_REG 0x47
41 #define IMU_SPI_CONFIG_REG 0x48
42 #define USER_SPI_CONFIG_REG 0x49
43 #define CLI_CONFIG_REG 0x4A
44 #define USER_COMMAND_REG 0x4B
45 #define SYNC_FREQ_REG 0x4C
47 #define USER_SCR_0_REG 0x5A
48 #define USER_SCR_3_REG 0x5D
49 #define UTC_TIMESTAMP_LWR_REG 0x5E
50 #define UTC_TIMESTAMP_UPR_REG 0x5F
55 #define STATUS_0_REG 0x60
56 #define FAULT_CODE_REG 0x61
57 #define BUF_CNT_0_REG 0x62
58 #define BUF_MAX_CNT_REG 0x63
61 #define TIMESTAMP_LWR_REG 0x65
62 #define TIMESTAMP_UPR_REG 0x66
67 #define SCR_LINE_REG 0x72
68 #define SCR_ERROR_REG 0x73
71 #define ENDURANCE_REG 0x76
72 #define FW_REV_REG 0x77
73 #define FW_DAY_MONTH_REG 0x78
74 #define FW_YEAR_REG 0x79
75 #define DEV_SN_REG 0x7A
78 #define BUF_WRITE_PAGE 254
80 #define BUF_WRITE_0_REG 0x89
81 #define FLASH_SIG_DRV_REG 0xBE
82 #define FLASH_SIG_REG 0xBF
85 #define BUF_READ_PAGE 255
87 #define STATUS_1_REG 0xC1
88 #define BUF_CNT_1_REG 0xC2
89 #define BUF_RETRIEVE_REG 0xC3
90 #define BUF_UTC_TIMESTAMP_REG 0xC4
91 #define BUF_US_TIMESTAMP_REG 0xC6
92 #define BUF_SIG_REG 0xC8
93 #define BUF_DATA_0_REG 0xC9
96 #define FW_REV_DEFAULT 0x0115
97 #define BUF_CONFIG_DEFAULT 0x0000
98 #define BUF_LEN_DEFAULT 0x0014
99 #define DIO_INPUT_CONFIG_DEFAULT 0x0011
100 #define DIO_OUTPUT_CONFIG_DEFAULT 0x8421
101 #define WATER_INT_CONFIG_DEFAULT 0x0020
102 #define ERROR_INT_CONFIG_DEFAULT 0xFFFC
103 #define IMU_SPI_CONFIG_DEFAULT 0x100F
104 #define USER_SPI_CONFIG_DEFAULT 0x0007
105 #define CLI_CONFIG_DEFAULT 0x2000
106 #define BTN_CONFIG_DEFAULT 0x8000
107 #define SYNC_FREQ_DEFAULT 2000
108 #define FLASH_SIG_DEFAULT 0x9D2A
111 #define DIO_OUTPUT_CONFIG_FLAG (1 << 0)
112 #define IMU_SPI_CONFIG_FLAG (1 << 1)
113 #define USER_SPI_CONFIG_FLAG (1 << 2)
114 #define USER_COMMAND_FLAG (1 << 3)
115 #define DIO_INPUT_CONFIG_FLAG (1 << 4)
116 #define ENABLE_CAPTURE_FLAG (1 << 5)
117 #define DEQUEUE_BUF_FLAG (1 << 6)
118 #define DISABLE_CAPTURE_FLAG (1 << 7)
121 #define CMD_CLEAR_BUFFER (1 << 0)
122 #define CMD_CLEAR_FAULT (1 << 1)
123 #define CMD_FACTORY_RESET (1 << 2)
124 #define CMD_FLASH_UPDATE (1 << 3)
125 #define CMD_PPS_ENABLE (1 << 4)
126 #define CMD_PPS_DISABLE (1 << 5)
127 #define CMD_START_SCRIPT (1 << 6)
128 #define CMD_STOP_SCRIPT (1 << 7)
129 #define CMD_WATERMARK_SET (1 << 8)
130 #define CMD_SYNC_GEN (1 << 9)
131 #define CMD_BOOTLOADER (1 << 13)
132 #define CMD_IMU_RESET (1 << 14)
133 #define CMD_SOFTWARE_RESET (1 << 15)
136 #define SPI_CONF_CPHA (1 << 0)
137 #define SPI_CONF_CPOL (1 << 1)
138 #define SPI_CONF_MSB_FIRST (1 << 2)
139 #define SPI_CONF_MASK (SPI_CONF_CPHA|SPI_CONF_CPOL|SPI_CONF_MSB_FIRST)
142 #define STATUS_BUF_WATERMARK (1 << 0)
143 #define STATUS_BUF_FULL (1 << 1)
144 #define STATUS_SPI_ERROR (1 << 2)
145 #define STATUS_SPI_OVERFLOW (1 << 3)
146 #define STATUS_OVERRUN (1 << 4)
147 #define STATUS_DMA_ERROR (1 << 5)
148 #define STATUS_PPS_UNLOCK (1 << 6)
149 #define STATUS_TEMP_WARNING (1 << 7)
150 #define STATUS_SCR_ERROR (1 << 10)
151 #define STATUS_SCR_RUNNING (1 << 11)
152 #define STATUS_FLASH_ERROR (1 << 12)
153 #define STATUS_FLASH_UPDATE (1 << 13)
154 #define STATUS_FAULT (1 << 14)
155 #define STATUS_WATCHDOG (1 << 15)
158 #define STATUS_CLEAR_MASK (STATUS_FLASH_ERROR|STATUS_FAULT|STATUS_FLASH_UPDATE|STATUS_WATCHDOG|STATUS_SCR_RUNNING)
161 #define BUF_CFG_REPLACE_OLDEST (1 << 0)
162 #define BUF_CFG_IMU_BURST (1 << 1)
163 #define BUF_CFG_BUF_BURST (1 << 2)
164 #define BUF_CFG_MASK (BUF_CFG_REPLACE_OLDEST|BUF_CFG_IMU_BURST|BUF_CFG_BUF_BURST)
167 #define WATERMARK_PULSE_MASK (1 << 15)
170 #define USB_STREAM_BITP 0
171 #define SD_STREAM_BITP 1
172 #define USB_ECHO_BITP 2
173 #define SD_AUTORUN_BITP 3
174 #define CLI_DELIM_BITP 8
176 #define USB_STREAM_BITM (1 << USB_STREAM_BITP)
177 #define SD_STREAM_BITM (1 << SD_STREAM_BITP)
178 #define USB_ECHO_BITM (1 << USB_ECHO_BITP)
179 #define SD_AUTORUN_BITM (1 << SD_AUTORUN_BITP)
180 #define CLI_DELIM_BITM (0xFF << CLI_DELIM_BITP)
182 #define CLI_CONFIG_CLEAR_MASK 0xFF0C
186 extern volatile uint16_t g_regs[
NUM_REG_PAGES * REG_PER_PAGE];
196 uint16_t
Reg_Write(uint8_t regAddr, uint8_t regValue);
#define BUF_READ_PAGE
Definition: reg.h:85
void DIO_Start_Sync_Gen()
Generates a clock on DIO2_Slave based on frequency in SYNC_FREQ.
Definition: dio.c:60
volatile uint32_t g_update_flags
Definition: reg.c:32
Header file for iSensor-SPI-Buffer register interfacing module.
#define BUF_WRITE_PAGE
Definition: reg.h:78
void IMU_Reset()
Hardware reset connected IMU.
Definition: imu.c:82
#define OUTPUT_PAGE
Definition: reg.h:28
void User_Interrupt_Update_Output_Pins(uint32_t watermark, uint32_t overflow, uint32_t error)
Updates the output pins based on given interrupt/overflow status.
Definition: user_interrupt.c:105
void User_SPI_Burst_Setup()
Configures SPI for a burst buffer read.
Definition: user_spi.c:88
Header file for iSensor-SPI-Buffer runtime firmware upgrade module.
void Reg_Buf_Dequeue_To_Outputs()
Dequeues an entry from the buffer and loads it to the primary output registers.
Definition: reg.c:158
Header file for iSensor-SPI-Buffer user SPI (slave SPI) module.
Header file for iSensor-SPI-Buffer SD card interfacing and script execution module.
Header file for iSensor-SPI-Buffer DIO interfacing module.
void DFU_Prepare_Reboot()
Set DFU reboot flag in RAM and reset system.
Definition: dfu.c:54
volatile uint32_t g_update_flags
Definition: reg.c:32
void Flash_Log_Fault(uint32_t faultCode)
Stores an error code to flash memory.
Definition: flash.c:173
volatile uint16_t g_regs[NUM_REG_PAGES *REG_PER_PAGE] __attribute__((aligned(32)))
uint16_t Reg_Read(uint8_t regAddr)
Process a register read request (from master)
Definition: reg.c:206
Implementation for iSensor-SPI-Buffer IMU interfacing module.
void SD_Card_Stop_Script()
Stop a running SD card script.
Definition: sd_card.c:201
#define NUM_REG_PAGES
Definition: reg.h:22
static uint16_t ProcessRegWrite(uint8_t regAddr, uint8_t regValue)
Process a write to the iSensor-SPI-Buffer registers.
Definition: reg.c:603
uint16_t IMU_Read_Register(uint8_t RegAddr)
Reads 16 bit value from the IMU.
Definition: imu.c:235
#define BUF_CONFIG_PAGE
Definition: reg.h:31
Header file for iSensor-SPI-Buffer timer module.
void Flash_Check_Logged_Fault()
Checks for error codes which may have been logged to flash, and sets the status register bit.
Definition: flash.c:142
void Timer_Disable_PPS()
Disable PPS timer functionality.
Definition: timer.c:155
void Flash_Update()
Flash update command handler.
Definition: flash.c:29
void Data_Capture_Disable()
disables autonomous data capture by disabling DR ISR.
Definition: data_capture.c:53
void Timer_Enable_PPS()
Enable PPS input for time stamp synchronization (improved long term stability over 20ppm crystal).
Definition: timer.c:144
volatile uint16_t * g_CurrentBufEntry
Definition: reg.c:35
#define USER_SPI_CS_INT_MSK
Definition: isr.h:18
static void GetBuildDate()
Populates the firmware date registers automatically.
Definition: reg.c:518
bool Reg_Is_Burst_Read(uint8_t addr)
Check if the requested read is a start of a burst.
Definition: reg.c:105
Header file for iSensor-SPI-Buffer USB command line register interface.
uint16_t IMU_Write_Register(uint8_t RegAddr, uint8_t RegValue)
Writes an 8 bit value to the IMU.
Definition: imu.c:273
uint32_t g_bufLastRegIndex
Definition: buffer.c:16
void Reg_Init()
Initialize the register module by loading all saves values from flash.
Definition: reg.c:125
void User_SPI_Update_Config(uint32_t CheckUnlock)
Updates the slave SPI (SPI2) config based on the USER_SPI_CONFIG register.
Definition: user_spi.c:163
void Reg_Update_Identifiers()
Load SN and date code registers to SRAM.
Definition: reg.c:139
#define ERROR_NONE
Definition: flash.h:36
Header file for iSensor-SPI-Buffer buffer data structure module.
void User_SPI_Reset(bool register_mode)
Reset user SPI port.
Definition: user_spi.c:40
void DIO_Update_Output_Config()
Validates DIO_OUTPUT_CONFIG settings and applies to GPIO.
Definition: dio.c:291
static void GetSN()
Populates the six SN registers automatically.
Definition: reg.c:499
Header file for iSensor-SPI-Buffer user interrupt (data ready) config and generation functions.
void Flash_Load_Registers()
Load register values from flash memory to SRAM.
Definition: flash.c:96
Header file for iSensor-SPI-Buffer main.
void Reg_Process_Command()
Processes a command register write. This function is called from main loop.
Definition: reg.c:322
volatile uint16_t * g_CurrentBufEntry
Definition: reg.c:35
Header file for iSensor-SPI-Buffer autonomous IMU data acquisition module.
void IMU_Update_SPI_Config()
Processes any changes to IMU_SPI_CONFIG reg and applies.
Definition: imu.c:294
command
Definition: script.h:20
volatile uint32_t g_userburstRunning
Definition: user_spi.c:17
void Reg_Button_Handler()
Handler for when the user button is pressed.
Definition: reg.c:478
void USB_Watermark_Autoset()
Helper function to set the watermark interrupt level for optimal USB streams.
Definition: usb.c:201
void DIO_Update_Input_Config()
Validates and updates the data ready input configuration based on DIO_INPUT_CONFIG.
Definition: dio.c:186
uint8_t * Buffer_Take_Element()
Take a single element from the buffer.
Definition: buffer.c:81
void Buffer_Reset()
Clears the buffer data structure.
Definition: buffer.c:186
static volatile uint32_t selected_page
Definition: reg.c:94
void Reg_Factory_Reset()
Load factory default values for all registers, and applies any settings changes.
Definition: reg.c:403
void SD_Card_Start_Script()
Start script run.
Definition: sd_card.c:139
uint16_t Reg_Write(uint8_t regAddr, uint8_t regValue)
Process a register write request (from master)
Definition: reg.c:278
Header file for the interrupt service routine module.
uint32_t Timer_Get_Microsecond_Timestamp()
Gets the current 32-bit value from the IMU sample timestamp timer.
Definition: timer.c:103
Header file for iSensor-SPI-Buffer flash memory interfacing functions.