Compare commits

..

10 Commits

Author SHA1 Message Date
weiting2 226f38bbba RIS REC with purple led 2020-08-03 17:43:09 +08:00
weiting2 f4861bb6cb CIS version with purple led 2020-08-03 14:04:40 +08:00
weiting2 c29273f7e6 using real data format 2020-07-31 10:39:40 +08:00
weiting2 f3391fe63b 4k with data process 2020-07-22 10:16:01 +08:00
weiting2 332e8a127f 8k SR without data process or 4k with data process 2020-07-21 16:25:36 +08:00
weiting2 ab83ab2ce0 8k SR without data process or 4k with data process 2020-07-21 16:13:09 +08:00
weiting2 498a3aceb6 modify get_date script for linux version CCS 2020-07-20 17:50:32 +08:00
weiting2 41c6cb2964 testing data rate 2020-07-20 16:53:32 +08:00
weiting2 33c3db2601 linux version CCS. test central 2020-07-17 17:43:35 +08:00
weiting2 60c885a625 linux version CCS. test central 2020-07-17 17:34:00 +08:00
8 changed files with 132 additions and 49 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
#folder=$($path | awk -F"/" '{$NF}')
folder=$(basename "$(pwd)")
if [ "$folder" == "ti" ] ; then
if [ "$folder" == "ti" ]; then
year=$(date +%-y)
month=$(date +%-m)
day=$(date +%-d)
@@ -27,14 +27,14 @@ static void SendCaliValue(uint8_t CaliNumber){
// ch = 2 * (CaliNumber % 4);
// uint8_t gain_level = CaliNumber / 4; // 0:gain, 1:offset
uint8_t channel_number = 8, index = 2;
uint8_t channel_number = 8, index = 1;
uint8_t gain_level = 0;
if(CaliNumber < 4){
gain_level = CaliNumber;
}
cali_buf[1] = CHIP_ID;
cali_buf[0] = CHIP_ID;
for(int i=0 ; i<channel_number ; i++){
cali_buf[index++] = (uint8_t) (CaliTable.Ch[i].Gain[gain_level] >> 8) & 0xFF;
cali_buf[index++] = (uint8_t) CaliTable.Ch[i].Gain[gain_level] & 0x00FF;
@@ -42,8 +42,9 @@ static void SendCaliValue(uint8_t CaliNumber){
cali_buf[index++] = (uint8_t) CaliTable.Ch[i].Offset[gain_level] & 0x00FF;
}
cali_buf[0] = index;
// for(int i=1 ; i<BLE_CDR_BUFF_SIZE ; i++){
// cali_buf[i] = i;
// }
SimpleProfile_SetParameter(BLE_CDR_BUFF_CHAR, index, cali_buf);
}
@@ -169,7 +169,7 @@ static void FlushNotify();
#define EVT_NEU_REG_SPI 0x0008 /** register spi event */
/** clock setting */
#define NEU_SYS_CLK 2000000 /**< 10Mhz */
#define NEU_SYS_CLK 4000000 /**< 10Mhz */
#define NEU_POLY_R_CLK 1000 /**< 1khz */
#define NEU_SPI_FREQ NEU_SYS_CLK/10 /**< 1Mhz */ // should be NEU_SYS_CLK/10
//#define NEU_LED_FREQ 1000000 /**< 1Mhz */
@@ -299,6 +299,12 @@ typedef enum{
#include "headstage_rec_ins.h"
#include "headstage_sti_ins.h"
/* Debug function and parameter
*
*/
static uint8_t data_rate_counter = 0;
static uint32_t msg_counter = 0;
static void SimpleBLEPeripheral_blastData();
/*
* todo: need to define some procedure to detect this device status
@@ -537,6 +543,7 @@ static void headstage_update_ris_instruction(uint8_t ins_len, uint8_t* instructi
}
case NEU_REC_PARAM: {
headstage_led_color(COLOR_MAGENTA);
uint8_t vgrp = instruction[0] & 0x1F;
uint8_t vgrn = (instruction[1] & 0xF8) >> 3;
uint8_t vgr_int_old = ((instruction[1] & 0x07) << 2) | ((instruction[2] & 0xC0) >> 6);
@@ -567,8 +574,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 = 0b0000000001000010;
INSTRUCTION.adc_clock_ratio = 50;
INSTRUCTION.recording_channel = 0b0000000000000010;
INSTRUCTION.adc_clock_ratio = 100; // sample rate = [NEU_SYS_CLK / (sys_clk_ratio = 10)] / adc_clock_ratio
INSTRUCTION.sys_clk_ratio = 10;
INSTRUCTION.sti_clock_ratio = 10;
INSTRUCTION.amplifier_gain = 0;
@@ -590,7 +597,7 @@ static void headstage_update_ris_instruction(uint8_t ins_len, uint8_t* instructi
INSTRUCTION.current_sti_cycle[0] = 100;
INSTRUCTION.current_sti_cycle[1] = 100;
INSTRUCTION.current_sti_cycle[8] = 10; // ch8 is volt ch
INSTRUCTION.sti_channel = 0b0000000000000011; // 0bxxxx_xxxv_cccc_cccc, c = current; v = volt, x = don't care
INSTRUCTION.sti_channel = 0b0000000000000000; // 0bxxxx_xxxv_cccc_cccc, c = current; v = volt, x = don't care
INSTRUCTION.arbitrary_en = 0;
INSTRUCTION.arbitrary_index = 0;
INSTRUCTION.sti_mode = 0; // 1 = continuous mode; 0 = limit mode
@@ -820,10 +827,6 @@ static void headstage_update_cis_instruction(uint8_t cis_oper) {
switch (cis_oper) {
case CIS_NOP: {
// nothing
for(int i=0 ; i<BLE_CDR_SAMLL_SIZE ; i++ ){
cdr_buf[i] = 0;
}
cdr_buf[0] = _B_4b4b(CIS_NOP, CHIP_ID);
cdr_buf[1] = _B_4b4b(CDR_SUCCESS, 0);
@@ -832,14 +835,9 @@ static void headstage_update_cis_instruction(uint8_t cis_oper) {
}
//#ifdef HEADSTAGE_CIS_VOLT_H
case CIS_VOLT: {
for(int i=0 ; i<BLE_CDR_SAMLL_SIZE ; i++ ){
cdr_buf[i] = 0;
}
cdr_buf[0] = BLE_CDR_SAMLL_SIZE; // data length
cdr_buf[1] = CIS_VOLT | CHIP_ID;
cdr_buf[2] = headstage_battery_volt1();
cdr_buf[3] = headstage_battery_volt2();
cdr_buf[0] = CIS_VOLT | CHIP_ID;
cdr_buf[1] = headstage_battery_volt1();
cdr_buf[2] = headstage_battery_volt2();
SimpleProfile_SetParameter(BLE_CDR_BUFF_CHAR, BLE_CDR_SAMLL_SIZE, cdr_buf);
@@ -871,40 +869,30 @@ static void headstage_update_cis_instruction(uint8_t cis_oper) {
//#endif
case CIS_VERSION:{
for(int i=0 ; i<BLE_CDR_SAMLL_SIZE ; i++ ){
cdr_buf[i] = 0;
}
cdr_buf[0] = BLE_CDR_SAMLL_SIZE;
cdr_buf[1] = VERSION_DATE_YEAR;
cdr_buf[2] = VERSION_DATE_MONTH;
cdr_buf[3] = VERSION_DATE_DAY;
cdr_buf[4] = VERSION_DATE_HOUR;
cdr_buf[5] = VERSION_DATE_MINUTE;
cdr_buf[0] = VERSION_DATE_YEAR;
cdr_buf[1] = VERSION_DATE_MONTH;
cdr_buf[2] = VERSION_DATE_DAY;
cdr_buf[3] = VERSION_DATE_HOUR;
cdr_buf[4] = VERSION_DATE_MINUTE;
uint8_t mac_int[4];
if( strncmp(CaliTable.DeviceName, "BOARD_TEST", 25)){
// has a specific cali data
get_board_name(CaliTable.DeviceName, mac_int, 4);
cdr_buf[6] = mac_int[0];
cdr_buf[7] = mac_int[1];
cdr_buf[5] = mac_int[0];
cdr_buf[6] = mac_int[1];
}
else{
// this board use default cali setting
cdr_buf[6] = 0xAB;
cdr_buf[7] = 0xCD;
cdr_buf[5] = 0xAB;
cdr_buf[6] = 0xCD;
}
SimpleProfile_SetParameter(BLE_CDR_BUFF_CHAR, BLE_CDR_SAMLL_SIZE, cdr_buf);
break;
}
default: {
for(int i=0 ; i<BLE_CDR_SAMLL_SIZE ; i++ ){
cdr_buf[i] = 0;
}
cdr_buf[0] = _B_4b4b(cis_oper, CHIP_ID);
cdr_buf[1] = _B_4b4b(CDR_FAILURE, 0);
@@ -1106,6 +1094,16 @@ static void headstage_neu_state_spi() {
// recording
else{
// for(int i=0 ; i<SPI_BUFFER_SIZE ; i++){
// spi_txbuf[i] = 0;
// }
//
// if(data_rate_counter >= 63){
// data_rate_counter = 0;
// SimpleBLEPeripheral_blastData();
// }
// data_rate_counter ++;
// headstage_spi_transaction(3);
headstage_neu_append_notify_data();
AppendSPITX(0, 0);
headstage_spi_transaction(SPI_BUFFER_SIZE);
@@ -1292,4 +1290,81 @@ static void headstage_neu_state_spi() {
}
}
/*********************************************************************
* @fn SimpleBLEPeripheral_blastData
*
* @brief Sends ATT notifications in a tight while loop to demo
* throughput
*
* @param none
*
* @return none
*/
static void SimpleBLEPeripheral_blastData() {
uint32_t not_time_stamp = headstage_time_stamp_us();
headstage_notify_buffer[0] = (msg_counter >> 24) & 0xFF;
headstage_notify_buffer[1] = (msg_counter >> 16) & 0xFF;
headstage_notify_buffer[2] = (msg_counter >> 8) & 0xFF;
headstage_notify_buffer[3] = msg_counter & 0xFF;
headstage_notify_buffer[4] = 0xFB;
headstage_notify_buffer[5] = not_time_stamp & 0xFF;
headstage_notify_buffer[6] = (not_time_stamp >> 8) & 0xFF;
headstage_notify_buffer[7] = (not_time_stamp >> 16) & 0xFF;
headstage_notify_buffer[8] = (not_time_stamp >> 24) & 0xFF;
msg_counter++;
SimpleProfile_SetParameter(BLE_NOT_BUFF_CHAR, BLE_NOT_BUFF_SIZE, headstage_notify_buffer);
// Subtract the total packet overhead of ATT and L2CAP layer from notification payload
// uint16_t len = MAX_PDU_SIZE - TOTAL_PACKET_OVERHEAD;
// attHandleValueNoti_t noti;
// bStatus_t status;
// noti.handle = 0x27;
// noti.len = len;
//
// uint32_t not_time_stamp;
//
// // Store hte connection handle for future reference
// uint16_t connectionHandle;
// GAPRole_GetParameter(GAPROLE_CONNHANDLE, &connectionHandle);
//
// not_time_stamp = Timestamp_get32() / 2;
// noti.pValue = (uint8 *)GATT_bm_alloc(connectionHandle, ATT_HANDLE_VALUE_NOTI, GATT_MAX_MTU, &len);
//
// if (noti.pValue != NULL) // if allocated
// {
// // Place index
// noti.pValue[2] = not_time_stamp & 0xFF;
// noti.pValue[3] = (not_time_stamp >> 8) & 0xFF;
// noti.pValue[4] = (not_time_stamp >> 16) & 0xFF;
// noti.pValue[5] = (not_time_stamp >> 24) & 0xFF;
// noti.pValue[6] = 100;
// noti.pValue[7] = 0;
//
// // Attempt to send the notification
// status = GATT_Notification(connectionHandle, &noti, GATT_NO_AUTHENTICATION);
// if (status != SUCCESS) // if noti not sent
// {
//// PIN_setOutputValue(hSbpPins, Board_LED1, Board_LED_ON);
// headstage_led_color(COLOR_RED);
// headstage_led_color(COLOR_BLACK);
// GATT_bm_free((gattMsg_t *)&noti, ATT_HANDLE_VALUE_NOTI);
// } else {
// // Notification is successfully sent, increment counters
//// Display_print0(dispHandle, 4, 0, "success");
//// PIN_setOutputValue(hSbpPins, Board_LED2, Board_LED_ON);
// headstage_led_color(COLOR_BLUE);
// headstage_led_color(COLOR_BLACK);
// msg_counter++;
// }
// } else {
// // bleNoResources was returned
// asm(" NOP ");
// }
// Reset debug pins
// PIN_setOutputValue(hSbpPins, Board_LED1, Board_LED_OFF);
// PIN_setOutputValue(hSbpPins, Board_LED2, Board_LED_OFF);
}
#endif
@@ -4,14 +4,14 @@
#define VERSION_DATE_YEAR 20
#define VERSION_DATE_MONTH 8
#define VERSION_DATE_DAY 14
#define VERSION_DATE_DAY 3
#define VERSION_DATE_HOUR 17
#define VERSION_DATE_MINUTE 34
#define VERSION_DATE_MINUTE 42
// this is NOT the version hash !!
// it's the last version hash
#define VERSION_HASH c347e44536488b3cfaa9e1ed2b4fbcb4513639ea
#define VERSION_GIT_BRANCH Neulive20_developement_linux
#define VERSION_HASH f4861bb6cb427dcb36cb0cb6e8f1c962dbd89fa8
#define VERSION_GIT_BRANCH neulive20_linux_debug
static void get_board_name(char *board_name_ch, uint8 *board_name_int, uint8 name_size){
uint8 name_offset = 18;
@@ -13,6 +13,7 @@
static uint8_t not_buf_offset = NOT_BUF_OFFSET_INIT;
static uint32_t not_time_stamp = 0;
static uint32_t debug_counter = 0;
static void headstage_notify_set_timestamp() {
not_time_stamp = headstage_time_stamp_us();
@@ -20,12 +21,18 @@ static void headstage_notify_set_timestamp() {
headstage_notify_buffer[3] = (not_time_stamp >> 8) & 0xFF;
headstage_notify_buffer[4] = (not_time_stamp >> 16) & 0xFF;
headstage_notify_buffer[5] = (not_time_stamp >> 24) & 0xFF;
// headstage_notify_buffer[2] = (debug_counter >> 24) & 0xFF;
// headstage_notify_buffer[3] = (debug_counter >> 16) & 0xFF;
// headstage_notify_buffer[4] = (debug_counter >> 8) & 0xFF;
// headstage_notify_buffer[5] = debug_counter & 0xFF;
// debug_counter ++;
}
static void headstage_notify_flip_buffer() {
uint8_t data_count = (not_buf_offset - NOT_BUF_OFFSET_INIT) / 3;
headstage_notify_buffer[0] = CHIP_ID;
headstage_notify_buffer[0] = 4;
headstage_notify_buffer[1] = data_count;
not_buf_offset = NOT_BUF_OFFSET_INIT;
@@ -120,17 +120,17 @@
// Maximum connection interval (units of 1.25ms, 800=1000ms) if automatic
// parameter update request is enabled
//#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 6
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 30
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 40
#else //! FEATURE_OAD
// Minimum connection interval (units of 1.25ms, 8=10ms) if automatic
// parameter update request is enabled
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL 80
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL 8
//#define DEFAULT_DESIRED_MIN_CONN_INTERVAL 14
// Maximum connection interval (units of 1.25ms, 8=10ms) if automatic
// parameter update request is enabled
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 80
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 40
//#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 25
#endif // FEATURE_OAD
@@ -82,7 +82,7 @@ extern "C" {
// Length of Characteristic 5 in bytes
#define SIMPLEPROFILE_CHAR1_LEN 2
#define SIMPLEPROFILE_CHAR2_LEN 34
#define SIMPLEPROFILE_CHAR2_LEN 50
#define SIMPLEPROFILE_CHAR3_LEN 20
#define SIMPLEPROFILE_CHAR4_LEN 200
//#define SIMPLEPROFILE_CHAR4_LEN 20