Kinetis Bootloader  2.0.0
Common bootloader for Kinetis devices
fsl_rtos_abstraction.h
1 /*
2  * Copyright (c) 2013, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  * of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  * list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 #if !defined(__FSL_RTOS_ABSTRACTION_H__)
31 #define __FSL_RTOS_ABSTRACTION_H__
32 
33 #include <stdint.h>
34 #include <stdbool.h>
35 
38 
40 // Declarations
42 typedef enum _osa_status_t
43 {
49 } osa_status_t;
50 
51 typedef struct Semaphore
52 {
53  volatile bool isWaiting;
54  volatile uint8_t semCount;
55  uint64_t tickStart;
56  uint32_t timeout;
57 } semaphore_t;
58 
60 typedef volatile int32_t sync_object_t;
61 
63 typedef volatile uint32_t lock_object_t;
64 
66 {
68  kSyncWaitForever = 0xffffffffU
69 };
70 
72 // API
74 
75 #if defined(__cplusplus)
76 extern "C" {
77 #endif
78 
80 
81 
106 osa_status_t OSA_SemaCreate(semaphore_t *pSem, uint8_t initValue);
107 
140 osa_status_t OSA_SemaWait(semaphore_t *pSem, uint32_t timeout);
141 
165 
186 
192 void OSA_TimeDelay(uint32_t delay);
193 
195 
197 
199 
200 
208 void sync_init(sync_object_t *obj, bool state);
209 
222 bool sync_wait(sync_object_t *obj, uint32_t timeout);
223 
229 void sync_signal(sync_object_t *obj);
230 
236 void sync_reset(sync_object_t *obj);
237 
239 
242 
244 
245 
247 void lock_init(void);
248 
250 void lock_acquire(void);
251 
253 void lock_release(void);
254 
256 
258 
259 #if defined(__cplusplus)
260 }
261 #endif
262 
263 #endif // __FSL_RTOS_ABSTRACTION_H__
264 // EOF
Definition: fsl_rtos_abstraction.h:47
void OSA_TimeDelay(uint32_t delay)
Delays execution for a number of milliseconds.
Definition: fsl_rtos_abstraction.c:199
Constant to pass for the sync_wait() timeout in order to wait indefinitely.
Definition: fsl_rtos_abstraction.h:68
volatile int32_t sync_object_t
Type for an interrupt synchronization object.
Definition: fsl_rtos_abstraction.h:60
volatile uint8_t semCount
Definition: fsl_rtos_abstraction.h:54
Definition: fsl_rtos_abstraction.h:44
Definition: fsl_rtos_abstraction.h:51
Definition: fsl_rtos_abstraction.h:46
sync_timeouts
Definition: fsl_rtos_abstraction.h:65
volatile bool isWaiting
Definition: fsl_rtos_abstraction.h:53
Definition: fsl_rtos_abstraction.h:45
osa_status_t
Definition: fsl_rtos_abstraction.h:42
osa_status_t OSA_SemaDestroy(semaphore_t *pSem)
Destroys a previously created semaphore.
Definition: fsl_rtos_abstraction.c:186
uint64_t tickStart
Definition: fsl_rtos_abstraction.h:55
osa_status_t OSA_SemaWait(semaphore_t *pSem, uint32_t timeout)
Pending a semaphore with timeout.
Definition: fsl_rtos_abstraction.c:106
void lock_init(void)
Initialize the lock object.
Definition: fsl_rtos_abstraction.c:241
osa_status_t OSA_SemaCreate(semaphore_t *pSem, uint8_t initValue)
Creates a semaphore with a given value.
Definition: fsl_rtos_abstraction.c:74
void lock_release(void)
Restore previous state.
Definition: fsl_rtos_abstraction.c:255
void lock_acquire(void)
Disable global irq and store previous state.
Definition: fsl_rtos_abstraction.c:248
osa_status_t OSA_SemaPost(semaphore_t *pSem)
Signals for someone waiting on the semaphore to wake up.
Definition: fsl_rtos_abstraction.c:163
uint32_t timeout
Definition: fsl_rtos_abstraction.h:56
volatile uint32_t lock_object_t
Type for an interrupt lock object.
Definition: fsl_rtos_abstraction.h:63