Nios® V Processor Software Developer Handbook

ID 743810
Date 9/26/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

9.3.3. Thread-Safe HAL Drivers

To enable a driver to be ported between the HAL and MicroC/OS-II environments, Intel defines a set of operating system-independent macros that provide access to operating system facilities. These macros implement functionality that is only relevant to a multi-threaded environment. When compiled for a a multithreaded uCOS/II project, the macros expand to MicroC/OS-II API calls. When compiled for a single-threaded HAL project, the macros expand to benign empty implementations. These macros are used in Intel-provided device driver code, and you can use them if you need to write a device driver with similar portability.

The path listed for the header file is relative to the <Intel Quartus installation directory>/nios2eds/components/micrium_uc_osii/UCOSII/inc directory.

Table 37.  OS-Independent Macros for Thread-Safe HAL Drivers
Macro Defined in Header MicroC/OS-II Implementation Single-Threaded HAL Implementation
ALT_FLAG_GRP(group) os/alt_flag.h Create a pointer to a flag group with the name group. Empty statement
ALT_EXTERN_FLAG_GRP(group) os/alt_flag.h Create an external reference to a pointer to a flag group with name group. Empty statement
ALT_STATIC_FLAG_GRP(group) os/alt_flag.h Create a static pointer to a flag group with the name group. Empty statement
ALT_FLAG_CREATE(group, flags) os/alt_flag.h Call OSFlagCreate() to initialize the flag group pointer, group, with the flags value flags. The error code is the return value of the macro. Return 0 (success)
ALT_FLAG_PEND(group, flags, wait_type, timeout) os/alt_flag.h Call OSFlagPend() with the first four input arguments set to group, flags, wait_type, and timeout respectively. The error code is the return value of the macro. Return 0 (success)
ALT_FLAG_POST(group, flags, opt) os/alt_flag.h Call OSFlagPost() with the first three input arguments set to group, flags, and opt respectively. The error code is the return value of the macro. Return 0 (success)
ALT_SEM(sem) os/alt_sem.h Create an OS_EVENT pointer with the name sem. Empty statement
ALT_EXTERN_SEM(sem) os/alt_sem.h Create an external reference to an OS_EVENT pointer with the name sem. Empty statement
ALT_STATIC_SEM(sem) os/alt_sem.h Create a static OS_EVENT pointer with the name sem. Empty statement
ALT_SEM_CREATE(sem, value) os/alt_sem.h Call OSSemCreate() with the argument value to initialize the OS_EVENT pointer sem. The return value is zero on success, or negative otherwise. Return 0 (success)
ALT_SEM_PEND(sem, timeout) os/alt_sem.h Call OSSemPend() with the first two argument set to sem and timeout respectively. The error code is the return value of the macro. Return 0 (success)
ALT_SEM_POST(sem) os/alt_sem.h Call OSSemPost() with the input argument sem. Return 0 (success)