Other Parts Discussed in Thread: CC2340R5
在GitHub上找到一份throughput相关的代码(github.com/.../throughput_peripheral)
计划移植到simplelink_lowpower_f3_sdk_7_20_00_29的data_stream示例,用于测试CC2340R5的吞吐量。
在BLEAppUtil_init里调用了ThroughputPeripheral_createTask,但是目前程序会卡在ThroughputPeripheral_taskFxn里的第一个EventP_pend。
请问是我哪里流程错了吗?
部分代码如下:
void BLEAppUtil_init(ErrorHandler_t errorHandler, StackInitDone_t initDoneHandler, BLEAppUtil_GeneralParams_t *initGeneralParams, BLEAppUtil_PeriCentParams_t *initPeriCentParams) { // Register the application error handler errorHandlerCb = errorHandler; // Register the init done handler - will be called from the GAP_DEVICE_INIT_DONE_EVENT appInitDoneHandler = initDoneHandler; // Assign the BLEAppUtil parameters from the user to the local parameters BLEAppUtilLocal_GeneralParams = initGeneralParams; BLEAppUtilLocal_PeriCentParams = initPeriCentParams; // Create a message queue for message to be sent to BLEAppUtil BLEAppUtil_createQueue(); // Create BLE stack task bleStack_createTasks(); // Create local app task BLEAppUtil_createBLEAppUtilTask(); ThroughputPeripheral_createTask(); // Construct a mutex that will be used by the following functions: // BLEAppUtil_registerEventHandler // BLEAppUtil_unRegisterEventHandler // BLEAppUtil_callEventHandler pthread_mutex_init(&mutex, NULL); }
int ThroughputPeripheral_createTask(void) { int retVal = 0; pthread_attr_t param_attribute; struct sched_param param; retVal = pthread_attr_init(¶m_attribute); param.sched_priority = TP_TASK_PRIORITY; retVal |= pthread_attr_setschedparam(¶m_attribute, ¶m); retVal |= pthread_attr_setstack(¶m_attribute, tpTaskStack, TP_TASK_STACK_SIZE); retVal |= pthread_attr_setdetachstate(¶m_attribute, PTHREAD_CREATE_DETACHED); retVal |= pthread_create(&tpTask, ¶m_attribute, &ThroughputPeripheral_taskFxn, NULL); return retVal; }
static void *ThroughputPeripheral_taskFxn(void *arg) { // Initialize application ThroughputPeripheral_init(); // Application main loop for (;;) { uint32_t events; // Waits for an event to be posted associated with the calling thread. // Note that an event associated with a thread is posted when a // message is queued to the message receive queue of the thread events = EventP_pend(syncEvent, TP_ALL_EVENTS, UTIL_EVENT_ID_NONE, ICALL_TIMEOUT_FOREVER);