![]() |
iSensor-SPI-Buffer
1.15
Firmware for the iSensor-SPI-Buffer board to enable full throughput buffered data capture on Analog Devices IMUs
|
iSensor-SPI-Buffer register interfacing module. Called by user SPI and USB CLI More...
#include "usb.h"
#include "reg.h"
#include "imu.h"
#include "sd_card.h"
#include "buffer.h"
#include "flash.h"
#include "data_capture.h"
#include "user_spi.h"
#include "dfu.h"
#include "dio.h"
#include "timer.h"
#include "user_interrupt.h"
#include "isr.h"
Functions | |
static uint16_t | ProcessRegWrite (uint8_t regAddr, uint8_t regValue) |
Process a write to the iSensor-SPI-Buffer registers. More... | |
static void | GetSN () |
Populates the six SN registers automatically. More... | |
static void | GetBuildDate () |
Populates the firmware date registers automatically. More... | |
volatile uint16_t g_regs[NUM_REG_PAGES *REG_PER_PAGE] | __attribute__ ((aligned(32))) |
bool | Reg_Is_Burst_Read (uint8_t addr) |
Check if the requested read is a start of a burst. More... | |
void | Reg_Init () |
Initialize the register module by loading all saves values from flash. More... | |
void | Reg_Update_Identifiers () |
Load SN and date code registers to SRAM. More... | |
void | Reg_Buf_Dequeue_To_Outputs () |
Dequeues an entry from the buffer and loads it to the primary output registers. More... | |
uint16_t | Reg_Read (uint8_t regAddr) |
Process a register read request (from master) More... | |
uint16_t | Reg_Write (uint8_t regAddr, uint8_t regValue) |
Process a register write request (from master) More... | |
void | Reg_Process_Command () |
Processes a command register write. This function is called from main loop. More... | |
void | Reg_Factory_Reset () |
Load factory default values for all registers, and applies any settings changes. More... | |
void | Reg_Button_Handler () |
Handler for when the user button is pressed. More... | |
Variables | |
volatile uint32_t | g_update_flags = 0 |
volatile uint16_t * | g_CurrentBufEntry |
static volatile uint32_t | selected_page = BUF_CONFIG_PAGE |
iSensor-SPI-Buffer register interfacing module. Called by user SPI and USB CLI
Copyright (c) Analog Devices Inc, 2020 All Rights Reserved.
volatile uint16_t g_regs [NUM_REG_PAGES * REG_PER_PAGE] __attribute__ | ( | (aligned(32)) | ) |
iSensor-SPI-Buffer global register array (read-able via SPI). Global scope
|
static |
Populates the firmware date registers automatically.
Registers are populated by parsing the DATE macro result, which is set at compile time
|
static |
Populates the six SN registers automatically.
The SN registers are populated from the 96-bit unique ID (UID)
|
static |
Process a write to the iSensor-SPI-Buffer registers.
This function handles filtering for read-only registers. It also handles setting the deferred processing flags as needed for any config/command register writes. This are processed on the next pass of the main loop.
void Reg_Buf_Dequeue_To_Outputs | ( | ) |
Dequeues an entry from the buffer and loads it to the primary output registers.
This function is called from the main loop to preserve SPI responsiveness while a buffer entry is being dequeued into the output registers. This allows a user to read the buffer contents while the values are being moved (if they start reading at buffer entry 0). After moving all values to the correct location in the output register array, the function sets up the burst read DMA (if enabled in user SPI config).
void Reg_Button_Handler | ( | ) |
Handler for when the user button is pressed.
This function executes commands based on the button configuration set in BTN_CONFIG. This function can be called from an interrupt context (EXTI rising edge interrupt for button). The EXTI pending interrupt register for the button line should be cleared before and after executing this function to add some implicit debouncing (interrupt won't trigger, then immediately trigger again).
void Reg_Factory_Reset | ( | ) |
Load factory default values for all registers, and applies any settings changes.
This is accomplished in "lazy" manner via a preprocessor define for each register default value (defaults are stored in program memory, storage is managed by compiler). This function only changes values in SRAM, does not change flash contents (registers will reset on next re-boot).
void Reg_Init | ( | ) |
Initialize the register module by loading all saves values from flash.
Most register values are loaded directly from the flash register array. Some values (SN and FW date) are encoded into the code, and must be loaded separately using Update_Identifiers()
bool Reg_Is_Burst_Read | ( | uint8_t | addr | ) |
Check if the requested read is a start of a burst.
For a burst to start, the buffer read page must be selected, the address must be BUF_RETRIEVE, and buffer burst mode must be enabled.
void Reg_Process_Command | ( | ) |
Processes a command register write. This function is called from main loop.
Only one command can be executed per write to the USER_COMMAND register. Command execution priority is determined by the order in which the command flags are checked.
uint16_t Reg_Read | ( | uint8_t | regAddr | ) |
Process a register read request (from master)
regAddr | The byte address of the register to read |
For selected pages not addressed by iSensor-SPI-Buffer, the read is passed through to the connected IMU, using the spi_passthrough module. If the selected page is [253 - 255] this read request is processed directly.
void Reg_Update_Identifiers | ( | ) |
Load SN and date code registers to SRAM.
These register values are encoded into the .text section of flash
uint16_t Reg_Write | ( | uint8_t | regAddr, |
uint8_t | regValue | ||
) |
Process a register write request (from master)
regAddr | The address of the register to write to |
regValue | The value to write to the register |
For selected pages not addressed by iSensor-SPI-Buffer, the write is passed through to the connected IMU, using the spi_passthrough module. If the selected page is [252 - 255] this write request is processed directly. The firmware echoes back the processed write value so that the master can verify the write contents on the next SPI transaction.
volatile uint16_t* g_CurrentBufEntry |
Pointer to buffer entry. Will be 0 if no buffer entry "loaded" to output registers
volatile uint32_t g_update_flags = 0 |
Register update flags for main loop processing. Global scope
|
static |
Selected page. Starts on 253 (config page)