This commit is contained in:
Ta-Shun Su
2019-05-07 23:31:39 +08:00
parent 2fa4300f8e
commit ae080d798b
3 changed files with 41 additions and 15 deletions
@@ -145,6 +145,7 @@ static uint8_t not_buf[BLE_NOT_BUFF_SIZE] = {0};
*
*/
static void headstage_send_notify() {
#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);
@@ -164,6 +165,11 @@ static void headstage_send_notify() {
GATT_bm_free((gattMsg_t *)&notify, ATT_HANDLE_VALUE_NOTI);
}
}
#else
SimpleProfile_SetParameter(BLE_NOT_BUFF_CHAR, BLE_NOT_BUFF_SIZE, not_buf);
#endif
}
/*====================
@@ -8,11 +8,11 @@
#define MAJOR_VERSION_NUMBER 0
#define MINOR_VERSION_NUMBER 1
#include "headstage_arm.h"
#include "headstage_gptimer.h"
#include "headstage_pin.h"
#include "headstage_spi.h"
#include "headstage_timestamp.h"
#include "headstage_arm.h"
/*============
==== SPI ====
@@ -198,13 +198,35 @@ static void headstage_tni_event() {
static void headstage_tni_init() {
// XXX spi parameter
/*
SPI_Params spi_params;
SPI_init();
SPI_Params_init(&spi_params);
spi_params.dataSize = 8;
spi_params.frameFormat = SPI_POL0_PHA1;
spi_params.bitRate = 12000000;
spi_params.mode = SPI_MASTER;
spi_handle = SPI_open(Board_SPI0, &spi_params);
*/
headstage_spi_open();
// XXX gptimer parameter
/*
GPTimerCC26XX_Params params;
GPTimerCC26XX_Params_init(&params);
params.width = GPT_CONFIG_16BIT;
params.mode = GPT_MODE_PERIODIC_DOWN;
params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
*/
headstage_gptimer_open();
// XXX pin configuration
headstage_pin_open();
headstage_pin_output(S2P_RST, 0);
headstage_pin_output(P2S_RST, 0);
}
static void headstage_update_ris_instruction(uint8_t *instruction) {
@@ -691,7 +713,7 @@ static void update_ins_sti_buffer() {
static void headstage_tni_periodic() {
if (!INSTRUCTION.flag_start) return;
bool adc_clock_signal = (INSTRUCTION.adc_clock_signal) ? FALSE : TRUE; // flip adc_clock_signal
bool adc_clock_signal = (INSTRUCTION.adc_clock_signal) ? FALSE : TRUE; // flip adc_clock_signal
INSTRUCTION.adc_clock_signal = adc_clock_signal;
if (IS_REC_MODE(INSTRUCTION.mode)) {
@@ -727,7 +749,13 @@ collect_data:
headstage_pin_output(S2P_RST, 1);
if (actual_frequency() < 1000) {
// low sampling rate data format check
// low sampling rate data
// append 0 at end of the data
not_buf[not_buf_offset] = 0;
not_buf[not_buf_offset + 1] = 0;
// prepare to send notify
notify_flip_buffer();
headstage_send_notify();
}
@@ -145,9 +145,6 @@
// Connection Pause Peripheral time value (in seconds)
#define DEFAULT_CONN_PAUSE_PERIPHERAL 2
// How often to perform periodic event (in msec)
#define SBP_PERIODIC_EVT_PERIOD 1000
#ifdef FEATURE_OAD
// The size of an OAD packet.
#define OAD_PACKET_SIZE ((OAD_BLOCK_SIZE) + 2)
@@ -160,11 +157,6 @@
#define SBP_TASK_STACK_SIZE 644
#endif
// Instruction type for DBS
#define REAL_INSTR 0x30
#define VIRTUAL_INSTR 0xC0
#define DATA_RECEIVE 0XA0
/*********************************************************************
* TYPEDEFS
*/
@@ -219,20 +211,18 @@ static uint8_t rspTxRetry = 0;
static void SimpleBLEPeripheral_init(void);
static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1);
static void SPI_MAIN(UArg a0, UArg a1);
static uint8_t SimpleBLEPeripheral_processStackMsg(ICall_Hdr *pMsg);
static uint8_t SimpleBLEPeripheral_processGATTMsg(gattMsgEvent_t *pMsg);
static void SimpleBLEPeripheral_processAppMsg(sbpEvt_t *pMsg);
static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState);
static void SimpleBLEPeripheral_sendAttRsp(void);
static void SimpleBLEPeripheral_freeAttRsp(uint8_t status);
static void SimpleBLEPeripheral_stateChangeCB(gaprole_States_t newState);
static void SimpleBLEPeripheral_enqueueMsg(uint8_t event, uint8_t state);
#ifndef FEATURE_OAD_ONCHIP
static void SimpleBLEPeripheral_charValueChangeCB(uint8_t paramID);
#endif //! FEATURE_OAD_ONCHIP
static void SimpleBLEPeripheral_enqueueMsg(uint8_t event, uint8_t state);
#ifdef FEATURE_OAD
void SimpleBLEPeripheral_processOadWriteCB(uint8_t event, uint16_t connHandle, uint8_t *pData);
@@ -332,10 +322,12 @@ static void SimpleBLEPeripheral_init(void) {
// configure RF Core tracer IO
IOCPortConfigureSet(IOID_8, IOC_PORT_RFC_TRC, IOC_STD_OUTPUT);
#else // !USE_FPGA
#ifdef DEBUG_SW_TRACE
// configure RF Core tracer IO
IOCPortConfigureSet(IOID_8, IOC_PORT_RFC_TRC, IOC_STD_OUTPUT | IOC_CURRENT_4MA | IOC_SLEW_ENABLE);
#endif // DEBUG_SW_TRACE
#endif // USE_FPGA
// Create an RTOS queue for message from profile to be sent to app.