[update] clean up pin define and gatt function

This commit is contained in:
ROY
2023-03-03 11:07:09 +08:00
parent 8d9e4eab63
commit b5da45124d
11 changed files with 268 additions and 600 deletions
@@ -0,0 +1,81 @@
/* --------------------
* define device name
* ------------------*/
#define DEVICE_NAME "Elite-BAT"
#define MAJOR_PRODUCT_NUMBER 0
#define MINOR_PRODUCT_NUMBER 3
#define MAJOR_VERSION_NUMBER 1
#define MINOR_VERSION_NUMBER 1
/* ---------------------------
* define device buffer size
* -------------------------*/
#define CUSTOM_GATT_LENGTH
#define BLE_CIS_BUFF_SIZE 20
#define BLE_INS_BUFF_SIZE 20
#define BLE_DAT_BUFF_SIZE 40
/* -------------------
* define device pin
* -----------------*/
// Elite Pin Board
#define E_PIN_LED_SPI_CLK DIO5
#define E_PIN_LED_SPI_SDI DIO6
#define E_PIN_ADCA0 DIO0
#define E_PIN_ADCA1 DIO1
#define E_PIN_ADCA2 DIO7
#define E_PIN_SWCSBB DIO2
#define E_PIN_MEMCS DIO3
#define E_PIN_DIO4 DIO4
#define E_PIN_I2C_SCK DIO8
#define E_PIN_I2C_SDA DIO9
#define E_PIN_DACCS DIO10
#define E_PIN_ADCCS DIO11
#define E_PIN_SCLK0 DIO12
#define E_PIN_MOSI DIO13
#define E_PIN_MISO DIO14
// SPI & I2C Board
#define E_SPI0_MISO PIN_UNASSIGNED
#define E_SPI0_MOSI E_PIN_LED_SPI_SDI
#define E_SPI0_CLK E_PIN_LED_SPI_CLK
#define E_SPI0_CS PIN_UNASSIGNED
#define E_SPI1_MISO E_PIN_MISO
#define E_SPI1_MOSI E_PIN_MOSI
#define E_SPI1_CLK E_PIN_SCLK0
#define E_SPI1_CS PIN_UNASSIGNED
#define E_I2C0_SCL0 E_PIN_I2C_SCK
#define E_I2C0_SDA0 E_PIN_I2C_SDA
// no use
#define D0 PIN_UNASSIGNED
#define D1 PIN_UNASSIGNED
#define D2 PIN_UNASSIGNED
#define D3 PIN_UNASSIGNED
#define D4 PIN_UNASSIGNED
#define D5 PIN_UNASSIGNED
#define D6 PIN_UNASSIGNED
#define D7 PIN_UNASSIGNED
#define LOAD0 PIN_UNASSIGNED
#define LOAD1 PIN_UNASSIGNED
#define LOAD2 PIN_UNASSIGNED
#define SHUT_DOWN PIN_UNASSIGNED //switch_on
#define HIGH_Z LOAD0, PIN_UNASSIGNED
#define CS_MEM LOAD0, PIN_UNASSIGNED
#define CS_ADC LOAD0, PIN_UNASSIGNED
#define CS_DAC LOAD0, PIN_UNASSIGNED
#define MEM_HOLD LOAD1, PIN_UNASSIGNED
#define P_10V_enable LOAD1, PIN_UNASSIGNED
#define P_5V_enable LOAD1, PIN_UNASSIGNED
#define I_MID_ON LOAD2, PIN_UNASSIGNED
#define I_LARGE_ON LOAD2, PIN_UNASSIGNED
#define V_SMALL_ON LOAD2, PIN_UNASSIGNED
#define V_MID_ON LOAD2, PIN_UNASSIGNED
#define I_SMALL_ON LOAD2, PIN_UNASSIGNED
#define OFF LOAD2, PIN_UNASSIGNED //6994
#define VOUT_SMALL_ON LOAD2, PIN_UNASSIGNED
@@ -0,0 +1,159 @@
#ifndef APPLICATION_CONFIG_H
#define APPLICATION_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
// !!! define DEF_ELITE_MODEL first please !!!
/*
*
* product number: MAJOR_PRODUCT_NUMBER, MINOR_PRODUCT_NUMBER, MAJOR_VERSION_NUMBER, MINOR_VERSION_NUMBER
* MAJOR_PRODUCT_NUMBER -> 0:Elite, 1:other serial
* Elite:
* MINOR_PRODUCT_NUMBER -> 1:legacy, 2:EDC, 3:BAT, 4:EIS, 5:TRIG, 6:MEGAFLY
*
* |------------------+------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
* | hardware | model name | hw upper board | hw lower board | product number | device name | data server lib name | UI |
* |------------------+------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
* | Elite EDC1.4 | DEF_ELITE_EDC_14 | Elite1.4-re Jun.2019 | Elite1.4-re Jun. 2019 | 0, 2, 1, 5 | "Elite-EDC" | Elite_EDC_1.4 | null |
* | Elite EDC1.5 | DEF_ELITE_EDC_15 | Elite1.5 Dec. 2019 | Elite1.5 Dec. 2019 | 0, 2, 1, 6 | "Elite-EDC" | Elite_EDC_1.5 | EliteEDC |
* | Elite EDC1.5re | DEF_ELITE_EDC_15RE | Elite1.5 Dec. 2019 | Elite1.5-re Jan. 2021 | 0, 2, 1, 7 | "Elite-EDC" | Elite_EDC_1.5re | EliteEDC |
* | Elite EDC1.5r2 | DEF_ELITE_EDC_15R2 | Elite1.5 Dec. 2019 | Elite1.5-r2 May. 2022 | 0, 2, 1, 8 | "Elite-EDC" | Elite_EDC_1.5r2 | EliteEDC |
* | Elite BAT0.1 | DEF_ELITE_BAT_01 | Elite2.0 Feb. 2022 | 0, 3, 1, 0 | "Elite-BAT" | Elite_BAT_0.1 | EliteEDC |
* | Elite BAT1.0 | DEF_ELITE_BAT_10 | BAT SMC V1.0 Aug.2022| BAT PWR V1.0 Aug. 2022 | 0, 3, 1, 1 | "Elite-BAT" | Elite_BAT_1.0 | EliteEDC |
* | Elite EIS1.0 | DEF_ELITE_EIS_10 | Elite1.5 Dec. 2019 | Elite EIS1.0 Aug. 2020 | 0, 4, 1, 0 | "Elite-EIS" | Elite_EIS_1.0 | EliteEIS |
* | Elite EIS1.1 | DEF_ELITE_EIS_11 | Elite1.5 Dec. 2019 | Elite EIS1.1 Feb. 2022 | 0, 4, 1, 1 | "Elite-EIS" | Elite_EIS_1.1 | EliteEIS |
* | Elite EISmini1.0 | DEF_ELITE_EIS_MINI_10 | EIS MINI May. 2022 | 0, 4, 1, 2 | "Elite-EIS-MINI" | Elite_EIS_MINI_1.0 | EliteEIS |
* | Elite TRIG0.1 | DEF_ELITE_TRIG_01 | Elite TRIG01 Jan. 2021 | 0, 5, 1, 0 | "Elite-TRIG" | Elite_TRIG_0.1 | EliteTrigger |
* | Elite MEGAFLY0.1 | DEF_ELITE_MEGAFLY_01 | Elite1.5 Dec. 2019 | Elite Megafly Sep. 2020 | 0, 6, 1, 0 | "Elite-MEGAFLY" | Elite_MEGAFLY_0.1 | null |
* |-----------------+------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
* ps.
* model name is FW engineer defined
* device name is used for controller
*/
#define DEF_ELITE_EDC_14 0
#define DEF_ELITE_EDC_15 1
#define DEF_ELITE_EDC_15RE 2
#define DEF_ELITE_EDC_15R2 3
#define DEF_ELITE_BAT_01 4
#define DEF_ELITE_BAT_10 5
#define DEF_ELITE_EIS_10 6
#define DEF_ELITE_EIS_11 7
#define DEF_ELITE_EIS_MINI_10 8
#define DEF_ELITE_TRIG_01 9
#define DEF_ELITE_MEGAFLY_01 10
#define DEF_ELITE_MAX 11
#define DEF_ELITE_MODEL DEF_ELITE_BAT_10
#ifndef DEF_ELITE_MODEL
#error "DEF_ELITE_MODEL not defined"
#endif
// model information
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_14)
#error "code no support"
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15)
#error "code no support"
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15RE)
#error "code no support"
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15R2)
#error "code no support"
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_01)
#error "code no support"
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_10)
#include "BAT_10_conf.h"
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_10)
#error "code no support"
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_11)
#error "code no support"
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_MINI_10)
#error "code no support"
#elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_01)
#error "code no support"
#elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_01)
#error "code no support"
#else
#error "no this model"
#endif
// model information
// #if (DEF_ELITE_MODEL == DEF_ELITE_EDC_14)
// #define DEVICE_NAME "Elite-EDC"
// #define MAJOR_PRODUCT_NUMBER 0
// #define MINOR_PRODUCT_NUMBER 2
// #define MAJOR_VERSION_NUMBER 1
// #define MINOR_VERSION_NUMBER 5
// #elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15)
// #define DEVICE_NAME "Elite-EDC"
// #define MAJOR_PRODUCT_NUMBER 0
// #define MINOR_PRODUCT_NUMBER 2
// #define MAJOR_VERSION_NUMBER 1
// #define MINOR_VERSION_NUMBER 6
// #elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15RE)
// #define DEVICE_NAME "Elite-EDC"
// #define MAJOR_PRODUCT_NUMBER 0
// #define MINOR_PRODUCT_NUMBER 2
// #define MAJOR_VERSION_NUMBER 1
// #define MINOR_VERSION_NUMBER 7
// #elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15R2)
// #define DEVICE_NAME "Elite-EDC"
// #define MAJOR_PRODUCT_NUMBER 0
// #define MINOR_PRODUCT_NUMBER 2
// #define MAJOR_VERSION_NUMBER 1
// #define MINOR_VERSION_NUMBER 8
// #elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_01)
// #define DEVICE_NAME "Elite-BAT"
// #define MAJOR_PRODUCT_NUMBER 0
// #define MINOR_PRODUCT_NUMBER 3
// #define MAJOR_VERSION_NUMBER 1
// #define MINOR_VERSION_NUMBER 0
// #elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_10)
// #define DEVICE_NAME "Elite-BAT"
// #define MAJOR_PRODUCT_NUMBER 0
// #define MINOR_PRODUCT_NUMBER 3
// #define MAJOR_VERSION_NUMBER 1
// #define MINOR_VERSION_NUMBER 1
// #elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_10)
// #define DEVICE_NAME "Elite-EIS"
// #define MAJOR_PRODUCT_NUMBER 0
// #define MINOR_PRODUCT_NUMBER 4
// #define MAJOR_VERSION_NUMBER 1
// #define MINOR_VERSION_NUMBER 0
// #elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_11)
// #define DEVICE_NAME "Elite-EIS"
// #define MAJOR_PRODUCT_NUMBER 0
// #define MINOR_PRODUCT_NUMBER 4
// #define MAJOR_VERSION_NUMBER 1
// #define MINOR_VERSION_NUMBER 1
// #elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_MINI_10)
// #define DEVICE_NAME "Elite-EIS"
// #define MAJOR_PRODUCT_NUMBER 0
// #define MINOR_PRODUCT_NUMBER 4
// #define MAJOR_VERSION_NUMBER 1
// #define MINOR_VERSION_NUMBER 2
// #elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_01)
// #define DEVICE_NAME "Elite-TRIG"
// #define MAJOR_PRODUCT_NUMBER 0
// #define MINOR_PRODUCT_NUMBER 5
// #define MAJOR_VERSION_NUMBER 1
// #define MINOR_VERSION_NUMBER 0
// #elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_01)
// #define DEVICE_NAME "Elite-MEGAFLY"
// #define MAJOR_PRODUCT_NUMBER 0
// #define MINOR_PRODUCT_NUMBER 6
// #define MAJOR_VERSION_NUMBER 1
// #define MINOR_VERSION_NUMBER 0
// #else
// #error "no this model"
// #endif
#ifdef __cplusplus
}
#endif
#endif // APPLICATION_CONFIG_H
@@ -1,10 +0,0 @@
#define DEF_ELITE_EDC_2_0
#if defined (DEF_ELITE_EDC_1_5_RE)
#include "boards_config/pin_config_edc15re.h"
#elif defined (DEF_ELITE_EDC_1_5)
#include "boards_config/pin_config_edc15.h"
#elif defined (DEF_ELITE_EDC_2_0)
#include "boards_config/pin_config_edc20.h"
#endif
@@ -1,45 +0,0 @@
#define D0 DIO3
#define D1 DIO4
#define D2 DIO5
#define D3 DIO6
#define D4 DIO7
#define D5 DIO8
#define D6 DIO9
#define D7 DIO10
#define LOAD0 DIO13
#define LOAD1 DIO12
#define LOAD2 DIO11
#define SHUT_DOWN DIO14
/* SPI Board */
#define Board_SPI0_MISO PIN_UNASSIGNED
#define Board_SPI0_MOSI D1
#define Board_SPI0_CLK D0
#define Board_SPI0_CS PIN_UNASSIGNED
#define Board_SPI1_MISO DIO1
#define Board_SPI1_MOSI D3
#define Board_SPI1_CLK D2
#define Board_SPI1_CS PIN_UNASSIGNED
#define CS_ADC LOAD0, D6
#define CS_DAC LOAD0, D7
#define MOSI LOAD0, D3
#define SCLK LOAD0, D2
#define LED_MOSI_A LOAD0, D1
#define LED_SCLK_A LOAD0, D0
#define CS_MEM LOAD0, D5
#define MEM_HOLD LOAD0, D4
#define HIGH_Z LOAD2, D5
#define I_MID_ON LOAD2, D0
#define I_SMALL_ON LOAD2, D4
#define I_LARGE_ON LOAD2, D1
#define V_SMALL_ON LOAD2, D2
#define V_MID_ON LOAD2, D3
#define VOUT_SMALL_ON LOAD2, D7
#define OFF LOAD2, D6
#define P_10V_enable LOAD1, D5
#define P_5V_enable LOAD1, D6
@@ -1,46 +0,0 @@
#define D0 DIO3
#define D1 DIO4
#define D2 DIO5
#define D3 DIO6
#define D4 DIO7
#define D5 DIO8
#define D6 DIO9
#define D7 DIO10
#define LOAD0 DIO13
#define LOAD1 DIO12
#define LOAD2 DIO11
#define SHUT_DOWN DIO14 //switch_on
/* SPI Board */
#define Board_SPI0_MISO PIN_UNASSIGNED
#define Board_SPI0_MOSI D1
#define Board_SPI0_CLK D0
#define Board_SPI0_CS PIN_UNASSIGNED
#define Board_SPI1_MISO DIO1
#define Board_SPI1_MOSI D3
#define Board_SPI1_CLK D2
#define Board_SPI1_CS PIN_UNASSIGNED
#define LED_SCLK_A LOAD0, D0
#define LED_MOSI_A LOAD0, D1
#define SCLK LOAD0, D2
#define MOSI LOAD0, D3
#define HIGH_Z LOAD0, D4
#define CS_MEM LOAD0, D5
#define CS_ADC LOAD0, D6
#define CS_DAC LOAD0, D7
#define MEM_HOLD LOAD1, D0
#define P_10V_enable LOAD1, D5
#define P_5V_enable LOAD1, D6
#define I_MID_ON LOAD2, D0
#define I_LARGE_ON LOAD2, D1
#define V_SMALL_ON LOAD2, D2
#define V_MID_ON LOAD2, D3
#define I_SMALL_ON LOAD2, D4
#define OFF LOAD2, D6 //6994
#define VOUT_SMALL_ON LOAD2, D7
@@ -1,85 +0,0 @@
/* Elite Pin Board */
#define E_PIN_LED_SPI_CLK DIO5
#define E_PIN_LED_SPI_SDI DIO6
#define E_PIN_ADCA0 DIO0
#define E_PIN_ADCA1 DIO1
#define E_PIN_ADCA2 DIO7
#define E_PIN_SWCSBB DIO2
#define E_PIN_MEMCS DIO3
#define E_PIN_DIO4 DIO4
#define E_PIN_I2C_SCK DIO8
#define E_PIN_I2C_SDA DIO9
#define E_PIN_DACCS DIO10
#define E_PIN_ADCCS DIO11
#define E_PIN_SCLK0 DIO12
#define E_PIN_MOSI DIO13
#define E_PIN_MISO DIO14
/* SPI Board */
#define Board_SPI0_MISO PIN_UNASSIGNED
#define Board_SPI0_MOSI E_PIN_LED_SPI_SDI
#define Board_SPI0_CLK E_PIN_LED_SPI_CLK
#define Board_SPI0_CS PIN_UNASSIGNED
#define Board_SPI1_MISO E_PIN_MISO
#define Board_SPI1_MOSI E_PIN_MOSI
#define Board_SPI1_CLK E_PIN_SCLK0
#define Board_SPI1_CS PIN_UNASSIGNED
/* I2C */
#define Board_I2C0_SCL0 E_PIN_I2C_SCK
#define Board_I2C0_SDA0 E_PIN_I2C_SDA
#define D0 PIN_UNASSIGNED
#define D1 PIN_UNASSIGNED
#define D2 PIN_UNASSIGNED
#define D3 PIN_UNASSIGNED
#define D4 PIN_UNASSIGNED
#define D5 PIN_UNASSIGNED
#define D6 PIN_UNASSIGNED
#define D7 PIN_UNASSIGNED
#define LOAD0 PIN_UNASSIGNED
#define LOAD1 PIN_UNASSIGNED
#define LOAD2 PIN_UNASSIGNED
#define SHUT_DOWN PIN_UNASSIGNED //switch_on
// #define ADC_CS DIO11
//#define DAC_CS DIO10
#define HIGH_Z LOAD0, PIN_UNASSIGNED
#define CS_MEM LOAD0, PIN_UNASSIGNED
#define CS_ADC LOAD0, PIN_UNASSIGNED
#define CS_DAC LOAD0, PIN_UNASSIGNED
#define MEM_HOLD LOAD1, PIN_UNASSIGNED
#define P_10V_enable LOAD1, PIN_UNASSIGNED
#define P_5V_enable LOAD1, PIN_UNASSIGNED
#define I_MID_ON LOAD2, PIN_UNASSIGNED
#define I_LARGE_ON LOAD2, PIN_UNASSIGNED
#define V_SMALL_ON LOAD2, PIN_UNASSIGNED
#define V_MID_ON LOAD2, PIN_UNASSIGNED
#define I_SMALL_ON LOAD2, PIN_UNASSIGNED
#define OFF LOAD2, PIN_UNASSIGNED //6994
#define VOUT_SMALL_ON LOAD2, PIN_UNASSIGNED
@@ -3,10 +3,10 @@
#define VERSION_DATE
#define VERSION_DATE_YEAR 23
#define VERSION_DATE_MONTH 2
#define VERSION_DATE_DAY 14
#define VERSION_DATE_HOUR 14
#define VERSION_DATE_MINUTE 21
#define VERSION_DATE_MONTH 3
#define VERSION_DATE_DAY 3
#define VERSION_DATE_HOUR 11
#define VERSION_DATE_MINUTE 7
// this is NOT the version hash !!
// it's the last version hash
@@ -48,6 +48,7 @@
/*********************************************************************
* INCLUDES
*/
#include "application_config/application_config.h"
#include <string.h>
#include <ti/sysbios/knl/Task.h>
@@ -89,13 +90,11 @@
#include "board_key.h"
#include "board.h"
#include "hardware/DAC_MAX5136.h"
#include "simple_peripheral.h"
// #include "EliteGPTimer.h"
#include "hardware/DAC_MAX5136.h"
#include <Board.h>
#include <ti/drivers/timer/GPTimerCC26XX.h>
#include <ti/sysbios/BIOS.h>
@@ -126,390 +125,6 @@ static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_In
GPTimerCC26XX_registerInterrupt(gptimer_handle, elite_gptimer_callback, GPT_INT_TIMEOUT); \
} while (0)
// #include "headstage.h"
/*
============================
Chip Parameter Specification
============================
======================= =============================
parameter value range
======================= =============================
sampling rate 10K .. 180k Hz / channel
recording channel 1, 4, 8, 16
AMP Gain 400, 1000, 2000
AMP Fast Settling Time 1 us
Stimulation voltage 2V .. 5V
Stimulation pulse width 40 us .. 490 us (50 us/step)
Stimulation pulse shape POS, NEG, P2N, N2P, AWF
Stimulation pulse times 1 .. 253 (4 times/step)
Stimulation pulse freq 30 .. 10K Hz
======================= =============================
=========================
Instruction Specification
=========================
::
| | 1 | 2 | 3 |
012345678901234567890123456789012
---------------------------------
|RIS|ID | |LEN| ............. | real instruction send
|VIS|ID |OP |LEN| ............. | virtual instruction send
H
header
ID
chip ID
RIS
real instruction type
VIS
virtual instruction type
OP
virtual instruction
LEN, length
command length in bytes
TYP_RIS = 0b0011_0000 # 3x
TYP_VIS = 0b1100_0000 # Cx
TYP_VDR = 0b1010_0000 # Ax
VIS_RST = 0b1111_0000 # Fx reset
VIS_ASK = 0b0011_0000 # 3x ask in
VIS_STI = 0b1100_0000 # Cx stimulate
VIS_FUH = 0b1001_0000 # 9x flush
VIS_INT = 0b0110_0000 # 6x interrupt
VIS_SHIFT_200K = 0b1010_0000 # Ax shift gear to 200K
VIS_SHIFT_10K = 0b1110_0000 # Ex shift gear to 10K
VIS_SHIFT_200R = 0b1000_0000 # 8x shift gear to 100R
=========================
Instruction for HeadStage
=========================
serial send ::
| | 1 | 2 | 3 |
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2
-----------------------------------------------------------------
|HEAD | ------------------------------------------------------- |
|0b100| | MOD | RATE |a|b|c|d| CH[a] | CH[b] | CH[c] | CH[d] | artifact recording mode
|0b101|AGN| LBF | AMP |C|F|S| SVT | SCH_P | SCH_N |A| | actually instruction send to DBS
|0b101|AGN| LBF | AMP |C|F|S| SVT | SCH_P | SCH_N | RATE | direct command
| CS | LEN |0b1010 | REG_A | |CV |O|B|E|I|PV |RA | DAC control register
| CS | LEN |0b1010 | REG_A | | DAC reset, no operation
| CS | LEN |SS|MUX |PGA |M | DR |T|U|NOP|r| ADC config register
| VIS |
HEAD
instruction type header.
MOD
in artifact recording mode. select which wave from should be generated/
====== ===========
value description
====== ===========
0b0001 ramp
====== ===========
SUB
stimulation instruction sub-type.
AGN
amp gain
LBF
low frequency band [1]_
AMP
amp mux channel.
RATE
ADC clock sample rate (index to a value table), used for slave side chip.
.. [1] : little-endian.
CS
choose instruction write to DAC or ADC
0000 = DAC
1111 = ADC
LEN
command length in bytes
DAC = 3 bytes
ADC = 2 bytes
REG_A
register address.
0100 = control address
0111 = software data reset
1111 = software full reset
0000/0101/0110/1101/1110 = no operation
CV
CLEAR voltage selection.
00 = zero scale
01 = midscale
10/11 = full scale
O
5% overrange.
0 = 5% overrange disable
1 = 5% overrange enable
B
bipolar range.
0 = DAC input for bipolar output range is straight binary coded
1 = DAC input for bipolar output range is two complement coded
E
thermal shutdown alert.
0 = internal digital supplt dosen't power down if die temperature exeeds 150 degrees
1 = internal digital supply powers down if die temperature exeeds 150 degrees
I
internal reference.
0 = internal reference turned off
1 = internal reference turned on (default)
PV
power up voltage.
00 = zero scale
01 = midscale
10/11 = full scale
RA
output range.
000 = -10V to +10V
001 = 0V to +10V
010 = -5V to +5V
011 = 0V to +5V
100 = -2.5V to +7.5V
101 = -3V to +3V
110 = 0V to +16V
111 = 0V to +20V
SS
Single-short conversion start
0 = no effect (default)
1 = start a single conversion
MUX
input multiplexer configuration
000 = AINp is AIN0 and AINn is AIN1 (default)
001 = AINp is AIN0 and AINn is AIN3
010 = AINp is AIN1 and AINn is AIN3
011 = AINp is AIN2 and AINn is AIN3
100 = AINp is AIN0 and AINn is GND
101 = AINp is AIN1 and AINn is GND
110 = AINp is AIN2 and AINn is GND
111 = AINp is AIN3 and AINn is GND
PGA
programmable gain amplifier configuration
(Full Scale Range = FSR)
000 = FSR is 6.144 V
001 = FSR is 4.096 V
010 = FSR is 2.048 V (default)
011 = FSR is 1.024 V
100 = FSR is 0.512 V
101 = FSR is 0.256 V
110 = FSR is 0.256 V
111 = FSR is 0.256 V
M
ADC operating mode
0 = continuous conversion mode
1 = Power-down and single-shot mode (default)
DR
data rate
(Sample per second = SPS)
000 = 8 SPS
001 = 16 SPS
010 = 32 SPS
011 = 64 SPS
100 = 128 SPS (default)
101 = 250 SPS
110 = 475 SPS
111 = 860 SPS
T
temperature sensor mode
0 = ADC mode (default)
1 = temperature sensor mode
P
pullup enable
0 = pullup resistor disable on DOUT
1 = pullup resistor enable on DOUT (default)
NOP
no operation
00/10/11 = Invalid data, do not update the contents of the Config register
01 = Valid, update the Config register (default)
serial receive ::
| | 1 | 2 | 3 |
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2
-----------------------------------------------------------------
| HEAD|E| data | .................................. received content from DBS
| CH | data | F | .............................. data in notify content
HEAD
0b101
E
EOC flag
CH
channel
data
data
F
flag
======= =======
F value mean
======= =======
0x00 success
0x11 invalid
======= =======
notify content::
| | 1 | 2 | 3 |
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2
-----------------------------------------------------------------
| chip ID | data length |
| cpu time |
| CH | data | F | CH | data | F |
| ............................................................. |
data length
byte counter from cpu time to end.
cpu time
first data time. (little endian, float)
============
program flow
============
**NOTE**
The function name start with ``@`` are headstage specific function
which just be declared in this header.
**NOTE**
The function name start with ``~`` are callback function
whose name is the correspond callback setter function
used to present call the callback function set by this setter function.
initialized
-----------
1. headstage_gtimer_init
#. headstage_spi_init
#. @headstage_init
periodic event
--------------
1. headstage_gptimer_main_handle
1. headstage_periodic_handle
*. [rec/arm mode]
1. @update_ins_rec_buffer
update channel and ADC clock bits.
1. @spi_transact_rec_instruction
spi_txbuf -> Headstage -> spi_rxbuf
1. collect_data
spi_rxbuf -> not_buf
1. [buff full] send_notify
SimpleProfile_SetParameter(not_buf -> 4)
*. [sti mode]
1. @update_ins_sti_buffer
#. @spi_transact_sti_instruction
characteristic change event
---------------------------
1. headstage_instruction_update_handle
SimpleProfile_GetParameter(3 -> ins_buf)
1. update_instruction
ins_buf -> instru
*. [INS_TYPE_RIS]
*. [HDR_DIR] decode_direct_instruction
*. [HDR_REC] decode_recording_instruction
*. [HDR_ARM] decode_artifact_recording_instruction
*. [HDR_STI] decode_stimulating_instruction
*. [simple] decode_stimulating_simple_instruction
*. [continuous frequency] decode_stimulating_continuous_frequency
*. [HDR_AWF] decode_stimulating_awf_instruction
*. [INS_TYPE_VIS]
*. [VIS_RST]
*. [VIS_INT]
#. update_clock_period
GPTimer_SetFreq
#. update_ins_buffer
instru -> spi_txbuf
*/
/*================
==== gptimer ====
===============*/
/*============
==== SPI ====
===========*/
/* system use SPI parameters */
#include <driverlib/timer.h>
#include <ti/drivers/SPI.h>
#include <ti/drivers/spi/SPICC26XXDMA.h>
@@ -537,27 +152,9 @@ characteristic change event
#define SBP_KEY_CHANGE_EVT 0x0010
#endif
/**************************
controller version
EliteZM02 0,2,1,5
EliteZM15 0,2,1,6
EliteZM_pulsefly 0,2,1,7
**************************/
// product information
#define DEVICE_NAME "Elite-BAT"
#define MAJOR_PRODUCT_NUMBER 0 // 0:Elite, 1:Neulive
#define MINOR_PRODUCT_NUMBER 2 // 1:Elite_legacy(Ori_Neulive) 2:Elite_zm 3:Elite_bat
#define MAJOR_VERSION_NUMBER 1
#define MINOR_VERSION_NUMBER 6
// buffer size
#define BLE_CIS_BUFF_CHAR SIMPLEPROFILE_CHAR2
#define BLE_INS_BUFF_CHAR SIMPLEPROFILE_CHAR3
#define BLE_DAT_BUFF_CHAR SIMPLEPROFILE_CHAR4
#define BLE_CIS_BUFF_SIZE SIMPLEPROFILE_CHAR2_LEN
#define BLE_INS_BUFF_SIZE SIMPLEPROFILE_CHAR3_LEN
#define BLE_DAT_BUFF_SIZE SIMPLEPROFILE_CHAR4_LEN
#include "application/BAT_10_app.h"
enum send_ins_para_order_e {
PARA_1 = 0x01,
PARA_2 = 0x02,
@@ -56,7 +56,7 @@ extern "C"
/*********************************************************************
* INCLUDES
*/
#include "application_config/application_config.h"
/*********************************************************************
* CONSTANTS
*/
@@ -81,13 +81,24 @@ extern "C"
// Simple Keys Profile Services bit fields
#define SIMPLEPROFILE_SERVICE 0x00000001
#ifndef CUSTOM_GATT_LENGTH
// Length of Characteristic 5 in bytes
#define SIMPLEPROFILE_CHAR5_LEN 5
/*user insert*/
#define SIMPLEPROFILE_CHAR4_LEN 40
#define SIMPLEPROFILE_CHAR4_LEN 20
#define SIMPLEPROFILE_CHAR3_LEN 20
#define SIMPLEPROFILE_CHAR2_LEN 20
#define SIMPLEPROFILE_CHAR1_LEN 20
#else
/*user insert*/
#define SIMPLEPROFILE_CHAR5_LEN 5
#define SIMPLEPROFILE_CHAR4_LEN BLE_DAT_BUFF_SIZE
#define SIMPLEPROFILE_CHAR3_LEN BLE_INS_BUFF_SIZE
#define SIMPLEPROFILE_CHAR2_LEN BLE_CIS_BUFF_SIZE
#define SIMPLEPROFILE_CHAR1_LEN 20
#define BLE_CIS_BUFF_CHAR SIMPLEPROFILE_CHAR2
#define BLE_INS_BUFF_CHAR SIMPLEPROFILE_CHAR3
#define BLE_DAT_BUFF_CHAR SIMPLEPROFILE_CHAR4
#endif
/*********************************************************************
* TYPEDEFS
*/