Compare commits

...

46 Commits

Author SHA1 Message Date
yichin d45420579a error fix 2020-05-20 17:34:31 +08:00
weiting2 1ac4b0b640 attempt to support "connect" function 2020-05-20 17:27:16 +08:00
weiting2 eb4b14af59 attempt to support "display scanned device" function 2020-05-19 11:06:10 +08:00
weiting2 325f34b867 attempt to support "display scanned device" function 2020-05-19 11:03:27 +08:00
weiting2 46cd82a2d6 attempt to support "display scanned device" function 2020-05-19 10:53:40 +08:00
weiting2 15bcefc9d1 attempt to support "display scanned device" function 2020-05-19 10:45:54 +08:00
weiting2 58dcd3f128 we can support "scan" instruction now 2020-05-18 18:20:41 +08:00
yichin 7aa40392d0 update cali data 2020-05-18 18:15:31 +08:00
yichin 1d32330d27 update cali data 2020-05-18 18:10:48 +08:00
weiting2 7c783ef0bf Merge remote-tracking branch 'origin/central_pseudo_controller' into central_pseudo_controller
# Conflicts:
#	simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/pesudo_controller/pesudo_pi_uart.h
2020-05-18 17:51:57 +08:00
weiting2 6b59a997c2 attempt to support "scan" instruction 2020-05-18 17:51:34 +08:00
yichin 774811d83b update cali data 2020-05-18 17:37:52 +08:00
weiting2 9b55ab972c attempt to support "scan" instruction 2020-05-18 17:31:49 +08:00
yichin f6828c9ad1 update cali data 2020-05-18 17:17:21 +08:00
yichin 5d00281bbe update cali data 2020-05-18 17:10:17 +08:00
weiting2 e60ba49220 attempt to support "scan" instruction 2020-05-18 16:44:36 +08:00
yichin 5f0c413e56 update cali data 2020-05-18 15:38:57 +08:00
weiting2 524e62bcc7 attempt to support "scan" instruction 2020-05-18 15:25:36 +08:00
yichin 2d2946753b error fix 2020-05-18 12:43:41 +08:00
weiting2 2c5ad43d22 attempt to support "scan" instruction 2020-05-18 12:32:11 +08:00
weiting2 ee9b117da0 UART read should not have timeout 2020-05-15 16:13:17 +08:00
weiting2 7e42d35d00 central mem board attempt to read UART 2020-05-15 12:46:41 +08:00
weiting2 c715aba1b8 attempt to avoid DIO2, 3 2020-05-14 17:59:20 +08:00
yichin 29e0d7b4f5 update pesudo controller name 2020-05-14 17:20:27 +08:00
yichin d91eaed4fb update cali data 2020-05-14 16:27:39 +08:00
yichin 6983f193ce UART init pullup 2020-05-14 16:24:52 +08:00
yichin 5640b54ae9 update cali data 2020-05-14 16:08:01 +08:00
yichin 9948179728 Merge remote-tracking branch 'origin/central_pseudo_controller' into central_pseudo_controller 2020-05-14 15:44:04 +08:00
weiting2 874a2cb05a pesudo controller LP 2020-05-14 13:15:32 +08:00
yichin 777709171f error fix 2020-05-14 09:58:33 +08:00
weiting2 885caace80 pesudo controller LP 2020-05-14 09:43:36 +08:00
yichin 40cb4d7a1e error fix 2020-05-13 18:51:56 +08:00
weiting2 680b0a0599 pesudo controller LP 2020-05-13 18:32:58 +08:00
weiting2 c60469f5b4 pesudo controller LP 2020-05-13 18:29:11 +08:00
yichin 6bc775b694 error fix 2020-05-13 18:07:16 +08:00
weiting2 547877b30d pesudo controller LP 2020-05-13 18:01:36 +08:00
weiting2 0af1434882 pesudo controller LP 2020-05-13 18:00:14 +08:00
yichin b1477d96f5 update cali data 2020-05-13 17:49:39 +08:00
weiting2 119d8e385c attempt to use LED 2020-05-11 12:06:59 +08:00
weiting2 23adda2e53 attempt to use UART 2020-05-11 11:44:10 +08:00
weiting2 c3cdf4c8ad attempt to use UART 2020-05-11 11:42:19 +08:00
weiting2 20a9324c58 attempt to use UART 2020-05-11 11:39:20 +08:00
weiting2 f5808d6731 attempt to use UART 2020-05-11 11:35:00 +08:00
weiting2 a16a487bf2 attempt to use UART 2020-05-11 11:23:27 +08:00
weiting2 2704879aa4 [stable] attempt to break start command into "VIT_START", "VIS_REC", "VIS_STI" 2020-05-11 11:14:45 +08:00
weiting2 693b2e457d [stable] attempt to break start command into "VIT_START", "VIS_REC", "VIS_STI" 2020-05-11 10:57:04 +08:00
14 changed files with 195 additions and 1101 deletions
@@ -79,7 +79,7 @@ const PIN_Config BoardGpioInitTable[] = {
Board_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
Board_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
Board_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */
Board_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */
Board_UART_RX | PIN_INPUT_EN | PIN_PULLUP, /* UART RX via debugger back channel */
Board_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */
Board_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */
Board_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */
@@ -80,8 +80,8 @@ extern const PIN_Config BoardGpioInitTable[];
#define Board_BTN2 IOID_14
/* UART Board */
#define Board_UART_RX IOID_2 /* RXD */
#define Board_UART_TX IOID_3 /* TXD */
#define Board_UART_RX IOID_25 /* RXD */
#define Board_UART_TX IOID_26 /* TXD */
#define Board_UART_CTS IOID_19 /* CTS */
#define Board_UART_RTS IOID_18 /* RTS */
@@ -193,6 +193,11 @@ extern ICall_Semaphore semaphore;
#define INS_TYPE_VIS 0xC0
#define INS_TYPE_CIS 0x70
// RIS operator
#define RIS_SEND_UART 0x01
#define RIS_PREPARE_SEND 0x02
// VIS operator
#define VIS_ASK 0x30
#define VIS_INT 0x60
@@ -384,8 +389,6 @@ static void headstage_update_instruction(uint8_t *instruction) {
uint8_t ins_oper = instruction[1] & 0xF0;
uint8_t ins_len = instruction[1] & 0x0F;
switch (ins_type) {
case INS_TYPE_RIS: {
headstage_update_ris_instruction(ins_len, instruction + 2);
@@ -406,6 +409,10 @@ static void headstage_update_instruction(uint8_t *instruction) {
}
break;
}
default:{
break;
}
}
}
@@ -97,9 +97,9 @@ static void headstage_@REPLACE@_event() {
==== function implement ====
==========================*/
static void headstage_init() {
// TODO
}
//static void headstage_init() {
// // TODO
//}
static void headstage_update_ris_instruction(uint8_t ins_len, uint8_t *instruction) {
// TODO
@@ -199,24 +199,24 @@ static void headstage_sti_event() {
==== function implement ====
==========================*/
static void headstage_init() {
headstage_pin_open();
// init global stable value
Types_FreqHz cpu_freq;
BIOS_getCpuFreq(&cpu_freq);
cpu_frequency = cpu_freq.lo;
headstage_gptimer_open();
headstage_pwm_open();
headstage_pin_output(PIN_POL0, 0);
headstage_pin_output(PIN_POL1, 0);
headstage_pin_output(PIN_PON0, 0);
headstage_pin_output(PIN_PON1, 0);
headstage_pin_output(PIN_TPS, 1);
}
//static void headstage_init() {
// headstage_pin_open();
//
// // init global stable value
// Types_FreqHz cpu_freq;
// BIOS_getCpuFreq(&cpu_freq);
// cpu_frequency = cpu_freq.lo;
//
// headstage_gptimer_open();
//
// headstage_pwm_open();
//
// headstage_pin_output(PIN_POL0, 0);
// headstage_pin_output(PIN_POL1, 0);
// headstage_pin_output(PIN_PON0, 0);
// headstage_pin_output(PIN_PON1, 0);
// headstage_pin_output(PIN_TPS, 1);
//}
static void headstage_update_ris_instruction(uint8_t ins_len, uint8_t *instruction) {
uint8_t ins_oper = instruction[0] & 0xE0;
@@ -36,12 +36,12 @@
static void headstage_test_periodic();
static void headstage_init() {
headstage_pin_open();
headstage_spi_open();
headstage_gptimer_open();
headstage_gptimer_set_frequency(1000);
}
//static void headstage_init() {
// headstage_pin_open();
// headstage_spi_open();
// headstage_gptimer_open();
// headstage_gptimer_set_frequency(1000);
//}
static void headstage_update_ris_instruction(uint8_t ins_len, uint8_t* instruction) {
}
@@ -196,14 +196,14 @@ static void headstage_tni_event() {
==== function implement ====
==========================*/
static void headstage_init() {
headstage_pin_open();
headstage_spi_open();
headstage_gptimer_open();
headstage_pin_output(PIN_S2P_RST, 0);
headstage_pin_output(PIN_P2S_RST, 0);
}
//static void headstage_init() {
// headstage_pin_open();
// headstage_spi_open();
// headstage_gptimer_open();
//
// headstage_pin_output(PIN_S2P_RST, 0);
// headstage_pin_output(PIN_P2S_RST, 0);
//}
static void headstage_update_ris_instruction(uint8_t ins_len, uint8_t *instruction) {
uint8_t header = instruction[0] & 0xE0;
@@ -693,16 +693,16 @@ static void headstage_reset() {
/*=========================================
==== initialize parameter and device. ====
========================================*/
static void headstage_init() {
headstage_pin_open();
headstage_spi_open();
headstage_pwm_open();
headstage_led_spi_color(COLOR_GREEN);
headstage_pin_output(PIN_RESET, 1); // initialize DBS chip
headstage_pin_output(PIN_STI_SEL, 1); // chip select is ok
headstage_pin_output(PIN_VGRP, 1);
headstage_pin_output(PIN_FASTSET, 0);
}
//static void headstage_init() {
// headstage_pin_open();
// headstage_spi_open();
// headstage_pwm_open();
// headstage_led_spi_color(COLOR_GREEN);
// headstage_pin_output(PIN_RESET, 1); // initialize DBS chip
// headstage_pin_output(PIN_STI_SEL, 1); // chip select is ok
// headstage_pin_output(PIN_VGRP, 1);
// headstage_pin_output(PIN_FASTSET, 0);
//}
static void headstage_update_ris_instruction(uint8_t ins_len, uint8_t* instruction) {
switch ((instruction[0] & 0xE0)) {
@@ -4,14 +4,14 @@
#define VERSION_DATE_YEAR 20
#define VERSION_DATE_MONTH 5
#define VERSION_DATE_DAY 6
#define VERSION_DATE_DAY 20
#define VERSION_DATE_HOUR 17
#define VERSION_DATE_MINUTE 17
#define VERSION_DATE_MINUTE 27
// this is NOT the version hash !!
// it's the last version hash
#define VERSION_HASH fcc89f3e1cbef6348808c6a076ee86909b02eeda
#define VERSION_GIT_BRANCH Neulive2.0_developement
#define VERSION_HASH eb4b14af59afe8af309a843a93f87cacc8c68072
#define VERSION_GIT_BRANCH central_pseudo_controller
static void get_board_name(char *board_name_ch, uint8 *board_name_int, uint8 name_size){
uint8 name_offset = 18;
@@ -221,23 +221,23 @@ static void headstage_dac_send(uint8_t command, uint8_t p1, uint8_t p2) {
==== function implement ====
==========================*/
static void headstage_init() {
headstage_pin_open();
headstage_led_open();
headstage_spi_open();
PIN_registerIntCb(headstage_pins_handle, &headstage_zm_pin_callback);
PIN_setInterrupt(headstage_pins_handle, PIN_SWITCH_ON | PIN_IRQ_NEGEDGE);
headstage_pin_output(PIN_SHUTDOWN_6994, 1);
headstage_pin_output(PIN_ENABLE_V05, 1);
headstage_pin_output(PIN_ENABLE_V10, 1);
headstage_pin_output(PIN_ADC_CS, 1);
headstage_pin_output(PIN_DAC_CS, 1);
INSTRUCTION.mode = MODE_POWER_ON;
}
//static void headstage_init() {
// headstage_pin_open();
// headstage_led_open();
// headstage_spi_open();
//
// PIN_registerIntCb(headstage_pins_handle, &headstage_zm_pin_callback);
// PIN_setInterrupt(headstage_pins_handle, PIN_SWITCH_ON | PIN_IRQ_NEGEDGE);
//
// headstage_pin_output(PIN_SHUTDOWN_6994, 1);
// headstage_pin_output(PIN_ENABLE_V05, 1);
// headstage_pin_output(PIN_ENABLE_V10, 1);
//
// headstage_pin_output(PIN_ADC_CS, 1);
// headstage_pin_output(PIN_DAC_CS, 1);
//
// INSTRUCTION.mode = MODE_POWER_ON;
//}
static void headstage_zm_turn(uint8_t on_off) {
if (on_off) {
@@ -6,19 +6,10 @@
#if defined(CC2650_LAUNCHXL)
// clang-format off
#define PIN_RESET IOID_0 // SPI1 to receive LSK
#define PIN_EN_ADC_SPI_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 Board_RLED IOID_6
#define Board_GLED IOID_7
#define Board_WAKE_CENTRAL IOID_8
// clang-format on
#elif defined(BOOSTXL_CC2650MA)
@@ -73,13 +64,23 @@
#define Board_PWMPIN6 PIN_UNASSIGNED
#define Board_PWMPIN7 PIN_UNASSIGNED
static PIN_Config headstage_pin_configuration[] = { //
PIN_RESET | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
PIN_EN_ADC_SPI_CLK | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
PIN_DC_DC | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
PIN_BATT_HALF | PIN_INPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
PIN_STI_CLK | PIN_INPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
static PIN_Config pesudo_pi_pin_configuration[] = { //
Board_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
Board_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
Board_WAKE_CENTRAL | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
//
PIN_TERMINATE};
PIN_TERMINATE
};
static PIN_State pesudo_pi_pins_state;
static PIN_Handle pesudo_pi_pins_handle;
#define headstage_pin_open() \
do { \
pesudo_pi_pins_handle = PIN_open(&pesudo_pi_pins_state, pesudo_pi_pin_configuration); \
} while (0)
#define headstage_pin_output(pin, value) PIN_setOutputValue(pesudo_pi_pins_handle, PIN_ID(pin), (value))
#endif // HEADSTAGE_PIN_UNI_H
@@ -0,0 +1,75 @@
#ifndef PESUDO_PI_UART_H
#define PESUDO_PI_UART_H
/*
* http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/tirtos/
* 2_20_00_06/exports/tirtos_full_2_20_00_06/products/tidrivers_cc13xx_cc26xx_2_20_00_08/
* docs/doxygen/html/_u_a_r_t_c_c26_x_x_8h.html
*/
#include <ti/drivers/UART.h>
#include <ti/drivers/uart/UARTCC26XX.h>
#include <ti/sysbios/knl/Clock.h>
#include "../neu/headstage_pin.h"
// Clock object used to timeout connection
static Clock_Struct SendUARTClock;
// Scan duration in ms
#define SEND_UART_DURATION 1000
#define UART_TX_BUF_SIZE 10
#define UART_RX_BUF_SIZE 10
static UART_Handle handle;
static UART_Params params;
static uint8_t UART_txBuf[UART_TX_BUF_SIZE];
static uint8_t UART_rxBuf[UART_RX_BUF_SIZE];
static void _send_uart(UArg arg0);
static void pesudo_pi_uart_init(){
uint32_t timeoutUs = 5000; // 5ms timeout, default timeout is no timeout (BIOS_WAIT_FOREVER)
// Init UART and specify non-default parameters
UART_Params_init(&params);
params.baudRate = 9600;
params.writeDataMode = UART_DATA_BINARY;
// params.readTimeout = timeoutUs / Clock_tickPeriod; // Default tick period is 10us
params.readTimeout = ti_sysbios_BIOS_WAIT_FOREVER;
// Open the UART and do the read
handle = UART_open(Board_UART, &params);
// int rxBytes = UART_read(handle, rxBuf, 100);
Util_constructClock(&SendUARTClock, _send_uart,
SEND_UART_DURATION, 0, false, 0);
return;
}
static void send_uart(uint8_t *txbuf, uint8_t size) {
headstage_pin_output(Board_WAKE_CENTRAL, Board_LED_ON);
headstage_pin_output(Board_RLED, Board_LED_ON);
for(int i=0 ; i<size && i<UART_TX_BUF_SIZE ; i++){
UART_txBuf[i] = txbuf[i];
}
// Util_startClock(&SendUARTClock);
CPUdelay(16000000);
UART_write(handle, UART_txBuf, UART_TX_BUF_SIZE);
headstage_pin_output(Board_RLED, Board_LED_OFF);
headstage_pin_output(Board_WAKE_CENTRAL, Board_LED_OFF);
}
static void _send_uart(UArg arg0){
UART_write(handle, UART_txBuf, UART_TX_BUF_SIZE);
headstage_pin_output(Board_RLED, Board_LED_OFF);
headstage_pin_output(Board_WAKE_CENTRAL, Board_LED_OFF);
}
#endif
@@ -608,9 +608,9 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
}
}
if (EVENT_MASK > 0) {
headstage_event_handle();
}
// if (EVENT_MASK > 0) {
// headstage_event_handle();
// }
// if (events & SBP_PERIODIC_EVT) {
// events &= ~SBP_PERIODIC_EVT;
@@ -853,7 +853,6 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
if (SUCCESS == HCI_LE_SetDataLenCmd(cxnHandle, requestedPDUSize, requestTxTime)) {
ConnectState = true;
headstage_led_color(COLOR_CYAN);
}
// Use numActive to determine the connection handle of the last
// connection
@@ -870,10 +869,8 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
SimpleBLEPeripheral_freeAttRsp(bleNotConnected);
ConnectState = false;
if(ErrorRestart){
headstage_led_color(COLOR_RED);
}
else{
headstage_led_color(COLOR_GREEN);
}
break;
@@ -884,10 +881,8 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
ErrorRestart = true;
CONNECT_HANDLE = 0xFFFF;
flag_notify(EVT_DISCONNECTED);
headstage_led_color(COLOR_RED);
break;
case GAPROLE_ERROR: // Error occurred - invalid state
headstage_led_color(COLOR_RED);
break;
case GAPROLE_INIT: // Waiting to be started
case GAPROLE_ADVERTISING: // Currently Advertising