fsl_rtos_abstraction.h
/*
* Copyright (c) 2013, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__FSL_RTOS_ABSTRACTION_H__)
#define __FSL_RTOS_ABSTRACTION_H__
#include <stdint.h>
#include <stdbool.h>
// Declarations
typedef enum _osa_status_t
{
kStatus_OSA_Success = 0U,
kStatus_OSA_Error = 1U,
kStatus_OSA_Timeout = 2U,
kStatus_OSA_Idle = 3U
} osa_status_t;
typedef struct Semaphore
{
volatile bool isWaiting;
volatile uint8_t semCount;
uint64_t tickStart;
uint32_t timeout;
} semaphore_t;
typedef volatile int32_t sync_object_t;
typedef volatile uint32_t lock_object_t;
enum sync_timeouts
{
kSyncWaitForever = 0xffffffffU
};
// API
#if defined(__cplusplus)
extern "C" {
#endif
osa_status_t OSA_SemaCreate(semaphore_t *pSem, uint8_t initValue);
osa_status_t OSA_SemaWait(semaphore_t *pSem, uint32_t timeout);
osa_status_t OSA_SemaPost(semaphore_t *pSem);
osa_status_t OSA_SemaDestroy(semaphore_t *pSem);
void OSA_TimeDelay(uint32_t delay);
void sync_init(sync_object_t *obj, bool state);
bool sync_wait(sync_object_t *obj, uint32_t timeout);
void sync_signal(sync_object_t *obj);
void sync_reset(sync_object_t *obj);
void lock_init(void);
void lock_acquire(void);
void lock_release(void);
#if defined(__cplusplus)
}
#endif
#endif // __FSL_RTOS_ABSTRACTION_H__
// EOF
kStatus_OSA_Idle
Definition: fsl_rtos_abstraction.h:47
OSA_TimeDelay
void OSA_TimeDelay(uint32_t delay)
Delays execution for a number of milliseconds.
Definition: fsl_rtos_abstraction.c:199
kSyncWaitForever
Constant to pass for the sync_wait() timeout in order to wait indefinitely.
Definition: fsl_rtos_abstraction.h:68
sync_object_t
volatile int32_t sync_object_t
Type for an interrupt synchronization object.
Definition: fsl_rtos_abstraction.h:60
semaphore_t::semCount
volatile uint8_t semCount
Definition: fsl_rtos_abstraction.h:54
kStatus_OSA_Success
Definition: fsl_rtos_abstraction.h:44
semaphore_t
Definition: fsl_rtos_abstraction.h:51
kStatus_OSA_Timeout
Definition: fsl_rtos_abstraction.h:46
sync_timeouts
sync_timeouts
Definition: fsl_rtos_abstraction.h:65
semaphore_t::isWaiting
volatile bool isWaiting
Definition: fsl_rtos_abstraction.h:53
kStatus_OSA_Error
Definition: fsl_rtos_abstraction.h:45
osa_status_t
osa_status_t
Definition: fsl_rtos_abstraction.h:42
OSA_SemaDestroy
osa_status_t OSA_SemaDestroy(semaphore_t *pSem)
Destroys a previously created semaphore.
Definition: fsl_rtos_abstraction.c:186
semaphore_t::tickStart
uint64_t tickStart
Definition: fsl_rtos_abstraction.h:55
OSA_SemaWait
osa_status_t OSA_SemaWait(semaphore_t *pSem, uint32_t timeout)
Pending a semaphore with timeout.
Definition: fsl_rtos_abstraction.c:106
lock_init
void lock_init(void)
Initialize the lock object.
Definition: fsl_rtos_abstraction.c:241
OSA_SemaCreate
osa_status_t OSA_SemaCreate(semaphore_t *pSem, uint8_t initValue)
Creates a semaphore with a given value.
Definition: fsl_rtos_abstraction.c:74
lock_release
void lock_release(void)
Restore previous state.
Definition: fsl_rtos_abstraction.c:255
lock_acquire
void lock_acquire(void)
Disable global irq and store previous state.
Definition: fsl_rtos_abstraction.c:248
OSA_SemaPost
osa_status_t OSA_SemaPost(semaphore_t *pSem)
Signals for someone waiting on the semaphore to wake up.
Definition: fsl_rtos_abstraction.c:163
semaphore_t::timeout
uint32_t timeout
Definition: fsl_rtos_abstraction.h:56
lock_object_t
volatile uint32_t lock_object_t
Type for an interrupt lock object.
Definition: fsl_rtos_abstraction.h:63