📄 tmdlhdmitx_iw.c
字号:
(size_t)taskTableR[handle].stackSize, (int)taskTableR[handle].priority, (const char *)"HDMI", 0 ); RETIF(!threadHandle, TMDL_ERR_DLHDMITX_NOT_STARTED) break; case 4: threadHandle = task_create ((void (*)(void*))ThreadProc4, 0, (size_t)taskTableR[handle].stackSize, (int)taskTableR[handle].priority, (const char *)"HDMI", 0 ); RETIF(!threadHandle, TMDL_ERR_DLHDMITX_NOT_STARTED) break; }#endif /* update task status */ taskTableR[handle].threadHandle = threadHandle; taskTableR[handle].started = True; return(TM_OK);}/****************************************************************************** \brief This function blocks the current task for the specified amount time. This is a passive wait. \param Duration Duration of the task blocking in milliseconds. \return The call result: - TM_OK: the call was successful - TMDL_ERR_DLHDMITX_NO_RESOURCES: the resource is not available******************************************************************************/#define MILLI_DELAY(_ms_) { task_delay(_ms_ * ST_GetClocksPerSecondLow() /1000);}tmErrorCode_t tmdlHdmiTxIWWait( UInt16 duration){#ifndef HS800 HANDLE timerHandle; LARGE_INTEGER time; timerHandle = CreateWaitableTimer(0, TRUE, 0); RETIF(timerHandle == 0, TMDL_ERR_DLHDMITX_NO_RESOURCES) time.QuadPart = -10000 * (long)duration; SetWaitableTimer(timerHandle, &time, 0, 0, 0, FALSE); WaitForSingleObject(timerHandle, INFINITE); CloseHandle(timerHandle);#else MILLI_DELAY(duration);#endif return(TM_OK);}#define MALLOC(x) memory_allocate(SystemPartition,x)#define FREE_MEM(x) memory_deallocate(SystemPartition,x)/****************************************************************************** \brief This function creates a message queue. \param QueueSize Maximum number of messages in the message queue. \param pHandle Pointer to the handle buffer. \return The call result: - TM_OK: the call was successful - TMDL_ERR_DLHDMITX_INCONSISTENT_PARAMS: an input parameter is inconsistent - TMDL_ERR_DLHDMITX_NO_RESOURCES: the resource is not available******************************************************************************/tmErrorCode_t tmdlHdmiTxIWQueueCreate( UInt8 queueSize, tmdlHdmiTxIWQueueHandle_t *pHandle){ UInt32 i; /* check that input pointer is not 0 */ RETIF(pHandle == 0, TMDL_ERR_DLHDMITX_INCONSISTENT_PARAMS) /* search for available queue slot */ for(i = 0; i < MAX_QUEUES; i++) { if (queueTable[i].created == False) break; } RETIF(i >= MAX_QUEUES, TMDL_ERR_DLHDMITX_NO_RESOURCES) /* allocate memory for the queue */ queueTable[i].queue = (UInt8 *)MALLOC(queueSize); RETIF(queueTable[i].queue == 0, TMDL_ERR_DLHDMITX_NO_RESOURCES) /* allocate semaphores for the queue */ queueTable[i].countSemaphore = semaphore_create_fifo(queueSize); RETIF(queueTable[i].countSemaphore == 0, TMDL_ERR_DLHDMITX_NO_RESOURCES) queueTable[i].accessSemaphore = semaphore_create_fifo(1); RETIF(queueTable[i].accessSemaphore == 0, TMDL_ERR_DLHDMITX_NO_RESOURCES) /* update status of the queue table */ queueTable[i].created = True; queueTable[i].queueSize = queueSize; *pHandle = (tmdlHdmiTxIWQueueHandle_t)i; return(TM_OK);}/****************************************************************************** \brief This function destroys an existing message queue. \param Handle Handle of the queue to be destroyed. \return The call result: - TM_OK: the call was successful - TMDL_ERR_DLHDMITX_BAD_HANDLE: the handle number is wrong - TMDL_ERR_DLHDMITX_RESOURCE_NOT_OWNED: the caller does not own the resource******************************************************************************/tmErrorCode_t tmdlHdmiTxIWQueueDestroy( tmdlHdmiTxIWQueueHandle_t handle){ RETIF(handle > MAX_QUEUES, TMDL_ERR_DLHDMITX_BAD_HANDLE) RETIF(queueTable[handle].created == False, TMDL_ERR_DLHDMITX_RESOURCE_NOT_OWNED) FREE_MEM((LPVOID)queueTable[handle].queue); semaphore_delete(queueTable[handle].countSemaphore); semaphore_delete(queueTable[handle].accessSemaphore); queueTable[handle].created = False; return(TM_OK);}/****************************************************************************** \brief This function sends a message into the specified message queue. \param Handle Handle of the queue that will receive the message. \param Message Message to be sent. \return The call result: - TM_OK: the call was successful - TMDL_ERR_DLHDMITX_BAD_HANDLE: the handle number is wrong - TMDL_ERR_DLHDMITX_RESOURCE_NOT_OWNED: the caller does not own the resource - TMDL_ERR_DLHDMITX_FULL: the queue is full******************************************************************************/tmErrorCode_t tmdlHdmiTxIWQueueSend( tmdlHdmiTxIWQueueHandle_t handle, UInt8 message){ tmErrorCode_t errorCode = TM_OK; /* check that handle is correct */ RETIF(handle > MAX_QUEUES, TMDL_ERR_DLHDMITX_BAD_HANDLE) RETIF(queueTable[handle].created != True, TMDL_ERR_DLHDMITX_RESOURCE_NOT_OWNED) /* ask for exclusive access to this queue */ semaphore_wait(queueTable[handle].accessSemaphore); if(queueTable[handle].queueFullness < (queueTable[handle].queueSize - 1)) { queueTable[handle].queue[queueTable[handle].writePointer] = message; queueTable[handle].queueFullness++; queueTable[handle].writePointer++; if(queueTable[handle].writePointer == queueTable[handle].queueSize) { queueTable[handle].writePointer = 0; } semaphore_signal(queueTable[handle].countSemaphore); } else { errorCode = TMDL_ERR_DLHDMITX_FULL; } /* release access to this queue */ semaphore_signal(queueTable[handle].accessSemaphore); return(TM_OK);}/****************************************************************************** \brief This function reads a message from the specified message queue. \param Handle Handle of the queue from which to read the message. \param pMessage Pointer to the message buffer. \return The call result: - TM_OK: the call was successful - TMDL_ERR_DLHDMITX_BAD_HANDLE: the handle number is wrong - TMDL_ERR_DLHDMITX_RESOURCE_NOT_OWNED: the caller does not own the resource - TMDL_ERR_DLHDMITX_INCONSISTENT_PARAMS: an input parameter is inconsistent******************************************************************************/tmErrorCode_t tmdlHdmiTxIWQueueReceive( tmdlHdmiTxIWQueueHandle_t handle, UInt8 *pMessage){ /* check that handle is correct */ RETIF(handle > MAX_QUEUES, TMDL_ERR_DLHDMITX_BAD_HANDLE) RETIF(queueTable[handle].created != True, TMDL_ERR_DLHDMITX_RESOURCE_NOT_OWNED) /* check that input pointer is not 0 */ RETIF(pMessage == 0, TMDL_ERR_DLHDMITX_INCONSISTENT_PARAMS) /* ask for a new message by acquiring the counting semaphore */ semaphore_wait(queueTable[handle].countSemaphore); /* if we reach this point, this means that we got a message */ /* ask for exclusive access to this queue */ semaphore_wait(queueTable[handle].accessSemaphore); *pMessage = queueTable[handle].queue[queueTable[handle].readPointer]; queueTable[handle].queueFullness--; queueTable[handle].readPointer++; if(queueTable[handle].readPointer == queueTable[handle].queueSize) { queueTable[handle].readPointer = 0; } /* release access to this queue */ semaphore_signal(queueTable[handle].accessSemaphore); return(TM_OK);}/****************************************************************************** \brief This function creates a semaphore. \param pHandle Pointer to the handle buffer. \return The call result: - TM_OK: the call was successful - TMDL_ERR_DLHDMITX_NO_RESOURCES: the resource is not available - TMDL_ERR_DLHDMITX_INCONSISTENT_PARAMS: an input parameter is inconsistent******************************************************************************/tmErrorCode_t tmdlHdmiTxIWSemaphoreCreate( tmdlHdmiTxIWSemHandle_t *pHandle){ /* check that input pointer is not 0 */ RETIF(pHandle == 0, TMDL_ERR_DLHDMITX_INCONSISTENT_PARAMS) pHandle = semaphore_create_fifo(1); RETIF((pHandle) == 0, TMDL_ERR_DLHDMITX_NO_RESOURCES) return(TM_OK);}/****************************************************************************** \brief This function destroys an existing semaphore. \param Handle Handle of the semaphore to be destroyed. \return The call result: - TM_OK: the call was successful - TMDL_ERR_DLHDMITX_BAD_HANDLE: the handle number is wrong******************************************************************************/tmErrorCode_t tmdlHdmiTxIWSemaphoreDestroy( tmdlHdmiTxIWSemHandle_t *handle){ semaphore_delete(handle); return(TM_OK);}/****************************************************************************** \brief This function acquires the specified semaphore. \param Handle Handle of the semaphore to be acquired. \return The call result: - TM_OK: the call was successful - TMDL_ERR_DLHDMITX_BAD_HANDLE: the handle number is wrong******************************************************************************/tmErrorCode_t tmdlHdmiTxIWSemaphoreP( tmdlHdmiTxIWSemHandle_t *handle){/* semaphore_wait(handle);*/ return(TM_OK);}/****************************************************************************** \brief This function releases the specified semaphore. \param Handle Handle of the semaphore to be released. \return The call result: - TM_OK: the call was successful - TMDL_ERR_DLHDMITX_BAD_HANDLE: the handle number is wrong******************************************************************************/tmErrorCode_t tmdlHdmiTxIWSemaphoreV( tmdlHdmiTxIWSemHandle_t *handle){/* semaphore_signal(handle);*/ return(TM_OK);}/****************************************************************************** \brief This function disables the interrupts for a specific device. \param \return The call result: - TM_OK: the call was successful******************************************************************************/void tmdlHdmiTxIWDisableInterrupts(tmdlHdmiIWDeviceInterrupt_t device){ interrupt_disable_number(device);}/****************************************************************************** \brief This function enables the interrupts for a specific device. \param \return The call result: - TM_OK: the call was successful******************************************************************************/void tmdlHdmiTxIWEnableInterrupts(tmdlHdmiIWDeviceInterrupt_t device){ interrupt_enable_number(device);}#ifdef __cplusplus}#endif/******************************************************************************//*============================================================================*//* END OF FILE *//*============================================================================*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -