I am trying to add Cap touch sample code generate from Sensor Controller Studio into SimpleBLEPeripheral.
Cap touch part works as a scif task.
void scTaskAlertCallback(void) {
// Clear the ALERT interrupt source
scifClearAlertIntSource();
// Transfer the TDC values to the application buffer
if (scifGetTaskIoStructAvailCount(SCIF_CAPACITIVE_TOUCH_DATA_LOGGER_TASK_ID, SCIF_STRUCT_OUTPUT) == 1) {
SCIF_CAPACITIVE_TOUCH_DATA_LOGGER_OUTPUT_T* pOutput = (SCIF_CAPACITIVE_TOUCH_DATA_LOGGER_OUTPUT_T*) scifGetTaskStruct(SCIF_CAPACITIVE_TOUCH_DATA_LOGGER_TASK_ID, SCIF_STRUCT_OUTPUT);
uint16_t* pBuffer = ppTdcValueBuffer[tdcValueBufferHead];
int n;
for (n = 0; n < PIN_COUNT; n++) {
pBuffer[n] = pOutput->pTdcValueRaw[n];
}
tdcValueBufferHead = (tdcValueBufferHead + 1) & 0x07;
scifHandoffTaskStruct(SCIF_CAPACITIVE_TOUCH_DATA_LOGGER_TASK_ID, SCIF_STRUCT_OUTPUT);
}
if (tdcValueBufferHead != tdcValueBufferTail) {
uint16_t* pBuffer = ppTdcValueBuffer[tdcValueBufferTail];
int pos = 0;
int n, i;
for (n = 0; n < PIN_COUNT; n++) {
uint32_t value = pBuffer[n];
tdcValueBufferTail = (tdcValueBufferTail + 1) & 0x07;
}
}
// Acknowledge the ALERT event
scifAckAlertEvents();
} // scTaskAlertCallback
void taskFxn(UArg a0, UArg a1) {
// Initialize the Sensor Controller
scifOsalInit();
scifOsalRegisterCtrlReadyCallback(scCtrlReadyCallback);
scifOsalRegisterTaskAlertCallback(scTaskAlertCallback);
scifInit(&scifDriverSetup);
//scifStartRtcTicksNow(0x00010000 / 32);
scifStartRtcTicksNow(0x00010000 / 14);
IntMasterEnable();
AONRTCEnable();
scifStartTasksNbl(BV(SCIF_CAPACITIVE_TOUCH_DATA_LOGGER_TASK_ID));
// Main loop
while (1) {
// // Wait for an ALERT callback
Semaphore_pend(Semaphore_handle(&semScTaskAlert), BIOS_WAIT_FOREVER);
}
} // taskFxn
Then connect SimpleBLEPeripheral with LightBlue running on iOS. Sooner or later connection will lost, and in this case, SimpleBLEPeripheral will not be able to connect or scan by LightBlue. System seems hang in somewhere. Only repower/ reset can recover the system.
Is there any low level conflict need to be take care?