Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a82ad36975 | |||
| 2320d5b757 | |||
| db02c38a47 | |||
| 550b3c1158 | |||
| d6070848b6 | |||
| 0eecf13936 | |||
| 4dd471961a | |||
| 3021f65838 | |||
| d355defa2d | |||
| 9f3f3335fc | |||
| 0c5632fe30 | |||
| 2a4924c5b2 | |||
| 19ec8c4d6f | |||
| a232f2d795 | |||
| 3090e2b4ea |
+14
-40
@@ -319,28 +319,24 @@ static bool build_sti_cur_instruction(uint8_t sti_channel, uint32_t* value) {
|
||||
*value = (0x01 << 23) | (op_neu << 16) | (INSTRUCTION.sti_t2[sti_channel] & 0x3F << 10) | (INSTRUCTION.sti_t1[sti_channel]);
|
||||
INSTRUCTION.ins_opcode = T_ND;
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case T_ND: {
|
||||
op_neu = sti_channel * 4 + 2;
|
||||
*value = (0x01 << 23) | (op_neu << 16) | (INSTRUCTION.sti_t4[sti_channel] & 0x03 << 14) | (INSTRUCTION.sti_t3[sti_channel] << 6) | (INSTRUCTION.sti_t2[sti_channel] & 0x03C0);
|
||||
INSTRUCTION.ins_opcode = T_RD;
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case T_RD: {
|
||||
op_neu = sti_channel * 4 + 3;
|
||||
*value = (0x01 << 23) | (op_neu << 16) | (INSTRUCTION.sti_t4[sti_channel] >> 2) & 0x7FFF;
|
||||
INSTRUCTION.ins_opcode = T_FT;
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case T_FT: {
|
||||
op_neu = sti_channel * 4 + 4;
|
||||
*value = (0x01 << 23) | (op_neu << 16) | (INSTRUCTION.sti_t5[sti_channel]) & 0x03FF;
|
||||
INSTRUCTION.ins_opcode = STI_CYCLE;
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case STI_CYCLE: {
|
||||
op_neu = (sti_channel / 2) + 42;
|
||||
@@ -351,12 +347,10 @@ static bool build_sti_cur_instruction(uint8_t sti_channel, uint32_t* value) {
|
||||
else
|
||||
*value = (0x01 << 23) | (op_neu << 16) | (INSTRUCTION.current_sti_cycle[sti_channel + 1] << 8) | (INSTRUCTION.current_sti_cycle[sti_channel]);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
INSTRUCTION.ins_opcode = T_ST;
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -372,23 +366,19 @@ static bool build_sti_volt(uint32_t* value) {
|
||||
*value = (0x01 << 23) | (0x25 << 16) | INSTRUCTION.sti_amplitude_h;
|
||||
INSTRUCTION.ins_opcode = LOW_SIDE;
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case LOW_SIDE: {
|
||||
*value = (0x01 << 23) | (0x26 << 16) | INSTRUCTION.sti_amplitude_l;
|
||||
INSTRUCTION.ins_opcode = VOLT_MODE_AMP;
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case VOLT_MODE_AMP: {
|
||||
*value = (0x01 << 23) | (0x27 << 16) | INSTRUCTION.voltage_sti_amplitude;
|
||||
INSTRUCTION.ins_opcode = BIAS_ONE;
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -404,17 +394,14 @@ static bool build_amp_bias(uint32_t* value) {
|
||||
*value = (0x01 << 23) | (0x39 << 16) | NEU_LNA_BIAS_ONE;
|
||||
INSTRUCTION.ins_opcode = BIAS_TWO;
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case BIAS_TWO: {
|
||||
*value = (0x01 << 23) | (0x3A << 16) | NEU_LNA_BIAS_TWO;
|
||||
INSTRUCTION.ins_opcode = BIAS_TWO;
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -445,17 +432,20 @@ static void headstage_init() {
|
||||
/**
|
||||
* @fn headstage_neu_append_notify_data
|
||||
*/
|
||||
|
||||
#define CHANNEL_VALID (INSTRUCTION.recording_channel & (0x0001 << channel))
|
||||
static void headstage_neu_append_notify_data() {
|
||||
uint8_t not_buf[3];
|
||||
// not_buf[0] = (spi_rxbuf[0] << 4) | spi_rxbuf[1];
|
||||
// not_buf[1] = spi_rxbuf[2];
|
||||
|
||||
not_buf[0] = spi_rxbuf[0]; // ch
|
||||
uint8_t channel = spi_rxbuf[0];
|
||||
if(!CHANNEL_VALID || (channel > 15)){
|
||||
// illegal channel
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t not_buf[3];
|
||||
not_buf[0] = channel; // ch
|
||||
not_buf[1] = spi_rxbuf[1];
|
||||
not_buf[2] = spi_rxbuf[2];
|
||||
|
||||
|
||||
// not_buf[1] = (INSTRUCTION.recording_channel | 0xFF00) >> 8;
|
||||
// not_buf[2] = (INSTRUCTION.recording_channel | 0x00FF);
|
||||
|
||||
@@ -703,8 +693,8 @@ static void headstage_update_ris_instruction(uint8_t ins_len, uint8_t* instructi
|
||||
INSTRUCTION.vgr_intp = 16;
|
||||
INSTRUCTION.vgr_intn = 16;
|
||||
INSTRUCTION.vgr_int_old = 16;
|
||||
INSTRUCTION.recording_channel = 0b0000000010000000;
|
||||
INSTRUCTION.adc_clock_ratio = 100;
|
||||
INSTRUCTION.recording_channel = 0b0000000000000010;
|
||||
INSTRUCTION.adc_clock_ratio = 200;
|
||||
INSTRUCTION.sys_clk_ratio = 10;
|
||||
INSTRUCTION.sti_clock_ratio = 10;
|
||||
INSTRUCTION.amplifier_gain = 0;
|
||||
@@ -976,7 +966,6 @@ static uint8_t build_neu_ins_config(uint8_t config_type, uint32_t* value) {
|
||||
} else {
|
||||
return NEU_SET_STI_CUR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NEU_SET_STI_VOLT: {
|
||||
done = build_sti_volt(value);
|
||||
@@ -985,55 +974,45 @@ static uint8_t build_neu_ins_config(uint8_t config_type, uint32_t* value) {
|
||||
} else {
|
||||
return NEU_SET_STI_VOLT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NEU_SET_POLARITY: {
|
||||
*value = (0x01 << 23) | (0x28 << 16) | INSTRUCTION.current_sti_polarity;
|
||||
return NEU_SET_STI_CLK;
|
||||
break;
|
||||
}
|
||||
case NEU_SET_STI_CLK: {
|
||||
*value = (0x01 << 23) | (0x34 << 16) | INSTRUCTION.sti_clock_ratio;
|
||||
return NEU_SET_STI_MODE;
|
||||
break;
|
||||
}
|
||||
// case NEU_SET_ARBITRARY: {
|
||||
// *value = (0x01 << 23) | (0x36 << 16) | INSTRUCTION.arbitrary_en;
|
||||
// return NEU_SET_ARB_INDEX;
|
||||
// break;
|
||||
// }
|
||||
// case NEU_SET_ARB_INDEX: {
|
||||
// *value = (0x01 << 23) | (0x37 << 16) | INSTRUCTION.arbitrary_index;
|
||||
// return NEU_SET_STI_MODE;
|
||||
// break;
|
||||
// }
|
||||
case NEU_SET_STI_MODE: {
|
||||
*value = (0x01 << 23) | (0x38 << 16) | (INSTRUCTION.sti_mode << 2) | (INSTRUCTION.sti_h_bridge << 1) | (INSTRUCTION.sti_ref);
|
||||
return NEU_SET_GENERAL_EN;
|
||||
break;
|
||||
}
|
||||
|
||||
/* These are recording parameter */
|
||||
case NEU_SET_GENERAL_EN: {
|
||||
*value = (0x01 << 23) | (0x2F << 16) | NEU_GENERAL_EN;
|
||||
return NEU_SET_REC_CHANNEL;
|
||||
break;
|
||||
}
|
||||
case NEU_SET_REC_CHANNEL: {
|
||||
*value = (0x01 << 23) | (0x30 << 16) | INSTRUCTION.recording_channel;
|
||||
// *value = (0x01 << 23) | (0x30 << 16) | 0b0000000001000000;
|
||||
return NEU_SET_AMP_GAIN;
|
||||
break;
|
||||
}
|
||||
case NEU_SET_AMP_GAIN: {
|
||||
*value = (0x01 << 23) | (0x31 << 16) | INSTRUCTION.amplifier_gain;
|
||||
return NEU_SET_ADC_CLK;
|
||||
break;
|
||||
}
|
||||
// case NEU_SET_SYS_CLK: {
|
||||
// *value = (0x01 << 23) | (0x32 << 16) | INSTRUCTION.sys_clk_ratio;
|
||||
// return NEU_SET_ADC_CLK;
|
||||
// break;
|
||||
// }
|
||||
case NEU_SET_ADC_CLK: {
|
||||
if(INSTRUCTION.adc_clock_ratio < 28){
|
||||
@@ -1042,7 +1021,6 @@ static uint8_t build_neu_ins_config(uint8_t config_type, uint32_t* value) {
|
||||
*value = (0x01 << 23) | (0x33 << 16) | INSTRUCTION.adc_clock_ratio;
|
||||
// *value = (0x01 << 23) | (0x33 << 16) | 0x00C8;
|
||||
return NEU_SET_AMP_BIAS;
|
||||
break;
|
||||
}
|
||||
case NEU_SET_AMP_BIAS: {
|
||||
done = build_amp_bias(value);
|
||||
@@ -1057,22 +1035,18 @@ static uint8_t build_neu_ins_config(uint8_t config_type, uint32_t* value) {
|
||||
else{
|
||||
return NEU_SET_AMP_BIAS;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// case NEU_SET_CHOPPER: {
|
||||
// *value = (0x01 << 23) | (0x3B << 16) | INSTRUCTION.chopper_ratio;
|
||||
// return NEU_SETUP_DONE;
|
||||
// break;
|
||||
// }
|
||||
// enable stimulate
|
||||
case NEU_SET_STI_CHANNEL: {
|
||||
*value = (0x01 << 23) | (0x2E << 16) | INSTRUCTION.sti_channel;
|
||||
return NEU_SETUP_DONE;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return NEU_SET_STI_CUR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1125,9 +1099,9 @@ static void headstage_neu_state_spi() {
|
||||
break;
|
||||
}
|
||||
case NEU_READ_DATA: {
|
||||
// headstage_neu_append_notify_data();
|
||||
SimpleProfile_SetParameter(BLE_CDR_BUFF_CHAR, SPI_RX_SIZE, spi_rxbuf);
|
||||
headstage_spi_transaction(SPI_RX_SIZE);
|
||||
headstage_neu_append_notify_data();
|
||||
// SimpleProfile_SetParameter(BLE_CDR_BUFF_CHAR, SPI_BUFFER_SIZE, spi_rxbuf);
|
||||
headstage_spi_transaction(SPI_BUFFER_SIZE);
|
||||
break;
|
||||
}
|
||||
case NEU_SINGLE_INS_READ: {
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ static SPI_Transaction spi_transaction;
|
||||
spi_parameter.bitRate = 12000000; \
|
||||
spi_parameter.transferTimeout = 1000; \
|
||||
spi_parameter.dataSize = 8; \
|
||||
spi_parameter.frameFormat = SPI_POL0_PHA0; \
|
||||
spi_parameter.frameFormat = SPI_POL0_PHA1; \
|
||||
spi_handle = SPI_open(Board_SPI0, &spi_parameter); \
|
||||
} while (0)
|
||||
|
||||
|
||||
+2
-1
@@ -69,7 +69,8 @@
|
||||
#define Board_SPI0_MISO PIN_SPI_MISO
|
||||
#define Board_SPI0_MOSI PIN_SPI_MOSI
|
||||
#define Board_SPI0_CLK PIN_SPI_CLK
|
||||
#define Board_SPI0_CSN PIN_SPI_CS
|
||||
//#define Board_SPI0_CSN PIN_SPI_CS
|
||||
#define Board_SPI0_CSN PIN_UNASSIGNED
|
||||
|
||||
/*
|
||||
* SPI1 interface work with LED
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
#define SPI_RX_SIZE 9
|
||||
|
||||
static uint8_t spi_txbuf[SPI_BUFFER_SIZE] = {0};
|
||||
static uint8_t spi_rxbuf[SPI_RX_SIZE] = {0};
|
||||
static uint8_t spi_rxbuf[SPI_BUFFER_SIZE] = {0};
|
||||
|
||||
static SPI_Handle headstage_spi_handle = NULL;
|
||||
|
||||
|
||||
+17
-18
@@ -153,7 +153,7 @@
|
||||
#define SBP_TASK_PRIORITY 1
|
||||
|
||||
#ifndef SBP_TASK_STACK_SIZE
|
||||
#define SBP_TASK_STACK_SIZE 1024
|
||||
#define SBP_TASK_STACK_SIZE 844
|
||||
#endif
|
||||
|
||||
// Internal Events for RTOS application
|
||||
@@ -408,9 +408,9 @@ static void SimpleBLEPeripheral_init(void) {
|
||||
// Register for GATT local events and ATT Responses pending for transmission
|
||||
GATT_RegisterForMsgs(self);
|
||||
|
||||
HCI_LE_ReadMaxDataLenCmd();
|
||||
|
||||
HCI_LE_WriteSuggestedDefaultDataLenCmd(251, 2120); // this is used for data length extension
|
||||
// HCI_LE_ReadMaxDataLenCmd();
|
||||
//
|
||||
// HCI_LE_WriteSuggestedDefaultDataLenCmd(251, 2120); // this is used for data length extension
|
||||
|
||||
}
|
||||
|
||||
@@ -581,19 +581,19 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
|
||||
ICall_freeMsg(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
// If RTOS queue is not empty, process app message.
|
||||
while (!Queue_empty(application_message_queue)) {
|
||||
sbpEvt_t *message = (sbpEvt_t *)Util_dequeueMsg(application_message_queue);
|
||||
if (message) {
|
||||
// Process message.
|
||||
SimpleBLEPeripheral_processAppMsg(message);
|
||||
|
||||
// If RTOS queue is not empty, process app message.
|
||||
while (!Queue_empty(application_message_queue)) {
|
||||
sbpEvt_t *message = (sbpEvt_t *)Util_dequeueMsg(application_message_queue);
|
||||
if (message) {
|
||||
// Process message.
|
||||
SimpleBLEPeripheral_processAppMsg(message);
|
||||
|
||||
// Free the space from the message.
|
||||
ICall_free(message);
|
||||
}
|
||||
// Free the space from the message.
|
||||
ICall_free(message);
|
||||
}
|
||||
}
|
||||
|
||||
if (EVENT_MASK > 0) {
|
||||
headstage_event_handle();
|
||||
}
|
||||
@@ -676,8 +676,8 @@ static uint8_t SimpleBLEPeripheral_processGATTMsg(gattMsgEvent_t *message) {
|
||||
|
||||
} else if (message->method == ATT_MTU_UPDATED_EVENT) {
|
||||
// MTU size updated
|
||||
headstage_debug_buffer[10] = 0xff;
|
||||
headstage_set_debug_information();
|
||||
// headstage_debug_buffer[10] = 0xff;
|
||||
// headstage_set_debug_information();
|
||||
} else if (message->method == ATT_HANDLE_VALUE_CFM) {
|
||||
// quick pass
|
||||
}
|
||||
@@ -823,7 +823,7 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
|
||||
uint8_t numActive = 0;
|
||||
numActive = linkDB_NumActive();
|
||||
|
||||
headstage_led_color(COLOR_CYAN);
|
||||
headstage_led_color(COLOR_RED);
|
||||
|
||||
uint16_t cxnHandle;
|
||||
uint16_t requestedPDUSize = 251; // payload = 251 - 7 = 244 byte
|
||||
@@ -839,7 +839,6 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
|
||||
uint8_t peerAddress[B_ADDR_LEN];
|
||||
GAPRole_GetParameter(GAPROLE_CONN_BD_ADDR, peerAddress);
|
||||
}
|
||||
flag_notify(EVT_CONNECTED);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user