[update] update device info
This commit is contained in:
+29
-19
@@ -6,19 +6,29 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* +---------------+----------------------+-------------------------+
|
||||
* | model name | upper board | lower board |
|
||||
* +---------------+----------------------+-------------------------+
|
||||
* | EDC1.4 | Elite1.4-re Jun.2019 | Elite1.4-re Jun. 2019 |<- DEF_ELITE_EDC_1_4
|
||||
* | EDC1.5 | Elite1.5 Dec. 2019 | Elite1.5 Dec. 2019 |<- DEF_ELITE_EDC_1_5
|
||||
* | EDC1.5re | Elite1.5 Dec. 2019 | Elite1.5-re Jan. 2021 |<- DEF_ELITE_EDC_1_5_RE
|
||||
* | EDC1.5r2 | Elite1.5 Dec. 2019 | Elite1.5 - r2 May. 2022 |<- DEF_ELITE_EDC_1_5_R2
|
||||
* | EIS1.0 | Elite1.5 Dec. 2019 | Elite EIS 1.0 Aug. 2020 |<- DEF_ELITE_EIS_1_0
|
||||
* | EIS1.1 | Elite1.5 Dec. 2019 | Elite EIS 1.1 Feb. 2022 |<- DEF_ELITE_EIS_1_1
|
||||
* | BAT1.0 | Elite2.0 Feb. 2022 |<- DEF_ELITE_BAT_1_0
|
||||
* | MEGAFLY0.1 | ? | ? |<- DEF_ELITE_MEGAFLY_0_1
|
||||
* | TRIG0.1 | Elite TRIG01 Jan. 2021 |<- DEF_ELITE_TRIG_0_1
|
||||
* +---------------+----------------------+-------------------------+
|
||||
*
|
||||
* product number: MAJOR_PRODUCT_NUMBER, MINOR_PRODUCT_NUMBER, MAJOR_VERSION_NUMBER, MINOR_VERSION_NUMBER
|
||||
* MAJOR_PRODUCT_NUMBER -> 0:Elite, 1:other serial
|
||||
* Elite:
|
||||
* MINOR_PRODUCT_NUMBER -> 1:legacy, 2:EDC, 3:BAT, 4:EIS, 5:TRIG, 6:MEGAFLY
|
||||
*
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* | model name | hw upper board | hw lower board | product number | device name | data server lib name | UI |
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* | DEF_ELITE_EDC_1_4 | Elite1.4-re Jun.2019 | Elite1.4-re Jun. 2019 | 0, 2, 1, 5 | "Elite-EDC" | Elite_EDC_1.4 | null |
|
||||
* | DEF_ELITE_EDC_1_5 | Elite1.5 Dec. 2019 | Elite1.5 Dec. 2019 | 0, 2, 1, 6 | "Elite-EDC" | Elite_EDC_1.5 | EliteEDC |
|
||||
* | DEF_ELITE_EDC_1_5_RE | Elite1.5 Dec. 2019 | Elite1.5-re Jan. 2021 | 0, 2, 1, 7 | "Elite-EDC" | Elite_EDC_1.5re | EliteEDC |
|
||||
* | DEF_ELITE_EDC_1_5_R2 | Elite1.5 Dec. 2019 | Elite1.5-r2 May. 2022 | 0, 2, 1, 8 | "Elite-EDC" | Elite_EDC_1.5r2 | EliteEDC |
|
||||
* | DEF_ELITE_BAT_1_0 | Elite2.0 Feb. 2022 | 0, 3, 1, 0 | "Elite-BAT" | Elite_BAT_1.0 | EliteEDC |
|
||||
* | DEF_ELITE_EIS_1_0 | Elite1.5 Dec. 2019 | Elite EIS1.0 Aug. 2020 | 0, 4, 1, 0 | "Elite-EIS" | Elite_EIS_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_1_1 | Elite1.5 Dec. 2019 | Elite EIS1.1 Feb. 2022 | 0, 4, 1, 1 | "Elite-EIS" | Elite_EIS_1.1 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_MINI_1_0 | EIS MINI May. 2022 | 0, 4, 1, 2 | "Elite-EIS-MINI" | Elite_EIS_MINI_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_TRIG_0_1 | Elite TRIG01 Jan. 2021 | 0, 5, 1, 0 | "Elite-TRIG" | Elite_TRIG_0.1 | null |
|
||||
* | DEF_ELITE_MEGAFLY_0_1 | Elite1.5 Dec. 2019 | Elite Megafly Sep. 2020 | 0, 6, 1, 0 | "Elite-MEGAFLY" | Elite_MEGAFLY_0.1 | null |
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* ps.
|
||||
* model name is FW engineer defined
|
||||
* device name is used for controller
|
||||
*/
|
||||
|
||||
|
||||
@@ -26,13 +36,13 @@ extern "C" {
|
||||
#define DEF_ELITE_EDC_1_5 1
|
||||
#define DEF_ELITE_EDC_1_5_RE 2
|
||||
#define DEF_ELITE_EDC_1_5_R2 3
|
||||
#define DEF_ELITE_EIS_1_0 4
|
||||
#define DEF_ELITE_EIS_1_1 5
|
||||
#define DEF_ELITE_BAT_1_0 6
|
||||
#define DEF_ELITE_MEGAFLY_0_1 7
|
||||
#define DEF_ELITE_BAT_1_0 4
|
||||
#define DEF_ELITE_EIS_1_0 5
|
||||
#define DEF_ELITE_EIS_1_1 6
|
||||
#define DEF_ELITE_EIS_MINI_1_0 7
|
||||
#define DEF_ELITE_TRIG_0_1 8
|
||||
#define DEF_ELITE_MAX 9
|
||||
|
||||
#define DEF_ELITE_MEGAFLY_0_1 9
|
||||
#define DEF_ELITE_MAX 10
|
||||
|
||||
#define DEF_ELITE_MODEL DEF_ELITE_EDC_1_5_RE
|
||||
#ifndef DEF_ELITE_MODEL
|
||||
|
||||
-4
@@ -4,11 +4,9 @@
|
||||
|
||||
static bool DACReset;
|
||||
|
||||
#ifdef ELITE_VERSION_1_4
|
||||
#define DACCLS 0x02
|
||||
#define DACOUT 0x31
|
||||
|
||||
|
||||
static void VoutGainControl(uint8_t VOUTLevel){
|
||||
if(VOUTLevel == 0){
|
||||
// VOUT gain level = 0, using 240K resister
|
||||
@@ -29,8 +27,6 @@ static void VoutGainControl(uint8_t VOUTLevel){
|
||||
volt_rec_en = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int32_t User2Real(uint16_t UserCode){
|
||||
/* transfer usercode to real voltage value (mV) */
|
||||
return (int32_t)((UserCode - 25000) / 5);
|
||||
|
||||
+3
-3
@@ -4,9 +4,9 @@
|
||||
|
||||
#define VERSION_DATE_YEAR 22
|
||||
#define VERSION_DATE_MONTH 7
|
||||
#define VERSION_DATE_DAY 22
|
||||
#define VERSION_DATE_HOUR 14
|
||||
#define VERSION_DATE_MINUTE 39
|
||||
#define VERSION_DATE_DAY 27
|
||||
#define VERSION_DATE_HOUR 10
|
||||
#define VERSION_DATE_MINUTE 16
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
|
||||
+157
-112
@@ -430,21 +430,6 @@ characteristic change event
|
||||
#define SBP_KEY_CHANGE_EVT 0x0010
|
||||
#endif
|
||||
|
||||
/**************************
|
||||
controller version
|
||||
EliteZM02 0,2,1,5
|
||||
EliteZM15 0,2,1,6
|
||||
EliteZM_pulsefly 0,2,1,7
|
||||
**************************/
|
||||
// product information
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0 // 0:Elite, 1:Neulive
|
||||
#define MINOR_PRODUCT_NUMBER 2 // 1:Elite_legacy(Ori_Neulive) 2:Elite_zm 3:Elite_bat
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 6
|
||||
|
||||
#define ELITE_VERSION_1_4
|
||||
|
||||
// buffer size
|
||||
#define BLE_CIS_BUFF_CHAR SIMPLEPROFILE_CHAR2
|
||||
#define BLE_INS_BUFF_CHAR SIMPLEPROFILE_CHAR3
|
||||
@@ -1571,112 +1556,172 @@ static void ZM_instruction_update_handle(uint8_t characteristic) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DEVICE_NAME
|
||||
#error "DEVICE_NAME not defined"
|
||||
#endif
|
||||
|
||||
#ifndef MAJOR_PRODUCT_NUMBER
|
||||
#error "MAJOR_PRODUCT_NUMBER not defined"
|
||||
#endif
|
||||
|
||||
#ifndef MINOR_PRODUCT_NUMBER
|
||||
#error "MINOR_PRODUCT_NUMBER not defined"
|
||||
#endif
|
||||
|
||||
#ifndef MAJOR_VERSION_NUMBER
|
||||
#error "MAJOR_VERSION_NUMBER not defined"
|
||||
#endif
|
||||
|
||||
#ifndef MINOR_VERSION_NUMBER
|
||||
#error "MINOR_VERSION_NUMBER not defined"
|
||||
#endif
|
||||
|
||||
#include "devinfoservice.h"
|
||||
#include "gapgattserver.h"
|
||||
#include "gattservapp.h"
|
||||
|
||||
struct date_t {
|
||||
uint8_t year;
|
||||
uint8_t month;
|
||||
uint8_t day;
|
||||
};
|
||||
|
||||
struct device_info_t {
|
||||
struct date_t date;
|
||||
};
|
||||
|
||||
struct device_info_t device_info;
|
||||
|
||||
void get_date(struct date_t *date)
|
||||
{
|
||||
const char *months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
struct date_t *d = date;
|
||||
char year_s[5] = {0};
|
||||
char month_s[4] = {0};
|
||||
char day_s[3] = {0};
|
||||
int i;
|
||||
char date_now[] = __DATE__;
|
||||
|
||||
memcpy(year_s, date_now + 9, 2);
|
||||
memcpy(month_s, date_now, 3);
|
||||
memcpy(day_s, date_now + 4, 2);
|
||||
|
||||
d->year = atoi(year_s);
|
||||
d->day = atoi(day_s);
|
||||
for (i=0; i<12; i++) {
|
||||
if (!strcmp(month_s, months[i])) {
|
||||
d->month = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* product number: MAJOR_PRODUCT_NUMBER, MINOR_PRODUCT_NUMBER, MAJOR_VERSION_NUMBER, MINOR_VERSION_NUMBER
|
||||
* MAJOR_PRODUCT_NUMBER -> 0:Elite, 1:other serial
|
||||
* Elite:
|
||||
* MINOR_PRODUCT_NUMBER -> 1:legacy, 2:EDC, 3:BAT, 4:EIS, 5:TRIG, 6:MEGAFLY
|
||||
*
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* | model name | hw upper board | hw lower board | product number | device name | data server lib name | UI |
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* | DEF_ELITE_EDC_1_4 | Elite1.4-re Jun.2019 | Elite1.4-re Jun. 2019 | 0, 2, 1, 5 | "Elite-EDC-1.4" | Elite_EDC_1.4 | null |
|
||||
* | DEF_ELITE_EDC_1_5 | Elite1.5 Dec. 2019 | Elite1.5 Dec. 2019 | 0, 2, 1, 6 | "Elite-EDC-1.5" | Elite_EDC_1.5 | EliteEDC |
|
||||
* | DEF_ELITE_EDC_1_5_RE | Elite1.5 Dec. 2019 | Elite1.5-re Jan. 2021 | 0, 2, 1, 7 | "Elite-EDC-1.5re" | Elite_EDC_1.5re | EliteEDC |
|
||||
* | DEF_ELITE_EDC_1_5_R2 | Elite1.5 Dec. 2019 | Elite1.5-r2 May. 2022 | 0, 2, 1, 8 | "Elite-EDC-1.5r2" | Elite_EDC_1.5r2 | EliteEDC |
|
||||
* | DEF_ELITE_BAT_1_0 | Elite2.0 Feb. 2022 | 0, 3, 1, 0 | "Elite-BAT-1.0" | Elite_BAT_1.0 | EliteEDC |
|
||||
* | DEF_ELITE_EIS_1_0 | Elite1.5 Dec. 2019 | Elite EIS1.0 Aug. 2020 | 0, 4, 1, 0 | "Elite-EIS-1.0" | Elite_EIS_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_1_1 | Elite1.5 Dec. 2019 | Elite EIS1.1 Feb. 2022 | 0, 4, 1, 1 | "Elite-EIS-1.1" | Elite_EIS_1.1 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_MINI_1_0 | EIS MINI May. 2022 | 0, 4, 1, 2 | "Elite-EIS-MINI-1.0" | Elite_EIS_MINI_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_TRIG_0_1 | Elite TRIG01 Jan. 2021 | 0, 5, 1, 0 | "Elite-TRIG-0.1" | Elite_TRIG_0.1 | null |
|
||||
* | DEF_ELITE_MEGAFLY_0_1 | Elite1.5 Dec. 2019 | Elite Megafly Sep. 2020 | 0, 6, 1, 0 | "Elite-MEGAFLY-0.1" | Elite_MEGAFLY_0.1 | null |
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* ps.
|
||||
* model name is FW engineer defined
|
||||
* device name is used for controller
|
||||
*/
|
||||
|
||||
|
||||
// model information
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_4)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 5
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 6
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_RE)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 7
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_R2)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 8
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_1_0)
|
||||
#define DEVICE_NAME "Elite-BAT"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 3
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_0)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_1)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 1
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_MINI_1_0)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 2
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_0_1)
|
||||
#define DEVICE_NAME "Elite-TRIG"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 5
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_0_1)
|
||||
#define DEVICE_NAME "Elite-MEGAFLY"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 6
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#endif
|
||||
|
||||
static void headstage_init_device_info() {
|
||||
char * date = __DATE__;
|
||||
uint8_t year = 10 * (date[9] - '0') + (date[10] - '0');
|
||||
uint8_t month = 0;
|
||||
|
||||
switch (date[0]) {
|
||||
case 'J':
|
||||
// Jan, January
|
||||
// Jun, June
|
||||
// Jul, July
|
||||
if (date[1] == 'a') {
|
||||
month = 1;
|
||||
} else if (date[2] == 'n') {
|
||||
month = 6;
|
||||
} else {
|
||||
month = 7;
|
||||
}
|
||||
break;
|
||||
case 'F':
|
||||
// Feb, February
|
||||
month = 2;
|
||||
break;
|
||||
case 'M':
|
||||
// Mar, March
|
||||
// May, May
|
||||
if (date[2] == 'r') {
|
||||
month = 3;
|
||||
} else {
|
||||
month = 5;
|
||||
}
|
||||
break;
|
||||
case 'A':
|
||||
// Apr, April
|
||||
// Ang, August
|
||||
if (date[1] == 'p') {
|
||||
month = 4;
|
||||
} else {
|
||||
month = 8;
|
||||
}
|
||||
break;
|
||||
case 'S':
|
||||
// Sep, September
|
||||
month = 9;
|
||||
break;
|
||||
case 'O':
|
||||
// Oct, October
|
||||
month = 10;
|
||||
break;
|
||||
case 'N':
|
||||
// Nov, November
|
||||
month = 11;
|
||||
break;
|
||||
case 'D':
|
||||
// Dec, December
|
||||
month = 12;
|
||||
break;
|
||||
}
|
||||
|
||||
uint8_t scanRspData[64];
|
||||
uint8_t scanRspData[64] = {9};
|
||||
uint8_t *p = scanRspData;
|
||||
*p++ = sizeof(DEVICE_NAME);
|
||||
*p++ = GAP_ADTYPE_LOCAL_NAME_COMPLETE;
|
||||
for (unsigned int i = 0; i < sizeof(DEVICE_NAME) - 1; i++) {
|
||||
struct device_info_t *dev = &device_info;
|
||||
int i;
|
||||
|
||||
get_date(&device_info.date);
|
||||
|
||||
*p++ = sizeof(DEVICE_NAME); // 10
|
||||
*p++ = GAP_ADTYPE_LOCAL_NAME_COMPLETE; // 09
|
||||
for (i=0; i<sizeof(DEVICE_NAME)-1; i++) {
|
||||
*p++ = DEVICE_NAME[i];
|
||||
}
|
||||
*p++ = 16;
|
||||
*p++ = GAP_ADTYPE_MANUFACTURER_SPECIFIC;
|
||||
*p++ = 'B';
|
||||
*p++ = 'P';
|
||||
*p++ = 'H';
|
||||
*p++ = 'S';
|
||||
*p++ = MAJOR_PRODUCT_NUMBER;
|
||||
*p++ = MINOR_PRODUCT_NUMBER;
|
||||
*p++ = MAJOR_VERSION_NUMBER;
|
||||
*p++ = MINOR_VERSION_NUMBER;
|
||||
*p++ = year;
|
||||
*p++ = month;
|
||||
*p++ = 'B';
|
||||
*p++ = 'A';
|
||||
*p++ = 'T';
|
||||
*p++ = (uint8_t)(NotifyVoltBat);
|
||||
*p++ = (uint8_t)(NotifyVoltBat >> 8);
|
||||
} // 69 108 105 116 101 45 69 73 83
|
||||
*p++ = 16; // 16
|
||||
*p++ = GAP_ADTYPE_MANUFACTURER_SPECIFIC; // 255
|
||||
*p++ = 'B'; // 66
|
||||
*p++ = 'P'; // 80
|
||||
*p++ = 'H'; // 72
|
||||
*p++ = 'S'; // 83
|
||||
*p++ = MAJOR_PRODUCT_NUMBER; // 0
|
||||
*p++ = MINOR_PRODUCT_NUMBER; // 4
|
||||
*p++ = MAJOR_VERSION_NUMBER; // 1
|
||||
*p++ = MINOR_VERSION_NUMBER; // 0
|
||||
*p++ = dev->date.year; // 22
|
||||
*p++ = dev->date.month; // 07
|
||||
*p++ = 'B'; // 66
|
||||
*p++ = 'A'; // 65
|
||||
*p++ = 'T'; // 84
|
||||
*p++ = (uint8_t)(NotifyVoltBat); // 44
|
||||
*p++ = (uint8_t)(NotifyVoltBat >> 8); // 33
|
||||
|
||||
GGS_SetParameter(GGS_DEVICE_NAME_ATT, sizeof(DEVICE_NAME), DEVICE_NAME);
|
||||
|
||||
|
||||
-311
@@ -1,311 +0,0 @@
|
||||
|
||||
#ifndef HEADSTAGE_H
|
||||
#error "headstage.h not include"
|
||||
#endif
|
||||
|
||||
#ifdef HEADSTAGE_H_H
|
||||
#error "headstage_*.h has be included"
|
||||
#endif
|
||||
|
||||
#ifndef HEADSTAGE_TNI_H
|
||||
#define HEADSTAGE_H_H
|
||||
#define HEADSTAGE_TNI_H
|
||||
|
||||
// product information
|
||||
#define DEVICE_NAME "Elite-v0.1"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 1
|
||||
#define MAJOR_VERSION_NUMBER 0
|
||||
#define MINOR_VERSION_NUMBER 1
|
||||
|
||||
// header
|
||||
#include <ti/drivers/PIN.h>
|
||||
#include "board.h"
|
||||
|
||||
/*============
|
||||
==== SPI ====
|
||||
===========*/
|
||||
|
||||
/* application use SPI parameters and buffers */
|
||||
|
||||
#define SPI_BUFFER_SIZE 16
|
||||
|
||||
/**
|
||||
* the pointer to point which channel is used currently.
|
||||
* -1 for not beginning.
|
||||
*/
|
||||
static int8 channel_pointer = -1;
|
||||
|
||||
static uint8_t spi_txbuf[SPI_BUFFER_SIZE] = {0};
|
||||
static uint8_t spi_rxbuf[SPI_BUFFER_SIZE] = {0};
|
||||
|
||||
/*=============================
|
||||
==== headstage variable ====
|
||||
============================*/
|
||||
|
||||
PIN_Handle pin_handle;
|
||||
static PIN_State DBS_rst;
|
||||
|
||||
// DBS reset pin
|
||||
|
||||
const PIN_Config BLE_IO[] = {
|
||||
//
|
||||
IOID_9 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
IOID_2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
IOID_3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
IOID_13 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
PIN_TERMINATE //
|
||||
};
|
||||
|
||||
/**
|
||||
* ADC clock switch signal.
|
||||
*/
|
||||
static bool adc_clock_signal = FALSE;
|
||||
|
||||
/*=======================================
|
||||
==== headstage function declaration ====
|
||||
======================================*/
|
||||
|
||||
static void headstage_tni_update_instruction_callback(uint8_t ins_type, uint8_t ins_op, uint8_t ins_len, uint8_t *ins);
|
||||
|
||||
/*=============================
|
||||
==== ramp data generating ====
|
||||
============================*/
|
||||
|
||||
static uint16_t ramp_data_counter = 0;
|
||||
|
||||
static void create_ramp(uint8_t *buff) {
|
||||
buff[0] = 0b10110000 | (0b00001111 & (uint8_t)(ramp_data_counter >> 6));
|
||||
buff[1] = (uint8_t)(ramp_data_counter << 2);
|
||||
ramp_data_counter += 1;
|
||||
}
|
||||
|
||||
/*=======================================
|
||||
==== headstage function implemented ====
|
||||
======================================*/
|
||||
|
||||
/**
|
||||
* change channel value to little endian
|
||||
*/
|
||||
static uint8 encode_channel(uint8 channel) {
|
||||
return 0x0F & (((channel & 0b1000) >> 3) | //
|
||||
((channel & 0b0100) >> 1) | //
|
||||
((channel & 0b0010) << 1) | //
|
||||
((channel & 0b0001) << 3));
|
||||
}
|
||||
|
||||
static void headstage_init() {
|
||||
set_update_instruction_callback(headstage_tni_update_instruction_callback);
|
||||
|
||||
// initialize the DBS reset pin
|
||||
pin_handle = PIN_open(&DBS_rst, BLE_IO);
|
||||
PIN_setOutputValue(pin_handle, IOID_9, 1);
|
||||
PIN_setOutputValue(pin_handle, IOID_2, 0);
|
||||
PIN_setOutputValue(pin_handle, IOID_3, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* change the recording clock bit in the instruction buffer.
|
||||
*/
|
||||
static void update_ins_rec_clock(uint8_t *buf, bool adc_clock_signal) {
|
||||
buf[3] = (buf[3] & 0b11110000) | ((adc_clock_signal) ? 0b1000 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* change the recording channel bit in the instruction buffer.
|
||||
*/
|
||||
static void update_ins_rec_channel(uint8_t *buf, uint8 channel) {
|
||||
buf[1] = (buf[1] & 0b00001111) | (encode_channel(channel) << 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* change the stimulation enable bit in the instruction buffer.
|
||||
*/
|
||||
static void update_ins_sti_enable(uint8_t *buf, bool enable) {
|
||||
buf[1] = (buf[1] & 0b11111101) | ((enable) ? 0b10 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* change the stimulating channel bit in the instruction buffer.
|
||||
*/
|
||||
static void update_ins_sti_channel(uint8_t *buf, uint8 sti_chp, uint8 sti_chn) {
|
||||
buf[2] = (buf[2] & 0b11110000) | encode_channel(sti_chp);
|
||||
buf[3] = (buf[3] & 0b00001111) | (encode_channel(sti_chn) << 4);
|
||||
}
|
||||
|
||||
static void update_ins_buffer() {
|
||||
uint8 header = 0b10100000;
|
||||
uint8 amp_gain = (instru.amp_gain & 0b11) << 3;
|
||||
uint8 amp_lbf = instru.amp_low_band_freq & 0b111;
|
||||
uint8 channel = 0; // should be call update_ins_channel to modify this value
|
||||
uint8 chopper = (instru.chopper) ? 0b00001000 : 0;
|
||||
uint8 fast_settle = (instru.fast_settle) ? 0b00000100 : 0;
|
||||
uint8 sti_enable = (instru.work_mode != STI_MODE_DISABLE) ? 0b00000010 : 0;
|
||||
uint8 sti_volt_l = (instru.sti_volt & 0b11111) >> 4;
|
||||
uint8 sti_volt_h = (instru.sti_volt & 0b01111) << 4;
|
||||
uint8 sti_chp = instru.sti_channel_pmos & 0b1111;
|
||||
uint8 sti_chn = (instru.sti_channel_nmos & 0b1111) << 4;
|
||||
uint8 clk_signal = 0; // should be call update_ins_clock to modify this value
|
||||
|
||||
spi_txbuf[0] = header | amp_gain | amp_lbf;
|
||||
spi_txbuf[1] = channel | chopper | fast_settle | sti_enable | sti_volt_l;
|
||||
spi_txbuf[2] = sti_volt_h | sti_chp;
|
||||
spi_txbuf[3] = sti_chn | clk_signal;
|
||||
}
|
||||
|
||||
static bool update_ins_rec_buffer() {
|
||||
adc_clock_signal = (adc_clock_signal) ? FALSE : TRUE; // switch adc_clock
|
||||
update_ins_rec_clock(spi_txbuf, adc_clock_signal);
|
||||
|
||||
if (adc_clock_signal) {
|
||||
// change to next channel
|
||||
|
||||
if (next_active_channel()) {
|
||||
update_ins_rec_channel(spi_txbuf, channel_pointer);
|
||||
} else {
|
||||
// no channel active
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the instruction content for SPI buffer, which is depended on the
|
||||
* work_mode. Expend the remind instruction according to the base instruction
|
||||
* which allocated at the beginning 4 bytes of the SPI buffer.
|
||||
*
|
||||
* ========= ===========
|
||||
* work_mode ins pattern
|
||||
* ========= ===========
|
||||
* POS, NEG 4 F D 0
|
||||
* P2N, N2P 4 4' F D
|
||||
* AWF not impl
|
||||
* ========= ===========
|
||||
*
|
||||
* pattern *4*
|
||||
* stimulation instruction.
|
||||
*
|
||||
* pattern *F*
|
||||
* set pmos channel to 0xF, release the remain voltage in the capacitance.
|
||||
*
|
||||
* pattern *D*
|
||||
* disable stimulation
|
||||
*
|
||||
* pattern *0*
|
||||
* nop.
|
||||
*
|
||||
* @param: buf: pointer of the SPI buffer.
|
||||
*/
|
||||
static void update_ins_sti_buffer() {
|
||||
switch (instru.work_mode) {
|
||||
case STI_MODE_POS:
|
||||
case STI_MODE_NEG:
|
||||
// copy [4:7]
|
||||
spi_txbuf[4] = spi_txbuf[0];
|
||||
spi_txbuf[5] = spi_txbuf[1];
|
||||
spi_txbuf[6] = spi_txbuf[2];
|
||||
spi_txbuf[7] = spi_txbuf[3];
|
||||
// copy [8:B]
|
||||
spi_txbuf[8] = spi_txbuf[0];
|
||||
spi_txbuf[9] = spi_txbuf[1];
|
||||
spi_txbuf[10] = spi_txbuf[2];
|
||||
spi_txbuf[11] = spi_txbuf[3];
|
||||
// reset [C:F]
|
||||
spi_txbuf[12] = 0;
|
||||
spi_txbuf[13] = 0;
|
||||
spi_txbuf[14] = 0;
|
||||
spi_txbuf[15] = 0;
|
||||
// change content
|
||||
update_ins_sti_enable(spi_txbuf, TRUE);
|
||||
// ins buf [4:7]
|
||||
update_ins_sti_enable(spi_txbuf + 4, TRUE);
|
||||
update_ins_sti_channel(spi_txbuf + 4, 0xF, instru.sti_channel_pmos);
|
||||
// ins buf [8:B]
|
||||
update_ins_sti_enable(spi_txbuf + 8, FALSE);
|
||||
break;
|
||||
case STI_MODE_P2N:
|
||||
case STI_MODE_N2P:
|
||||
// copy [4:7]
|
||||
spi_txbuf[4] = spi_txbuf[0];
|
||||
spi_txbuf[5] = spi_txbuf[1];
|
||||
spi_txbuf[6] = spi_txbuf[2];
|
||||
spi_txbuf[7] = spi_txbuf[3];
|
||||
// copy [8:B]
|
||||
spi_txbuf[8] = spi_txbuf[0];
|
||||
spi_txbuf[9] = spi_txbuf[1];
|
||||
spi_txbuf[10] = spi_txbuf[2];
|
||||
spi_txbuf[11] = spi_txbuf[3];
|
||||
// copy [C:F]
|
||||
spi_txbuf[12] = spi_txbuf[0];
|
||||
spi_txbuf[13] = spi_txbuf[1];
|
||||
spi_txbuf[14] = spi_txbuf[2];
|
||||
spi_txbuf[15] = spi_txbuf[3];
|
||||
// change content
|
||||
update_ins_sti_enable(spi_txbuf + 0, TRUE);
|
||||
update_ins_sti_channel(spi_txbuf + 0, instru.sti_channel_pmos, instru.sti_channel_nmos);
|
||||
// ins buf [4:7]
|
||||
update_ins_sti_enable(spi_txbuf + 4, TRUE);
|
||||
update_ins_sti_channel(spi_txbuf + 4, instru.sti_channel_nmos, instru.sti_channel_pmos);
|
||||
// ins buf [8:B]
|
||||
update_ins_sti_enable(spi_txbuf + 8, TRUE);
|
||||
update_ins_sti_channel(spi_txbuf + 8, 0xF, instru.sti_channel_nmos);
|
||||
// ins buf [C:F]
|
||||
update_ins_sti_enable(spi_txbuf + 12, FALSE);
|
||||
break;
|
||||
case STI_MODE_AWF:
|
||||
// XXX define the voltage change
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void headstage_tni_update_instruction_callback(uint8_t ins_type, uint8_t ins_op, uint8_t ins_len, uint8_t *ins) {
|
||||
switch (ins_type) {
|
||||
case INS_TYPE_VIS: {
|
||||
// reset
|
||||
case VIS_RST:
|
||||
// reset. reset all variable
|
||||
adc_clock_signal = FALSE;
|
||||
memset(spi_txbuf, 0, SPI_BUFFER_SIZE);
|
||||
break;
|
||||
|
||||
// interrupt
|
||||
case VIS_INT:
|
||||
// stop. reset channel table
|
||||
ramp_data_counter = 0;
|
||||
memset(spi_txbuf, 0, SPI_BUFFER_SIZE);
|
||||
break;
|
||||
}
|
||||
case INS_TYPE_RIS:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t *spi_transact_rec_instruction() {
|
||||
if (IS_REC_MODE(instru.work_mode)) {
|
||||
PIN_setOutputValue(pin_handle, IOID_13, 1); // DBS_P2S turn on
|
||||
headstage_spi_transaction(SPI_BUFFER_SIZE, spi_txbuf, spi_rxbuf);
|
||||
PIN_setOutputValue(pin_handle, IOID_13, 0); // DBS_P2S turn off
|
||||
|
||||
} else if (IS_ARM_MODE(instru.work_mode) && !adc_clock_signal) {
|
||||
create_ramp(spi_rxbuf);
|
||||
}
|
||||
|
||||
if (adc_clock_signal) {
|
||||
return NULL;
|
||||
} else {
|
||||
return spi_rxbuf;
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t *spi_transact_sti_instruction() {
|
||||
headstage_spi_transaction(16, spi_txbuf, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
+1
-4
@@ -472,9 +472,6 @@ static void SimpleBLEPeripheral_init(void) {
|
||||
GAPRole_SetParameter(GAPROLE_TIMEOUT_MULTIPLIER, sizeof(uint16_t), &desiredConnTimeout);
|
||||
}
|
||||
|
||||
// Set the GAP Characteristics
|
||||
// GGS_SetParameter(GGS_DEVICE_NAME_ATT, sizeof(DEVICE_NAME), DEVICE_NAME);
|
||||
|
||||
// Set advertising interval
|
||||
{
|
||||
uint16_t advInt = DEFAULT_ADVERTISING_INTERVAL;
|
||||
@@ -660,7 +657,7 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
|
||||
InitGPT();
|
||||
|
||||
while(1) {
|
||||
ModeLED(BT_WAIT);
|
||||
|
||||
if (events & SBP_PERIODIC_EVT) {
|
||||
events &= ~SBP_PERIODIC_EVT;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user