Compare commits

...

102 Commits

Author SHA1 Message Date
weiting2 143f733077 add version script 2020-02-24 17:58:46 +08:00
weiting2 a774a98ea4 add version script 2020-02-24 17:54:17 +08:00
weiting2 22350a3555 add version script 2020-02-24 17:53:04 +08:00
weiting2 bd3ab34263 add version script 2020-02-24 17:51:54 +08:00
weiting2 1f3ef4c84a add version script 2020-02-24 17:50:46 +08:00
weiting2 2add4a55ef add version script 2020-02-24 17:50:39 +08:00
weiting2 8788cf21c4 add version script 2020-02-24 17:47:37 +08:00
weiting2 2ddc9eb927 add version script 2020-02-24 17:47:28 +08:00
weiting2 a4f8684bef add version script 2020-02-24 17:45:23 +08:00
weiting2 10c6cf52b1 add version script 2020-02-24 17:42:14 +08:00
weiting2 f12064e029 add version script 2020-02-24 17:42:04 +08:00
weiting2 985cf9f977 add version script 2020-02-24 17:41:02 +08:00
weiting2 1b54fcae86 add version script 2020-02-24 17:37:14 +08:00
weiting2 f1b2e5a530 add version script 2020-02-24 17:25:24 +08:00
weiting2 2464c99999 add version script 2020-02-24 17:09:06 +08:00
weiting2 17fd5ace9b amplitude = 0x01FF 2020-02-24 11:46:08 +08:00
weiting2 e266de61bf amplitude = 0x01FF 2020-02-24 11:39:09 +08:00
weiting2 e8ba02eb7a amplitude = 0x01FF 2020-02-24 11:29:49 +08:00
weiting2 40edc8677f fix t2~t5 assign bug 2020-02-24 10:53:49 +08:00
weiting2 82d9be071b fix t2~t5 assign bug 2020-02-24 10:28:29 +08:00
weiting2 81760c35c9 I forgot to set amplitude at the last commit QQ 2020-02-21 18:33:38 +08:00
weiting2 9a361e6e97 new test pattern 2020-02-21 17:33:16 +08:00
weiting2 67a276dbb6 current_sti_polarity should be 16-bits 2020-02-21 17:13:48 +08:00
weiting2 be1276785c bug fix 2020-02-21 16:57:20 +08:00
weiting2 2f8b646a4f return NEU_SETUP_DONE at correct time 2020-02-21 16:42:36 +08:00
yichin 1ff7bc8746 error fix 3 2020-02-21 12:17:45 +08:00
weiting2 1dbf5c1b6b using warm up instruction 2020-02-21 12:11:59 +08:00
weiting2 5ba1f22de8 using warm up instruction 2020-02-21 11:40:12 +08:00
weiting2 e04a49b6a0 using warm up instruction 2020-02-21 09:55:48 +08:00
weiting2 5b2529ad71 try to read register 2020-02-19 18:25:05 +08:00
weiting2 e0a193c671 Merge remote-tracking branch 'origin/Neulive20_MergeWith13' into Neulive20_MergeWith13 2020-02-19 16:54:52 +08:00
weiting2 99023db231 try to read register 2020-02-19 16:54:43 +08:00
yichin 2c5c92e578 error fix 2020-02-19 16:48:15 +08:00
weiting2 22594e36c0 we can config more than one channel now 2020-02-19 16:44:44 +08:00
weiting2 9018c98a68 test sti instruction 2020-02-19 14:45:52 +08:00
weiting2 62ed077791 test sti instruction 2020-02-19 14:28:09 +08:00
weiting2 68b32a5a15 test sti instruction 2020-02-19 11:56:55 +08:00
weiting2 a24aebf4ac test sti instruction 2020-02-19 11:29:19 +08:00
weiting2 95a7926f36 test sti instruction 2020-02-19 10:37:49 +08:00
yichin 76d5537b7a Merge remote-tracking branch 'origin/Neulive20_MergeWith13' into Neulive20_MergeWith13 2020-02-19 10:10:00 +08:00
weiting2 75f1fcc663 test sti instruction 2020-02-19 09:56:46 +08:00
weiting2 ab803c7a54 test sti instruction 2020-02-18 18:56:09 +08:00
yichin 0431f8f1be Merge remote-tracking branch 'origin/Neulive20_MergeWith13' into Neulive20_MergeWith13 2020-02-18 18:42:40 +08:00
weiting2 4f1884a468 test sti instruction 2020-02-18 18:42:12 +08:00
yichin 1789fd82a0 Merge remote-tracking branch 'origin/Neulive20_MergeWith13' into Neulive20_MergeWith13 2020-02-18 18:17:31 +08:00
weiting2 9602b5e7fb test sti instruction 2020-02-18 17:52:22 +08:00
yichin 08e9cc715f error fix 2020-02-18 16:53:23 +08:00
weiting2 578b483c68 Merge remote-tracking branch 'origin/Neulive20_MergeWith13' into Neulive20_MergeWith13 2020-02-18 16:46:13 +08:00
weiting2 fc2bd6b187 test sti instruction 2020-02-18 16:46:04 +08:00
yichin e7180b56ee Merge remote-tracking branch 'origin/Neulive20_MergeWith13' into Neulive20_MergeWith13 2020-02-18 14:10:19 +08:00
yichin 020703e07d error fix 2020-02-18 14:10:06 +08:00
weiting2 c1e8443ceb test sti instruction 2020-02-18 14:09:22 +08:00
weiting2 7cda4c4dec test sti instruction 2020-02-18 11:47:01 +08:00
weiting2 4194730f9c get register value (for debug) 2020-02-18 10:40:14 +08:00
weiting2 a3fabf7eb6 get register value (for debug) 2020-02-18 10:07:07 +08:00
weiting2 33b17782cf get register value (for debug) 2020-02-15 18:20:54 +08:00
weiting2 0307d7ba2a H-bridge test 2020-02-15 17:20:46 +08:00
weiting2 00c431dfd0 H-bridge test 2020-02-15 17:19:19 +08:00
weiting2 317b34a8c0 t4 = 0.5 * t1 2020-02-15 16:55:32 +08:00
weiting2 09060b0b6f test current sti 2020-02-15 16:14:42 +08:00
weiting2 4cdda6dacb Merge remote-tracking branch 'origin/Neulive20_MergeWith13' into Neulive20_MergeWith13 2020-02-15 15:36:56 +08:00
weiting2 54193ffae7 test current sti 2020-02-15 15:36:45 +08:00
yichin af5cd3dcf2 error fix 2020-02-15 15:27:34 +08:00
yichin c9985a3c67 Merge remote-tracking branch 'origin/Neulive20_MergeWith13' into Neulive20_MergeWith13
# Conflicts:
#	simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_version.h
2020-02-15 15:26:26 +08:00
yichin 1d7aa1b0ad add version.h 2020-02-15 15:25:58 +08:00
weiting2 bb4561bd4e test current sti 2020-02-15 15:24:14 +08:00
weiting2 9077420de8 [BUG] voltage stimulate has a bug, voltage_sti_amplitude can't assign 2020-02-15 12:05:28 +08:00
weiting2 26e5f36783 stimulate test 2020-02-15 11:46:43 +08:00
weiting2 4d5b7b3033 stimulate test 2020-02-15 11:22:36 +08:00
weiting2 ed73d2fdae sti channel should be a u16, not u8
(because current+volt have 8+1 = 9 channel)
2020-02-14 18:44:14 +08:00
weiting2 a00aec83ff return version from CIS 2020-02-14 18:21:10 +08:00
yichin 6b611ff248 return version from CIS
new cali table
2020-02-14 18:20:14 +08:00
weiting2 e2af8153ed return version from CIS 2020-02-14 18:19:03 +08:00
weiting2 5724a22c9d try to use volt sti 2020-02-14 18:14:57 +08:00
weiting2 ee8e207004 [stable] recording well function; system clk = 2M; sample rate = 2k (default, ADC_clk_ratio=100) 2020-02-14 12:12:06 +08:00
weiting2 a2c93167ce 8k sample rate 2020-02-13 18:01:36 +08:00
weiting2 e94fd65e8f notify data size should be 241, not 20 2020-02-13 16:54:08 +08:00
weiting2 ddf2f9e8f5 will it break down if pi3 don't save data 2020-02-13 16:00:49 +08:00
weiting2 923e6408e7 will it break down if don't send notify 2020-02-13 15:21:15 +08:00
weiting2 96e6a441b9 2k sample rate 2020-02-13 13:54:28 +08:00
weiting2 fbb8a4cbf6 1k sample rate 2020-02-13 11:46:01 +08:00
weiting2 2c84a79ebb test notify 2020-02-13 11:19:20 +08:00
weiting2 7bd2381dca test notify 2020-02-13 11:09:27 +08:00
weiting2 a922b0cc40 test notify 2020-02-13 11:05:54 +08:00
weiting2 3c0cf37074 test notify 2020-02-13 10:45:00 +08:00
weiting2 f9412ed0ea test notify 2020-02-13 10:37:54 +08:00
weiting2 da6647391c notify length = 241; should be 20 2020-02-13 10:13:37 +08:00
weiting2 a2c6c0298e notify length = 241; should be 20 2020-02-12 18:48:03 +08:00
weiting2 aa6c58df79 test instruction 2020-02-12 18:01:53 +08:00
yichin 71d43c26be error fix 2020-02-12 16:34:53 +08:00
weiting2 e9dea14165 is interrupt a bug? 2020-02-12 16:32:06 +08:00
weiting2 3b076f0faa Merge remote-tracking branch 'origin/Neulive20_MergeWith13' into Neulive20_MergeWith13 2020-02-12 15:28:36 +08:00
weiting2 2f4c6ce787 notify buffer size = 20 2020-02-12 15:28:27 +08:00
yichin 6425ffd91c error fix; still have pin init error 2020-02-12 12:01:39 +08:00
weiting2 cbbe0a7387 merge everything in neu1.3 2020-02-12 10:09:04 +08:00
yichin ad0c8e6bd6 error fix; still have pin init error 2020-02-11 18:57:40 +08:00
weiting2 68085d5ea5 merge everything in neu1.3 2020-02-11 18:45:48 +08:00
weiting2 bfba8a23e1 merge everything in neu1.3 2020-02-11 18:36:49 +08:00
weiting2 2cd847b57b merge peripheral.c headstage.h pin.h 2020-02-11 18:29:28 +08:00
weiting2 11928ccbb8 merge peripheral.c headstage.h pin.h 2020-02-11 18:16:38 +08:00
weiting2 7bc70b5a72 merge peripheral.c headstage.h pin.h 2020-02-11 17:35:24 +08:00
weiting2 e10eeb48dd merge peripheral.c headstage.h pin.h 2020-02-11 15:45:28 +08:00
20 changed files with 985 additions and 392 deletions
Executable
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
year=$(date +%y)
month=$(date +%m)
day=$(date +%d)
hour=$(date +%H)
minute=$(date +%M)
hash=$(git rev-parse HEAD)
sed -i "5c #define VERSION_DATE_YEAR ${year}"\
./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_version.h
sed -i "6c #define VERSION_DATE_MONTH ${month}"\
./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_version.h
sed -i "7c #define VERSION_DATE_DAY ${day}"\
./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_version.h
sed -i "8c #define VERSION_DATE_HOUR ${hour}"\
./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_version.h
sed -i "9c #define VERSION_DATE_MINUTE ${minute}"\
./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_version.h
sed -i "13c #define VERSION_HASH ${hash}"\
./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_version.h
#cat ./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_version.h
@@ -12,7 +12,7 @@
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_TARGET_CONFIG" value="${target_config_active_default:simple_peripheral_cc2650em_app}"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="C:/ti\ccsv8\ccs_base\emulation\gel\images\cc26xx\cc26x0_rtos_rom_syms.out"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/simple_peripheral_cc2650em_app"/>
</listAttribute>
@@ -51,6 +51,7 @@ extern "C" {
#include <ti/drivers/PIN.h>
#include <driverlib/ioc.h>
#define HEADSTAGE_UNI_2_0
#ifdef HEADSTAGE_UNI_2_0
#include "neu/headstage_pin.h"
#else
@@ -193,6 +193,8 @@ extern ICall_Semaphore semaphore;
#define CIS_NOP 0x00
#define CIS_VOLT 0x10
#define CIS_LED 0x20
#define CIS_CALI 0x30
#define CIS_VERSION 0x40
// CIS return status code
#define CDR_SUCCESS 0x0
@@ -316,7 +318,7 @@ typedef struct {
==== device implement implement header ====
=========================================*/
#include "headstage_uni.h"
#include "headstage_neu.h"
/*!
* main function
@@ -0,0 +1,14 @@
#ifndef BIT_COUNT
#define BIT_COUNT
static uint8_t BitCount(uint8_t u8_value){
uint8_t ret = 0;
for(int i=0 ; i<8 ; i++){
if(u8_value & (1 << i)){
ret ++;
}
}
return ret;
}
#endif
@@ -0,0 +1,87 @@
#ifndef NEU_INSTRUCTION
#define NEU_INSTRUCTION
struct HEADSTAGE_PARAMETER_TABLE {
uint8_t current_sti_cycle[NEU_STI_CHANNEL_COUNTS]; /** stimulation times will be executed. */
// sti_tx[0~7] is current stimulate
// sti_tx[8] assign to voltage mode channel. */
uint16_t sti_t1[NEU_STI_CHANNEL_COUNTS]; /**< first stimulation pulse duration, it can't be 0. */
uint16_t sti_t2[NEU_STI_CHANNEL_COUNTS]; /**< interval between biphasic pulses. */
uint16_t sti_t3[NEU_STI_CHANNEL_COUNTS]; /**< second stimulation pulse duration. */
uint32_t sti_t4[NEU_STI_CHANNEL_COUNTS]; /**< discharge time per stimulation. */
uint16_t sti_t5[NEU_STI_CHANNEL_COUNTS]; /**< discharge time after final stimulation. */
bool sti_mode; /**< if true: continuous mode, else limited mode. */
bool sti_h_bridge; /**< if true: enable h bridge, else single ended. */
bool sti_ref; /**< if true: reference cell body to gnd, else single ended is used. */
uint16_t current_sti_polarity; /**<
* default : low side.
* define which channel is high side or low side.
*/
uint8_t voltage_sti_channel; /**<
* voltage_channel[7:4] represent pmos channel,
* voltage_channel[3:0] represent nmos channel
*/
uint8_t amplifier_gain; /**<
* parameter table to represent actual amplifier gain
* ----------
* | bit |mean|
* ----------
* |0b00 | 100|
* ----------
* |0b01 | 400|
* ----------
* |0b10 | 800|
* -----------
* |0b11 | 25 |
* -----------
*/
/**< these parameter define the bias voltage of amplifier. */
uint8_t vgrp;
uint8_t vgrn;
uint8_t vgr_int_old;
uint8_t vgr_intp;
uint8_t vgr_intn;
uint8_t ins_opcode; /**< check instruction opcode which is transmitted to DBS. */
uint8_t voltage_sti_amplitude; /**< voltage mode stimulation amplitude control. */
uint16_t arbitrary_index; /**< this index to keep address of arbitrary data we have already stored. */
uint16_t arbitrary_en; /**< if true: enable arbitrary mode stimulation. */
uint16_t recording_channel; /**< recording_channel[17] represent enabling channel 17. */
uint16_t sti_amplitude_h; /**< positive side amplitude. */
uint16_t sti_amplitude_l; /**< negative side amplitude. */
uint16_t sys_clk_ratio; /**< frequency divider ratio for digital core clock. */
uint16_t adc_clock_ratio; /**< frequency divider ratio for adc clock. */
uint16_t sti_clock_ratio; /**< frequency divider ratio for stimulation clock. */
uint16_t chopper_ratio; /**< freqeuncy divider for chopper. */
uint16_t sti_channel; /**<
* if stimulation[7] == true, stimulation channel 7 is enabled .
* if stimulation[4] == true. stimulation channel 4 is enabled .
*/
uint8_t sti_ch_config_done; // number of stimulate channel which is config done
} INSTRUCTION = {0};
/**
* @brief:
* manage which operation to be conducted
*/
struct HEADSTAGE_STATE {
uint8_t state;
uint8_t config_type;
uint8_t index;
} NEULIVE_STATE = {0};
#endif
@@ -192,7 +192,7 @@ static void headstage_led_color(uint8_t color) {
==== LED implement (GPIO) ====
============================*/
#if defined (HEADSTAGE_UNI_H) || defined(HEADSTAGE_TEST_DATA_H)
#ifdef HEADSTAGE_UNI_H
#define HEADSTAGE_LED_USE_GPIO
#endif
@@ -44,31 +44,31 @@ static uint8_t headstage_notify_buffer[BLE_NOT_BUFF_SIZE] = {0};
*
*/
static void headstage_notify_send() {
#ifdef HEADSTAGE_NOTIFY_USE_ATT
uint16_t buffer_size = BLE_NOT_BUFF_SIZE;
uint8_t *value = (uint8 *)GATT_bm_alloc(CONNECT_HANDLE, ATT_HANDLE_VALUE_NOTI, GATT_MAX_MTU, &buffer_size);
if (value != NULL) {
memcpy(value, headstage_notify_buffer, buffer_size);
attHandleValueNoti_t notify = {
// clang-format off
.handle = 0x1E,
.len = buffer_size,
.pValue = value
// clang-format on
};
if (GATT_Notification(CONNECT_HANDLE, &notify, 0) != SUCCESS) {
// notify not send
GATT_bm_free((gattMsg_t *)&notify, ATT_HANDLE_VALUE_NOTI);
}
}
#else
//#ifdef HEADSTAGE_NOTIFY_USE_ATT
// uint16_t buffer_size = BLE_NOT_BUFF_SIZE;
// uint8_t *value = (uint8 *)GATT_bm_alloc(CONNECT_HANDLE, ATT_HANDLE_VALUE_NOTI, GATT_MAX_MTU, &buffer_size);
//
// if (value != NULL) {
// memcpy(value, headstage_notify_buffer, buffer_size);
//
// attHandleValueNoti_t notify = {
// // clang-format off
// .handle = 0x1E,
// .len = buffer_size,
// .pValue = value
// // clang-format on
// };
//
// if (GATT_Notification(CONNECT_HANDLE, &notify, 0) != SUCCESS) {
// // notify not send
// GATT_bm_free((gattMsg_t *)&notify, ATT_HANDLE_VALUE_NOTI);
// }
// }
//
//#else
SimpleProfile_SetParameter(BLE_NOT_BUFF_CHAR, BLE_NOT_BUFF_SIZE, headstage_notify_buffer);
#endif
//#endif
}
#endif // HEADSTAGE_NOTIFY_H
@@ -123,6 +123,9 @@
#include "uni/headstage_spi.h"
#include "uni/headstage_pwm.h"
#include "uni/uni1.3_parameter.h"
#include "neulive13_CalibrationTable.h"
#include "headstage_calibration_CIS.h"
#include "headstage_version.h"
/************************************
* instruction building macro
@@ -852,6 +855,17 @@ static void headstage_update_cis_instruction(uint8_t cis_oper) {
break;
}
#endif
case CIS_VERSION:{
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;
SimpleProfile_SetParameter(BLE_CDR_BUFF_CHAR, BLE_CDR_BUFF_SIZE, cdr_buf);
break;
}
default: {
cdr_buf[0] = _B_4b4b(cis_oper, CHIP_ID);
cdr_buf[1] = _B_4b4b(CDR_FAILURE, 0);
@@ -884,9 +898,14 @@ static void headstage_uni_umc_data_append_notify_buffer(uint8_t* dat_buf) {
headstage_uni_delay();
} else {
if ((dat_buf[1] & 0x28) == 0x28) {
// headstage_led_spi_color(COLOR_YELLOW);
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);
// dat_buf[0] = (dat_buf[0] << 1) | ((dat_buf[1] >> 7) & 0x01);
// dat_buf[2] = ((dat_buf[1] & 0b00000111) << 2) | (dat_buf[2] & 0b11100000);
// dat_buf[1] = (dat_buf[1] >> 3) & 0b00001111;
}
uint8_t channel;
@@ -0,0 +1,15 @@
#ifndef VERSION_DATE
#define VERSION_DATE
#define VERSION_DATE_YEAR 20
#define VERSION_DATE_MONTH 02
#define VERSION_DATE_DAY 24
#define VERSION_DATE_HOUR 17
#define VERSION_DATE_MINUTE 58
// this is NOT the version hash !!
// it's the last version hash
#define VERSION_HASH a774a98ea462e2422a7c1793dc9cb68c4de7e948
#endif
@@ -0,0 +1,23 @@
#ifndef CHECK_MOSI
#define CHECK_MOSI
#include "headstage_led.h"
/*
* MOSI channel meet with INSTRUCTION.recording_channel ?
*/
static uint8_t CheckMOSI(uint8_t* MOSI){
uint8_t ch = MOSI[0];
uint16_t selectCh = 0x0001 << ch;
if(selectCh & INSTRUCTION.recording_channel){
return 1;
}
else{
// headstage_led_color(COLOR_RED);
// headstage_led_color(COLOR_GREEN);
return 0;
}
}
#endif
@@ -10,7 +10,7 @@
#define NOT_BUF_OFFSET_INIT 8
static uint32_t not_buf_offset = NOT_BUF_OFFSET_INIT;
static uint8_t not_buf_offset = NOT_BUF_OFFSET_INIT;
static uint32_t not_time_stamp = 0;
static void headstage_notify_set_timestamp() {
@@ -23,7 +23,7 @@ static void headstage_notify_set_timestamp() {
}
static void headstage_notify_flip_buffer() {
uint8_t data_count = (not_buf_offset - NOT_BUF_OFFSET_INIT) / 2;
uint8_t data_count = (not_buf_offset - NOT_BUF_OFFSET_INIT) / 3;
headstage_notify_buffer[0] = CHIP_ID;
headstage_notify_buffer[1] = data_count;
@@ -39,13 +39,15 @@ static uint8_t headstage_notify_append_data(uint8_t *data_value) {
if (data_value == NULL) {
headstage_notify_buffer[not_buf_offset++] = 0x00;
headstage_notify_buffer[not_buf_offset++] = 0x03;
headstage_notify_buffer[not_buf_offset++] = 0x00;
headstage_notify_buffer[not_buf_offset++] = 0x00;
} else {
headstage_notify_buffer[not_buf_offset++] = data_value[0];
headstage_notify_buffer[not_buf_offset++] = data_value[1];
headstage_notify_buffer[not_buf_offset++] = data_value[2];
}
if (not_buf_offset == BLE_NOT_BUFF_SIZE) {
if (not_buf_offset >= BLE_NOT_BUFF_SIZE - 1) {
uint32_t current = headstage_time_stamp_us();
uint32_t time_delta = ((current - not_time_stamp)) & 0xFFFF;
@@ -25,19 +25,19 @@
// clang-format off
#define PIN_RESET IOID_0 // SPI1 to receive LSK
#define PIN_EN_ADC_SPI_CLK IOID_1 // SPI1 clock
#define PIN_LED_SDI IOID_0 // SPI1 to receive LSK
#define PIN_LED_CLK IOID_1 // SPI1 clock
#define PIN_DC_DC IOID_2 // STI select need
#define PIN_BATT_HALF IOID_3 //
#define PIN_AMP_VCK IOID_4 //
#define PIN_LED_SDI IOID_7 //
#define PIN_LED_CLK IOID_8 //
#define PIN_STI_CLK IOID_9 //
#define PIN_SPI_MISO IOID_10 //
#define PIN_SPI_MOSI IOID_11 //
#define PIN_SPI_CS IOID_12 //
#define PIN_SPI_CLK IOID_13 //
#define PIN_SYS_CLK IOID_14 //
#define PIN_EN_ADC_SPI_CLK IOID_3 //
#define PIN_BATT_HALF IOID_4 //
#define PIN_SPI_MISO IOID_7 //
#define PIN_SPI_MOSI IOID_8 //
#define PIN_SPI_CS IOID_9 //
#define PIN_SPI_CLK IOID_10 //
#define PIN_SYS_CLK IOID_11 //
#define PIN_RESET IOID_12 //
#define PIN_AMP_VCK IOID_13 //
#define PIN_STI_CLK IOID_14 //
// clang-format on
#endif
@@ -47,7 +47,8 @@
#define Board_SPI0_MISO PIN_SPI_MISO
#define Board_SPI0_MOSI PIN_SPI_MOSI
#define Board_SPI0_CLK PIN_SPI_CLK
#define Board_SPI0_CSN PIN_SPI_CS
//#define Board_SPI0_CSN PIN_SPI_CS
#define Board_SPI0_CSN PIN_UNASSIGNED
/*
* SPI1 interface work with LED
@@ -0,0 +1,96 @@
#ifndef NEU_2_RST
#define NEU_2_RST
#include "headstage_instruction.h"
#include "neu/headstage_spi.h"
static void ResetINSTRUCTION();
static void MCUReset(){
// Reset INSTRUCTION & NEULIVE_STATE
ResetINSTRUCTION();
// SPI buffer reset
for(int i=0 ; i<SPI_BUFFER_SIZE ; i++ ){
spi_txbuf[i] = 0;
spi_rxbuf[i] = 0;
}
SPICallBack = ONE_SHOT_SPI;
// FlushSPICounter = 0;
for(int i=0 ; i<SPI_LED_BUFF_SIZE ; i++){
headstage_spi_led_txbuf[i] = 0;
}
// CIS buffer reset
for(int i=0 ; i<BLE_CDR_BUFF_SIZE ; i++){
cdr_buf[i] = 0;
}
// Notify Buffer reset
for(int i=0 ; i<BLE_NOT_BUFF_SIZE ; i++){
headstage_notify_buffer[i] = 0;
}
not_buf_offset = NOT_BUF_OFFSET_INIT;
not_time_stamp = 0;
headstage_led_color(COLOR_GREEN); // color green
}
static void DBSReset(){
headstage_pin_output(PIN_RESET, 0);
headstage_cpu_delay_ms(10);
headstage_pin_output(PIN_DC_DC, 1);
headstage_pin_output(PIN_EN_ADC_SPI_CLK, 1);
headstage_pin_output(PIN_RESET, 1);
}
static void Neu2Reset(){
DBSReset();
MCUReset();
}
static void ResetINSTRUCTION(){
INSTRUCTION.vgrp = 16;
INSTRUCTION.vgrn = 16;
INSTRUCTION.vgr_intp = 16;
INSTRUCTION.vgr_intn = 16;
INSTRUCTION.vgr_int_old = 16;
INSTRUCTION.recording_channel = 0b0000000000000000;
INSTRUCTION.adc_clock_ratio = 100;
INSTRUCTION.sys_clk_ratio = 10;
INSTRUCTION.sti_clock_ratio = 10;
INSTRUCTION.amplifier_gain = 0;
INSTRUCTION.chopper_ratio = 2;
INSTRUCTION.sti_t1[1] = 1;
INSTRUCTION.sti_t2[1] = 0;
INSTRUCTION.sti_t3[1] = 0;
INSTRUCTION.sti_t4[1] = 0;
INSTRUCTION.sti_t5[1] = 0;
INSTRUCTION.sti_channel = 2;
INSTRUCTION.arbitrary_en = 0;
INSTRUCTION.arbitrary_index = 0;
INSTRUCTION.sti_h_bridge = 0;
INSTRUCTION.sti_mode = 0;
INSTRUCTION.sti_ref = 0;
INSTRUCTION.current_sti_polarity = 2;
INSTRUCTION.sti_amplitude_h = 0;
INSTRUCTION.sti_amplitude_l = 0;
INSTRUCTION.ins_opcode = BIAS_ONE;
INSTRUCTION.sti_ch_config_done = 0;
uint8_t voltage_sti_channel = 0;
uint8_t voltage_sti_amplitude = 0;
for(int i=0 ; i<NEU_STI_CHANNEL_COUNTS ; i++){
INSTRUCTION.current_sti_cycle[i] = 0;
}
NEULIVE_STATE.state = NEU_IDLE;
NEULIVE_STATE.config_type = 0;
NEULIVE_STATE.index = 0;
}
#endif
@@ -12,7 +12,7 @@
#include <ti/drivers/dma/UDMACC26XX.h>
#include <ti/drivers/spi/SPICC26XXDMA.h>
#define SPI_BUFFER_SIZE 20
#define SPI_BUFFER_SIZE 3
static uint8_t spi_txbuf[SPI_BUFFER_SIZE] = {0};
static uint8_t spi_rxbuf[SPI_BUFFER_SIZE] = {0};
@@ -22,6 +22,7 @@ static SPI_Handle headstage_spi_handle = NULL;
static SPI_Transaction headstage_spi_transaction;
static void headstage_spi_callback(SPI_Handle handle, SPI_Transaction* transaction);
static bool OpenSPI = false;
// SPI parameters initialize
#define headstage_spi_open() \
@@ -38,14 +39,14 @@ static void headstage_spi_callback(SPI_Handle handle, SPI_Transaction* transacti
headstage_spi_handle = SPI_open(Board_SPI0, &spi_parameter); \
} while (0)
#define headstage_spi_transaction(handle, length, tx, rx) \
({ \
SPI_Transaction transaction = headstage_spi_transaction ; \
transaction.count = (length); \
transaction.txBuf = (tx); \
transaction.rxBuf = (rx); \
SPI_transfer(handle, &transaction); \
})
//#define headstage_spi_transaction(handle, length, tx, rx) \
// ({ \
// SPI_Transaction transaction = headstage_spi_transaction ; \
// transaction.count = (length); \
// transaction.txBuf = (tx); \
// transaction.rxBuf = (rx); \
// SPI_transfer(handle, &transaction); \
// })
#define headstage_spi_transaction(length) \
({ \
@@ -70,4 +71,54 @@ static void headstage_spi_callback(SPI_Handle handle, SPI_Transaction* transacti
} \
} while (0)
//static void ReopenSPI(){
// SPI_init();
// SPI_Params spi_parameter;
// SPI_Params_init(&spi_parameter);
// spi_parameter.transferMode = SPI_MODE_CALLBACK;
// spi_parameter.mode = SPI_SLAVE;
// spi_parameter.bitRate = NEU_SPI_FREQ;
// spi_parameter.dataSize = 8;
// spi_parameter.frameFormat = SPI_POL0_PHA1;
// spi_parameter.transferCallbackFxn = headstage_spi_callback;
// headstage_spi_handle = SPI_open(Board_SPI0, &spi_parameter);
//}
//static void WriteSPI(uint8_t length){
// if(OpenSPI){
// ReopenSPI();
// }
//
// for(int i=length ; i<SPI_BUFFER_SIZE ; i++){
// spi_rxbuf[i] = 0x00;
// }
//
// SPICallBack = FLUSH_BUFFER;
// headstage_spi_transaction.count = 3;
// headstage_spi_transaction.txBuf = spi_txbuf;
// headstage_spi_transaction.rxBuf = spi_rxbuf;
//
// SPI_transfer(headstage_spi_handle, &headstage_spi_transaction);
//}
//static void ReadSPI(){
// if(OpenSPI){
// ReopenSPI();
// }
//
// SPICallBack = READ_REG;
// headstage_spi_transaction.count = 3;
// headstage_spi_transaction.txBuf = spi_txbuf;
// headstage_spi_transaction.rxBuf = spi_rxbuf;
//
// SPI_transfer(headstage_spi_handle, &headstage_spi_transaction);
//}
static void AppendSPITX(uint8_t index, uint32_t value){
tx_put_u24(index, value);
for(int i=3 ; i<SPI_BUFFER_SIZE ; i++){
spi_txbuf[i] = 0;
}
}
#endif
@@ -10,7 +10,7 @@
#define NOT_BUF_OFFSET_INIT 8
static uint32_t not_buf_offset = NOT_BUF_OFFSET_INIT;
static uint8_t not_buf_offset = NOT_BUF_OFFSET_INIT;
static uint32_t not_time_stamp = 0;
static void headstage_notify_set_timestamp() {
@@ -76,14 +76,14 @@
#endif
static PIN_Config headstage_pin_configuration[] = { //
PIN_STI_SEL | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
PIN_RESET | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
PIN_VGRP | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
PIN_FASTSET | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
PIN_LED_CLK | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
PIN_LED_OUT | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
//
PIN_TERMINATE};
//static PIN_Config headstage_pin_configuration[] = { //
// PIN_STI_SEL | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// PIN_RESET | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// PIN_VGRP | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// PIN_FASTSET | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// PIN_LED_CLK | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// PIN_LED_OUT | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// //
// PIN_TERMINATE};
#endif // HEADSTAGE_PIN_UNI_H
@@ -407,7 +407,9 @@ static void SimpleBLEPeripheral_init(void) {
// Register for GATT local events and ATT Responses pending for transmission
GATT_RegisterForMsgs(self);
headstage_led_spi_color(COLOR_GREEN);
// HCI_LE_ReadMaxDataLenCmd();
//
// HCI_LE_WriteSuggestedDefaultDataLenCmd(251, 2120); // this is used for data length extension
}
@@ -507,7 +509,7 @@ static void headstage_init_device_info() {
for (unsigned int i = 0; i < sizeof(DEVICE_NAME) - 1; i++) {
*p++ = DEVICE_NAME[i];
}
*p++ = 15;
*p++ = 11;
*p++ = GAP_ADTYPE_MANUFACTURER_SPECIFIC;
// unsafe_memcpy(p, "BPHS", 4);
*p++ = 'B';
@@ -520,11 +522,6 @@ static void headstage_init_device_info() {
*p++ = MINOR_VERSION_NUMBER;
*p++ = year;
*p++ = month;
*p++ = 'B';
*p++ = 'A';
*p++ = 'T';
*p++ = headstage_battery_percent();
GGS_SetParameter(GGS_DEVICE_NAME_ATT, sizeof(DEVICE_NAME), DEVICE_NAME);
@@ -828,7 +825,7 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
GAPRole_GetParameter(GAPROLE_CONNHANDLE, &cxnHandle);
if (SUCCESS == HCI_LE_SetDataLenCmd(cxnHandle, requestedPDUSize, requestTxTime)) {
headstage_led_spi_color(COLOR_CYAN);
headstage_led_color(COLOR_CYAN);
}
// Use numActive to determine the connection handle of the last
// connection
@@ -849,12 +846,12 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
// Device just timed out from a connection but is not yet advertising, is in waiting period before advertising again
// disconnected
SimpleBLEPeripheral_freeAttRsp(bleNotConnected);
headstage_led_spi_color(COLOR_RED); /** for neulive1.3 call headstage_led_spi_color ; for neulive2.0 call headstage_led_color */
headstage_led_color(COLOR_RED);
CONNECT_HANDLE = 0xFFFF;
flag_notify(EVT_DISCONNECTED);
break;
case GAPROLE_ERROR: // Error occurred - invalid state
headstage_led_spi_color(COLOR_RED);
headstage_led_color(COLOR_RED);
break;
case GAPROLE_INIT: // Waiting to be started
case GAPROLE_ADVERTISING: // Currently Advertising
@@ -85,6 +85,7 @@ extern "C" {
#define SIMPLEPROFILE_CHAR2_LEN 10
#define SIMPLEPROFILE_CHAR3_LEN 20
#define SIMPLEPROFILE_CHAR4_LEN 200
//#define SIMPLEPROFILE_CHAR4_LEN 20
#define SIMPLEPROFILE_CHAR5_LEN 20
/*********************************************************************