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.
{
.block_num = 0,
.channel_num = 3
};
_cyhal_utils_disconnect_and_free(
P0_0);
void cyhal_hwmgr_free(const cyhal_resource_inst_t *obj)
Free the specified resource to allow it to be reused.
Definition: cyhal_hwmgr.c:196
cyhal_resource_t type
The resource block type.
Definition: cyhal_hw_resources.h:589
@ CYHAL_RSC_TCPWM
Definition: cyhal_hw_resources.h:234
Represents a particular instance of a resource on the chip.
Definition: cyhal_hw_resources.h:588
@ P0_0
Port 0 Pin 0.
Definition: cyhal_psoc6_01_104_m_csp_ble.h:55
◆ cyhal_hwmgr_init()
Initializes the hardware manager to keep track of what resources are being used.
- Returns
- The status of the init request
◆ cyhal_hwmgr_reserve()
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] | obj | The 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()
◆ cyhal_hwmgr_allocate()
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] | type | The type of resource to allocate. |
[out] | obj | The resource object. |
- Returns
- The status of the allocate request.