Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5cb9be51f2 | |||
| f4130016bd |
+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