NHAL Interface v0.5.0
Hardware Abstraction Layer Interface for Embedded Systems
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions
nhal_common.h File Reference
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  nhal_async_config
 

Typedefs

typedef uint16_t nhal_timeout_ms
 
typedef void(* nhal_async_complete_cb_t) (void *context)
 

Enumerations

enum  nhal_async_status_t { NHAL_ASYNC_STATUS_IDLE , NHAL_ASYNC_STATUS_BUSY , NHAL_ASYNC_STATUS_COMPLETE , NHAL_ASYNC_STATUS_ERROR }
 
enum  nhal_result_t {
  NHAL_OK = 0 , NHAL_ERR_INVALID_ARG , NHAL_ERR_INVALID_CONFIG , NHAL_ERR_NOT_INITIALIZED ,
  NHAL_ERR_ALREADY_INITIALIZED , NHAL_ERR_NOT_CONFIGURED , NHAL_ERR_NOT_STARTED , NHAL_ERR_ALREADY_STARTED ,
  NHAL_ERR_BUSY , NHAL_ERR_TIMEOUT , NHAL_ERR_HW_FAILURE , NHAL_ERR_UNSUPPORTED ,
  NHAL_ERR_NO_RESPONSE , NHAL_ERR_TRANSMISSION_ERROR , NHAL_ERR_BUFFER_FULL , NHAL_ERR_BUFFER_OVERFLOW ,
  NHAL_ERR_OUT_OF_MEMORY , NHAL_ERR_OTHER
}
 Unified HAL result type for all peripheral operations. More...
 

Functions

void nhal_delay_microseconds (uint32_t microseconds)
 Blocking delay for specified number of microseconds.
 
void nhal_delay_milliseconds (uint32_t milliseconds)
 Blocking delay for specified number of milliseconds.
 
uint64_t nhal_get_timestamp_microseconds (void)
 Get monotonic timestamp in microseconds since boot.
 
uint32_t nhal_get_timestamp_milliseconds (void)
 Get monotonic timestamp in milliseconds since boot.
 

Typedef Documentation

◆ nhal_async_complete_cb_t

typedef void(* nhal_async_complete_cb_t) (void *context)

Definition at line 56 of file nhal_common.h.

◆ nhal_timeout_ms

typedef uint16_t nhal_timeout_ms

Definition at line 6 of file nhal_common.h.

Enumeration Type Documentation

◆ nhal_async_status_t

Enumerator
NHAL_ASYNC_STATUS_IDLE 

No async operation in progress.

NHAL_ASYNC_STATUS_BUSY 

Async operation in progress.

NHAL_ASYNC_STATUS_COMPLETE 

Operation completed successfully.

NHAL_ASYNC_STATUS_ERROR 

Operation completed with error.

Definition at line 8 of file nhal_common.h.

◆ nhal_result_t

Unified HAL result type for all peripheral operations.

Enumerator
NHAL_OK 

Operation completed successfully.

NHAL_ERR_INVALID_ARG 

Invalid arguments provided.

NHAL_ERR_INVALID_CONFIG 

Invalid configuration.

NHAL_ERR_NOT_INITIALIZED 

Peripheral not initialized.

NHAL_ERR_ALREADY_INITIALIZED 

Already initialized.

NHAL_ERR_NOT_CONFIGURED 

Peripheral not configured.

NHAL_ERR_NOT_STARTED 

Operation not started.

NHAL_ERR_ALREADY_STARTED 

Already started/running.

NHAL_ERR_BUSY 

Resource busy/locked/unavailable.

NHAL_ERR_TIMEOUT 

Operation timeout.

NHAL_ERR_HW_FAILURE 

Hardware failure.

NHAL_ERR_UNSUPPORTED 

Feature not supported.

NHAL_ERR_NO_RESPONSE 

No response from target (NACK, etc.).

NHAL_ERR_TRANSMISSION_ERROR 

General transmission error.

NHAL_ERR_BUFFER_FULL 

Buffer full.

NHAL_ERR_BUFFER_OVERFLOW 

Buffer overflow.

NHAL_ERR_OUT_OF_MEMORY 

Memory allocation failed.

NHAL_ERR_OTHER 

Unspecified error.

Definition at line 22 of file nhal_common.h.

Function Documentation

◆ nhal_delay_microseconds()

void nhal_delay_microseconds ( uint32_t  microseconds)

Blocking delay for specified number of microseconds.

This function performs a busy-wait delay, blocking the calling thread for the specified duration. Should be used for precise timing requirements where scheduler-based delays are insufficient.

Parameters
microsecondsNumber of microseconds to delay

◆ nhal_delay_milliseconds()

void nhal_delay_milliseconds ( uint32_t  milliseconds)

Blocking delay for specified number of milliseconds.

This function performs a busy-wait delay, blocking the calling thread for the specified duration. Should be used for precise timing requirements where scheduler-based delays are insufficient.

Parameters
millisecondsNumber of milliseconds to delay

◆ nhal_get_timestamp_microseconds()

uint64_t nhal_get_timestamp_microseconds ( void  )

Get monotonic timestamp in microseconds since boot.

This function returns a monotonic timestamp suitable for measuring time intervals with microsecond precision. The timestamp resets on system boot and may rollover after ~4294 seconds on 32-bit systems. Unsigned arithmetic automatically handles rollover correctly for interval calculations.

Returns
Monotonic timestamp in microseconds

◆ nhal_get_timestamp_milliseconds()

uint32_t nhal_get_timestamp_milliseconds ( void  )

Get monotonic timestamp in milliseconds since boot.

This function returns a monotonic timestamp suitable for measuring time intervals with millisecond precision. The timestamp resets on system boot and may rollover after ~49 days on 32-bit systems. Unsigned arithmetic automatically handles rollover correctly for interval calculations.

Returns
Monotonic timestamp in milliseconds