Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f30e22a63 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
#safe table
|
||||
#Thu Feb 20 11:57:56 CST 2020
|
||||
framework.info=0
|
||||
.crc1d527c35.v1
|
||||
@@ -0,0 +1,4 @@
|
||||
#safe table
|
||||
#Thu Feb 20 11:57:56 CST 2020
|
||||
framework.info=1
|
||||
.crc1c901602.v1
|
||||
Binary file not shown.
BIN
Binary file not shown.
+6
-16
@@ -5,26 +5,16 @@
|
||||
|
||||
#include <driverlib/aon_batmon.h>
|
||||
#define MAX_BATTERY_CAPACITY 4200
|
||||
static uint8_t battery_volt = 256;
|
||||
static uint8_t battery_percent = 100;
|
||||
|
||||
static uint8_t headstage_battery_volt1() {
|
||||
static uint8_t headstage_battery_percent() {
|
||||
uint8_t internal_battery_percent;
|
||||
uint32_t internal_batt_sense = AONBatMonBatteryVoltageGet();
|
||||
internal_batt_sense = (internal_batt_sense * 125) >> 5;
|
||||
// internal_batt_sense = (internal_batt_sense * 100) / MAX_BATTERY_CAPACITY;
|
||||
internal_batt_sense = (internal_batt_sense * 100) / MAX_BATTERY_CAPACITY;
|
||||
internal_battery_percent = internal_batt_sense & 0xff;
|
||||
battery_volt = internal_battery_percent;
|
||||
return battery_volt;
|
||||
if (internal_battery_percent < battery_percent) battery_percent = internal_battery_percent;
|
||||
return battery_percent;
|
||||
}
|
||||
|
||||
static uint8_t headstage_battery_volt2() {
|
||||
uint8_t internal_battery_percent;
|
||||
uint32_t internal_batt_sense = AONBatMonBatteryVoltageGet();
|
||||
internal_batt_sense = (internal_batt_sense * 125) >> 5;
|
||||
// internal_batt_sense = (internal_batt_sense * 100) / MAX_BATTERY_CAPACITY;
|
||||
internal_battery_percent = (internal_batt_sense >> 8) & 0xff;
|
||||
battery_volt = internal_battery_percent;
|
||||
return battery_volt;
|
||||
}
|
||||
|
||||
#endif // HEADSTAGE_BATT_H
|
||||
#endif // HEADSTAGE_BATT_H
|
||||
|
||||
+20
-103
@@ -779,7 +779,7 @@ static void headstage_update_vis_instruction(uint8_t vis_oper) {
|
||||
case VIS_STI:
|
||||
if (headstage_state == UMC_STATE_INTERRUPT) { //This if cond. seems only for old version digital core
|
||||
headstage_state = UMC_STATE_INITIAL;
|
||||
INSTRUCTION.channel_pointer = 0;
|
||||
INSTRUCTION.channel_pointer=0;
|
||||
rearrange_channel_mux_table();
|
||||
UMC_STATE.config_type = CONFIG_AMP_MUX;
|
||||
headstage_led_spi_color(COLOR_BLACK);
|
||||
@@ -787,7 +787,7 @@ static void headstage_update_vis_instruction(uint8_t vis_oper) {
|
||||
headstage_spi_ask_transaction(4);
|
||||
} else {
|
||||
headstage_state = UMC_STATE_HANDSHAKE;
|
||||
INSTRUCTION.channel_pointer = 0;
|
||||
INSTRUCTION.channel_pointer=0;
|
||||
rearrange_channel_mux_table();
|
||||
headstage_pwm_start(headstage_system_pwm_handle);
|
||||
headstage_pwm_start(headstage_poly_r_pwm_handle);
|
||||
@@ -803,7 +803,7 @@ static void headstage_update_vis_instruction(uint8_t vis_oper) {
|
||||
case VIS_INT:
|
||||
headstage_reset();
|
||||
headstage_state = UMC_STATE_HANDSHAKE;
|
||||
INSTRUCTION.channel_pointer = 0;
|
||||
INSTRUCTION.channel_pointer=0;
|
||||
break;
|
||||
|
||||
case VIS_BLE_T:
|
||||
@@ -838,8 +838,7 @@ static void headstage_update_cis_instruction(uint8_t cis_oper) {
|
||||
case CIS_VOLT: {
|
||||
|
||||
cdr_buf[0] = CIS_VOLT | CHIP_ID;
|
||||
cdr_buf[1] = headstage_battery_volt1();
|
||||
cdr_buf[2] = headstage_battery_volt2();
|
||||
cdr_buf[1] = headstage_battery_percent();
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CDR_BUFF_CHAR, BLE_CDR_BUFF_SIZE, cdr_buf);
|
||||
|
||||
@@ -880,119 +879,37 @@ static uint8_t headstage_debug_instruction(uint8_t* ins_buf) {
|
||||
|
||||
// todo: check data length extension with this function -> this function should be
|
||||
static void headstage_uni_umc_data_append_notify_buffer(uint8_t* dat_buf) {
|
||||
// check LSK data preamble ( 9b01100_0001 ) header 58(0101xxxx)
|
||||
// if (channel == INSTRUCTION.last_enable_channel) : preamble + header + 10b data
|
||||
// else: 9b00000_0000 + header + 10b data
|
||||
// check LSK data preamble ( 0b01100_0001 ) 58(01011000) 2c(00101100)
|
||||
// sometimes we lose the first bit , it means we only receive
|
||||
// 0110_0000_1010_1xxx_xxxx_xxxX_XXXX_XXXX and
|
||||
// 1100_0001_0101_xxxx_xxxx_xxXX_XXXX_XXXX
|
||||
if (((dat_buf[0] & 0xC1) != 0xC1) && (dat_buf[0] != 0x00)) {
|
||||
headstage_led_spi_color(COLOR_CYAN);
|
||||
if ((dat_buf[1] & 0x28) == 0x28) {
|
||||
dat_buf[0] = (dat_buf[0] << 1) | ((dat_buf[1] >> 7) & 0x01);
|
||||
dat_buf[1] = (dat_buf[1] << 1) | ((dat_buf[2] >> 7) & 0x01);
|
||||
dat_buf[2] = (dat_buf[2] << 1) | ((dat_buf[3] >> 7) & 0x01);
|
||||
}
|
||||
//headstage_uni_delay();
|
||||
headstage_led_spi_color(COLOR_CYAN);
|
||||
headstage_uni_delay();
|
||||
} else {
|
||||
if ((dat_buf[1] & 0x28) == 0x28) {
|
||||
dat_buf[0] = (dat_buf[0] << 1) | ((dat_buf[1] >> 7) & 0x01);
|
||||
dat_buf[1] = (dat_buf[1] << 1) | ((dat_buf[2] >> 7) & 0x01);
|
||||
dat_buf[2] = (dat_buf[2] << 1) | ((dat_buf[3] >> 7) & 0x01);
|
||||
}
|
||||
}
|
||||
//headstage_led_spi_color(COLOR_CYAN);
|
||||
uint8_t channel;
|
||||
uint8_t channel_pointer = INSTRUCTION.channel_pointer;
|
||||
uint8_t pramb;
|
||||
|
||||
switch (INSTRUCTION.enable_channel_number){
|
||||
case 1:
|
||||
pramb = 0;
|
||||
channel = reverse_channel[INSTRUCTION.channel_mux[channel_pointer]];
|
||||
break;
|
||||
case 2:
|
||||
if ((dat_buf[0] & 0xC1) == 0xC1) {
|
||||
channel = reverse_channel[INSTRUCTION.last_enable_channel];
|
||||
}
|
||||
//else if (dat_buf[0] == 0 && pramb == 0) {}
|
||||
else{
|
||||
if(channel_pointer==0 && INSTRUCTION.channel_mux[channel_pointer]==INSTRUCTION.last_enable_channel)
|
||||
{channel_pointer++;}
|
||||
|
||||
if ((INSTRUCTION.last_enable_channel%2) == 0)
|
||||
if (channel_pointer == INSTRUCTION.last_enable_channel)
|
||||
{channel = reverse_channel[INSTRUCTION.channel_mux[channel_pointer - 1]];}
|
||||
else
|
||||
{channel = reverse_channel[INSTRUCTION.channel_mux[channel_pointer + 1]];}
|
||||
else
|
||||
{channel = reverse_channel[INSTRUCTION.channel_mux[channel_pointer]];}
|
||||
}
|
||||
channel_pointer++;
|
||||
INSTRUCTION.channel_pointer = channel_pointer % (INSTRUCTION.last_enable_channel+1);
|
||||
break;
|
||||
//case 3:
|
||||
// if ((dat_buf[0] & 0xC1) == 0xC1) {
|
||||
// channel = reverse_channel[INSTRUCTION.last_enable_channel];
|
||||
// }
|
||||
// else {
|
||||
|
||||
// channel = reverse_channel[INSTRUCTION.channel_mux[channel_pointer]];
|
||||
// }
|
||||
// channel_pointer++;
|
||||
// INSTRUCTION.channel_pointer = channel_pointer % (INSTRUCTION.enable_channel_number);
|
||||
// break;
|
||||
default: // for enable_channel_num >4
|
||||
//expectation on preamble
|
||||
if (INSTRUCTION.channel_mux[channel_pointer] == INSTRUCTION.last_enable_channel){
|
||||
pramb=1;
|
||||
}
|
||||
else {
|
||||
pramb=0;
|
||||
if ((dat_buf[1] & 0x28) == 0x28) {
|
||||
dat_buf[0] = (dat_buf[0] << 1) | ((dat_buf[1] >> 7) & 0x01);
|
||||
dat_buf[1] = (dat_buf[1] << 1) | ((dat_buf[2] >> 7) & 0x01);
|
||||
dat_buf[2] = (dat_buf[2] << 1) | ((dat_buf[3] >> 7) & 0x01);
|
||||
}
|
||||
|
||||
if ((dat_buf[0] & 0xC1) == 0xC1) {
|
||||
uint8_t channel;
|
||||
uint8_t channel_pointer = INSTRUCTION.channel_pointer;
|
||||
|
||||
if ((INSTRUCTION.enable_channel_number == 1)) {
|
||||
channel = reverse_channel[INSTRUCTION.last_enable_channel];
|
||||
}
|
||||
else{
|
||||
if(channel_pointer==0 && INSTRUCTION.channel_mux[channel_pointer]==INSTRUCTION.last_enable_channel)
|
||||
{channel_pointer++;}
|
||||
|
||||
channel = reverse_channel[INSTRUCTION.channel_mux[channel_pointer]];
|
||||
}
|
||||
//else {
|
||||
// channel = reverse_channel[13];
|
||||
// //headstage_led_spi_color(COLOR_RED);
|
||||
//}
|
||||
|
||||
//if (channel <= INSTRUCTION.last_enable_channel){
|
||||
} else {
|
||||
//uint8_t channel_pointer = (INSTRUCTION.channel_pointer + 1) % INSTRUCTION.last_enable_channel;
|
||||
channel = reverse_channel[INSTRUCTION.channel_mux[channel_pointer]];
|
||||
channel_pointer++;
|
||||
INSTRUCTION.channel_pointer = channel_pointer % (INSTRUCTION.last_enable_channel+1);
|
||||
//}
|
||||
break;
|
||||
}
|
||||
|
||||
//left shift the data buffer by 1 bit according to header position
|
||||
/*if (((dat_buf[0] & 0xC1) != 0xC1) && (dat_buf[0] != 0x00)) {
|
||||
// headstage_uni_delay();
|
||||
} else {
|
||||
*/
|
||||
|
||||
//if (channel < (INSTRUCTION.last_enable_channel+1)){
|
||||
}
|
||||
uint8_t data_size = headstage_notify_append_data(channel, dat_buf);
|
||||
if (data_size >= BLE_NOT_BUFF_SIZE) {
|
||||
headstage_notify_flip_buffer();
|
||||
headstage_notify_send();
|
||||
}
|
||||
//}
|
||||
/*else if (channel > INSTRUCTION.last_enable_channel){
|
||||
headstage_led_spi_color(COLOR_RED);
|
||||
channel_pointer = channel_pointer+2; //This line may not work for complex channel arrangement
|
||||
}*/
|
||||
//else{
|
||||
/* DO nothing */
|
||||
//}
|
||||
|
||||
}
|
||||
// uint16_t data_value = (uint16_t)(((dat_buf[1] & 0x0F) << 6) | ((dat_buf[2] & 0xFC) >> 2));
|
||||
headstage_spi_lsk_transaction(3);
|
||||
}
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
|
||||
#ifndef VERSION_DATE
|
||||
#define VERSION_DATE
|
||||
|
||||
#define VERSION_DATE_YEAR 20
|
||||
#define VERSION_DATE_MONTH 2
|
||||
#define VERSION_DATE_DAY 14
|
||||
#define VERSION_DATE_HOUR 18
|
||||
#define VERSION_DATE_MINUTE 30
|
||||
|
||||
#endif
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>uni</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
+4
-6
@@ -408,7 +408,8 @@ static void SimpleBLEPeripheral_init(void) {
|
||||
GATT_RegisterForMsgs(self);
|
||||
|
||||
headstage_led_spi_color(COLOR_GREEN);
|
||||
// HCI_LE_ReadMaxDataLenCmd(); //YiChin said this command is not necessary
|
||||
HCI_LE_ReadMaxDataLenCmd();
|
||||
|
||||
HCI_LE_WriteSuggestedDefaultDataLenCmd(251, 2120); // this is used for data length extension
|
||||
|
||||
|
||||
@@ -510,7 +511,7 @@ static void headstage_init_device_info() {
|
||||
for (unsigned int i = 0; i < sizeof(DEVICE_NAME) - 1; i++) {
|
||||
*p++ = DEVICE_NAME[i];
|
||||
}
|
||||
*p++ = 16;
|
||||
*p++ = 15;
|
||||
*p++ = GAP_ADTYPE_MANUFACTURER_SPECIFIC;
|
||||
// unsafe_memcpy(p, "BPHS", 4);
|
||||
*p++ = 'B';
|
||||
@@ -526,8 +527,7 @@ static void headstage_init_device_info() {
|
||||
*p++ = 'B';
|
||||
*p++ = 'A';
|
||||
*p++ = 'T';
|
||||
*p++ = headstage_battery_volt1();
|
||||
*p++ = headstage_battery_volt2();
|
||||
*p++ = headstage_battery_percent();
|
||||
|
||||
|
||||
GGS_SetParameter(GGS_DEVICE_NAME_ATT, sizeof(DEVICE_NAME), DEVICE_NAME);
|
||||
@@ -847,7 +847,6 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
|
||||
case GAPROLE_WAITING:
|
||||
// Device is started but not advertising, is in waiting period before advertising again
|
||||
SimpleBLEPeripheral_freeAttRsp(bleNotConnected);
|
||||
headstage_led_spi_color(COLOR_GREEN);
|
||||
break;
|
||||
|
||||
case GAPROLE_WAITING_AFTER_TIMEOUT:
|
||||
@@ -863,7 +862,6 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
|
||||
break;
|
||||
case GAPROLE_INIT: // Waiting to be started
|
||||
case GAPROLE_ADVERTISING: // Currently Advertising
|
||||
headstage_led_spi_color(COLOR_GREEN);
|
||||
case GAPROLE_CONNECTED_ADV: // In a connection and advertising
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user