1 /***************************************************************************//** 2 * \file cyhal_interconnect.h 3 * 4 * \brief 5 * Provides a high level interface for interacting with the internal digital 6 * routing on the chip. This interface abstracts out the chip specific details. 7 * If any chip specific functionality is necessary, or performance is critical 8 * the low level functions can be used directly. 9 * 10 ******************************************************************************** 11 * \copyright 12 * Copyright 2018-2022 Cypress Semiconductor Corporation (an Infineon company) or 13 * an affiliate of Cypress Semiconductor Corporation 14 * 15 * SPDX-License-Identifier: Apache-2.0 16 * 17 * Licensed under the Apache License, Version 2.0 (the "License"); 18 * you may not use this file except in compliance with the License. 19 * You may obtain a copy of the License at 20 * 21 * http://www.apache.org/licenses/LICENSE-2.0 22 * 23 * Unless required by applicable law or agreed to in writing, software 24 * distributed under the License is distributed on an "AS IS" BASIS, 25 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 * See the License for the specific language governing permissions and 27 * limitations under the License. 28 *******************************************************************************/ 29 30 /** 31 * \addtogroup group_hal_interconnect Interconnect (Internal Digital Routing) 32 * \ingroup group_hal 33 * \{ 34 * High level interface to the Infineon digital routing. 35 * 36 * \section subsection_interconnect_features Features 37 * Facilities for runtime manipulation of the on chip routing. 38 * The following types of connections are supported: 39 * * Connection from a peripheral to a pin. (A dedicated connection must exist 40 between the pin and the peripheral; see the device datasheet for more details) 41 * * Connecting two peripherals in hardware using the on-chip trigger signaling 42 * 43 * \section subsection_interconnect_quickstart Quick Start 44 * * \ref cyhal_connect_pin can be used to connect a pin to a peripheral.(A dedicated connection must exist 45 * between the pin and the peripheral; see the device datasheet for more details) 46 * * \ref cyhal_disconnect_pin can be used to disconnect a pin from a peripheral. 47 * The drive mode will be reset to High-Z after disconnecting 48 * 49 * \section section_interconnect_snippets Code Snippets 50 * 51 * \subsection subsection_interconnect_snippet1 Snippet 1: Connecting a pin to TCPWM block 52 * The following code snippet demonstrates connecting a GPIO pin to an active TCPWM block on a device 53 * using the \ref cyhal_connect_pin. It is assumed that the TCPWM is already configured and active.<br> 54 * \snippet hal_interconnect.c snippet_cyhal_interconnect_connect_pin 55 * 56 * \subsection subsection_interconnect_snippet2 Snippet 2: Connecting a Timer output signal to a DMA input signal 57 * The following code snippet demonstrates configuring and connecting a Timer 58 * which will overflow every 2 seconds and, in doing so, trigger a DMA channel 59 * start. 60 * \snippet hal_interconnect.c snippet_cyhal_interconnect_timer_to_dma 61 */ 62 63 #pragma once 64 65 #include <stdint.h> 66 #include <stdbool.h> 67 #include "cy_result.h" 68 #include "cyhal_hw_types.h" 69 70 #if defined(__cplusplus) 71 extern "C" { 72 #endif 73 74 /** \addtogroup group_hal_results_interconnect Interconnect HAL Results 75 * Interconnect specific return codes 76 * \ingroup group_hal_results 77 * \{ *//** 78 */ 79 80 /** The source and destination are already connected */ 81 #define CYHAL_INTERCONNECT_RSLT_ALREADY_CONNECTED \ 82 (CY_RSLT_CREATE_EX(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_HAL, CYHAL_RSLT_MODULE_INTERCONNECT, 0)) 83 /** Connection is invalid */ 84 #define CYHAL_INTERCONNECT_RSLT_INVALID_CONNECTION \ 85 (CY_RSLT_CREATE_EX(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_HAL, CYHAL_RSLT_MODULE_INTERCONNECT, 1)) 86 /** Cannot disconnect. Either no connection in the first place or a bad argument */ 87 #define CYHAL_INTERCONNECT_RSLT_CANNOT_DISCONNECT \ 88 (CY_RSLT_CREATE_EX(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_HAL, CYHAL_RSLT_MODULE_INTERCONNECT, 2)) 89 90 /** 91 * \} 92 */ 93 94 /** Connect a pin to a peripheral terminal. This will route a direct connection from the pin to the peripheral. 95 * Any previous direct connection from the pin will be overriden.<br> 96 * See \ref subsection_interconnect_snippet1 97 * @param[in] pin_connection The pin and target peripheral terminal to be connected 98 * @param[in] drive_mode The drive mode to use for the pin 99 * @return The status of the connect request 100 */ 101 cy_rslt_t cyhal_connect_pin(const cyhal_resource_pin_mapping_t *pin_connection, uint8_t drive_mode); 102 103 /** Disconnect a peripheral from a pin. This will also reset the pin's drive mode to High-Z. 104 * @param[in] pin The pin to be disconnected 105 * @return The status of the disconnect request 106 */ 107 cy_rslt_t cyhal_disconnect_pin(cyhal_gpio_t pin); 108 109 #if defined(__cplusplus) 110 } 111 #endif 112 113 #ifdef CYHAL_INTERCONNECT_IMPL_HEADER 114 #include CYHAL_INTERCONNECT_IMPL_HEADER 115 #endif /* CYHAL_INTERCONNECT_IMPL_HEADER */ 116 117 /** \} group_hal_interconnect */ 118