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
status = cyhal_connect_pin(map, CY_GPIO_DM_STRONG);
if (CY_RSLT_SUCCESS != status)
{
cyhal_hwmgr_free(&pin_rsc);
}
}

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

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