Multimodal-CV-FW-USB-ADS1298R/pca10056/blank/config/custom_board.h

92 lines
3.3 KiB
C

#ifndef CUSTOM_BOARD_H
#define CUSTOM_BOARD_H
#define NRF52840_BREAKOUT_BOARD 1
#define ADS1298 1
#if ADS1298
#define ADS1298_STATS 0
#endif
// Testing with nRF52840:
#if NRF52840_BREAKOUT_BOARD
#define ADS1298_DRDY_PIN 11
#define ADS1298_MISO_PIN 12
#define ADS1298_SCK_PIN 13
#define ADS1298_CS_PIN 14
// I don't think you're supposed to tie PWDN and reset together on ADS1298
#define ADS1298_PWDN_PIN 15
#define ADS1298_MOSI_PIN 16
// This is the packet format for data received over USB:
// [CN:4bit][TN:4bit][..data]
// COMMAND NIBBLES (4-bit definitions), CN_
#define CN_WRITE_IC_REGS 0x8 // 0b1000
#define CN_READ_IC_REGS 0x4 // 0b0100
#define CN_STREAM_CONTROL 0xB // 0b1011
#define CN_MISC_CONTROLS 0xE // 0b1110
// CTRL_REQUEST_BATTERY_LEVEL :: 0xBB
// TARGET NIBBLES (4-bit definitions)
#define TN_IC_ADS1298 0x1
#define TN_IC_EXT 0xF // Extended .. check the next byte!
#define TN_STREAM_START 0x2
#define TN_STREAM_STOP 0xF
#define TN_STREAM_REQUEST_BATTERY_LEVEL 0xB
// #define TN_STREAM_REQUEST_WHO_AM_I 0xD
#define TN_STREAM_REQUEST_PERIPHERAL_INFO 0xE
#define TN_MISC_THROUGHPUT_TEST 0xF
#define TN_MISC_RTT_REQUEST 0x1
// #################### RESPONSE CODES ####################
// #NOTE: 0x01 and 0x02 are reserved (for now) for legacy BLE reasons. I should deprecate and
// remove these.
#define CTRL_STAT_INFO_STRING 0x01
#define CTRL_STAT_INFO_BYTES_SENT 0x02
#define CTRL_STAT_INFO_PERIPHERALS 0x03
#define CTRL_STAT_INFO_HW_FW_VERSION 0x04
#define CTRL_STAT_INFO_WHO_AM_I 0x05
#define CTRL_STAT_INFO_BATTERY_LEVEL 0xB1
// For register readback, the following bytes will be ic-dependent, as
// some devices have more than 62 bytes worth of registers, so it may
// need to be split up into pages.
#define CTRL_REGISTER_READBACK 0xC8
#define CTRL_ACK_WRITE_IC_REGISTER 0xDF
#define CTRL_ACK_RTT_REQUEST 0xE0
// %%% IC Identifiers %%%
// I want a SINGLE table for 8-bit IDs corresponding to different ICs
// These values can be anything from 0x06:0xFF, as long as it doesn't conflict
// with any of the reserved ones from above.
// If the USB packet leads [0] with the ID, then it is a data packet
// in the typical format of [ID, Serial, ...data] where the length of data
// should be statically determined in advance.
// For example, with the ADS1298, the packet length is determined based on the
// channel count (see: ads1298_set_data_buffer_length for more details)
// #define RESPONSE_PACKET 0x00
#define IC_ID_ADS1298 0xD1
#define IC_ID_EXT 0xFF // see next byte for extended table
#define FIRST_NIBBLE(x) ((x >> 4) & 0xF)
#define SECOND_NIBBLE(x) (x & 0xF)
// For IC controls, we want to prefix the registers with the length: [u16???]
// Data format will be different for each device.
// For ADS1298
// [CN:4bit][TN:4bit][length:u8][..data]
// For other device with 1 register read/write at a time
// [CN:4bit][TN:4bit][RegisterID][RegisterData] for single register
#endif // NRF52840_BREAKOUT_BOARD
enum recording_mode_t {
RECORDING_MODE_DISABLED = 0,
RECORDING_MODE_ALL = 1
};
#endif // CUSTOM_BOARD_H