1 /******************************************************************************* 2 * \file cy_trigmux.h 3 * \version 1.60.1 4 * 5 * This file provides constants and parameter values for the Trigger multiplexer driver. 6 * 7 ******************************************************************************** 8 * \copyright 9 * Copyright (c) (2016-2022), Cypress Semiconductor Corporation (an Infineon company) or 10 * an affiliate of Cypress Semiconductor Corporation. 11 * 12 * Licensed under the Apache License, Version 2.0 (the "License"); 13 * you may not use this file except in compliance with the License. 14 * You may obtain a copy of the License at 15 * 16 * http://www.apache.org/licenses/LICENSE-2.0 17 * 18 * Unless required by applicable law or agreed to in writing, software 19 * distributed under the License is distributed on an "AS IS" BASIS, 20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 * See the License for the specific language governing permissions and 22 * limitations under the License. 23 *******************************************************************************/ 24 25 /** 26 * \addtogroup group_trigmux 27 * \{ 28 * The trigger multiplexer provides access to the multiplexer that selects a set 29 * of trigger output signals from different peripheral blocks to route them to the 30 * specific trigger input of another peripheral block. 31 * 32 * The functions and other declarations used in this driver are in cy_trigmux.h. 33 * You can include cy_pdl.h to get access to all functions 34 * and declarations in the PDL. 35 * 36 * The TrigMux driver is based on the trigger multiplexer's hardware block. 37 * The Trigger multiplexer block consists of multiple trigger multiplexers. 38 * These trigger multiplexers are grouped in trigger groups. All the trigger 39 * multiplexers in the trigger group share similar input options. 40 * 41 * For PERI_ver1: 42 * The trigger multiplexer groups are either reduction multiplexers or distribution 43 * multiplexers. The figure below illustrates a generic trigger multiplexer block 44 * implementation with a reduction multiplexer layer of N trigger groups and a 45 * distribution multiplexer layer of M trigger groups. 46 * \image html trigmux_architecture.png 47 * The reduction multiplexer groups have input options that are the trigger outputs 48 * coming from the different peripheral blocks and the reduction multiplexer groups 49 * route them to intermediate signals. The distribution multiplexer groups have input 50 * options from these intermediate signals and route them back to multiple peripheral 51 * blocks as their trigger inputs. 52 * 53 * For PERI_ver2: 54 * The trigger multiplexer groups structure is flat - all the groups are essentially 55 * distribution multiplexers (there are no any intermediate trigger signals), so the 56 * structure is simpler in comparison with PERI_ver1, however a bit less flexible. 57 * Additionally there are another type of trigger interconnections: one-to-one 58 * trigger lines. These are not multiplexers, only single trigger wires from/to 59 * the dedicated peripherals. Multiple groups of one-to-one trigger lines 60 * significantly improve the whole triggering interconnect system flexibility. 61 * 62 * The trigger architecture of the PSoC device is explained in the technical reference 63 * manual (TRM). Refer to the TRM to better understand the trigger multiplexer routing 64 * architecture available. 65 * 66 * \section group_trigmux_section_Configuration_Considerations Configuration Considerations 67 * 68 * For PERI_ver1: 69 * To route a trigger signal from one peripheral in the PSoC 70 * to another, the user must configure a reduction multiplexer and a distribution 71 * multiplexer. The \ref Cy_TrigMux_Connect is used to configure a trigger multiplexer connection. 72 * The user will need two calls of this API, one for the reduction multiplexer and another 73 * for the distribution multiplexer, to achieve the trigger connection from a source 74 * peripheral to a destination peripheral. 75 * 76 * For PERI_ver2: 77 * To route a trigger signal from one peripheral in the PSoC device to another, the user can configure 78 * either a trigger multiplexer using \ref Cy_TrigMux_Connect or a one-to-one trigger line 79 * using \ref Cy_TrigMux_Select. Only one function call is required to connect one peripheral 80 * to another (unlike for PERI_ver1). 81 * 82 * The Cy_TrigMux_Connect() function has two main parameters, inTrig and outTrig that 83 * refer to the input and output trigger lines connected using the multiplexer. 84 * These parameters are represented in the following format:<br> 85 * For PERI_ver1: 86 * \image html trigmux_parameter_30.png 87 * For PERI_ver2: 88 * \image html trigmux_parameter_30_2.png 89 * In addition, the \ref Cy_TrigMux_Connect function also has an invert and trigger type parameter. 90 * Refer to the API reference for a detailed description of this parameter. 91 * All the constants associated with the different trigger signals in the system 92 * (input and output) are defined as constants in the device configuration header file. 93 * 94 * For PERI_ver1: 95 * The constants for TrigMux in the device configuration header file are divided into four 96 * types based on the signal being input/output and being part of a reduction/distribution 97 * trigger multiplexer. 98 * 99 * The four types of the input/output parameters are: 100 * 1) The parameters for the reduction multiplexer's inputs (input signals of TrigMux); 101 * 2) The parameters for the reduction multiplexer's outputs (intermediate signals); 102 * 3) The parameters for the distribution multiplexer's inputs (intermediate signals); 103 * 4) The parameters for the distribution multiplexer's outputs (output signals of TrigMux). 104 * 105 * For PERI_ver2: 106 * There are two types of TrigMux signal definitions in the device configuration header: 107 * 1) The parameters for the trigger interconnection system input signals. 108 * 2) The parameters for the trigger interconnection system output signals. 109 * Also there are separate groups of trigger multiplexer input/outputs and groups of 110 * trigger one-to-one line input/outputs. 111 * 112 * Refer to the TRM for a more detailed description of this architecture and different options. 113 * 114 * The steps to connect one peripheral block to the other: 115 * 116 * For PERI_ver1: 117 * Step 1. Find the trigger group number in the Trigger Group Inputs section of the device 118 * configuration header file that corresponds to the output of the source peripheral block. 119 * For example, TRIG11_IN_TCPWM0_TR_OVERFLOW0 (see \ref group_trigmux_red_in_enums and the diagram 120 * at the top of this section) input of the Reduction multiplexers belongs to Trigger Group 11. 121 * 122 * Step 2. Find the trigger group number in the Trigger Group Outputs section of the device 123 * configuration header file that corresponds to the input of the destination peripheral block. 124 * For example, TRIG0_OUT_CPUSS_DW0_TR_IN0 (see \ref group_trigmux_dst_out_enums) output of the 125 * Distribution multiplexer belongs to Trigger Group 0. 126 * 127 * Step 3. Find the same trigger group number in the Trigger Group Inputs section of the 128 * device configuration header file that corresponds to the trigger group number found in 129 * Step 1. Select the Reduction multiplexer output that can be connected to the trigger group 130 * found in Step 2. For example, TRIG0_IN_TR_GROUP11_OUTPUT0 (see \ref group_trigmux_dst_in_enums) 131 * means that Reduction Multiplexer Output 0 of Trigger Group 11 can be connected to 132 * Trigger Group 0. 133 * 134 * Step 4. Find the same trigger group number in the Trigger Group Outputs section of the 135 * device configuration header file that corresponds to the trigger group number found in Step 2. 136 * Select the distribution multiplexer input that can be connected to the trigger group found 137 * in Step 1. For example, TRIG11_OUT_TR_GROUP0_INPUT9 (see \ref group_trigmux_red_out_enums) 138 * means that the Distribution Multiplexer Input 9 of Trigger Group 0 can be connected to the 139 * output of the Reduction multiplexer in Trigger Group 11 found in Step 3. 140 * 141 * Step 5. Call Cy_TrigMux_Connect() API twice: the first call - with the constants for the 142 * inTrig and outTrig parameters found in Steps 1 and Step 4, the second call - with the 143 * constants for the inTrig and outTrig parameters found in Steps 2 and Step 3. 144 * For example: 145 * \snippet trigmux/snippet/main.c snippet_Cy_TrigMux_PERI_ver1 146 * 147 * For PERI_ver2: 148 * Step 1. Find the trigger group number in the Trigger Group Inputs section of the device 149 * configuration header file that corresponds to the output of the source peripheral block. 150 * For example, TRIG_IN_MUX_0_TCPWM0_TR_OVERFLOW0 (see \ref group_trigmux_in_enums) TrigMux 151 * input belongs to Trigger Group 0. It is the same TCPWM0 counter 0 overflow output 152 * (as in the example for PERI_ver1). 153 * 154 * Step 2. Find the same trigger group number in the Trigger Group Outputs section of the 155 * device configuration header file that corresponds to the trigger group number found in 156 * Step 1. Select the TrigMux output that can be connected to the destination peripheral block. 157 * For example, TRIG_OUT_MUX_0_PDMA0_TR_IN0 (see \ref group_trigmux_out_enums) means that the 158 * trigger multiplexer Output 0 of Trigger Group 0 can be connected to the DW0 channel 0 trigger 159 * input (the same DMA channel as mentioned in the example for PERI_ver1). 160 * 161 * Step 3. Call Cy_TrigMux_Connect() API once: 162 * \snippet trigmux/snippet/main.c snippet_Cy_TrigMux_PERI_ver2 163 * 164 * \section group_trigmux_more_information More Information 165 * For more information on the TrigMux peripheral, refer to the technical reference manual (TRM). 166 * 167 * \section group_trigmux_Changelog Changelog 168 * <table class="doxtable"> 169 * <tr><th>Version</th><th>Changes</th><th>Reason for Change</th></tr> 170 * <tr> 171 * <td>1.60.1</td> 172 * <td>Updated \ref Cy_TrigMux_SwTrigger API.</td> 173 * <td>Coverity error fixes.</td> 174 * </tr> 175 * <tr> 176 * <td>1.60</td> 177 * <td>Updated Cy_TrigMux_SwTrigger API and added CY_TRIGMUX_INTRIG_MASK macro.</td> 178 * <td>Support for CAT1D Devices added.</td> 179 * </tr> 180 * <tr> 181 * <td>1.50</td> 182 * <td>Updated driver to support the CAT1C family of devices.</td> 183 * <td>Added new family of devices.</td> 184 * </tr> 185 * <tr> 186 * <td>1.40</td> 187 * <td>Fixed MISRA violation.</td> 188 * <td>MISRA compliance.</td> 189 * </tr> 190 * <tr> 191 * <td rowspan="2">1.30</td> 192 * <td>Minor bug fixes.</td> 193 * <td>Keep device specific changes under a compile time device flag.</td> 194 * </tr> 195 * <tr> 196 * <td>Added new device support.</td> 197 * <td>Added new family of device.</td> 198 * </tr> 199 * <tr> 200 * <td>1.20.3</td> 201 * <td>Minor documentation updates.</td> 202 * <td>Removed MISRA 2004 compliance details and verified MISRA 2012 compliance.</td> 203 * </tr> 204 * <tr> 205 * <td>1.20.2</td> 206 * <td>Minor documentation updates.</td> 207 * <td>Documentation enhancement.</td> 208 * </tr> 209 * <tr> 210 * <td>1.20.1</td> 211 * <td>Documentation is extended/improved.</td> 212 * <td>Enhancement based on usability feedback.</td> 213 * </tr> 214 * <tr> 215 * <td rowspan="3">1.20</td> 216 * <td>Flattened the organization of the driver source code into the single source directory and the single include directory.</td> 217 * <td>Driver library directory-structure simplification.</td> 218 * </tr> 219 * <tr> 220 * <td>Added new API functions: 221 * - \ref Cy_TrigMux_Select 222 * - \ref Cy_TrigMux_Deselect 223 * - \ref Cy_TrigMux_SetDebugFreeze 224 * 225 * Modified the \ref Cy_TrigMux_SwTrigger API function logic. 226 * </td> 227 * <td>New devices support.</td> 228 * </tr> 229 * <tr> 230 * <td>Added register access layer. Use register access macros instead 231 * of direct register access using dereferenced pointers.</td> 232 * <td>Makes register access device-independent, so that the PDL does 233 * not need to be recompiled for each supported part number.</td> 234 * </tr> 235 * <tr> 236 * <td>1.10.1</td> 237 * <td>Renamed the internal macro in Cy_TrigMux_Connect() 238 * function to CY_TRIGMUX_IS_TRIGTYPE_VALID.</td> 239 * <td></td> 240 * </tr> 241 * <tr> 242 * <td>1.10</td> 243 * <td>The input/output bit in the trigLine parameter of the 244 * Cy_TrigMux_SwTrigger() function is changed to 30.<br> 245 * The invert parameter type is changed to bool.<br> 246 * Added input parameter validation to the API functions.</td> 247 * <td></td> 248 * </tr> 249 * <tr> 250 * <td>1.0</td> 251 * <td>Initial version</td> 252 * <td></td> 253 * </tr> 254 * </table> 255 * 256 * \defgroup group_trigmux_macros Macros 257 * \defgroup group_trigmux_functions Functions 258 * \defgroup group_trigmux_enums Enumerated Types 259 * \{ 260 * \defgroup group_trigmux_red_enums Reduction Trigger Mutiplexers 261 * \{ 262 * \defgroup group_trigmux_red_in_enums Reduction Trigger Mutiplexer Inputs 263 * \defgroup group_trigmux_red_out_enums Reduction Trigger Mutiplexer Outputs 264 * \} 265 * \defgroup group_trigmux_dst_enums Distribution Trigger Mutiplexers 266 * \{ 267 * \defgroup group_trigmux_dst_in_enums Distribution Trigger Mutiplexer Inputs 268 * \defgroup group_trigmux_dst_out_enums Distribution Trigger Mutiplexer Outputs 269 * \} 270 * \defgroup group_trigmux_in_enums Trigger Mutiplexer Inputs 271 * \defgroup group_trigmux_out_enums Trigger Mutiplexer Outputs 272 * \defgroup group_trigmux_1to1_enums One-To-One Trigger Lines 273 * \} 274 */ 275 276 #if !defined(CY_TRIGMUX_H) 277 #define CY_TRIGMUX_H 278 279 #include "cy_device.h" 280 281 #if defined (CY_IP_MXSPERI) || defined (CY_IP_MXPERI) 282 283 #include "cy_syslib.h" 284 285 #if defined(__cplusplus) 286 extern "C" { 287 #endif 288 289 /****************************************************************************** 290 * Macros 291 *****************************************************************************/ 292 293 /** 294 * \addtogroup group_trigmux_macros 295 * \{ 296 */ 297 298 /** The driver major version */ 299 #define CY_TRIGMUX_DRV_VERSION_MAJOR 1 300 301 /** The driver minor version */ 302 #define CY_TRIGMUX_DRV_VERSION_MINOR 60 303 304 /** TRIGMUX PDL ID */ 305 #define CY_TRIGMUX_ID CY_PDL_DRV_ID(0x33UL) /**< The trigger multiplexer driver identifier */ 306 307 /** Values for the cycles parameter in the \ref Cy_TrigMux_SwTrigger() function */ 308 #define CY_TRIGGER_INFINITE (255UL) /**< The trigger will be active until the user clears it or a hardware deactivates it. */ 309 #define CY_TRIGGER_DEACTIVATE (0UL) /**< Use this parameter value to deactivate the trigger. */ 310 #define CY_TRIGGER_TWO_CYCLES (2UL) /**< The only valid cycles number value for PERI_ver2. */ 311 312 /** \} group_trigmux_macros */ 313 314 /** \cond BWC macros */ 315 #define CY_TR_MUX_TR_INV_ENABLE (0x01u) 316 #define CY_TR_MUX_TR_INV_DISABLE (0x00u) 317 #define CY_TR_ACTIVATE_DISABLE (0x00u) 318 #define CY_TR_ACTIVATE_ENABLE (0x01u) 319 #define CY_TR_GROUP_MASK (0x0F00u) 320 #define CY_TR_MASK (0x007Fu) 321 #define CY_TR_GROUP_SHIFT (0x08u) 322 #define CY_TR_OUT_CTL_MASK (0x40000000uL) 323 #define CY_TR_OUT_CTL_SHIFT (30u) 324 #define CY_TR_PARAM_MASK (CY_TR_OUT_CTL_MASK | CY_TR_GROUP_MASK | CY_TR_MASK) 325 #define CY_TR_CYCLES_MIN (0u) 326 #define CY_TR_CYCLES_MAX (255u) 327 /** \endcond */ 328 329 330 /** 331 * \addtogroup group_trigmux_enums 332 * \{ 333 */ 334 335 /****************************************************************************** 336 * Enumerations 337 *****************************************************************************/ 338 339 /** The TRIGMUX error codes. */ 340 typedef enum 341 { 342 CY_TRIGMUX_SUCCESS = 0x0UL, /**< Successful */ 343 CY_TRIGMUX_BAD_PARAM = CY_TRIGMUX_ID | CY_PDL_STATUS_ERROR | 0x1UL, /**< One or more invalid parameters */ 344 CY_TRIGMUX_INVALID_STATE = CY_TRIGMUX_ID | CY_PDL_STATUS_ERROR | 0x2UL /**< Operation not set up or is in an improper state */ 345 } cy_en_trigmux_status_t; 346 347 /** \} group_trigmux_enums */ 348 349 /** 350 * \addtogroup group_trigmux_functions 351 * \{ 352 */ 353 354 cy_en_trigmux_status_t Cy_TrigMux_Connect(uint32_t inTrig, uint32_t outTrig, bool invert, en_trig_type_t trigType); 355 cy_en_trigmux_status_t Cy_TrigMux_SwTrigger(uint32_t trigLine, uint32_t cycles); 356 cy_en_trigmux_status_t Cy_TrigMux_Select(uint32_t outTrig, bool invert, en_trig_type_t trigType); 357 cy_en_trigmux_status_t Cy_TrigMux_Deselect(uint32_t outTrig); 358 cy_en_trigmux_status_t Cy_TrigMux_SetDebugFreeze(uint32_t outTrig, bool enable); 359 360 /** \} group_trigmux_functions */ 361 362 #if defined(__cplusplus) 363 } 364 #endif 365 366 #endif /* CY_IP_MXSPERI, CY_IP_MXPERI */ 367 368 #endif /* CY_TRIGMUX_H */ 369 370 /** \} group_trigmux */ 371 372 /* [] END OF FILE */ 373