Compare commits

..

1 Commits

Author SHA1 Message Date
yichin 646650ddee test data rate 2020-05-06 18:05:37 +08:00
16 changed files with 1106 additions and 198 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_PULLUP, /* UART RX via debugger back channel */
Board_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* 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_25 /* RXD */
#define Board_UART_TX IOID_26 /* TXD */
#define Board_UART_RX IOID_2 /* RXD */
#define Board_UART_TX IOID_3 /* TXD */
#define Board_UART_CTS IOID_19 /* CTS */
#define Board_UART_RTS IOID_18 /* RTS */
@@ -104,6 +104,7 @@ static bool ConnectState = false;
static bool ErrorRestart = false;
static bool turn_off_sti = false;
static uint8_t SPICallBack = 0;
static uint32_t data_counter = 0;
/*======================
==== event control ====
@@ -193,11 +194,6 @@ 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
@@ -389,6 +385,8 @@ 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);
@@ -409,10 +407,6 @@ 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 20
#define VERSION_DATE_DAY 6
#define VERSION_DATE_HOUR 17
#define VERSION_DATE_MINUTE 27
#define VERSION_DATE_MINUTE 17
// this is NOT the version hash !!
// it's the last version hash
#define VERSION_HASH eb4b14af59afe8af309a843a93f87cacc8c68072
#define VERSION_GIT_BRANCH central_pseudo_controller
#define VERSION_HASH fcc89f3e1cbef6348808c6a076ee86909b02eeda
#define VERSION_GIT_BRANCH Neulive2.0_developement
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) {
@@ -25,7 +25,7 @@ static void headstage_notify_set_timestamp() {
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] = data_counter ++;
headstage_notify_buffer[1] = data_count;
not_buf_offset = NOT_BUF_OFFSET_INIT;
@@ -6,10 +6,19 @@
#if defined(CC2650_LAUNCHXL)
// clang-format off
#define Board_RLED IOID_6
#define Board_GLED IOID_7
#define Board_WAKE_CENTRAL IOID_8
#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 //
// clang-format on
#elif defined(BOOSTXL_CC2650MA)
@@ -64,23 +73,13 @@
#define Board_PWMPIN6 PIN_UNASSIGNED
#define Board_PWMPIN7 PIN_UNASSIGNED
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,
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,
//
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))
PIN_TERMINATE};
#endif // HEADSTAGE_PIN_UNI_H
@@ -15,6 +15,7 @@ static void MCUReset(){
STI = false;
turn_off_sti = false;
IsFirstData = true;
data_counter = 0;
// SPI reset
SPI_close(headstage_spi_handle);
@@ -1,75 +0,0 @@
#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,6 +853,7 @@ 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
@@ -869,8 +870,10 @@ 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;
@@ -881,8 +884,10 @@ 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