Hardware Abstraction Layer (HAL)
Interconnect (Internal Digital Routing)

General Description

High level interface to the Infineon digital routing.

Features

Facilities for runtime manipulation of the on chip routing. The following types of connections are supported:

Quick Start

Code Snippets

Snippet 1: Connecting a pin to TCPWM block

The following code snippet demonstrates connecting a GPIO pin to an active TCPWM block on a device using the cyhal_connect_pin. It is assumed that the TCPWM is already configured and active.

// Find out the resource block that connects the specified pins from the provided resource pin
// mapping table cyhal_pin_map_tcpwm_line. This example connects the pin to the TCPWM line pin
_CYHAL_UTILS_GET_RESOURCE(P2_4, cyhal_pin_map_tcpwm_line);
// Obtain the GPIO pin resource
cyhal_resource_inst_t pin_rsc = _cyhal_utils_get_gpio_resource(P2_4);
// Reserve the resource in hardware manager to prevent other HAL blocks from using it
cy_rslt_t status = cyhal_hwmgr_reserve(&pin_rsc);
if (CY_RSLT_SUCCESS == status)
{
// The resource is free, connect it to the block
if (CY_RSLT_SUCCESS != status)
{
cyhal_hwmgr_free(&pin_rsc);
}
}
@ CYHAL_GPIO_DRIVE_STRONG
Strong output.
Definition: cyhal_gpio.h:158
cy_rslt_t cyhal_hwmgr_reserve(const cyhal_resource_inst_t *obj)
Reserve the specified resource.
Definition: cyhal_hwmgr.c:177
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
Represents a particular instance of a resource on the chip.
Definition: cyhal_hw_resources.h:588
const cyhal_resource_pin_mapping_t cyhal_pin_map_tcpwm_line[68]
List of valid pin to peripheral connections for the tcpwm_line signal.
Represents an association between a pin and a resource.
Definition: cyhal_psoc6_01_104_m_csp_ble.h:143
@ P2_4
Port 2 Pin 4.
Definition: cyhal_psoc6_01_124_bga.h:73
cy_rslt_t cyhal_connect_pin(const cyhal_resource_pin_mapping_t *pin_connection, uint8_t drive_mode)
Connect a pin to a peripheral terminal.
Definition: cyhal_interconnect.c:502
uint32_t cy_rslt_t
Provides the result of an operation as a structured bitfield.
Definition: cy_result.h:426
#define CY_RSLT_SUCCESS
cy_rslt_t return value indicating success
Definition: cy_result.h:453

Snippet 2: Connecting a Timer output signal to a DMA input signal

The following code snippet demonstrates configuring and connecting a Timer which will overflow every 2 seconds and, in doing so, trigger a DMA channel start.

cyhal_source_t timer_source;
uint32_t src_arr[] = { 100, 200 };
uint32_t dst_arr[] = { 0, 0 };
const cyhal_timer_cfg_t timer_cfg =
{
.period = 20000,
.direction = CYHAL_TIMER_DIR_UP,
.is_compare = false,
.is_continuous = true,
.value = 0
};
const cyhal_dma_cfg_t dma_cfg =
{
.src_addr = (uint32_t)src_arr,
.src_increment = 1,
.dst_addr = (uint32_t)dst_arr,
.dst_increment = 1,
.transfer_width = 32,
.length = 2,
.burst_size = 0,
};
// Configure simple dma transfer from src_arr to dst_arr
cyhal_dma_configure(&dma, &dma_cfg);
// Setup timer to run continuously, overflowing every 2 seconds
cyhal_timer_init(&timer, NC, NULL);
cyhal_timer_configure(&timer, &timer_cfg);
cyhal_timer_set_frequency(&timer, 10000);
// Connect timer overflow trigger to DMA start
// Once timer is started, a DMA transfer will be triggered every 2 seconds (when the timer
// overflows) until the connection is disabled.
// Disable the connection
uint32_t src_addr
Source address. Some devices can apply special requirements for user data arrays. Please refer to imp...
Definition: cyhal_dma.h:246
cy_rslt_t cyhal_dma_connect_digital(cyhal_dma_t *obj, cyhal_source_t source, cyhal_dma_input_t input)
Connects a source signal and enables the specified input to the DMA channel.
void cyhal_dma_free(cyhal_dma_t *obj)
Free the DMA object.
cy_rslt_t cyhal_dma_disconnect_digital(cyhal_dma_t *obj, cyhal_source_t source, cyhal_dma_input_t input)
Disconnects a source signal and disables the specified input to the DMA channel.
#define cyhal_dma_init(obj, priority, direction)
Initialize the DMA peripheral.
Definition: cyhal_dma.h:311
cy_rslt_t cyhal_dma_configure(cyhal_dma_t *obj, const cyhal_dma_cfg_t *cfg)
Setup the DMA channel behavior.
@ CYHAL_DMA_TRANSFER_FULL
All bursts are triggered and a single CYHAL_DMA_TRANSFER_COMPLETE will occur at the end.
Definition: cyhal_dma.h:232
@ CYHAL_DMA_DIRECTION_MEM2MEM
Memory to memory.
Definition: cyhal_dma.h:167
@ CYHAL_DMA_INPUT_TRIGGER_ALL_ELEMENTS
Transfer all elements when an input signal is received.
Definition: cyhal_dma.h:196
Configuration of a DMA channel.
Definition: cyhal_dma.h:245
#define CYHAL_DMA_PRIORITY_DEFAULT
Default DMA channel priority.
Definition: cyhal_dma_impl.h:66
DMA object.
Definition: cyhal_hw_types.h:216
Timer object.
Definition: cyhal_hw_types.h:1478
@ NC
No Connect/Invalid Pin.
Definition: cyhal_psoc6_01_104_m_csp_ble.h:53
cyhal_trigger_source_psoc6_01_t
Name of each input trigger.
Definition: cyhal_triggers_psoc6_01.h:355
uint32_t compare_value
Timer/counter comparison value.
Definition: cyhal_timer.h:178
cy_rslt_t cyhal_timer_configure(cyhal_timer_t *obj, const cyhal_timer_cfg_t *cfg)
Updates the configuration and counter value of the timer/counter object.
cy_rslt_t cyhal_timer_enable_output(cyhal_timer_t *obj, cyhal_timer_output_t signal, cyhal_source_t *source)
Enables the specified output signal from a tcpwm that will be triggered when the corresponding event ...
cy_rslt_t cyhal_timer_set_frequency(cyhal_timer_t *obj, uint32_t hz)
Configures the timer frequency.
cy_rslt_t cyhal_timer_disable_output(cyhal_timer_t *obj, cyhal_timer_output_t signal)
Disables the specified output signal from a timer.
void cyhal_timer_free(cyhal_timer_t *obj)
Deinitialize the timer/counter object.
cy_rslt_t cyhal_timer_init(cyhal_timer_t *obj, cyhal_gpio_t pin, const cyhal_clock_t *clk)
Initialize the timer/counter peripheral and configure the pin.
cy_rslt_t cyhal_timer_start(cyhal_timer_t *obj)
Starts the timer/counter with the pre-set configuration from cyhal_timer_configure.
@ CYHAL_TIMER_OUTPUT_OVERFLOW
Overflow signal.
Definition: cyhal_timer.h:156
@ CYHAL_TIMER_DIR_UP
Counts up.
Definition: cyhal_timer.h:130
Describes the current configuration of a timer/counter.
Definition: cyhal_timer.h:168

API Reference

 Interconnect HAL Results
 Interconnect specific return codes.
 

Functions

cy_rslt_t cyhal_connect_pin (const cyhal_resource_pin_mapping_t *pin_connection, uint8_t drive_mode)
 Connect a pin to a peripheral terminal. More...
 
cy_rslt_t cyhal_disconnect_pin (cyhal_gpio_t pin)
 Disconnect a peripheral from a pin. More...
 

Function Documentation

◆ cyhal_connect_pin()

cy_rslt_t cyhal_connect_pin ( const cyhal_resource_pin_mapping_t pin_connection,
uint8_t  drive_mode 
)

Connect a pin to a peripheral terminal.

This will route a direct connection from the pin to the peripheral. Any previous direct connection from the pin will be overriden.
See Snippet 1: Connecting a pin to TCPWM block

Parameters
[in]pin_connectionThe pin and target peripheral terminal to be connected
[in]drive_modeThe drive mode to use for the pin
Returns
The status of the connect request

◆ cyhal_disconnect_pin()

cy_rslt_t cyhal_disconnect_pin ( cyhal_gpio_t  pin)

Disconnect a peripheral from a pin.

This will also reset the pin's drive mode to High-Z.

Parameters
[in]pinThe pin to be disconnected
Returns
The status of the disconnect request