Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 262757d609 | |||
| 973f57f757 | |||
| 05d36a6f1e | |||
| fe977541f2 | |||
| fb543aa7b4 | |||
| 78720a9a7e | |||
| baeeafd002 | |||
| be9084d8f1 | |||
| da1e1a54ac |
+4
-4
@@ -2,17 +2,17 @@
|
||||
<launchConfiguration type="com.ti.ccstudio.debug.launchType.device.debugging">
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <PropertyValues> <property id="ConnectOnStartup"> <curValue>1</curValue> </property> <property id="EnableInstalledBreakpoint"> <curValue>1</curValue> </property> <property id="IgnoreSoftLaunchFailures"> <curValue>0</curValue> </property> </PropertyValues> "/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <PropertyValues> <property id="ConnectOnStartup"> <curValue>1</curValue> </property> <property id="EnableInstalledBreakpoint"> <curValue>1</curValue> </property> <property id="IgnoreSoftLaunchFailures"> <curValue>0</curValue> </property> </PropertyValues> "/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <PropertyValues> <property id="ConnectOnStartup"> <curValue>1</curValue> </property> <property id="EnableInstalledBreakpoint"> <curValue>1</curValue> </property> <property id="IgnoreSoftLaunchFailures"> <curValue>0</curValue> </property> </PropertyValues> "/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <PropertyValues> <property id="ConnectOnStartup"> <curValue>1</curValue> </property> <property id="EnableInstalledBreakpoint"> <curValue>1</curValue> </property> <property id="IgnoreSoftLaunchFailures"> <curValue>0</curValue> </property> </PropertyValues> "/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_app}"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_app}"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_app}"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_app}"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="simple_peripheral_cc2650em_app"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="simple_peripheral_cc2650em_app"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="simple_peripheral_cc2650em_app"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="simple_peripheral_cc2650em_app"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_TARGET_CONFIG" value="${target_config_active_default:simple_peripheral_cc2650em_app}"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
|
||||
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/simple_peripheral_cc2650em_app"/>
|
||||
</listAttribute>
|
||||
|
||||
@@ -146,6 +146,7 @@ extern const PIN_Config BoardGpioInitTable[];
|
||||
#define Board_GLED PIN_UNASSIGNED /* Green LED */
|
||||
#define Board_RLED PIN_UNASSIGNED /* Red LED */
|
||||
|
||||
|
||||
/* UART Board */
|
||||
#define Board_UART_TX Board_BP_UART_Rx /* RXD */
|
||||
#define Board_UART_RX Board_BP_UART_Tx /* TXD */
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ typedef enum {
|
||||
READ_REG, // read DBS register value, used after a "read" SPI instruction (MISO)
|
||||
READ_REG2, // read DBS register value, used after a "read" SPI instruction (MISO)
|
||||
END_TRANSMIT, // read DBS register value, used after a "read" SPI instruction (MISO)
|
||||
CONTI_SPI_WITH_FLUSH, // end spi instruction
|
||||
ONE_SHOT_SPI, // end spi instruction
|
||||
READ_MOSI
|
||||
} SPI_CB_MODE;
|
||||
|
||||
|
||||
+3
-1
@@ -2,7 +2,9 @@
|
||||
#ifndef NEU_CALI_TABLE
|
||||
#define NEU_CALI_TABLE
|
||||
|
||||
#define BOARD_TEST
|
||||
// define Device_Name if "BOARD_TEST" as default
|
||||
// else find headstage ID
|
||||
#define BOARD_18_04_ED_37_C6_41
|
||||
|
||||
typedef struct _SingleChannelCali{
|
||||
uint16_t Gain[4];
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ static void check_register(uint8_t register_to_check, uint16_t instruction_to_fi
|
||||
check_reg_counter = 0;
|
||||
if(check_ins(instruction_to_fit)){
|
||||
NEULIVE_STATE.state = next_state;
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
|
||||
// update rec_sti_command
|
||||
if(!(rec_sti_command & ENABLE_STI)){
|
||||
@@ -70,7 +70,7 @@ static void check_register(uint8_t register_to_check, uint16_t instruction_to_fi
|
||||
IsFirstData = true;
|
||||
}
|
||||
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
ReopenSPI();
|
||||
}
|
||||
headstage_spi_transaction(3);
|
||||
@@ -167,7 +167,7 @@ static void check_sti_t1_t5(NEU_WORK_STATE next_state){
|
||||
else{
|
||||
NEULIVE_STATE.state = next_state;
|
||||
}
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
headstage_spi_transaction(3);
|
||||
}
|
||||
|
||||
|
||||
+5
-8
@@ -8,7 +8,6 @@
|
||||
#define SYS_GENERAL_ENABLE_INDEX 1
|
||||
#define SYS_LNA_BIOS1_INDEX 2
|
||||
#define SYS_LNA_BIOS2_INDEX 3
|
||||
#define SYS_STI_CLK_RATIO_INDEX 4
|
||||
|
||||
#define REC_CHANNEL_INDEX 0
|
||||
#define REC_GAIN_INDEX 1
|
||||
@@ -46,7 +45,7 @@ void write_reg(DBSRegister *self, uint16_t reg_value){
|
||||
spi_txbuf[0] = 0x80 | self->address;
|
||||
spi_txbuf[1] = (reg_value >> 8) & 0xFF ;
|
||||
spi_txbuf[2] = reg_value & 0xFF;
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
headstage_spi_transaction(SPI_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
@@ -59,17 +58,16 @@ void read_reg(DBSRegister *self){
|
||||
}
|
||||
|
||||
|
||||
static uint16_t sys_register_default_value[5] = {
|
||||
static uint16_t sys_register_default_value[4] = {
|
||||
0x0000,
|
||||
0x40F2,
|
||||
0x0210,
|
||||
0x4210,
|
||||
0x0002
|
||||
0x4210
|
||||
};
|
||||
static uint16_t rec_register_value[3];
|
||||
static uint16_t sti_register_value[43];
|
||||
|
||||
static DBSRegister sys_register[5];
|
||||
static DBSRegister sys_register[4];
|
||||
static DBSRegister rec_register[3];
|
||||
static DBSRegister sti_register[43];
|
||||
|
||||
@@ -78,7 +76,6 @@ static void InitSysRegister(){
|
||||
sys_register[SYS_GENERAL_ENABLE_INDEX].address = 47; // general enable
|
||||
sys_register[SYS_LNA_BIOS1_INDEX].address = 57;
|
||||
sys_register[SYS_LNA_BIOS2_INDEX].address = 58;
|
||||
sys_register[SYS_STI_CLK_RATIO_INDEX].address = 52;
|
||||
|
||||
for(int i=0 ; i<sizeof(sys_register)/sizeof(DBSRegister) ; i++){
|
||||
sys_register[i].WriteRegister = false;
|
||||
@@ -135,7 +132,7 @@ static void InitDBSRegister(){
|
||||
InitStiRegister();
|
||||
|
||||
// for(int i=1 ; i<sizeof(sys_register)/sizeof(DBSRegister) ; i++){
|
||||
for(int i=1 ; i<5 ; i++){
|
||||
for(int i=1 ; i<4 ; i++){
|
||||
sys_register[i].WriteRegister = true;
|
||||
}
|
||||
flag_notify(EVT_NEU_SPI);
|
||||
|
||||
+24
-24
@@ -644,7 +644,7 @@ static void headstage_update_vis_instruction(uint8_t vis_oper) {
|
||||
FlushNotify();
|
||||
}
|
||||
NEULIVE_STATE.state = NEU_RST;
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
flag_notify(EVT_NEU_SPI);
|
||||
/**< stop spi transaction */
|
||||
break; /**< reset all the parameter */
|
||||
@@ -726,7 +726,7 @@ static void headstage_update_vis_instruction(uint8_t vis_oper) {
|
||||
}
|
||||
|
||||
NEULIVE_STATE.config_type = NEU_WARM_UP;
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
|
||||
// is neu wording now?
|
||||
if( (rec_sti_command & STATUS_STI) || (rec_sti_command & STATUS_REC) ){
|
||||
@@ -745,7 +745,7 @@ static void headstage_update_vis_instruction(uint8_t vis_oper) {
|
||||
INSTRUCTION.ins_opcode = BIAS_ONE;
|
||||
|
||||
NEULIVE_STATE.config_type = NEU_WARM_UP;
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
|
||||
// is neu wording now?
|
||||
if( (rec_sti_command & STATUS_STI) || (rec_sti_command & STATUS_REC) ){
|
||||
@@ -763,7 +763,7 @@ static void headstage_update_vis_instruction(uint8_t vis_oper) {
|
||||
rec_sti_command |= ENABLE_STI;
|
||||
NEULIVE_STATE.state = NEU_WRITE_STI_INS;
|
||||
NEULIVE_STATE.config_type = NEU_WARM_UP;
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
INSTRUCTION.ins_opcode = T_ZE;
|
||||
|
||||
// is neu wording now?
|
||||
@@ -810,7 +810,7 @@ static void headstage_update_vis_instruction(uint8_t vis_oper) {
|
||||
rec_sti_command &= ~ENABLE_REC;
|
||||
rec_sti_command &= ~ENABLE_STI;
|
||||
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
NEULIVE_STATE.state = NEU_IDLE;
|
||||
STI = false;
|
||||
Neu2Reset();
|
||||
@@ -973,7 +973,7 @@ static void headstage_neu_state_spi() {
|
||||
|
||||
/* recording */
|
||||
case NEU_WRITE_REC_INS: {
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
|
||||
nxt_ins = build_rec_ins(NEULIVE_STATE.config_type, &value); /**< set instruction one by one in order to set all the parameter.*/
|
||||
NEULIVE_STATE.config_type = nxt_ins;
|
||||
@@ -1027,7 +1027,7 @@ static void headstage_neu_state_spi() {
|
||||
value = (0x01 << 23) | (0x33 << 16) | INSTRUCTION.adc_clock_ratio;
|
||||
AppendSPITX(0, value);
|
||||
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
NEULIVE_STATE.state = NEU_CHECK_SAMPLE_RATE;
|
||||
headstage_spi_transaction(3);
|
||||
break;
|
||||
@@ -1041,7 +1041,7 @@ static void headstage_neu_state_spi() {
|
||||
|
||||
case NEU_PREPARE_READ:{
|
||||
if(spi_state_counter < 6){
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
NEULIVE_STATE.state = NEU_PREPARE_READ;
|
||||
spi_state_counter ++;
|
||||
AppendSPITX(0, 0);
|
||||
@@ -1072,7 +1072,7 @@ static void headstage_neu_state_spi() {
|
||||
// go to send sti instruction
|
||||
NEULIVE_STATE.state = NEU_WRITE_STI_INS;
|
||||
NEULIVE_STATE.config_type = NEU_WARM_UP;
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
INSTRUCTION.ins_opcode = T_ZE;
|
||||
|
||||
AppendSPITX(0, 0);
|
||||
@@ -1082,7 +1082,7 @@ static void headstage_neu_state_spi() {
|
||||
// disable stimulation
|
||||
else if( !(rec_sti_command & ENABLE_STI) && (rec_sti_command & STATUS_STI) ){
|
||||
NEULIVE_STATE.state = NEU_STI_INT;
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
|
||||
AppendSPITX(0, 0);
|
||||
headstage_spi_transaction(SPI_BUFFER_SIZE);
|
||||
@@ -1095,7 +1095,7 @@ static void headstage_neu_state_spi() {
|
||||
|
||||
if(rec_sti_command & STATUS_STI){
|
||||
NEULIVE_STATE.state = NEU_STI;
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
|
||||
AppendSPITX(0, 0);
|
||||
headstage_spi_transaction(SPI_BUFFER_SIZE);
|
||||
@@ -1111,7 +1111,7 @@ static void headstage_neu_state_spi() {
|
||||
spi_txbuf[i] = 0;
|
||||
spi_rxbuf[i] = 0;
|
||||
}
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
ReopenSPI();
|
||||
headstage_spi_transaction(SPI_BUFFER_SIZE);
|
||||
}
|
||||
@@ -1129,7 +1129,7 @@ static void headstage_neu_state_spi() {
|
||||
|
||||
/* stimulation */
|
||||
case NEU_WRITE_STI_INS:{
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
|
||||
nxt_ins = build_sti_ins(NEULIVE_STATE.config_type, &value); /**< set instruction one by one in order to set all the parameter.*/
|
||||
NEULIVE_STATE.config_type = nxt_ins;
|
||||
@@ -1181,7 +1181,7 @@ static void headstage_neu_state_spi() {
|
||||
value = (0x01 << 23) | (0x2E << 16) | INSTRUCTION.sti_channel;
|
||||
AppendSPITX(0, value);
|
||||
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
NEULIVE_STATE.state = NEU_STI_LED;
|
||||
headstage_spi_transaction(3);
|
||||
break;
|
||||
@@ -1192,7 +1192,7 @@ static void headstage_neu_state_spi() {
|
||||
// value = (0x01 << 23) | (0x2E << 16) | INSTRUCTION.sti_channel;
|
||||
// AppendSPITX(0, value);
|
||||
//
|
||||
// SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
// SPICallBack = ONE_SHOT_SPI;
|
||||
// NEULIVE_STATE.state = NEU_CHECK_STI_CH;
|
||||
// headstage_spi_transaction(3);
|
||||
// break;
|
||||
@@ -1209,7 +1209,7 @@ static void headstage_neu_state_spi() {
|
||||
|
||||
headstage_led_control();
|
||||
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
AppendSPITX(0, 0);
|
||||
headstage_spi_transaction(SPI_BUFFER_SIZE);
|
||||
break;
|
||||
@@ -1220,7 +1220,7 @@ static void headstage_neu_state_spi() {
|
||||
// recv disable sti command
|
||||
if(!(rec_sti_command & ENABLE_STI)){
|
||||
NEULIVE_STATE.state = NEU_STI_INT;
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
|
||||
AppendSPITX(0, 0);
|
||||
headstage_spi_transaction(SPI_BUFFER_SIZE);
|
||||
@@ -1230,7 +1230,7 @@ static void headstage_neu_state_spi() {
|
||||
else if(rec_sti_command & ENABLE_REC){
|
||||
NEULIVE_STATE.state = NEU_WRITE_REC_INS;
|
||||
NEULIVE_STATE.config_type = NEU_WARM_UP;
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
INSTRUCTION.ins_opcode = BIAS_ONE;
|
||||
|
||||
AppendSPITX(0, 0);
|
||||
@@ -1250,7 +1250,7 @@ static void headstage_neu_state_spi() {
|
||||
// terminate stimulation
|
||||
case NEU_STI_INT: {
|
||||
NEULIVE_STATE.state = NEU_STI_INT_TWICE;
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
|
||||
value = (0x01 << 23) | (0x2E << 16) | 0;
|
||||
AppendSPITX(0, value);
|
||||
@@ -1260,7 +1260,7 @@ static void headstage_neu_state_spi() {
|
||||
|
||||
case NEU_STI_INT_TWICE: {
|
||||
NEULIVE_STATE.state = NEU_CHECK_STI_INT;
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
|
||||
value = (0x01 << 23) | (0x2E << 16) | 0;
|
||||
AppendSPITX(0, value);
|
||||
@@ -1281,7 +1281,7 @@ static void headstage_neu_state_spi() {
|
||||
|
||||
case NEU_LED:{
|
||||
NEULIVE_STATE.state = NEU_IDLE;
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
|
||||
AppendSPITX(0, 0);
|
||||
headstage_led_control();
|
||||
@@ -1446,7 +1446,7 @@ static uint8_t check_register_value(DBSRegister *dbs_register, uint8_t reg_size,
|
||||
}
|
||||
else{
|
||||
AppendSPITX(0, 0);
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
headstage_spi_transaction(SPI_BUFFER_SIZE);
|
||||
}
|
||||
}
|
||||
@@ -1477,7 +1477,7 @@ static void recording_handle(){
|
||||
headstage_led_control();
|
||||
|
||||
if(rec_sti_command & STATUS_STI){
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
AppendSPITX(0, 0);
|
||||
headstage_spi_transaction(SPI_BUFFER_SIZE);
|
||||
}
|
||||
@@ -1490,7 +1490,7 @@ static void recording_handle(){
|
||||
spi_txbuf[i] = 0;
|
||||
spi_rxbuf[i] = 0;
|
||||
}
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
ReopenSPI();
|
||||
headstage_spi_transaction(SPI_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
+6
-6
@@ -3,15 +3,15 @@
|
||||
#define VERSION_DATE
|
||||
|
||||
#define VERSION_DATE_YEAR 20
|
||||
#define VERSION_DATE_MONTH 11
|
||||
#define VERSION_DATE_DAY 13
|
||||
#define VERSION_DATE_HOUR 18
|
||||
#define VERSION_DATE_MINUTE 30
|
||||
#define VERSION_DATE_MONTH 10
|
||||
#define VERSION_DATE_DAY 26
|
||||
#define VERSION_DATE_HOUR 17
|
||||
#define VERSION_DATE_MINUTE 3
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
#define VERSION_HASH 1cde4cfe026202aae24460eb1cf778477a9828e3
|
||||
#define VERSION_GIT_BRANCH neulive_onchange_central_debug
|
||||
#define VERSION_HASH 764bd9364d7a99761ada31d35af557a39e1d65a4
|
||||
#define VERSION_GIT_BRANCH neulive20_development_onchange_central
|
||||
|
||||
static void get_board_name(char *board_name_ch, uint8 *board_name_int, uint8 name_size){
|
||||
uint8 name_offset = 18;
|
||||
|
||||
+243
-1
@@ -9,9 +9,40 @@
|
||||
#endif
|
||||
|
||||
#include "headstage_dbs_object.h"
|
||||
|
||||
#define NOT_BUF_OFFSET_INIT 8
|
||||
|
||||
#include "headstage_cali_table.h"
|
||||
|
||||
static uint8_t numFFT = 64; // user define
|
||||
static uint8_t step = 32; // which is numFFT/2
|
||||
static uint8_t stageFFT = 6; // which is log2(numFFT)
|
||||
//static int twiddle_real[16] = {10000, 9238, 7071, 3826, 0, -3827, -7072, -9239, -10000, -9239, \
|
||||
// -7072, -3827, -1, 3826, 7071, 9238};
|
||||
//
|
||||
//static int twiddle_imag[16] = { 0, -3827, -7072, -9239, -10000, -9239, -7072, -3827, -1, 3826, \
|
||||
// 7071, 9238, 10000, 9238, 7071, 3826};
|
||||
static int twiddle_real[64] = {10000, 9951, 9807, 9569, 9238, 8819, 8314, 7730, 7071, 6343, \
|
||||
5555, 4713, 3826, 2902, 1950, 980, 0, -981, -1951, -2903, \
|
||||
-3827, -4714, -5556, -6344, -7072, -7731, -8315, -8820, -9239, -9570, \
|
||||
-9808, -9952, -10000, -9952, -9808, -9570, -9239, -8820, -8315, -7731, \
|
||||
-7072, -6344, -5556, -4714, -3827, -2903, -1951, -981, -1, 980,\
|
||||
1950, 2902, 3826, 4713, 5555, 6343, 7071, 7730, 8314, 8819, \
|
||||
9238, 9569, 9807, 9951 };
|
||||
|
||||
static int twiddle_imag[64] = { 0, -981, -1951, -2903, -3827, -4714, -5556, -6344, -7072, -7731, \
|
||||
-8315, -8820, -9239, -9570, -9808, -9952, -10000, -9952, -9808, -9570, \
|
||||
-9239, -8820, -8315, -7731, -7072, -6344, -5556, -4714, -3827, -2903, \
|
||||
-1951, -981, -1, 980, 1950, 2902, 3826, 4713, 5555, 6343, \
|
||||
7071, 7730, 8314, 8819, 9238, 9569, 9807, 9951, 10000, 9951, \
|
||||
9807, 9569, 9238, 8819, 8314, 7730, 7071, 6343, 5555, 4713, \
|
||||
3826, 2902, 1950, 980};
|
||||
|
||||
static void FFT(int* pred_LFP, int* imag_LFP, int numFFT);
|
||||
static void BitReverse(int* BR_Array, int numFFT);
|
||||
static void CLP(int raw_data);
|
||||
static int ADC_U2S( uint16_t unsigned_buff);
|
||||
|
||||
|
||||
static uint8_t not_buf_offset = NOT_BUF_OFFSET_INIT;
|
||||
static uint32_t not_time_stamp = 0;
|
||||
|
||||
@@ -49,10 +80,39 @@ static void headstage_neu_append_notify_data() {
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t borshin_raw;
|
||||
int16_t borshin_a;
|
||||
int16_t borshin_b;
|
||||
uint8_t borshin_sample_rate;
|
||||
int borshin_real;
|
||||
int borshin_compute_data;
|
||||
static uint8_t borshin_sample_count;
|
||||
|
||||
uint8_t not_buf[2];
|
||||
not_buf[0] = (channel & 0x0F) << 4 | (spi_rxbuf[1] & 0x0F);
|
||||
not_buf[1] = spi_rxbuf[2];
|
||||
|
||||
// Borshin FFT start here <<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>----------------------
|
||||
borshin_sample_count = !borshin_sample_count;
|
||||
if (borshin_sample_count){
|
||||
|
||||
borshin_raw = (spi_rxbuf[1]&0x0F)<<8 | spi_rxbuf[2]; // range from [ FFF , 000 ]
|
||||
borshin_a = CaliTable.Ch[channel].Gain[ rec_register_value[REC_CHANNEL_INDEX] ];
|
||||
borshin_b = CaliTable.Ch[channel].Offset[ rec_register_value[REC_CHANNEL_INDEX] ];
|
||||
borshin_real = (borshin_raw - 2048 - borshin_b)*1000/borshin_a; // range from +- someting [ no FFF , 000 ]
|
||||
borshin_compute_data = borshin_real >> 10;
|
||||
borshin_sample_rate = 2000000/10/rec_register_value[REC_ADC_CLOCK_INDEX];
|
||||
// if (borshin_raw<3450&&borshin_raw>600)
|
||||
// headstage_pin_output(PIN_CLP, 1);
|
||||
// else
|
||||
// headstage_pin_output(PIN_CLP, 0);
|
||||
CLP( borshin_compute_data ); // This function input is 12-bit value
|
||||
// the function will buffer 16-point then
|
||||
// perform 16-point FFT.
|
||||
// Afterwards, calculate sum of PSD then
|
||||
// decided if HVS happened. (GPIO_4)
|
||||
// Borshin FFT END here <<<<<<<<<<<<<<<<<<<<----------------------------->>>>>>>>>>>>>>>>>>>>
|
||||
}
|
||||
uint8_t data_size = headstage_notify_append_data(not_buf);
|
||||
|
||||
if (data_size >= BLE_NOT_BUFF_SIZE) {
|
||||
@@ -108,3 +168,185 @@ static uint8_t headstage_notify_append_data(uint8_t *data_value) {
|
||||
}
|
||||
|
||||
#endif // HEADSTAGE_NOTIFY_TDC4VAF2_H
|
||||
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* @fn FFT
|
||||
*
|
||||
* @brief TI Cortex M3 doesn't have floating-point ALU, we have to do
|
||||
* fixed-point FFT. And in-place FFT because lack of RAM.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
static void FFT(int* pred_LFP, int* imag_LFP, int numFFT){
|
||||
// testing_sig = !testing_sig;
|
||||
// uint8_t stageFFT = 6; // static global log2(numFFT)
|
||||
int l;
|
||||
int product_real, product_imag;
|
||||
int upfly_real, upfly_imag;
|
||||
int downfly_real, downfly_imag;
|
||||
|
||||
for (int i=0; i<stageFFT; i++){
|
||||
l = 1<<i;
|
||||
for (int j=0; j<numFFT; j+=2*l){
|
||||
for (int k=0; k<l; k++){
|
||||
//printf("stage = %d , butterfly_top = %d , butterfly_down = %d , twiddle[%d] \n", i, j+k, j+k+l, NFFT*(k)/2/l);
|
||||
product_real = pred_LFP[j+k+l] * twiddle_real[numFFT*(k)/2/l] \
|
||||
- imag_LFP[j+k+l] * twiddle_imag[numFFT*(k)/2/l];
|
||||
product_imag = pred_LFP[j+k+l] * twiddle_imag[numFFT*(k)/2/l] \
|
||||
+ imag_LFP[j+k+l] * twiddle_real[numFFT*(k)/2/l];
|
||||
|
||||
product_real = product_real/10000; // left shift number =10 which is up to Int_twiddle-factor
|
||||
product_imag = product_imag/10000;
|
||||
|
||||
upfly_real = pred_LFP[j+k] + product_real;
|
||||
upfly_imag = imag_LFP[j+k] + product_imag;
|
||||
|
||||
downfly_real = pred_LFP[j+k] - product_real;
|
||||
downfly_imag = imag_LFP[j+k] - product_imag;
|
||||
|
||||
pred_LFP[j+k] = upfly_real;
|
||||
imag_LFP[j+k] = upfly_imag;
|
||||
|
||||
pred_LFP[j+k+l] = downfly_real;
|
||||
imag_LFP[j+k+l] = downfly_imag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn ADC_U2S
|
||||
*
|
||||
* @brief ADC sample data in 12-bit which is FFF~000, but for FFT
|
||||
* it needs to be pulled back to +7FF to -7FF. These is based
|
||||
* on simulation result, which is like the function ADC_ISR()
|
||||
* in Ramesh or Remy's code. [ ADC_unsigned_2_signed ]
|
||||
*
|
||||
* @param unsigned 16-bit input
|
||||
*
|
||||
* @return signed 16-bit output ----_0000_0000_0000 ~ ----_1000_0000_0000
|
||||
*/
|
||||
static int ADC_U2S( uint16_t unsigned_buff){
|
||||
|
||||
// 0x0FFF ~ 0x0000 (16-bit unsigned)
|
||||
int output; // 0x07FF-0x0000 ~ 0x0FFF-0x0800
|
||||
// int is 32-bit 0x0000_0000
|
||||
if ( unsigned_buff >= 0x00000800)
|
||||
output = unsigned_buff - 0x00000800;
|
||||
else
|
||||
output = unsigned_buff | 0xFFFFF800;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn BitReverse
|
||||
*
|
||||
* @brief Do array Bit-Reverse before perform FFT
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
static void BitReverse(int* BR_Array, int numFFT){
|
||||
|
||||
|
||||
// This BIR specify for 7-bit (0000_0000 ~ 0111_1111)
|
||||
uint8_t n=0;
|
||||
int tmp;
|
||||
|
||||
// for (uint8_t i=0; i<numFFT; i++){
|
||||
// n = i; // printf ("%d %d\n",i,n);
|
||||
// n = (n&0x0f)<<4 | (n&0xf0)>>4; // 0123_4567 -> 4567_0123
|
||||
// n = (n&0x33)<<2 | (n&0xcc)>>2; // 4567_0123 -> 6745_2301
|
||||
// n = (n&0xaa)<<2 | (n&0x55)>>1; // 7856_3412 -> 7654_3210
|
||||
// n = n >> 1; // 7654_3210 -> 0765_4321
|
||||
// if (n>i){
|
||||
// tmp = BR_Array[n];
|
||||
// BR_Array[n] = BR_Array[i];
|
||||
// BR_Array[i] = tmp;
|
||||
// }
|
||||
// }
|
||||
|
||||
// This BIR specify for 6-bit (0000_0000 ~ 0011_1111)
|
||||
for (uint8_t i=0; i<numFFT; i++){
|
||||
n = i; // printf ("%d %d\n",i,n);
|
||||
n = (n&0x07)<<3 | (n)>>3; // 0012_3456 -> 0045_6123
|
||||
n = (n&0x09)<<2 | (n&0x36)>>1; // 0045_6123 -> 0064_5312
|
||||
n = (n&0x09)<<1 | (n&0x12)>>1 | (n&0x24); // 0064_5312 -> 0065_4321
|
||||
if (n>i){
|
||||
tmp = BR_Array[n];
|
||||
BR_Array[n] = BR_Array[i];
|
||||
BR_Array[i] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
} // END Bit Reverse Order Sort
|
||||
|
||||
/*********************************************************************
|
||||
* @fn CLP ( Closed LooP )
|
||||
*
|
||||
* @brief
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
static void CLP(int signed_real_data){
|
||||
|
||||
int signed_buff;
|
||||
static int accumu_sum;
|
||||
static int x_in[64];
|
||||
static int real[64];
|
||||
static int imag[64];
|
||||
static int count;
|
||||
int abs_tmp;
|
||||
|
||||
// signed_buff = ADC_U2S(unsigned_real_data);
|
||||
x_in[count] = signed_real_data;
|
||||
real[count] = signed_real_data;
|
||||
imag[count] = 0;
|
||||
count++;
|
||||
if (count >= numFFT){
|
||||
BitReverse( real, numFFT);
|
||||
FFT( real, imag, numFFT);
|
||||
abs_tmp=0;
|
||||
accumu_sum = 0;
|
||||
for ( int i=0; i<numFFT; i++){
|
||||
accumu_sum = accumu_sum + (real[i]*real[i]+imag[i]*imag[i]);
|
||||
if (i>0){
|
||||
if (i==1){
|
||||
abs_tmp = real[i]*real[i]+imag[i]*imag[i];
|
||||
}
|
||||
real[i-1] = x_in[i];
|
||||
imag[i-1] = 0;
|
||||
x_in[i-1] = x_in[i];
|
||||
}
|
||||
}
|
||||
int flag;
|
||||
flag = abs_tmp*100/(accumu_sum>>1);
|
||||
if (flag > 62 && flag < 65 ){
|
||||
headstage_pin_output(PIN_CLP, 1);
|
||||
}
|
||||
else {
|
||||
headstage_pin_output(PIN_CLP, 0);
|
||||
}
|
||||
// if (abs_tmp > 300000 ){
|
||||
// headstage_pin_output(PIN_CLP, 1);
|
||||
// }
|
||||
// else {
|
||||
// headstage_pin_output(PIN_CLP, 0);
|
||||
// }
|
||||
count--;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
+4
-2
@@ -29,7 +29,8 @@
|
||||
#define PIN_LED_CLK IOID_1 // SPI1 clock
|
||||
#define PIN_DC_DC IOID_2 // STI select need
|
||||
#define PIN_EN_ADC_SPI_CLK IOID_3 //
|
||||
#define PIN_BATT_HALF IOID_4 //
|
||||
//#define PIN_BATT_HALF IOID_4 //
|
||||
#define PIN_CLP IOID_4 // cDBS detect HVS LED::also added in config table
|
||||
#define PIN_SPI_MISO IOID_7 //
|
||||
#define PIN_SPI_MOSI IOID_8 //
|
||||
#define PIN_SPI_CS IOID_9 //
|
||||
@@ -77,7 +78,8 @@ static PIN_Config headstage_pin_configuration[] = { //
|
||||
PIN_RESET | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
PIN_EN_ADC_SPI_CLK | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
PIN_DC_DC | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
PIN_BATT_HALF | PIN_INPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
PIN_CLP | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, // cDBS detect HVS LED::added in config table
|
||||
// PIN_BATT_HALF | PIN_INPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
PIN_STI_CLK | PIN_INPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
// TODO : add PIN_IRQ for STI clock to detect STI status (update LED & resend STI command if failed before)
|
||||
PIN_TERMINATE};
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ static void MCUReset(){
|
||||
spi_txbuf[i] = 0;
|
||||
spi_rxbuf[i] = 0;
|
||||
}
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
ReopenSPI();
|
||||
|
||||
for(int i=0 ; i<SPI_LED_BUFF_SIZE ; i++){
|
||||
|
||||
+3
-3
@@ -143,7 +143,7 @@ static void headstage_spi_callback(SPI_Handle handle, SPI_Transaction* transacti
|
||||
break;
|
||||
}
|
||||
case FLUSH_BUFFER2:{
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
for(int i=0 ; i<SPI_BUFFER_SIZE ; i++){
|
||||
spi_txbuf[i] = 0x00;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ static void headstage_spi_callback(SPI_Handle handle, SPI_Transaction* transacti
|
||||
// headstage_spi_transaction(SPI_BUFFER_SIZE);
|
||||
break;
|
||||
}
|
||||
case CONTI_SPI_WITH_FLUSH:{
|
||||
case ONE_SHOT_SPI:{
|
||||
SPICallBack = FLUSH_BUFFER;
|
||||
for(int i=0 ; i<SPI_BUFFER_SIZE ; i++){
|
||||
spi_txbuf[i] = 0x00;
|
||||
@@ -172,7 +172,7 @@ static void headstage_spi_callback(SPI_Handle handle, SPI_Transaction* transacti
|
||||
}
|
||||
|
||||
case CLOSE_SPI:{
|
||||
SPICallBack = CONTI_SPI_WITH_FLUSH;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
SPI_close(headstage_spi_handle);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user