API Design Principles
The NitroCortex API follows consistent design principles across all components:
- Prefix Convention: All functions use component prefixes (
NT_for NitroOS,NF_for NitroFS, etc.) - Return Codes: Functions return
NT_STATUSfor error handling - Thread Safety: APIs are thread-safe when used with NitroOS
- MISRA-C 2025: All code is MISRA-C compliant for safety-critical applications
Return Codes
| Code | Value | Description |
|---|---|---|
NT_OK | 0 | Operation successful |
NT_ERROR | -1 | Generic error |
NT_TIMEOUT | -2 | Operation timed out |
NT_NOMEM | -3 | Out of memory |
NT_INVALID | -4 | Invalid parameter |
NT_BUSY | -5 | Resource busy |
NitroOS API
Task Management
NT_TaskCreate() NitroOS
Creates a new task with the specified entry point, stack size, and priority (0-31, higher = more priority).
NT_TaskDelay() NitroOS
Suspends the current task for the specified number of system ticks.
NT_TaskYield() NitroOS
Yields execution to another ready task of equal or higher priority.
Synchronization
NT_MutexCreate() NitroOS
Creates a mutex with priority inheritance support.
NT_MutexLock() NitroOS
Acquires the mutex, blocking until available or timeout expires.
NT_SemCreate() NitroOS
Creates a counting semaphore with the specified initial count.
NitroFS API
File Operations
NF_FOpen() NitroFS
Opens a file with stdio-compatible mode string ("r", "w", "a", "rb", "wb", etc.).
NF_FRead() NitroFS
Reads data from file into buffer. Returns number of items read.
NF_FWrite() NitroFS
Writes data from buffer to file. Returns number of items written.
NitroSIM API
NS_Init() NitroSIM
Initializes the emulator with target configuration (core type, memory map, peripherals).
NS_LoadELF() NitroSIM
Loads an ELF executable into emulator memory.
NS_Run() NitroSIM
Executes the specified number of CPU cycles, or until breakpoint/halt.
NitroVISION API
NV_Init() NitroVISION
Initializes the TUI system with the specified console (UART, VT100, etc.).
NV_CreateWindow() NitroVISION
Creates a new window with title bar, border, and optional close button.
NV_AddButton() NitroVISION
Adds a clickable button widget to a window.