1 #ifndef CSR_FRAMEWORK_EXT_H__
2 #define CSR_FRAMEWORK_EXT_H__
3 /*****************************************************************************
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
8 Refer to LICENSE.txt included with this source for details
11 *****************************************************************************/
13 #include "csr_result.h"
14 #include "csr_framework_ext_types.h"
21 #define CSR_FE_RESULT_NO_MORE_EVENTS ((CsrResult) 0x0001)
22 #define CSR_FE_RESULT_INVALID_POINTER ((CsrResult) 0x0002)
23 #define CSR_FE_RESULT_INVALID_HANDLE ((CsrResult) 0x0003)
24 #define CSR_FE_RESULT_NO_MORE_MUTEXES ((CsrResult) 0x0004)
25 #define CSR_FE_RESULT_TIMEOUT ((CsrResult) 0x0005)
26 #define CSR_FE_RESULT_NO_MORE_THREADS ((CsrResult) 0x0006)
28 /* Thread priorities */
29 #define CSR_THREAD_PRIORITY_HIGHEST ((u16) 0)
30 #define CSR_THREAD_PRIORITY_HIGH ((u16) 1)
31 #define CSR_THREAD_PRIORITY_NORMAL ((u16) 2)
32 #define CSR_THREAD_PRIORITY_LOW ((u16) 3)
33 #define CSR_THREAD_PRIORITY_LOWEST ((u16) 4)
35 #define CSR_EVENT_WAIT_INFINITE ((u16) 0xFFFF)
37 /*----------------------------------------------------------------------------*
42 * Creates an event and returns a handle to the created event.
46 * CSR_RESULT_SUCCESS in case of success
47 * CSR_FE_RESULT_NO_MORE_EVENTS in case of out of event resources
48 * CSR_FE_RESULT_INVALID_POINTER in case the eventHandle pointer is invalid
50 *----------------------------------------------------------------------------*/
51 CsrResult CsrEventCreate(CsrEventHandle *eventHandle);
53 /*----------------------------------------------------------------------------*
58 * Wait fore one or more of the event bits to be set.
62 * CSR_RESULT_SUCCESS in case of success
63 * CSR_FE_RESULT_TIMEOUT in case of timeout
64 * CSR_FE_RESULT_INVALID_HANDLE in case the eventHandle is invalid
65 * CSR_FE_RESULT_INVALID_POINTER in case the eventBits pointer is invalid
67 *----------------------------------------------------------------------------*/
68 CsrResult CsrEventWait(CsrEventHandle *eventHandle, u16 timeoutInMs, u32 *eventBits);
70 /*----------------------------------------------------------------------------*
79 * CSR_RESULT_SUCCESS in case of success
80 * CSR_FE_RESULT_INVALID_HANDLE in case the eventHandle is invalid
82 *----------------------------------------------------------------------------*/
83 CsrResult CsrEventSet(CsrEventHandle *eventHandle, u32 eventBits);
85 /*----------------------------------------------------------------------------*
90 * Destroy the event associated.
95 *----------------------------------------------------------------------------*/
96 void CsrEventDestroy(CsrEventHandle *eventHandle);
98 /*----------------------------------------------------------------------------*
103 * Create a mutex and return a handle to the created mutex.
107 * CSR_RESULT_SUCCESS in case of success
108 * CSR_FE_RESULT_NO_MORE_MUTEXES in case of out of mutex resources
109 * CSR_FE_RESULT_INVALID_POINTER in case the mutexHandle pointer is invalid
111 *----------------------------------------------------------------------------*/
112 CsrResult CsrMutexCreate(CsrMutexHandle *mutexHandle);
114 /*----------------------------------------------------------------------------*
119 * Unlock the mutex refered to by the provided handle.
123 * CSR_RESULT_SUCCESS in case of success
124 * CSR_FE_RESULT_INVALID_HANDLE in case the mutexHandle is invalid
126 *----------------------------------------------------------------------------*/
127 CsrResult CsrMutexUnlock(CsrMutexHandle *mutexHandle);
129 /*----------------------------------------------------------------------------*
134 * Destroy the previously created mutex.
139 *----------------------------------------------------------------------------*/
140 void CsrMutexDestroy(CsrMutexHandle *mutexHandle);
142 /*----------------------------------------------------------------------------*
147 * Lock the global mutex. The global mutex is a single pre-initialised
148 * shared mutex, spinlock or similar that does not need to be created prior
149 * to use. The limitation is that there is only one single lock shared
150 * between all code. Consequently, it must only be used very briefly to
151 * either protect simple one-time initialisation or to protect the creation
152 * of a dedicated mutex by calling CsrMutexCreate.
154 *----------------------------------------------------------------------------*/
155 void CsrGlobalMutexLock(void);
157 /*----------------------------------------------------------------------------*
159 * CsrGlobalMutexUnlock
162 * Unlock the global mutex.
164 *----------------------------------------------------------------------------*/
165 void CsrGlobalMutexUnlock(void);
167 /*----------------------------------------------------------------------------*
172 * Sleep for a given period.
177 *----------------------------------------------------------------------------*/
178 void CsrThreadSleep(u16 sleepTimeInMs);