1 /***************************************************************************//**
2 * \file cy_tcpwm_shiftreg.h
3 * \version 1.70
4 *
5 * \brief
6 * The header file of the TCPWM Shift Register driver.
7 *
8 ********************************************************************************
9 * \copyright
10 * Copyright 2016-2021 Cypress Semiconductor Corporation
11 * SPDX-License-Identifier: Apache-2.0
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 *     http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *******************************************************************************/
25 
26 #if !defined(CY_TCPWM_SHIFTREG_H)
27 #define CY_TCPWM_SHIFTREG_H
28 
29 #include "cy_tcpwm.h"
30 
31 #ifdef CY_IP_MXTCPWM
32 
33 #if defined(__cplusplus)
34 extern "C" {
35 #endif
36 
37 /**
38 * \addtogroup group_tcpwm_shiftreg
39 * Driver API for Shift Register.
40 *
41 * The functions and other declarations used in this part of the driver are in cy_tcpwm_shiftreg.h.
42 * You can also include cy_pdl.h to get access to all functions and declarations in the PDL.
43 *
44 * Shift Register functionality shifts the counter value to the right.
45 * A shift register is used to apply a signal delay function which can be used
46 * eg: in detecting frequency shift keying (FSK) signals.
47 * A shift register is also used in parallel-in to serial-out data conversion
48 * and serial-in to parallel-out data conversion.
49 *
50 * Features:
51 * * 16- or 32-bit Counter
52 * * 2 compare (CC0/CC1) registers with double buffer.
53 * * Programmable Counter taps through PERIOD_BUFF register.
54 * * Line output generated from a XOR combination of all enabled counter taps (bit position) defined by PERIOD_BUFF.
55 * * Programmable Compare Register. Compare value can be swapped with a buffered compare value on comparison event.
56 * * Interrupt on Comparison match events (CC0_MATCH/CC1_MATCH).
57 * * Start, Reload, Stop, Shift, and Serial-in Inputs.
58 * * Comparison match and Line Outputs.
59 * * Line output can be output with invert polarity.
60 *
61 * \note Shift Register mode is available only in TCPWM Version 2
62 *
63 * \section group_tcpwm_shiftreg_configuration Configuration Considerations
64 * The Shift Register configuration can be divided to number of sequential
65 * steps listed below:
66 * * \ref group_tcpwm_shiftreg_config
67 * * \ref group_tcpwm_shiftreg_pins
68 * * \ref group_tcpwm_shiftreg_clock
69 * * \ref group_tcpwm_shiftreg_enable
70 * * \ref group_tcpwm_shiftreg_start
71 *
72 * \subsection group_tcpwm_shiftreg_config Configure Shift Register
73 * To configure Shift Register, provide the configuration parameters in the
74 * \ref cy_stc_tcpwm_shiftreg_config_t structure. The configuration structure
75 * can be modified through software, but if the configurator in ModusToolbox is used
76 * then the configuration structure will be updated with the users inputs. To initialize
77 * the driver, call \ref Cy_TCPWM_ShiftReg_Init function providing a pointer to the
78 * populated \ref cy_stc_tcpwm_shiftreg_config_t structure.
79 *
80 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_Init
81 *
82 * \subsection group_tcpwm_shiftreg_pins Assign and Configure Pins
83 * The dedicated TCPWM pins can be used. The HSIOM register must be configured to
84 * connect the block to the pins. Use the \ref group_gpio driver API to do that.
85 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_Pins
86 *
87 * \subsection group_tcpwm_shiftreg_clock Assign Clock Divider
88 * The clock source must be connected for proper operation.
89 * Any of the peripheral clock dividers could be used. Use the
90 * \ref group_sysclk driver API to do that.
91 *
92 * \subsection group_tcpwm_shiftreg_enable Enable Shift Register
93 * Shift Register has to be enabled before starting
94 *
95 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_Enable
96 *
97 * \subsection group_tcpwm_shiftreg_start Start Shift Register
98 * To start Shift Register operation \ref Cy_TCPWM_TriggerStart_Single API can be used.
99 *
100 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_Start
101 * \{
102 */
103 
104 /**
105 * \defgroup group_tcpwm_macros_shiftreg          Macros
106 * \defgroup group_tcpwm_functions_shiftreg       Functions
107 * \defgroup group_tcpwm_data_structures_shiftreg Data Structures
108 * \} */
109 
110 /**
111 * \addtogroup group_tcpwm_data_structures_shiftreg
112 * \{
113 */
114 
115 #if (CY_IP_MXTCPWM_VERSION >= 2U) || defined (CY_DOXYGEN)
116 /** Shift Register configuration structure */
117 typedef struct cy_stc_tcpwm_shiftreg_config
118 {
119     uint32_t    clockPrescaler;     /**< Sets the clock prescaler inside the TCWPM block.*/
120     uint32_t    tapsEnabled;        /**< In shift register this sets the enabled taps. */
121     uint32_t    compare0;           /**< Sets the value for Compare 0. */
122     uint32_t    compareBuf0;        /**< Sets the value for the buffered Compare 0. */
123     bool        enableCompare0Swap; /**< If enabled, the compare 0 values are swapped on the terminal count. */
124     uint32_t    compare1;           /**< Sets the value for Compare 1. */
125     uint32_t    compareBuf1;        /**< Sets the value for the buffered Compare 1. */
126     bool        enableCompare1Swap; /**< If enabled, the compare1 values are swapped on the terminal count. */
127     uint32_t    interruptSources;   /**< Enables an interrupt on the terminal count, capture or compare.  */
128     uint32_t    invertShiftRegOut;  /**< Inverts the ShiftReg output.*/
129     uint32_t    invertShiftRegOutN; /**< Inverts the ShiftReg compliment output.*/
130     uint32_t    reloadInputMode;    /**< Configures how the reload input behaves.  */
131     uint32_t    reloadInput;        /**< Selects which input the reload uses. The inputs are device-specific.  */
132     uint32_t    startInputMode;     /**< Configures how the start input behaves. See \ref group_tcpwm_input_modes. */
133     uint32_t    startInput;         /**< Selects which input the start uses. The inputs are device-specific. */
134     uint32_t    killInputMode;      /**< Configures how the kill0 input behaves. */
135     uint32_t    killInput;          /**< Selects which input the kill0 uses. The inputs are device-specific. */
136     uint32_t    shiftInputMode;     /**< Configures how the shift input behaves. */
137     uint32_t    shiftInput;         /**< Selects which input the shift uses. The inputs are device-specific. */
138     uint32_t    serialInputMode;    /**< Configures how the serial input behaves. */
139     uint32_t    serialInput;        /**< Selects which input the serial uses. Inputs are device-specific. */
140     uint32_t    shiftRegOnDisable;  /**< Specifies the behavior of the ShiftReg outputs line_out and line_compl_out while the Shift Register is disabled. */
141     uint32_t    trigger0Event;      /**< Configures which internal event generates on output trigger 0. */
142     uint32_t    trigger1Event;      /**< Configures which internal event generates on output trigger 1. */
143 #if defined (CY_IP_MXS40TCPWM) || defined (CY_DOXYGEN)
144     bool        buffer_swap_enable; /**< Configures swapping mechanism between CC0 and buffered CC0, CC1 and buffered CC1, PERIOD and buffered PERIOD, DT and buffered DT  */
145 #endif /* defined (CY_IP_MXS40TCPWM) || defined (CY_DOXYGEN) */
146 }cy_stc_tcpwm_shiftreg_config_t;
147 
148 #else
149 
150 typedef struct cy_stc_tcpwm_shiftreg_config cy_stc_tcpwm_shiftreg_config_t;
151 
152 #endif /* CY_IP_MXTCPWM_VERSION >= 2U */
153 
154 /** \} group_tcpwm_data_structures_shiftreg */
155 
156 /**
157 * \addtogroup group_tcpwm_macros_shiftreg
158 * \{
159 * \defgroup group_tcpwm_shiftreg_clk_prescalers Shift Register CLK Prescaler values
160 * \{
161 * Clock prescaler values.
162 */
163 #define CY_TCPWM_SHIFTREG_PRESCALER_DIVBY_1      (0U) /**< Divide by 1 */
164 #define CY_TCPWM_SHIFTREG_PRESCALER_DIVBY_2      (1U) /**< Divide by 2 */
165 #define CY_TCPWM_SHIFTREG_PRESCALER_DIVBY_4      (2U) /**< Divide by 4 */
166 #define CY_TCPWM_SHIFTREG_PRESCALER_DIVBY_8      (3U) /**< Divide by 8 */
167 #define CY_TCPWM_SHIFTREG_PRESCALER_DIVBY_16     (4U) /**< Divide by 16 */
168 #define CY_TCPWM_SHIFTREG_PRESCALER_DIVBY_32     (5U) /**< Divide by 32 */
169 #define CY_TCPWM_SHIFTREG_PRESCALER_DIVBY_64     (6U) /**< Divide by 64 */
170 #define CY_TCPWM_SHIFTREG_PRESCALER_DIVBY_128    (7U) /**< Divide by 128 */
171 /** \} group_tcpwm_shiftreg_clk_prescalers */
172 
173 /** \defgroup group_tcpwm_shiftreg_output_line Shift Register Output Lines
174 * Specifies the Shift Register output line.
175 * \{
176 */
177 #define    CY_TCPWM_SHIFTREG_LINE_OUT         (0U)    /**< Shift Register Line output */
178 #define    CY_TCPWM_SHIFTREG_LINE_OUT_INV     (1U)    /**< Shift Register Line output compliment */
179 /** \} group_tcpwm_shiftreg_output_line */
180 
181 /** \defgroup group_tcpwm_shiftreg_output_invert Shift Register output invert
182 * \{
183 * Output invert modes.
184 */
185 #define CY_TCPWM_SHIFTREG_INVERT_ENABLE          (1U)  /**< Invert the output mode */
186 #define CY_TCPWM_SHIFTREG_INVERT_DISABLE         (0U)  /**< Do not invert the output mode */
187 /** \} group_tcpwm_shiftreg_output_invert */
188 
189 
190 /** \defgroup group_tcpwm_shiftreg_output_on_disable Shift Register Disabled Output
191 * Specifies the behavior of the Shift Register outputs while Shift Register is disabled.
192 * \{
193 */
194 #define    CY_TCPWM_SHIFTREG_OUTPUT_HIGHZ    (0U)    /**< Shift Register output (default) high impedance */
195 #define    CY_TCPWM_SHIFTREG_OUTPUT_RETAIN   (1U)    /**< Shift Register outputs are retained */
196 #define    CY_TCPWM_SHIFTREG_OUTPUT_LOW      (2U)    /**< Shift Register output LOW */
197 #define    CY_TCPWM_SHIFTREG_OUTPUT_HIGH     (3U)    /**< Shift Register output HIGH */
198 /** \} group_tcpwm_shiftreg_output_on_disable */
199 
200 /** \defgroup group_tcpwm_shiftreg_status Shift Register Status
201 * \{
202 * The Shift Register status.
203 */
204 #define CY_TCPWM_SHIFTREG_STATUS_RUNNING (0x00008000UL) /**< Shift Register is running */
205 /** \} group_tcpwm_shiftreg_status */
206 
207 /** \} group_tcpwm_macros_shiftreg */
208 
209 /***************************************
210 *        Registers Constants
211 ***************************************/
212 
213 /** \cond INTERNAL */
214 #define CY_TCPWM_MODE_SHIFTREG           (7U)
215 
216 /** \endcond */
217 
218 
219 /*******************************************************************************
220 *        Function Prototypes
221 *******************************************************************************/
222 
223 /**
224 * \addtogroup group_tcpwm_functions_shiftreg
225 * \{
226 */
227 
228 cy_en_tcpwm_status_t Cy_TCPWM_ShiftReg_Init(TCPWM_Type const *base, uint32_t cntNum, cy_stc_tcpwm_shiftreg_config_t const *config);
229 void Cy_TCPWM_ShiftReg_DeInit(TCPWM_Type const *base, uint32_t cntNum, cy_stc_tcpwm_shiftreg_config_t const *config);
230 #if (CY_IP_MXTCPWM_VERSION >= 2U) || defined (CY_DOXYGEN)
231 __STATIC_INLINE void Cy_TCPWM_ShiftReg_Enable(TCPWM_Type *base, uint32_t cntNum);
232 __STATIC_INLINE void Cy_TCPWM_ShiftReg_Disable(TCPWM_Type *base, uint32_t cntNum);
233 __STATIC_INLINE uint32_t Cy_TCPWM_ShiftReg_GetStatus(TCPWM_Type const *base, uint32_t cntNum);
234 __STATIC_INLINE void Cy_TCPWM_ShiftReg_SetCompare0Val(TCPWM_Type *base, uint32_t cntNum, uint32_t compare0);
235 __STATIC_INLINE uint32_t Cy_TCPWM_ShiftReg_GetCompare0Val(TCPWM_Type const *base, uint32_t cntNum);
236 __STATIC_INLINE void Cy_TCPWM_ShiftReg_SetCompare0BufVal(TCPWM_Type *base, uint32_t cntNum, uint32_t compareBuf0);
237 __STATIC_INLINE uint32_t Cy_TCPWM_ShiftReg_GetCompare0BufVal(TCPWM_Type const *base, uint32_t cntNum);
238 __STATIC_INLINE void Cy_TCPWM_ShiftReg_EnableCompare0Swap(TCPWM_Type *base, uint32_t cntNum, bool enable);
239 __STATIC_INLINE void Cy_TCPWM_ShiftReg_SetCompare1Val(TCPWM_Type *base, uint32_t cntNum, uint32_t compare1);
240 __STATIC_INLINE uint32_t Cy_TCPWM_ShiftReg_GetCompare1Val(TCPWM_Type const *base, uint32_t cntNum);
241 __STATIC_INLINE void Cy_TCPWM_ShiftReg_SetCompare1BufVal(TCPWM_Type *base, uint32_t cntNum, uint32_t compareBuf1);
242 __STATIC_INLINE uint32_t Cy_TCPWM_ShiftReg_GetCompare1BufVal(TCPWM_Type const *base, uint32_t cntNum);
243 __STATIC_INLINE void Cy_TCPWM_ShiftReg_EnableCompare1Swap(TCPWM_Type *base, uint32_t cntNum, bool enable);
244 __STATIC_INLINE void Cy_TCPWM_ShiftReg_SetCounter(TCPWM_Type *base, uint32_t cntNum, uint32_t count);
245 __STATIC_INLINE uint32_t Cy_TCPWM_ShiftReg_GetCounter(TCPWM_Type const *base, uint32_t cntNum);
246 __STATIC_INLINE void Cy_TCPWM_ShiftReg_SetTaps(TCPWM_Type *base, uint32_t cntNum, uint32_t taps);
247 __STATIC_INLINE uint32_t Cy_TCPWM_ShiftReg_GetTaps(TCPWM_Type const *base, uint32_t cntNum);
248 __STATIC_INLINE uint32_t Cy_TCPWM_ShiftReg_LineOutStatus (TCPWM_Type const *base, uint32_t cntNum, uint32_t shiftRegOutSelect);
249 #endif
250 #if defined (CY_IP_MXS40TCPWM) || defined (CY_DOXYGEN)
251 __STATIC_INLINE void Cy_TCPWM_Shiftreg_EnableSwap(TCPWM_Type *base, uint32_t cntNum,  bool enable);
252 #endif /* defined (CY_IP_MXS40TCPWM) || defined (CY_DOXYGEN) */
253 
254 #if (CY_IP_MXTCPWM_VERSION >= 2U) || defined (CY_DOXYGEN)
255 /*******************************************************************************
256 * Function Name: Cy_TCPWM_ShiftReg_Enable
257 ****************************************************************************//**
258 *
259 * Enables the counter in the TCPWM block for the Shift Register operation.
260 *
261 * \param base
262 * The pointer to a TCPWM instance.
263 *
264 * \param cntNum
265 * The Counter instance number in the selected TCPWM.
266 *
267 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_Enable
268 *
269 *******************************************************************************/
Cy_TCPWM_ShiftReg_Enable(TCPWM_Type * base,uint32_t cntNum)270 __STATIC_INLINE void Cy_TCPWM_ShiftReg_Enable(TCPWM_Type *base, uint32_t cntNum)
271 {
272     Cy_TCPWM_Enable_Single(base, cntNum);
273 }
274 
275 /*******************************************************************************
276 * Function Name: Cy_TCPWM_ShiftReg_Disable
277 ****************************************************************************//**
278 *
279 * Disables the counter in the TCPWM block.
280 *
281 * \param base
282 * The pointer to a TCPWM instance.
283 *
284 * \param cntNum
285 * The Counter instance number in the selected TCPWM.
286 *
287 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_Disable
288 *
289 *******************************************************************************/
Cy_TCPWM_ShiftReg_Disable(TCPWM_Type * base,uint32_t cntNum)290 __STATIC_INLINE void Cy_TCPWM_ShiftReg_Disable(TCPWM_Type *base, uint32_t cntNum)
291 {
292     Cy_TCPWM_Disable_Single(base, cntNum);
293 }
294 
295 
296 /*******************************************************************************
297 * Function Name: Cy_TCPWM_ShiftReg_GetStatus
298 ****************************************************************************//**
299 *
300 * Returns the status of the Shift Register whether it is running or not.
301 *
302 * \param base
303 * The pointer to a TCPWM instance.
304 *
305 * \param cntNum
306 * The Counter instance number in the selected TCPWM.
307 *
308 * \return
309 * The status. See \ref group_tcpwm_shiftreg_status
310 *
311 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_GetStatus
312 *
313 *******************************************************************************/
Cy_TCPWM_ShiftReg_GetStatus(TCPWM_Type const * base,uint32_t cntNum)314 __STATIC_INLINE uint32_t Cy_TCPWM_ShiftReg_GetStatus(TCPWM_Type const *base, uint32_t cntNum)
315 {
316     uint32_t status = 0UL;
317 
318     status = TCPWM_GRP_CNT_STATUS(base, TCPWM_GRP_CNT_GET_GRP(cntNum), cntNum);
319 
320     return(status);
321 }
322 
323 
324 /*******************************************************************************
325 * Function Name: Cy_TCPWM_ShiftReg_SetCompare0Val
326 ****************************************************************************//**
327 *
328 * Sets the compare value for Compare 0 when the compare mode enabled.
329 *
330 * \param base
331 * The pointer to a TCPWM instance.
332 *
333 * \param cntNum
334 * The Counter instance number in the selected TCPWM.
335 *
336 * \param compare0
337 * The Compare 0 value.
338 *
339 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_SetCompare0Val
340 *
341 *******************************************************************************/
Cy_TCPWM_ShiftReg_SetCompare0Val(TCPWM_Type * base,uint32_t cntNum,uint32_t compare0)342 __STATIC_INLINE void Cy_TCPWM_ShiftReg_SetCompare0Val(TCPWM_Type *base, uint32_t cntNum,  uint32_t compare0)
343 {
344     Cy_TCPWM_Block_SetCC0Val(base, cntNum, compare0);
345 }
346 
347 
348 /*******************************************************************************
349 * Function Name: Cy_TCPWM_ShiftReg_GetCompare0Val
350 ****************************************************************************//**
351 *
352 * Returns compare 0 value.
353 *
354 * \param base
355 * The pointer to a TCPWM instance.
356 *
357 * \param cntNum
358 * The Counter instance number in the selected TCPWM.
359 *
360 * \return
361 * Compare 0 value.
362 *
363 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_SetCompare0Val
364 *
365 *******************************************************************************/
Cy_TCPWM_ShiftReg_GetCompare0Val(TCPWM_Type const * base,uint32_t cntNum)366 __STATIC_INLINE uint32_t Cy_TCPWM_ShiftReg_GetCompare0Val(TCPWM_Type const *base, uint32_t cntNum)
367 {
368     return Cy_TCPWM_Block_GetCC0Val(base, cntNum);
369 }
370 
371 
372 /*******************************************************************************
373 * Function Name: Cy_TCPWM_ShiftReg_SetCompare0BufVal
374 ****************************************************************************//**
375 *
376 * Sets the buffered compare value for Compare 0 when the compare mode enabled.
377 *
378 * \param base
379 * The pointer to a TCPWM instance.
380 *
381 * \param cntNum
382 * The Counter instance number in the selected TCPWM.
383 *
384 * \param compareBuf0
385 * The buffered Compare 0 value.
386 *
387 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_SetCompare0BufVal
388 *
389 *******************************************************************************/
Cy_TCPWM_ShiftReg_SetCompare0BufVal(TCPWM_Type * base,uint32_t cntNum,uint32_t compareBuf0)390 __STATIC_INLINE void Cy_TCPWM_ShiftReg_SetCompare0BufVal(TCPWM_Type *base, uint32_t cntNum,  uint32_t compareBuf0)
391 {
392     Cy_TCPWM_Block_SetCC0BufVal(base, cntNum, compareBuf0);
393 }
394 
395 
396 /*******************************************************************************
397 * Function Name: Cy_TCPWM_ShiftReg_GetCompare0BufVal
398 ****************************************************************************//**
399 *
400 * Returns the buffered compare 0 value.
401 *
402 * \param base
403 * The pointer to a TCPWM instance.
404 *
405 * \param cntNum
406 * The Counter instance number in the selected TCPWM.
407 *
408 * \return
409 * Buffered compare 0 value.
410 *
411 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_SetCompare0BufVal
412 *
413 *******************************************************************************/
Cy_TCPWM_ShiftReg_GetCompare0BufVal(TCPWM_Type const * base,uint32_t cntNum)414 __STATIC_INLINE uint32_t Cy_TCPWM_ShiftReg_GetCompare0BufVal(TCPWM_Type const *base, uint32_t cntNum)
415 {
416     return Cy_TCPWM_Block_GetCC0BufVal(base, cntNum);
417 }
418 
419 
420 /*******************************************************************************
421 * Function Name: Cy_TCPWM_ShiftReg_SetCompare1Val
422 ****************************************************************************//**
423 *
424 * Sets the compare value for Compare 1 when the compare mode enabled.
425 *
426 * \param base
427 * The pointer to a TCPWM instance.
428 *
429 * \param cntNum
430 * The Counter instance number in the selected TCPWM.
431 *
432 * \param compare1
433 * The Compare 1 value.
434 *
435 *******************************************************************************/
Cy_TCPWM_ShiftReg_SetCompare1Val(TCPWM_Type * base,uint32_t cntNum,uint32_t compare1)436 __STATIC_INLINE void Cy_TCPWM_ShiftReg_SetCompare1Val(TCPWM_Type *base, uint32_t cntNum,  uint32_t compare1)
437 {
438     Cy_TCPWM_Block_SetCC1Val(base, cntNum, compare1);
439 }
440 
441 
442 /*******************************************************************************
443 * Function Name: Cy_TCPWM_ShiftReg_GetCompare1Val
444 ****************************************************************************//**
445 *
446 * Returns compare 1 value.
447 *
448 * \param base
449 * The pointer to a TCPWM instance.
450 *
451 * \param cntNum
452 * The Counter instance number in the selected TCPWM.
453 *
454 * \return
455 * Compare 1 value.
456 *
457 *******************************************************************************/
Cy_TCPWM_ShiftReg_GetCompare1Val(TCPWM_Type const * base,uint32_t cntNum)458 __STATIC_INLINE uint32_t Cy_TCPWM_ShiftReg_GetCompare1Val(TCPWM_Type const *base, uint32_t cntNum)
459 {
460     return Cy_TCPWM_Block_GetCC1Val(base, cntNum);
461 }
462 
463 
464 /*******************************************************************************
465 * Function Name: Cy_TCPWM_ShiftReg_SetCompare1BufVal
466 ****************************************************************************//**
467 *
468 * Sets the buffered compare value for Compare 1 when the compare mode enabled.
469 *
470 * \param base
471 * The pointer to a TCPWM instance.
472 *
473 * \param cntNum
474 * The Counter instance number in the selected TCPWM.
475 *
476 * \param compareBuf1
477 * The buffered Compare 1 value.
478 *
479 *
480 *******************************************************************************/
Cy_TCPWM_ShiftReg_SetCompare1BufVal(TCPWM_Type * base,uint32_t cntNum,uint32_t compareBuf1)481 __STATIC_INLINE void Cy_TCPWM_ShiftReg_SetCompare1BufVal(TCPWM_Type *base, uint32_t cntNum,  uint32_t compareBuf1)
482 {
483     Cy_TCPWM_Block_SetCC1BufVal(base, cntNum, compareBuf1);
484 }
485 
486 
487 /*******************************************************************************
488 * Function Name: Cy_TCPWM_ShiftReg_GetCompare1BufVal
489 ****************************************************************************//**
490 *
491 * Returns the buffered compare 1 value.
492 *
493 * \param base
494 * The pointer to a TCPWM instance.
495 *
496 * \param cntNum
497 * The Counter instance number in the selected TCPWM.
498 *
499 * \return
500 * Buffered compare 1 value.
501 *
502 *******************************************************************************/
Cy_TCPWM_ShiftReg_GetCompare1BufVal(TCPWM_Type const * base,uint32_t cntNum)503 __STATIC_INLINE uint32_t Cy_TCPWM_ShiftReg_GetCompare1BufVal(TCPWM_Type const *base, uint32_t cntNum)
504 {
505     return Cy_TCPWM_Block_GetCC1BufVal(base, cntNum);
506 }
507 
508 /*******************************************************************************
509 * Function Name: Cy_TCPWM_ShiftReg_EnableCompare0Swap
510 ****************************************************************************//**
511 *
512 * Enables the comparison swap of compare 0 and compareBuf 0 on
513 * corresponding command or external trigger.
514 *
515 * \param base
516 * The pointer to a TCPWM instance.
517 *
518 * \param cntNum
519 * The Counter instance number in the selected TCPWM.
520 *
521 * \param enable
522 * true = swap enabled; false = swap disabled
523 *
524 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_EnableCompare0Swap
525 *
526 *******************************************************************************/
Cy_TCPWM_ShiftReg_EnableCompare0Swap(TCPWM_Type * base,uint32_t cntNum,bool enable)527 __STATIC_INLINE void Cy_TCPWM_ShiftReg_EnableCompare0Swap(TCPWM_Type *base, uint32_t cntNum,  bool enable)
528 {
529      Cy_TCPWM_Block_EnableCompare0Swap(base, cntNum, enable);
530 }
531 
532 
533 /*******************************************************************************
534 * Function Name: Cy_TCPWM_ShiftReg_EnableCompare1Swap
535 ****************************************************************************//**
536 *
537 * Enables the comparison swap of compare 1 and compareBuf 1 on
538 * corresponding command or external trigger.
539 *
540 * \param base
541 * The pointer to a TCPWM instance.
542 *
543 * \param cntNum
544 * The Counter instance number in the selected TCPWM.
545 *
546 * \param enable
547 * true = swap enabled; false = swap disabled
548 *
549 *******************************************************************************/
Cy_TCPWM_ShiftReg_EnableCompare1Swap(TCPWM_Type * base,uint32_t cntNum,bool enable)550 __STATIC_INLINE void Cy_TCPWM_ShiftReg_EnableCompare1Swap(TCPWM_Type *base, uint32_t cntNum,  bool enable)
551 {
552     Cy_TCPWM_Block_EnableCompare1Swap(base, cntNum, enable);
553 }
554 
555 
556 /*******************************************************************************
557 * Function Name: Cy_TCPWM_ShiftReg_SetCounter
558 ****************************************************************************//**
559 *
560 * Sets the value of the counter.
561 *
562 * \param base
563 * The pointer to a TCPWM instance.
564 *
565 * \param cntNum
566 * The Counter instance number in the selected TCPWM.
567 *
568 * \param count
569 * The value to write into the counter.
570 *
571 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_SetCounter
572 *
573 *******************************************************************************/
Cy_TCPWM_ShiftReg_SetCounter(TCPWM_Type * base,uint32_t cntNum,uint32_t count)574 __STATIC_INLINE void Cy_TCPWM_ShiftReg_SetCounter(TCPWM_Type *base, uint32_t cntNum,  uint32_t count)
575 {
576     Cy_TCPWM_Block_SetCounter(base, cntNum, count);
577 }
578 
579 
580 /*******************************************************************************
581 * Function Name: Cy_TCPWM_ShiftReg_GetCounter
582 ****************************************************************************//**
583 *
584 * Returns the value in the counter.
585 *
586 * \param base
587 * The pointer to a TCPWM instance.
588 *
589 * \param cntNum
590 * The Counter instance number in the selected TCPWM.
591 *
592 * \return
593 * The current counter value.
594 *
595 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_SetCounter
596 *
597 *******************************************************************************/
Cy_TCPWM_ShiftReg_GetCounter(TCPWM_Type const * base,uint32_t cntNum)598 __STATIC_INLINE uint32_t Cy_TCPWM_ShiftReg_GetCounter(TCPWM_Type const *base, uint32_t cntNum)
599 {
600     return Cy_TCPWM_Block_GetCounter(base, cntNum);
601 }
602 
603 
604 /*******************************************************************************
605 * Function Name: Cy_TCPWM_ShiftReg_SetTaps
606 ****************************************************************************//**
607 *
608 * Sets which taps are enabled.
609 *
610 * \param base
611 * The pointer to a TCPWM instance.
612 *
613 * \param cntNum
614 * The Counter instance number in the selected TCPWM.
615 *
616 * \param taps
617 * The taps that will be enabled.
618 *
619 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_SetTaps
620 *
621 *******************************************************************************/
Cy_TCPWM_ShiftReg_SetTaps(TCPWM_Type * base,uint32_t cntNum,uint32_t taps)622 __STATIC_INLINE void Cy_TCPWM_ShiftReg_SetTaps(TCPWM_Type *base, uint32_t cntNum,  uint32_t taps)
623 {
624     TCPWM_GRP_CNT_PERIOD_BUFF(base, TCPWM_GRP_CNT_GET_GRP(cntNum), cntNum) = taps;
625 }
626 
627 
628 /*******************************************************************************
629 * Function Name: Cy_TCPWM_ShiftReg_GetTaps
630 ****************************************************************************//**
631 *
632 * Returns which taps are enabled.
633 *
634 * \param base
635 * The pointer to a COUNTER PWM instance.
636 *
637 * \param cntNum
638 * The Counter instance number in the selected TCPWM.
639 *
640 * \return
641 * Returns which taps are enabled.
642 *
643 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_SetTaps
644 *
645 *******************************************************************************/
Cy_TCPWM_ShiftReg_GetTaps(TCPWM_Type const * base,uint32_t cntNum)646 __STATIC_INLINE uint32_t Cy_TCPWM_ShiftReg_GetTaps(TCPWM_Type const *base, uint32_t cntNum)
647 {
648     uint32_t result = 0UL;
649 
650     result = TCPWM_GRP_CNT_PERIOD_BUFF(base, TCPWM_GRP_CNT_GET_GRP(cntNum), cntNum);
651     return result;
652 }
653 
654 
655 /*******************************************************************************
656 * Function Name: Cy_TCPWM_ShiftReg_LineOutStatus
657 ****************************************************************************//**
658 *
659 * Returns the current level of the selected Shift Register output line.
660 *
661 * \param base
662 * The pointer to a TCPWM instance.
663 *
664 * \param cntNum
665 * The Counter instance number in the selected TCPWM.
666 *
667 * \param shiftRegOutSelect
668 * Defines which Shift Register output line is being checked: line_out or line_out_inv.
669 *
670 * \return
671 * The current Shift Register output line level.
672 *
673 * \snippet tcpwm/shiftreg/snippet/main.c snippet_Cy_TCPWM_ShiftReg_LineOutStatus
674 *
675 *******************************************************************************/
Cy_TCPWM_ShiftReg_LineOutStatus(TCPWM_Type const * base,uint32_t cntNum,uint32_t shiftRegOutSelect)676 __STATIC_INLINE uint32_t Cy_TCPWM_ShiftReg_LineOutStatus (TCPWM_Type const *base, uint32_t cntNum, uint32_t shiftRegOutSelect)
677 {
678     uint32_t status = 0UL;
679 
680     status = TCPWM_GRP_CNT_STATUS(base, TCPWM_GRP_CNT_GET_GRP(cntNum), cntNum);
681 
682      switch(shiftRegOutSelect)
683      {
684          case CY_TCPWM_SHIFTREG_LINE_OUT:
685              status = _FLD2VAL(TCPWM_GRP_CNT_V2_STATUS_LINE_OUT, status);
686              break;
687          case CY_TCPWM_SHIFTREG_LINE_OUT_INV:
688              status = _FLD2VAL(TCPWM_GRP_CNT_V2_STATUS_LINE_COMPL_OUT, status);
689              break;
690          default:
691              /* Not a Valid Line output */
692              CY_ASSERT_L3(false);
693              break;
694     }
695     return status;
696 }
697 
698 #endif /* CY_IP_MXTCPWM_VERSION >= 2U */
699 
700 #if defined (CY_IP_MXS40TCPWM) || defined (CY_DOXYGEN)
701 /*******************************************************************************
702 * Function Name: Cy_TCPWM_Shiftreg_EnableSwap
703 ****************************************************************************//**
704 *
705 * Enables/disables swapping mechanism between CC0 and buffered CC0, CC1 and buffered CC1, PERIOD and buffered PERIOD, DT and buffered DT.
706 *
707 * \param base
708 * The pointer to a TCPWM instance.
709 *
710 * \param cntNum
711 * The Counter instance number in the selected TCPWM.
712 *
713 * \param enable
714 * true = swap enabled; false = swap disabled
715 *
716 *
717 *******************************************************************************/
Cy_TCPWM_Shiftreg_EnableSwap(TCPWM_Type * base,uint32_t cntNum,bool enable)718 __STATIC_INLINE void Cy_TCPWM_Shiftreg_EnableSwap(TCPWM_Type *base, uint32_t cntNum,  bool enable)
719 {
720     Cy_TCPWM_Block_EnableSwap(base, cntNum, enable);
721 }
722 #endif /* defined (CY_IP_MXS40TCPWM) */
723 
724 /** \} group_tcpwm_functions_shiftreg */
725 
726 /** \} group_tcpwm_shiftreg */
727 
728 #if defined(__cplusplus)
729 }
730 #endif
731 
732 #endif /* CY_IP_MXTCPWM */
733 
734 #endif /* CY_TCPWM_SHIFTREG_H */
735 
736 /* [] END OF FILE */
737