HWMGR (Hardware Manager)

group group_hal_hwmgr

High level interface to the Hardware Manager.

Features

  • Allows HAL drivers or application firmware to mark specific hardware resources as reserved. When this is done, other reservation requests for the same resource will be denied.

  • For resources which are interchangeable such as clock dividers, provides allocation and reservation of an available instance.

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
    cyhal_resource_inst_t resource =
    {
        .type        = CYHAL_RSC_TCPWM,
        .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

Functions

cy_rslt_t cyhal_hwmgr_init(void)

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

Return

The status of the init request

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.

See

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

The status of the reserve request

Parameters
  • [in] obj: The resource object that should be reserved

void cyhal_hwmgr_free(const cyhal_resource_inst_t *obj)

Free the specified resource to allow it to be reused.

See

Snippet 1: Freeing a block used by PDL or configurators
Parameters
  • [inout] obj: The resource object to free

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.

Return

The status of the allocate request.

Parameters
  • [in] type: The type of resource to allocate.

  • [out] obj: The resource object.