Platform API Reference
Platform portability layer
iot_threads.h
Go to the documentation of this file.
1 /*
2  * Amazon FreeRTOS Platform V1.1.0
3  * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://aws.amazon.com/freertos
23  * http://www.FreeRTOS.org
24  */
25 
31 #ifndef IOT_THREADS_H_
32 #define IOT_THREADS_H_
33 
34 /* The config header is always included first. */
35 #include "iot_config.h"
36 
37 /* Standard includes. */
38 #include <stdbool.h>
39 #include <stdint.h>
40 
41 /* Platform layer types include. */
43 
113 /* @[declare_platform_threads_createdetachedthread] */
114 bool Iot_CreateDetachedThread( IotThreadRoutine_t threadRoutine,
115  void * pArgument,
116  int32_t priority,
117  size_t stackSize );
118 /* @[declare_platform_threads_createdetachedthread] */
119 
149 /* @[declare_platform_threads_mutexcreate] */
150 bool IotMutex_Create( IotMutex_t * pNewMutex,
151  bool recursive );
152 /* @[declare_platform_threads_mutexcreate] */
153 
166 /* @[declare_platform_threads_mutexdestroy] */
167 void IotMutex_Destroy( IotMutex_t * pMutex );
168 /* @[declare_platform_threads_mutexdestroy] */
169 
181 /* @[declare_platform_threads_mutexlock] */
182 void IotMutex_Lock( IotMutex_t * pMutex );
183 /* @[declare_platform_threads_mutexlock] */
184 
198 /* @[declare_platform_threads_mutextrylock] */
199 bool IotMutex_TryLock( IotMutex_t * pMutex );
200 /* @[declare_platform_threads_mutextrylock] */
201 
213 /* @[declare_platform_threads_mutexunlock] */
214 void IotMutex_Unlock( IotMutex_t * pMutex );
215 /* @[declare_platform_threads_mutexunlock] */
216 
247 /* @[declare_platform_threads_semaphorecreate] */
248 bool IotSemaphore_Create( IotSemaphore_t * pNewSemaphore,
249  uint32_t initialValue,
250  uint32_t maxValue );
251 /* @[declare_platform_threads_semaphorecreate] */
252 
265 /* @[declare_platform_threads_semaphoredestroy] */
266 void IotSemaphore_Destroy( IotSemaphore_t * pSemaphore );
267 /* @[declare_platform_threads_semaphoredestroy] */
268 
279 /* @[declare_platform_threads_semaphoregetcount] */
280 uint32_t IotSemaphore_GetCount( IotSemaphore_t * pSemaphore );
281 /* @[declare_platform_threads_semaphoregetcount] */
282 
296 /* @[declare_platform_threads_semaphorewait] */
297 void IotSemaphore_Wait( IotSemaphore_t * pSemaphore );
298 /* @[declare_platform_threads_semaphorewait] */
299 
316 /* @[declare_platform_threads_semaphoretrywait] */
317 bool IotSemaphore_TryWait( IotSemaphore_t * pSemaphore );
318 /* @[declare_platform_threads_semaphoretrywait] */
319 
338 /* @[declare_platform_threads_semaphoretimedwait] */
339 bool IotSemaphore_TimedWait( IotSemaphore_t * pSemaphore,
340  uint32_t timeoutMs );
341 /* @[declare_platform_threads_semaphoretimedwait] */
342 
352 /* @[declare_platform_threads_semaphorepost] */
353 void IotSemaphore_Post( IotSemaphore_t * pSemaphore );
354 /* @[declare_platform_threads_semaphorepost] */
355 
356 #endif /* ifndef IOT_THREADS_H_ */
IotSemaphore_Destroy
void IotSemaphore_Destroy(IotSemaphore_t *pSemaphore)
Free resources used by a semaphore.
IotSemaphore_t
_IotSystemSemaphore_t IotSemaphore_t
The type used to represent semaphores, configured with the type _IotSystemSemaphore_t.
Definition: iot_platform_types.h:97
IotMutex_Lock
void IotMutex_Lock(IotMutex_t *pMutex)
Lock a mutex. This function should only return when the mutex is locked; it is not expected to fail.
IotMutex_Unlock
void IotMutex_Unlock(IotMutex_t *pMutex)
Unlock a mutex. This function should only return when the mutex is unlocked; it is not expected to fa...
IotMutex_Create
bool IotMutex_Create(IotMutex_t *pNewMutex, bool recursive)
Create a new mutex.
IotSemaphore_Post
void IotSemaphore_Post(IotSemaphore_t *pSemaphore)
Post to (unlock) a semaphore. This function should only return when the semaphore post succeeds; it i...
IotMutex_t
_IotSystemMutex_t IotMutex_t
The type used to represent mutexes, configured with the type _IotSystemMutex_t.
Definition: iot_platform_types.h:75
iot_platform_types.h
Types of the platform layer.
IotSemaphore_GetCount
uint32_t IotSemaphore_GetCount(IotSemaphore_t *pSemaphore)
Query the current count of the semaphore.
IotMutex_TryLock
bool IotMutex_TryLock(IotMutex_t *pMutex)
Attempt to lock a mutex. Return immediately if the mutex is not available.
Iot_CreateDetachedThread
bool Iot_CreateDetachedThread(IotThreadRoutine_t threadRoutine, void *pArgument, int32_t priority, size_t stackSize)
Create a new detached thread, i.e. a thread that cleans up after itself.
IotThreadRoutine_t
void(* IotThreadRoutine_t)(void *)
Thread routine function.
Definition: iot_platform_types.h:105
IotMutex_Destroy
void IotMutex_Destroy(IotMutex_t *pMutex)
Free resources used by a mutex.
IotSemaphore_Create
bool IotSemaphore_Create(IotSemaphore_t *pNewSemaphore, uint32_t initialValue, uint32_t maxValue)
Create a new counting semaphore.
IotSemaphore_TryWait
bool IotSemaphore_TryWait(IotSemaphore_t *pSemaphore)
Attempt to wait on (lock) a semaphore. Return immediately if the semaphore is not available.
IotSemaphore_TimedWait
bool IotSemaphore_TimedWait(IotSemaphore_t *pSemaphore, uint32_t timeoutMs)
Attempt to wait on (lock) a semaphore with a timeout.
IotSemaphore_Wait
void IotSemaphore_Wait(IotSemaphore_t *pSemaphore)
Wait on (lock) a semaphore. This function should only return when the semaphore wait succeeds; it is ...