Hardware Abstraction Layer for FreeRTOS
Hardware Abstraction Layer for FreeRTOS
Collaboration diagram for Hardware Abstraction Layer for FreeRTOS:

Modules

 ADC Subsystem
 
 Accelerator Subsystem
 
 CAN Subsystem
 
 Cache Subsystem
 
 Capture Subsystem
 
 Clock Subsystem
 
 Counter Subsystem
 
 DAC Subsystem
 
 Driver for Shared Memmory for heterogeneous Multicore Possessor
 
 Example driver
 
 GPIO Subsystem
 
 Gyroscope Subsystem
 
 I2C Subsystem
 
 IRQ Subsystem
 
 LTC6811 driver
 
 Linker Script Macros
 
 MPU9250 driver
 
 Mailbox
 
 Mux Subsystem
 
 Newlib Function
 
 Operation System Layer for FreeRTOS
 
 PWM Subsystem
 
 Real Time Clock (RTC) or Warl Clock driver.
 
 Remoteproc Subssystem
 
 SD Card Controller Interface
 
 SPI Subsystem
 
 TLC5947 Driver
 
 TPS65381 driver
 
 Temperature Subsystem
 
 Timer Subsystem
 
 UART Subsystem
 
 Useful Macros
 

Data Structures

struct  hal
 

Macros

#define HAL_DEFINE_GLOBAL_ARRAY(gns)
 
#define HAL_GET_DEV(gns, index)   (void *) hal_getDev((uintptr_t **) &_devs, &_devs_end, index)
 
#define HAL_LOCK(data, waittime, errcode)
 
#define HAL_UNLOCK(data, errcode)
 
#define HAL_DEFINE_DEVICE_ENTRY(gns, ns, p)   extern struct gns##_generic const * const ns##_##p
 
#define HAL_ADDDEV(gns, ns, p)   struct gns##_generic SECTION(".rodata.devs") USED NO_REORDER const * const ns##_##p = (void const *) &p
 
#define HAL_ADD(ns, p)   HAL_ADDDEV(hal, ns, p)
 
#define HAL_GET_GLOBAL_DEV(index)   HAL_GET_DEV(hal, index)
 
#define HAL_NAME(n)
 
#define HAL_GET_ID(gns, ns, p)
 

Functions

int32_t hal_init (void *data)
 
int32_t hal_deinit (void *data)
 
bool hal_isInit (void *data)
 
int32_t hal_lock (void *data, TickType_t waittime)
 
int32_t hal_unlock (void *data)
 
uintptr_t * hal_getDev (uintptr_t **devs, uintptr_t **end, uint32_t index)
 
 HAL_DEFINE_GLOBAL_ARRAY (hal)
 

Detailed Description

#include <hal.h>

This is the abstract Hardware Abstraction Layer Interface (HAL) is the main Interface for all Driver. All Driver shall implement the Interface.

All Driver Interfaces implemented the hal struct and have a init Function and a deinit Function. The init function return a Handler to access the instances of the driver. The deinit function disable the driver instance.

Each Driver has the possibility to make the instances threadsave. With the function lock and unlock the Driver can lock an unlock the instances.

All Pointer to all Instants stored in a separated Section sored by driver type (like uart, pwm, timer, ..)

For driver without a specified type a generic Array is created named hal use HAL_ADD() Macro to create a new entry.

The Linker Script must contain DEV_DEFAULT().

All driver instants are static allocated.

Macro Definition Documentation

◆ HAL_ADD

#define HAL_ADD (   ns,
 
)    HAL_ADDDEV(hal, ns, p)

Add some Devices without Global Namespace like a instances of MPU9250 Driver

◆ HAL_ADDDEV

#define HAL_ADDDEV (   gns,
  ns,
 
)    struct gns##_generic SECTION(".rodata.devs") USED NO_REORDER const * const ns##_##p = (void const *) &p

Add Device Entry to Device Array

Parameters
gnsGlobal Namespace of Driver like uart, pwm, ...
nsNamespace of Driver
pPointer to Driver Struct

◆ HAL_DEFINE_DEVICE_ENTRY

#define HAL_DEFINE_DEVICE_ENTRY (   gns,
  ns,
 
)    extern struct gns##_generic const * const ns##_##p

Define Device Entry

Parameters
gnsGlobal Namespace of Driver like uart, pwm, ...
nsNamespace of Driver
pPointer to Driver Struct

◆ HAL_DEFINE_GLOBAL_ARRAY

#define HAL_DEFINE_GLOBAL_ARRAY (   gns)
Value:
extern uintptr_t *_devs; \
extern uintptr_t *_devs_end

Define Global Array for Namespace

Parameters
gnsNamespace like uart

◆ HAL_GET_DEV

#define HAL_GET_DEV (   gns,
  index 
)    (void *) hal_getDev((uintptr_t **) &_devs, &_devs_end, index)

Get Device form global Array

Call HAL_DEFINE_GLOBAL_ARRAY() before

Parameters
gnsNamespace like uart
indexIndex in Array
Returns
see hal_getDev()

◆ HAL_GET_GLOBAL_DEV

#define HAL_GET_GLOBAL_DEV (   index)    HAL_GET_DEV(hal, index)

Get device form global Namespace

◆ HAL_GET_ID

#define HAL_GET_ID (   gns,
  ns,
 
)
Value:
({ \
HAL_DEFINE_DEVICE_ENTRY(gns, ns, p); \
uint32_t ret; \
ret = (uint32_t) ((((uintptr_t) (&ns##_##p)) - ((uintptr_t) (&_devs))) / sizeof(uintptr_t)); \
ret; \
})

Get Unique ID based on driver pointer

Parameters
gnsNamespace like uart
nsNamespace of Driver
pPointer to Driver Struct

◆ HAL_LOCK

#define HAL_LOCK (   data,
  waittime,
  errcode 
)
Value:
do { \
int32_t lock_ret = hal_lock(data, waittime); \
if (lock_ret != 1) { \
return errcode; \
}; \
} while(0)

Lock Driver

Parameters
dataDriver Struct like hal
waittimeMax Waittime see xSemaphoreTakeRecursive()
errcodeError Code automatically returned

◆ HAL_NAME

#define HAL_NAME (   n)

◆ HAL_UNLOCK

#define HAL_UNLOCK (   data,
  errcode 
)
Value:
do { \
int32_t unlock_ret = hal_unlock(data); \
if (unlock_ret != 1) { \
return errcode; \
} \
} while(0)

Unlock Driver

Parameters
dataDriver Struct like hal
errcodeError Code automatically returned

Function Documentation

◆ HAL_DEFINE_GLOBAL_ARRAY()

HAL_DEFINE_GLOBAL_ARRAY ( hal  )

◆ hal_deinit()

int32_t hal_deinit ( void *  data)
inline

Deinit Hal Driver

Parameters
dataDriver Struct like hal
Returns
-1 on error 0 on ok

◆ hal_getDev()

uintptr_t* hal_getDev ( uintptr_t **  devs,
uintptr_t **  end,
uint32_t  index 
)
inline

Get Device form global Array

Parameters
devsArray
endLast Position in Array
indexIndex in Array
Returns
NULL if index to big else pointer to dev

◆ hal_init()

int32_t hal_init ( void *  data)
inline

Init Hal driver

Parameters
dataDriver Struct like hal
Returns
-1 on error 0 on ok

◆ hal_isInit()

bool hal_isInit ( void *  data)
inline

Check Driver is Init

Parameters
dataDriver Struct like hal
Returns
true = on is init false on is not init

◆ hal_lock()

int32_t hal_lock ( void *  data,
TickType_t  waittime 
)
inline

Lock Driver

Parameters
dataDriver Struct like hal
waittimeMax Waittime see xSemaphoreTakeRecursive()
Returns
0 on error 1 on ok like xSemaphoreTakeRecursive()

◆ hal_unlock()

int32_t hal_unlock ( void *  data)
inline

Unlock Driver

Parameters
dataDriver Struct like hal
Returns
0 on error 1 on ok like xSemaphoreTakeRecursive()
hal.h
hal_lock
int32_t hal_lock(void *data, TickType_t waittime)
Definition: hal.h:108
hal_unlock
int32_t hal_unlock(void *data)
Definition: hal.h:122