Hardware Abstraction Layer (HAL)
HWMGR (Hardware Manager)

General Description

High level interface to the Hardware Manager.

Features

Quick Start

Code snippets

Snippet 1: Freeing a block used by PDL or configurators

The following snippet shows how a specific resource used directly in PDL or the configurators can be freed so that it can be used by HAL.

/* The resource that is being used */
{
.block_num = 0,
.channel_num = 3
};
/* Use resource directly in PDL or configurators */
/* If the resource is no longer needed and can be used by the HAL, free the resource in Hardware Manager */
cyhal_hwmgr_free(&resource);
/* Disconnect any interconnects used between resources and pin */
_cyhal_utils_disconnect_and_free(P0_0);
/* resource can now be used by HAL */

API Reference

 HWMGR HAL Results
 HWMGR specific return codes.
 

Functions

cy_rslt_t cyhal_hwmgr_init (void)
 Initializes the hardware manager to keep track of what resources are being used. More...
 
cy_rslt_t cyhal_hwmgr_reserve (const cyhal_resource_inst_t *obj)
 Reserve the specified resource. More...
 
void cyhal_hwmgr_free (const cyhal_resource_inst_t *obj)
 Free the specified resource to allow it to be reused. More...
 
cy_rslt_t cyhal_hwmgr_allocate (cyhal_resource_t type, cyhal_resource_inst_t *obj)
 Allocates a free block of the specified type if available This function is used when the exact block number and channel number of the resource is not known. More...
 

Function Documentation

◆ cyhal_hwmgr_init()

cy_rslt_t cyhal_hwmgr_init ( void  )

Initializes the hardware manager to keep track of what resources are being used.

Returns
The status of the init request

◆ cyhal_hwmgr_reserve()

cy_rslt_t cyhal_hwmgr_reserve ( const cyhal_resource_inst_t obj)

Reserve the specified resource.

The exact block number and channel number must be specified. If this is not know, use cyhal_hwmgr_allocate.

Note
This function is called by the init function of hardware blocks. Calling this again for the same block will result in error since the hardware block is already marked as consumed.
Parameters
[in]objThe resource object that should be reserved
Returns
The status of the reserve request

See Snippet 1: Freeing a block used by PDL or configurators

◆ cyhal_hwmgr_free()

void cyhal_hwmgr_free ( const cyhal_resource_inst_t obj)

Free the specified resource to allow it to be reused.

Parameters
[in,out]objThe resource object to free

See Snippet 1: Freeing a block used by PDL or configurators

◆ cyhal_hwmgr_allocate()

cy_rslt_t cyhal_hwmgr_allocate ( cyhal_resource_t  type,
cyhal_resource_inst_t obj 
)

Allocates a free block of the specified type if available This function is used when the exact block number and channel number of the resource is not known.

This function loops through all available resource of the specified type and assigns the resource if available. This function internally calls cyhal_hwmgr_reserve function and hence, it should not be called again.

Parameters
[in]typeThe type of resource to allocate.
[out]objThe resource object.
Returns
The status of the allocate request.