Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5cb9be51f2 | |||
| f4130016bd | |||
| 8ae2e1771c | |||
| 549db3f6d4 | |||
| 54dd4bc643 | |||
| 435acb745b | |||
| 3cf2bb99f7 |
+3
@@ -114,9 +114,11 @@ typedef enum {
|
||||
static bool STI = false;
|
||||
static bool IsFirstData = true;
|
||||
static uint8_t spi_state_counter = 0;
|
||||
static uint8_t check_reg_counter = 0;
|
||||
static bool ConnectState = false;
|
||||
static bool ErrorRestart = false;
|
||||
static SPI_CB_MODE SPICallBack;
|
||||
static uint8 adc_spi_en_switch = 1;
|
||||
|
||||
/*
|
||||
* Let C = command, S = status;
|
||||
@@ -245,6 +247,7 @@ extern ICall_Semaphore semaphore;
|
||||
#define VIS_ASK 0x50
|
||||
#define VIS_INT 0x60
|
||||
#define VIS_FAST_SET 0x70
|
||||
#define VIS_EN_ADC_CLK 0x80
|
||||
#define VIS_CAL 0xA0
|
||||
#define VIS_START 0xC0
|
||||
#define VIS_RST 0xF0
|
||||
|
||||
+9
-9
@@ -14,17 +14,17 @@ static uint8_t check_ins(uint16_t trans_ins){
|
||||
}
|
||||
|
||||
static void check_register(uint8_t register_to_check, uint16_t instruction_to_fit, NEU_WORK_STATE next_state){
|
||||
if(spi_state_counter < 6){
|
||||
if(check_reg_counter < 6){
|
||||
SPICallBack = CONTINUOUS_TRANS;
|
||||
spi_txbuf[0] = register_to_check & 0x7F;
|
||||
spi_txbuf[1] = register_to_check;
|
||||
spi_txbuf[2] = register_to_check;
|
||||
spi_txbuf[1] = NEULIVE_STATE.state;
|
||||
spi_txbuf[2] = check_reg_counter;
|
||||
|
||||
spi_state_counter ++;
|
||||
check_reg_counter ++;
|
||||
headstage_spi_transaction(3);
|
||||
}
|
||||
else{
|
||||
spi_state_counter = 0;
|
||||
check_reg_counter = 0;
|
||||
if(check_ins(instruction_to_fit)){
|
||||
NEULIVE_STATE.state = next_state;
|
||||
SPICallBack = ONE_SHOT_SPI;
|
||||
@@ -163,17 +163,17 @@ static void check_sti_t1_t5(NEU_WORK_STATE next_state){
|
||||
}
|
||||
|
||||
static uint8_t check_sti_register(uint8_t address, uint16_t instruction_to_fit){
|
||||
spi_state_counter = 0;
|
||||
while(spi_state_counter < 6){
|
||||
check_reg_counter = 0;
|
||||
while(check_reg_counter < 6){
|
||||
SPICallBack = READ_REG;
|
||||
spi_txbuf[0] = address & 0x7F;
|
||||
spi_txbuf[1] = address;
|
||||
spi_txbuf[2] = address;
|
||||
|
||||
headstage_spi_transaction(3); // spi_state_counter++ would be executed in SPI callback
|
||||
headstage_spi_transaction(3); // check_reg_counter++ would be executed in SPI callback
|
||||
}
|
||||
|
||||
spi_state_counter = 0;
|
||||
check_reg_counter = 0;
|
||||
|
||||
// success = 1; failed = 0
|
||||
return check_ins(instruction_to_fit);
|
||||
|
||||
+7
-1
@@ -459,7 +459,7 @@ static void headstage_spi_callback(SPI_Handle handle, SPI_Transaction* transacti
|
||||
}
|
||||
|
||||
case READ_REG:{
|
||||
spi_state_counter ++;
|
||||
check_reg_counter ++;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -685,6 +685,12 @@ static void headstage_update_vis_instruction(uint8_t vis_oper) {
|
||||
break;
|
||||
}
|
||||
|
||||
case VIS_EN_ADC_CLK:{
|
||||
adc_spi_en_switch ^= 1;
|
||||
headstage_pin_output(PIN_EN_ADC_SPI_CLK, adc_spi_en_switch);
|
||||
break;
|
||||
}
|
||||
|
||||
case VIS_START: {
|
||||
// for(int i=0 ; i<12 ; i++){
|
||||
// FlushNotify();
|
||||
|
||||
+4
-4
@@ -4,13 +4,13 @@
|
||||
|
||||
#define VERSION_DATE_YEAR 20
|
||||
#define VERSION_DATE_MONTH 7
|
||||
#define VERSION_DATE_DAY 3
|
||||
#define VERSION_DATE_HOUR 16
|
||||
#define VERSION_DATE_MINUTE 3
|
||||
#define VERSION_DATE_DAY 9
|
||||
#define VERSION_DATE_HOUR 10
|
||||
#define VERSION_DATE_MINUTE 16
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
#define VERSION_HASH b10ee4de657a39fc4d8179822d4bf0f2231b3b73
|
||||
#define VERSION_HASH 549db3f6d4f60019e726ba2b4318c2dd968cf3d5
|
||||
#define VERSION_GIT_BRANCH Neulive2.0_developement
|
||||
|
||||
static void get_board_name(char *board_name_ch, uint8 *board_name_int, uint8 name_size){
|
||||
|
||||
+2
@@ -19,6 +19,8 @@ static void MCUReset(){
|
||||
// SPI reset
|
||||
SPI_close(headstage_spi_handle);
|
||||
spi_state_counter = 0;
|
||||
check_reg_counter = 0;
|
||||
|
||||
for(int i=0 ; i<SPI_BUFFER_SIZE ; i++ ){
|
||||
spi_txbuf[i] = 0;
|
||||
spi_rxbuf[i] = 0;
|
||||
|
||||
+62
@@ -803,6 +803,45 @@ static void SimpleBLEPeripheral_stateChangeCB(gaprole_States_t newState) {
|
||||
SimpleBLEPeripheral_enqueueMsg(SBP_STATE_CHANGE_EVT, newState);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn BitReverse
|
||||
*
|
||||
* @brief Change input Array in bit reversed index 0101(5)->1010(10)
|
||||
* cause FFT need Butterfly pairs.
|
||||
*
|
||||
* @param newState - new state (??)
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
static void BitReverse(int BR_array[],int NUM_FFT) {
|
||||
#if (NUM_FFT >= 512)
|
||||
unsigned int swapA, swapB, sw_cnt;
|
||||
#endif
|
||||
|
||||
#if (NUM_FFT <= 256)
|
||||
unsigned int swapA, swapB, sw_cnt;
|
||||
#endif
|
||||
|
||||
|
||||
unsigned char BR_table = [0,4,2,6,1,3,5,7];
|
||||
int TemStore;
|
||||
|
||||
for (sw_cnt=1; sw_cnt<NUM_FFT/2; sw_cnt++){
|
||||
swapA = sw_cnt;
|
||||
swapB = BR_table[sw_cnt] *2;
|
||||
if (swapB > swapA){
|
||||
TemStore = BR_array[swapA];
|
||||
BR_array[swapA] = BR_array[swapB];
|
||||
BR_array[swapB] = TemStore;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SimpleBLEPeripheral_processStateChangeEvt
|
||||
*
|
||||
@@ -820,11 +859,34 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
|
||||
|
||||
GAPRole_GetParameter(GAPROLE_BD_ADDR, ownAddress);
|
||||
|
||||
uint16_t CH1[], CH2[], CH3[], CH4[], CH5[], CH6[], CH7[], CH8[]; // <======= BS 0709
|
||||
|
||||
|
||||
// use 6 bytes of device address for 8 bytes of system ID value
|
||||
systemId[0] = ownAddress[0];
|
||||
systemId[1] = ownAddress[1];
|
||||
systemId[2] = ownAddress[2];
|
||||
|
||||
switch(ch){ // <======= BS 0709
|
||||
case(1):
|
||||
idx = size(CH1);
|
||||
if (idx<6){
|
||||
CH1[idx+1] = dataIN;
|
||||
}
|
||||
else if (idx<FFT_NUM){
|
||||
LFP_tmp = CH1[idx-1]*w1 + CH1[idx-2]*w2 + CH1[idx-3]*w3 + CH1[idx-4]*w4 + CH1[idx-5]*w5;
|
||||
CH1[idx+1] = (LFP_tmp < 0) ? 0 - LFP_tmp : LFP_tmp;
|
||||
}
|
||||
else{
|
||||
BitReverse(CH1);
|
||||
FFT(CH1)
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// set middle bytes to zero
|
||||
systemId[4] = 0x00;
|
||||
systemId[3] = 0x00;
|
||||
|
||||
Reference in New Issue
Block a user