1 /**
2 * @file xmc_posif.h
3 * @date 2017-06-24
4 *
5 * @cond
6 *********************************************************************************************************************
7 * XMClib v2.1.24 - XMC Peripheral Driver Library
8 *
9 * Copyright (c) 2015-2019, Infineon Technologies AG
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the
13 * following conditions are met:
14 *
15 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
18 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
19 * disclaimer in the documentation and/or other materials provided with the distribution.
20 *
21 * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote
22 * products derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with
33 * Infineon Technologies AG dave@infineon.com).
34 *********************************************************************************************************************
35 *
36 * Change History
37 * --------------
38 *
39 * 2015-02-18:
40 * - Initial version
41 *
42 * 2015-02-20:
43 * - Driver description added <BR>
44 *
45 * 2015-06-19:
46 * - Removed version macros and declaration of GetDriverVersion API <BR>
47 *
48 * 2015-07-02:
49 * - Updated XMC_POSIF_QD_GetDirection API
50 *
51 * 2016-03-09:
52 * - Optimization of write only registers
53 *
54 * 2017-06-24
55 * - Added posif map connectivity file<br>
56 *
57 * @endcond
58 *
59 */
60
61
62 #ifndef XMC_POSIF_H
63 #define XMC_POSIF_H
64
65 /*********************************************************************************************************************
66 * HEADER FILES
67 ********************************************************************************************************************/
68 #include <xmc_common.h>
69
70 #if defined(POSIF0)
71 #include <xmc_scu.h>
72 #include "xmc_posif_map.h"
73
74 /**
75 * @addtogroup XMClib XMC Peripheral Library
76 * @{
77 */
78
79 /**
80 * @addtogroup POSIF
81 * @brief Position Interface Unit (POSIF) driver for the XMC microcontroller family <br>
82 *
83 * The POSIF unit is a flexible and powerful component for motor control systems that use
84 * rotary encoders or hall sensors as feedback loop. It provides interface for motor position and velocity measurement.
85 * POSIF unit works with CCU4 and CCU8 to enable position and velocity measurement and to control PWM outputs using multi channel pattern.<br>
86 *
87 * Driver is divided in three POSIF functional blocks - Hall Sensor Control (POSIF_HSC), Quadrature Decoder (POSIF_QD) and
88 * MultiChannel Mode (POSIF_MCM). <br>
89 *
90 * POSIF driver features:
91 * -# Configuration structure XMC_POSIF_CONFIG_t and initialization function XMC_POSIF_Init() to configure global settings
92 * -# Allows to change the operating mode using XMC_POSIF_SetMode()
93 * -# Allows the selection of one of the four inputs (A, B, C or D) using XMC_POSIF_SelectInputSource(). In hall sensor control, inputs are
94 * hall0, hall1 and hall2 signals. For quadrature decoder mode, inputs are phase A, phase B and index signals.
95 * -# Hall Sensor Control (APIs prefixed with XMC_POSIF_HSC_) <br>
96 * - Configuration structure XMC_POSIF_HSC_CONFIG_t and initialization function XMC_POSIF_HSC_Init()
97 * - Update current and expected hall pattern in shadow register using XMC_POSIF_HSC_SetHallPatterns()
98 * - Allows immediate shadow transfer using XMC_POSIF_HSC_UpdateHallPattern()
99 * -# Quadrature Decoder (APIs prefixed with XMC_POSIF_QD_) <br>
100 * - Configuration structure XMC_POSIF_QD_CONFIG_t and initialization function XMC_POSIF_QD_Init()
101 * - Get direction of rotation using XMC_POSIF_QD_GetDirection()
102 * -# MultiChannel Mode (APIs prefixed with XMC_POSIF_MCM_) <br>
103 * - Configuration structure XMC_POSIF_MCM_CONFIG_t and initialization function XMC_POSIF_MCM_Init()
104 * - Update multichannel pattern in shadow register using XMC_POSIF_MCM_SetMultiChannelPattern()
105 * - Allows immediate shadow transfer using XMC_POSIF_MCM_UpdateMultiChannelPattern()
106 * -# User need to call respective init functions to configure POSIF operating mode. e.g to configure POSIF in hall sensor control with multichannel mode
107 * call both XMC_POSIF_HSC_Init() and XMC_POSIF_MCM_Init().
108 * -# Allows to enable and disable interrupt sources and assign to service request node using XMC_POSIF_EnableEvent(), XMC_POSIF_DisableEvent() and XMC_POSIF_SetInterruptNode()
109 *
110 * @note POSIF is not available on XMC11 and XMC12 devices
111 *
112 * @{
113 */
114
115 /*********************************************************************************************************************
116 * MACROS
117 ********************************************************************************************************************/
118 #if ((UC_SERIES == XMC45) || (UC_SERIES == XMC44) || (UC_SERIES == XMC47) || (UC_SERIES == XMC48) || (UC_SERIES == XMC14))
119 #define XMC_POSIF_CHECK_MODULE_PTR(PTR) ( ((PTR)== POSIF0) || ((PTR)== POSIF1) ) /*< Check for valid module pointer */
120 #else
121 #define XMC_POSIF_CHECK_MODULE_PTR(PTR) ( ((PTR)== POSIF0)) /*< Check for valid module pointer */
122 #endif
123
124 /*********************************************************************************************************************
125 * ENUMS
126 ********************************************************************************************************************/
127 /**
128 * Defines the return status, to verify the POSIF related API calls. Use type @ref XMC_POSIF_STATUS_t for this enum.
129 */
130 typedef enum XMC_POSIF_STATUS
131 {
132 XMC_POSIF_STATUS_OK = 0U, /**< API fulfills request */
133 XMC_POSIF_STATUS_ERROR /**< API cannot fulfill request */
134 } XMC_POSIF_STATUS_t;
135
136 /**
137 * Defines POSIF configurable modes.Use type @ref XMC_POSIF_MODE_t for this enum.
138 * The members defines the function selector(FSEL) bitfields of \a PCONF register.
139 */
140 typedef enum XMC_POSIF_MODE
141 {
142 XMC_POSIF_MODE_HALL_SENSOR = 0U, /**< Hall sensor mode */
143 XMC_POSIF_MODE_QD , /**< Quadrature Decoder mode */
144 XMC_POSIF_MODE_MCM , /**< Standalone Multichannel mode */
145 XMC_POSIF_MODE_MCM_QD /**< Quadrature Decoder + Standalone Multichannel mode */
146 } XMC_POSIF_MODE_t;
147
148 /**
149 * Defines POSIF configurable input ports.Use type @ref XMC_POSIF_INPUT_PORT_t for this enum.
150 * The member defines the respective input selector(INSELX) bitfields of \a PCONF register.
151 * It selects, which input is used for the phase or Hall input function (depending on the module is set for
152 * Quadrature Decoder or Hall Sensor Mode). Same enum can be used to configure pattern update signal select by configuring
153 * \a PCONF register's \a MSETS bit field.
154 */
155 typedef enum XMC_POSIF_INPUT_PORT
156 {
157 XMC_POSIF_INPUT_PORT_A = 0U, /**< INPUT-A */
158 XMC_POSIF_INPUT_PORT_B , /**< INPUT-B */
159 XMC_POSIF_INPUT_PORT_C , /**< INPUT-C */
160 XMC_POSIF_INPUT_PORT_D , /**< INPUT-D */
161 XMC_POSIF_INPUT_PORT_E , /**< INPUT-E */
162 XMC_POSIF_INPUT_PORT_F , /**< INPUT-F */
163 XMC_POSIF_INPUT_PORT_G , /**< INPUT-G */
164 XMC_POSIF_INPUT_PORT_H /**< INPUT-H */
165 } XMC_POSIF_INPUT_PORT_t;
166
167 /**
168 * Defines active level of an input signal.Use type @ref XMC_POSIF_INPUT_ACTIVE_LEVEL_t for this enum.
169 */
170 typedef enum XMC_POSIF_INPUT_ACTIVE_LEVEL
171 {
172 XMC_POSIF_INPUT_ACTIVE_LEVEL_HIGH = 0U, /**< Input - Active High */
173 XMC_POSIF_INPUT_ACTIVE_LEVEL_LOW /**< Input - Active Low */
174 } XMC_POSIF_INPUT_ACTIVE_LEVEL_t;
175
176 /**
177 * Defines POSIF input debounce filter configuration.POSIF inputs are connected to low pass filter and
178 * this enum is used to configure low pass filters cut off frequency.
179 * Use type @ref XMC_POSIF_FILTER_t for this enum.
180 * The member defines the low pass filter configuration(LPC) bitfield of \a PCONF register.
181 */
182 typedef enum XMC_POSIF_FILTER
183 {
184 XMC_POSIF_FILTER_DISABLED = 0U, /**< No filtering */
185 XMC_POSIF_FILTER_1_CLOCK_CYCLE , /**< Filter of 1 Clock Cycle */
186 XMC_POSIF_FILTER_2_CLOCK_CYCLE , /**< Filter of 2 Clock Cycles */
187 XMC_POSIF_FILTER_4_CLOCK_CYCLE , /**< Filter of 4 Clock Cycles */
188 XMC_POSIF_FILTER_8_CLOCK_CYCLE , /**< Filter of 8 Clock Cycles */
189 XMC_POSIF_FILTER_16_CLOCK_CYCLE , /**< Filter of 16 Clock Cycles */
190 XMC_POSIF_FILTER_32_CLOCK_CYCLE , /**< Filter of 32 Clock Cycles */
191 XMC_POSIF_FILTER_64_CLOCK_CYCLE /**< Filter of 64 Clock Cycles */
192 } XMC_POSIF_FILTER_t;
193
194 /**
195 * Defines POSIF events.Use type @ref XMC_POSIF_IRQ_EVENT_t for this enum.
196 * The member defines available event sources.It is used to configure which event to be used for
197 * interrupt generation using \a PFLGE register. [ PFLG,SPFLG,RPFLG]
198 */
199 typedef enum XMC_POSIF_IRQ_EVENT
200 {
201 XMC_POSIF_IRQ_EVENT_CHE = 0U, /**< Hall Mode : Correct Hall Event */
202 XMC_POSIF_IRQ_EVENT_WHE = 1U, /**< Hall Mode : Wrong Hall Event */
203 XMC_POSIF_IRQ_EVENT_HALL_INPUT = 2U, /**< Hall Mode : Hall Input update */
204 XMC_POSIF_IRQ_EVENT_MCP_SHADOW_TRANSFER = 4U, /**< Hall Mode + MCM Mode : MC Pattern shadow transfer */
205 XMC_POSIF_IRQ_EVENT_INDX = 8U, /**< Quadrature Mode : Index event detection */
206 XMC_POSIF_IRQ_EVENT_ERR = 9U, /**< Quadrature Mode : Quadrature Phase Error */
207 XMC_POSIF_IRQ_EVENT_CNT = 10U, /**< Quadrature Mode : Quadrature Clock event */
208 XMC_POSIF_IRQ_EVENT_DIR = 11U, /**< Quadrature Mode : Quadrature Direction change event */
209 XMC_POSIF_IRQ_EVENT_PCLK = 12U /**< Quadrature Mode : Quadrature period clock generation event */
210 } XMC_POSIF_IRQ_EVENT_t;
211
212 /**
213 * Defines POSIF service request lines.Use type @ref XMC_POSIF_SR_ID_t for this enum.
214 * It used to connect POSIF event to required service request line.
215 * in \a PFLGE register for interrupt generation.
216 */
217 typedef enum XMC_POSIF_SR_ID
218 {
219 XMC_POSIF_SR_ID_0 = 0U, /**< SR-0 */
220 XMC_POSIF_SR_ID_1 /**< SR-1 */
221 } XMC_POSIF_SR_ID_t;
222
223 /**
224 * Defines position decoder mode selection.Use type @ref XMC_POSIF_QD_MODE_t for this enum.
225 * The member defines configuration for the operation of the quadrature decoder mode.
226 * It used to configure \a QDC register.
227 */
228 typedef enum XMC_POSIF_QD_MODE
229 {
230 XMC_POSIF_QD_MODE_QUADRATURE = 0U, /**< Standard Quadrature Mode */
231 XMC_POSIF_QD_MODE_DIRECTION_COUNT /**< Direction Count Mode */
232 } XMC_POSIF_QD_MODE_t;
233
234 /**
235 * Defines motor rotation direction.Use type @ref XMC_POSIF_QD_DIR_t for this enum.
236 * The member defines the direction in quadrature mode.
237 */
238 typedef enum XMC_POSIF_QD_DIR
239 {
240 XMC_POSIF_QD_DIR_COUNTERCLOCKWISE = 0U, /**< Counter Clockwise */
241 XMC_POSIF_QD_DIR_CLOCKWISE /**< Clockwise */
242 } XMC_POSIF_QD_DIR_t;
243
244 /**
245 * Defines frequency of index signal generation.Use type @ref XMC_POSIF_QD_INDEX_GENERATION_t for this enum.
246 * Member represents available configuration for index marker generation using \a ICM bit field in \a QDC register.
247 */
248 typedef enum XMC_POSIF_QD_INDEX_GENERATION
249 {
250 XMC_POSIF_QD_INDEX_GENERATION_NEVER = 0U, /**< Never generate the index marker signal */
251 XMC_POSIF_QD_INDEX_GENERATION_ONCE , /**< Generate only once after the first revolution */
252 XMC_POSIF_QD_INDEX_GENERATION_ALWAYS /**< Index marker generated upon every revolution */
253 } XMC_POSIF_QD_INDEX_GENERATION_t;
254
255 /**
256 * Defines trigger edge in hall sensor mode.Use type @ref XMC_POSIF_HSC_TRIGGER_EDGE_t for this enum.
257 * It can be used to configure \a PCONF register's \a SPES and \a MSES bit fields.
258 */
259 typedef enum XMC_POSIF_HSC_TRIGGER_EDGE
260 {
261 XMC_POSIF_HSC_TRIGGER_EDGE_RISING = 0U, /**< Rising edge */
262 XMC_POSIF_HSC_TRIGGER_EDGE_FALLING /**< Falling edge */
263 } XMC_POSIF_HSC_TRIGGER_EDGE_t;
264
265 /*********************************************************************************************************************
266 * DATA STRUCTURES
267 ********************************************************************************************************************/
268
269 /*Anonymous structure/union guard start*/
270 #if defined(__CC_ARM)
271 #pragma push
272 #pragma anon_unions
273 #elif defined(__TASKING__)
274 #pragma warning 586
275 #endif
276
277 /**
278 *
279 * Defines POSIF peripheral register structure.Use type @ref XMC_POSIF_t for this data structure.
280 */
281 typedef POSIF_GLOBAL_TypeDef XMC_POSIF_t;
282
283 /**
284 * Defines POSIF quadrature decoder initialization data structure.
285 * Use type @ref XMC_POSIF_QD_CONFIG_t for this data structure.
286 * It used to configure Quadrature mode using \a QDC register.
287 */
288 typedef struct XMC_POSIF_QD_CONFIG
289 {
290 XMC_POSIF_QD_MODE_t mode; /**< Operational Mode of the quadrature encoder and decoder */
291 union
292 {
293 struct
294 {
295 uint32_t phase_a: 1; /**< Phase-A active level configuration */
296 uint32_t phase_b: 1; /**< Phase-B active level configuration */
297 uint32_t phase_leader: 1; /**< Which of the two phase signals[Phase A or Phase B] leads the other? */
298 uint32_t : 1;
299 uint32_t index: 2; /**< Index signal generation control. Use @ref XMC_POSIF_QD_INDEX_GENERATION_t to configure this field.*/
300 uint32_t : 26;
301 };
302 uint32_t qdc;
303 };
304 } XMC_POSIF_QD_CONFIG_t;
305
306 /**
307 * Defines POSIF hall sensor control initialization data structure.
308 * Use type @ref XMC_POSIF_HSC_CONFIG_t for this data structure.
309 * It used to initialize hall sensor mode configuration using \a PCONF register.
310 */
311 typedef struct XMC_POSIF_HSC_CONFIG
312 {
313 union
314 {
315 struct
316 {
317 uint32_t : 4;
318 uint32_t disable_idle_signal: 1; /**< Should idle signal be disabled upon wrong hall event? */
319 uint32_t : 11;
320 uint32_t sampling_trigger: 1; /**< Of HSDA and HSDB, which one is to be used to trigger POSIF to sample hall pattern? */
321 uint32_t sampling_trigger_edge: 1; /**< Which edge of the sampling trigger signal is to be considered? */
322 uint32_t : 6;
323 uint32_t external_error_port: 2; /**< Of the 4 external error ports, which one is to be considered? */
324 uint32_t external_error_enable: 1; /**< Should external errors lead to Wrong Hall event? */
325 uint32_t external_error_level: 1; /**< What should be the active level of external error signal? */
326 uint32_t: 4;
327 };
328 uint32_t hall_config;
329 };
330 } XMC_POSIF_HSC_CONFIG_t;
331
332 /**
333 * Defines POSIF multi-channel mode initialization data structure.
334 * Use type @ref XMC_POSIF_MCM_CONFIG_t for this data structure.
335 * It used to initialize multi channel mode configuration using \a PCONF register.
336 */
337 typedef struct XMC_POSIF_MCM_CONFIG
338 {
339 union
340 {
341 struct
342 {
343 uint32_t : 5;
344 uint32_t pattern_sw_update: 1; /**< should multi channel pattern updated by SW ? */
345 uint32_t : 12;
346 uint32_t pattern_update_trigger: 3; /**< Of the 8 update triggers, which one is to be considered? */
347 uint32_t pattern_trigger_edge: 1; /**< Which edge of the pattern update trigger is to be considered? */
348 uint32_t pwm_sync: 2; /**< Of the 4 pwm sync inputs, which one is to be considered? */
349 uint32_t : 8;
350 };
351 uint32_t mcm_config;
352 };
353 }XMC_POSIF_MCM_CONFIG_t;
354
355 /**
356 * Defines POSIF module initialization data structure.
357 * Use type @ref XMC_POSIF_CONFIG_t for this data structure.
358 * It is used to initialize POSIF module using \a PCONF register.
359 */
360 typedef struct XMC_POSIF_CONFIG
361 {
362 union
363 {
364 struct
365 {
366 uint32_t mode: 2; /**< POSIF Operational mode. Use @ref XMC_POSIF_MODE_t to configure */
367 uint32_t :6;
368 uint32_t input0: 2; /**< Choice of input for Input-1 */
369 uint32_t input1: 2; /**< Choice of input for Input-2 */
370 uint32_t input2: 2; /**< Choice of input for Input-3 */
371 uint32_t :14;
372 uint32_t filter: 3; /**< Input filter configuration */
373 uint32_t: 1;
374 };
375 uint32_t pconf;
376 };
377 } XMC_POSIF_CONFIG_t;
378
379 /*Anonymous structure/union guard end*/
380 #if defined(__CC_ARM)
381 #pragma pop
382 #elif defined(__TASKING__)
383 #pragma warning restore
384 #endif
385
386 /*********************************************************************************************************************
387 * API Prototypes
388 ********************************************************************************************************************/
389 #ifdef __cplusplus
390 extern "C" {
391 #endif
392
393 /**
394 * @param peripheral Pointer to an instance of POSIF module of type @ref XMC_POSIF_t
395 * @retval None
396 *
397 * \par<b>Description</b><br>
398 * De-asserts the POSIF module from reset and enables the clock.\n
399 * Configures \a PRCLR0 register's \a POSIF0RS or \a POSIF1RS bit field depends upon \a peripheral.
400 * If running on other than XMC45 device then it will ungate the peripheral clock.
401 *
402 * \par<b>Note</b><br>
403 * This is the first API which application must invoke to configure POSIF.
404 * It is internally called by XMC_POSIF_Init().
405 *
406 * \par<b>Related APIs:</b><BR>
407 * XMC_POSIF_Disable(),XMC_POSIF_Init() \n\n\n
408 */
409 void XMC_POSIF_Enable(XMC_POSIF_t *const peripheral);
410
411 /**
412 * @param peripheral Pointer to an instance of POSIF module of type @ref XMC_POSIF_t
413 * @retval None
414 *
415 * \par<b>Description</b><br>
416 * Asserts the POSIF module into reset and disables the clock.\n
417 * If running on other than XMC45 device then in addition it will gate the peripheral clock.
418 * Configures \a PRCLR0 register's \a POSIF0RS or \a POSIF1RS bitfield depends upon \a peripheral.
419 *
420 * \par<b>Related APIs:</b><BR>
421 * XMC_POSIF_Enable()\n\n\n
422 */
423 void XMC_POSIF_Disable(XMC_POSIF_t *const peripheral);
424
425 /**
426 * @param peripheral Pointer to an instance of POSIF module of type @ref XMC_POSIF_t
427 * @param config Pointer to POSIF configuration data(operation mode,input selection and filter configuration)
428 * @retval None
429 *
430 * \par<b>Description</b><br>
431 * Initialize POSIF module with \a config.\n
432 * Configures POSIF global registers.This is the first API which application must invoke to configure POSIF.
433 * It sets up parameters common to all the POSIF modes - hall sensor,quadrature decoder and multi-channel modes of operation.
434 * Configures \a PCONF register with mode of operation,input selection and filter configuration.
435 *
436 * \par<b>Related APIs:</b><BR>
437 * XMC_POSIF_HSC_Init(),XMC_POSIF_QD_Init(),XMC_POSIF_MCM_Init() \n\n\n
438 */
439 void XMC_POSIF_Init(XMC_POSIF_t *const peripheral, const XMC_POSIF_CONFIG_t * const config);
440
441 /**
442 * @param peripheral Pointer to an instance of POSIF module
443 * @param config Pointer to hall sensor control initialization data of type @ref XMC_POSIF_HSC_CONFIG_t
444 * @retval XMC_POSIF_STATUS_t Returns @ref XMC_POSIF_STATUS_OK if configured in Hall Sensor Mode
445 * else return @ref XMC_POSIF_STATUS_ERROR.
446 *
447 * \par<b>Description</b><br>
448 * Initializes hall sensor control mode.\n
449 * Configures \a PCONF register with which POSIF input trigger to be used for
450 * sampling hall pattern.Configures \a PCONF register for idle signal generation for wrong hall event.
451 *
452 * \par<b>Note</b><br>
453 * It is necessary to have called XMC_POSIF_Init first with Hall sensor mode before invocation of this API.
454 *
455 * \par<b>Related APIs:</b><BR>
456 * XMC_POSIF_Init() \n\n\n
457 */
458 XMC_POSIF_STATUS_t XMC_POSIF_HSC_Init(XMC_POSIF_t *const peripheral, const XMC_POSIF_HSC_CONFIG_t * const config);
459
460 /**
461 * @param peripheral Pointer to an instance of POSIF module
462 * @param config Pointer to quadrature decoder initialization data
463 * @retval XMC_POSIF_STATUS_t Returns quadrature mode initialization status of type @ref XMC_POSIF_STATUS_t
464 *
465 * \par<b>Description</b><br>
466 * Initializes quadrature decoder control mode.\n
467 * Configures \a PCONF register with quadrature mode using @ref XMC_POSIF_QD_MODE_t data structure.
468 * Initializes \a QDC register with quadrature mode configuration using @ref XMC_POSIF_QD_CONFIG_t structure.
469 *
470 * \par<b>Note</b><br>
471 * It is necessary to have called XMC_POSIF_Init first with Quadrature decoder mode before invocation of this API.
472 *
473 * \par<b>Related APIs:</b><BR>
474 * XMC_POSIF_Init() \n\n\n
475 */
476 XMC_POSIF_STATUS_t XMC_POSIF_QD_Init(XMC_POSIF_t *const peripheral, const XMC_POSIF_QD_CONFIG_t * const config);
477
478 /**
479 * @param peripheral Pointer to an instance of POSIF module
480 * @param config Pointer to quadrature decoder initialization data
481 * @retval XMC_POSIF_STATUS_t Returns multi channel pattern initialization status of type @ref XMC_POSIF_STATUS_t
482 *
483 * \par<b>Description</b><br>
484 * Initializes multi channel mode in Hall mode, standalone multi-channel mode and quadrature with multi-channel mode.\n
485 * Configures \a PCONF register with multi channel mode using @ref XMC_POSIF_MCM_CONFIG_t data structure.
486 *
487 * \par<b>Note</b><br>
488 * It is necessary to call XMC_POSIF_Init first before invocation of this API.
489 * For XMC_POSIF_MODE_HALL_SENSOR, it is necessary to have called XMC_POSIF_HSC_Init before invocation of this API.
490 * For XMC_POSIF_MODE_MCM_QD, it is necessary to have called XMC_POSIF_QD_Init before invocation of this API.
491 *
492 * \par<b>Related APIs:</b><BR>
493 * XMC_POSIF_Init(),XMC_POSIF_HSC_Init(),XMC_POSIF_QD_Init() \n\n\n
494 */
495 XMC_POSIF_STATUS_t XMC_POSIF_MCM_Init(XMC_POSIF_t *const peripheral, const XMC_POSIF_MCM_CONFIG_t * const config);
496
497 /**
498 * @param peripheral Pointer to an instance of POSIF module
499 * @param mode POSIF operating mode of type @ref XMC_POSIF_MODE_t
500 * @retval None
501 *
502 * \par<b>Description</b><br>
503 * Configures POSIF module for \a mode.\n
504 * Configures \a PCONF register's a\ FSEL bitfield with \a mode.
505 * Refer @ref XMC_POSIF_MODE_t for available options.
506 *
507 * \par<b>Note</b><br>
508 * POSIF module should be in stopped state while changing the operating mode.
509 *
510 * \par<b>Related APIs:</b><BR>
511 * XMC_POSIF_Stop() \n\n\n
512 */
XMC_POSIF_SetMode(XMC_POSIF_t * const peripheral,const XMC_POSIF_MODE_t mode)513 __STATIC_INLINE void XMC_POSIF_SetMode(XMC_POSIF_t *const peripheral, const XMC_POSIF_MODE_t mode)
514 {
515 peripheral->PCONF = ((peripheral->PCONF & ~(uint32_t)(POSIF_PCONF_FSEL_Msk)) |
516 (((uint32_t)mode << POSIF_PCONF_FSEL_Pos) & (uint32_t)POSIF_PCONF_FSEL_Msk));
517 }
518
519 /**
520 * @param peripheral Pointer to an instance of POSIF module
521 * @param input0 Choice of input for input 0 [0-3]
522 * @param input1 Choice of input for input 1 [0-3]
523 * @param input2 Choice of input for input 2 [0-3]
524 * @retval None
525 *
526 * \par<b>Description</b><br>
527 * Configures which input to be connected to POSIF module. \n
528 * Configures \a PCONF register's INSEL0,INSEL1,INSEL2 bit fields with source for the input connection for \a input0
529 * \a input1, \a input2 respectively.
530 *
531 * \par<b>Note</b><br>
532 * Configures which input is used for the Phase X or Hall input X function depending upon the module is
533 * set for Quadrature Decoder or Hall Sensor Mode.
534 *
535 * \par<b>Related APIs:</b><BR>
536 * XMC_POSIF_Init() \n\n\n
537 */
538 void XMC_POSIF_SelectInputSource(XMC_POSIF_t *const peripheral, const XMC_POSIF_INPUT_PORT_t input0,
539 const XMC_POSIF_INPUT_PORT_t input1, const XMC_POSIF_INPUT_PORT_t input2);
540
541
542 /**
543 * @param peripheral Pointer to an instance of POSIF module
544 * @retval None
545 *
546 * \par<b>Description</b><br>
547 * Starts POSIF \a peripheral functional state machine.\n
548 * Starts POSIF state machine for \a peripheral.Configures \a PRUNS register's \a SRB bit field with 1.
549 *
550 * \par<b>Note</b><br>
551 * Global properties of POSIF along with mode specific properties should have been initialized before starting of POSIF
552 * FSM.
553 *
554 * \par<b>Related APIs:</b><BR>
555 * XMC_POSIF_Stop(),XMC_POSIF_IsRunning() \n\n\n
556 */
XMC_POSIF_Start(XMC_POSIF_t * const peripheral)557 __STATIC_INLINE void XMC_POSIF_Start(XMC_POSIF_t *const peripheral)
558 {
559 peripheral->PRUNS = (uint32_t)POSIF_PRUNS_SRB_Msk;
560 }
561
562 /**
563 * @param peripheral Pointer to an instance of POSIF module
564 * @retval None
565 *
566 * \par<b>Description</b><br>
567 * Stops POSIF \a peripheral functional state machine.\n
568 * Stop POSIF functional state machine and clears current internal status of the \a peripheral.
569 * Configures \a PRUNC register's \a CRB bit field with 1.
570 *
571 * \par<b>Related APIs:</b><BR>
572 * XMC_POSIF_Start(),XMC_POSIF_IsRunning() \n\n\n
573 */
XMC_POSIF_Stop(XMC_POSIF_t * const peripheral)574 __STATIC_INLINE void XMC_POSIF_Stop(XMC_POSIF_t *const peripheral)
575 {
576 peripheral->PRUNC = (uint32_t)(POSIF_PRUNC_CRB_Msk | POSIF_PRUNC_CSM_Msk);
577 }
578
579 /**
580 * @param peripheral Pointer to an instance of POSIF module
581 * @retval bool Returns false: IDLE, true:RUNNING
582 *
583 * \par<b>Description</b><br>
584 * Returns the status of POSIF module - Running or IDLE.\n
585 * Retrieves the status from \a PRUN register's \a SRB bit.
586 *
587 * \par<b>Related APIs:</b><BR>
588 * XMC_POSIF_Start(),XMC_POSIF_Stop() \n\n\n
589 */
XMC_POSIF_IsRunning(XMC_POSIF_t * const peripheral)590 __STATIC_INLINE bool XMC_POSIF_IsRunning(XMC_POSIF_t *const peripheral)
591 {
592 return ((bool)peripheral->PRUN);
593 }
594
595 /**
596 * @param peripheral Pointer to an instance of POSIF module
597 * @retval uint8_t Returns last sampled hall sensor pattern. Range : [0-7]
598 *
599 * \par<b>Description</b><br>
600 * Returns last sampled hall sensor pattern of \a peripheral.\n
601 * Retrieves the last sampled hall sensor pattern from \a PDBG register's \a HSP bit field of \a peripheral.
602 * Applications can at any point in time retrieve the last sampled hall sensor pattern by invoking this API.
603 *
604 * \par<b>Note</b><br>
605 * This is applicable only to the hall sensor mode of operation.
606 *
607 * \par<b>Related APIs:</b><BR>
608 * XMC_POSIF_HSC_GetCurrentPattern(),XMC_POSIF_HSC_GetExpectedPattern() \n\n\n
609 */
XMC_POSIF_HSC_GetLastSampledPattern(XMC_POSIF_t * const peripheral)610 __STATIC_INLINE uint8_t XMC_POSIF_HSC_GetLastSampledPattern(XMC_POSIF_t *const peripheral)
611 {
612 return ((uint8_t)((peripheral->PDBG) & POSIF_PDBG_HSP_Msk) >> POSIF_PDBG_HSP_Pos);
613 }
614
615 /**
616 * @param peripheral Pointer to an instance of POSIF module
617 * @retval uint8_t Returns current hall sensor pattern. Range : [0-7]
618 *
619 * \par<b>Description</b><br>
620 * Returns current sampled hall sensor pattern of \a peripheral.\n
621 * Retrieves the current hall sensor pattern from \a HALP register's \a HCP bit field of \a peripheral.
622 * Applications can at any point in time retrieve the current hall sensor pattern by invoking this API.
623 *
624 * \par<b>Note</b><br>
625 * This is applicable only to the hall sensor mode of operation.
626 *
627 * \par<b>Related APIs:</b><BR>
628 * XMC_POSIF_HSC_GetLastSampledPattern(),XMC_POSIF_HSC_GetExpectedPattern() \n\n\n
629 */
XMC_POSIF_HSC_GetCurrentPattern(XMC_POSIF_t * const peripheral)630 __STATIC_INLINE uint8_t XMC_POSIF_HSC_GetCurrentPattern(XMC_POSIF_t *const peripheral)
631 {
632 return ((uint8_t)((peripheral->HALP & POSIF_HALP_HCP_Msk) >> POSIF_HALP_HCP_Pos));
633 }
634
635 /**
636 * @param peripheral Pointer to an instance of POSIF module
637 * @retval uint8_t Returns expected hall sensor pattern. Range : [0-7]
638 *
639 * \par<b>Description</b><br>
640 * Returns expected hall sensor pattern of \a peripheral.\n
641 * Retrieves the expected hall sensor pattern from \a HALP register's \a HEP bit field of \a peripheral.
642 * Applications can at any point in time retrieve the expected hall sensor pattern by invoking this API.
643 *
644 * \par<b>Note</b><br>
645 * This is applicable only to the hall sensor mode of operation.
646 *
647 * \par<b>Related APIs:</b><BR>
648 * XMC_POSIF_HSC_GetLastSampledPattern(),XMC_POSIF_HSC_GetCurrentPattern() \n\n\n
649 */
XMC_POSIF_HSC_GetExpectedPattern(XMC_POSIF_t * const peripheral)650 __STATIC_INLINE uint8_t XMC_POSIF_HSC_GetExpectedPattern(XMC_POSIF_t *const peripheral)
651 {
652 return ((uint8_t)((peripheral->HALP & POSIF_HALP_HEP_Msk) >> POSIF_HALP_HEP_Pos));
653 }
654
655 /**
656 * @param peripheral Pointer to an instance of POSIF module
657 * @param pattern The hall sensor pattern to be programmed into current pattern [0-7]
658 * @retval None
659 *
660 * \par<b>Description</b><br>
661 * Configures current Hall sensor \a pattern of \a peripheral.\n
662 * Configures the Current hall sensor pattern on \a HALPS shadow register's \a HCPS bit field of \a peripheral.
663 * Applications can set at any point in time program the current hall sensor pattern by invoking this API.
664 *
665 * \par<b>Note</b><br>
666 * This is applicable only to the hall sensor mode of operation. It may be noted that the pattern is merely
667 * written to the shadow register. Transfer from the shadow register is based on a hardware transfer trigger
668 * or software trigger through API @ref XMC_POSIF_HSC_UpdateHallPattern().
669 *
670 * \par<b>Related APIs:</b><BR>
671 * XMC_POSIF_HSC_GetCurrentPattern(),XMC_POSIF_HSC_SetExpectedPattern() \n\n\n
672 */
XMC_POSIF_HSC_SetCurrentPattern(XMC_POSIF_t * const peripheral,const uint8_t pattern)673 __STATIC_INLINE void XMC_POSIF_HSC_SetCurrentPattern(XMC_POSIF_t *const peripheral, const uint8_t pattern)
674 {
675 peripheral->HALPS = ((peripheral->HALPS & ~(uint32_t)(POSIF_HALPS_HCPS_Msk)) |
676 (((uint32_t)pattern << POSIF_HALPS_HCPS_Pos) & (uint32_t)POSIF_HALPS_HCPS_Msk));
677 }
678
679 /**
680 * @param peripheral Pointer to an instance of POSIF module
681 * @param pattern The hall sensor pattern to be programmed into expected pattern [0-7]
682 * @retval None
683 *
684 * \par<b>Description</b><br>
685 * Configures the expected hall sensor \a pattern of \a peripheral.\n
686 * Applications can set at any point in time program the hall sensor expected patterns by invoking this API.
687 * Configures the expected hall sensor pattern on \a HALPS shadow register's \a HEPS bit field of \a peripheral.
688 *
689 * \par<b>Note</b><br>
690 * This is applicable only to the hall sensor mode of operation.It may be noted that the pattern is merely
691 * written to the shadow register. Transfer from the shadow register is based on a hardware transfer trigger
692 * or software trigger through API @ref XMC_POSIF_HSC_UpdateHallPattern().
693 *
694 * \par<b>Related APIs:</b><BR>
695 * XMC_POSIF_HSC_GetExpectedPattern() \n\n\n
696 */
XMC_POSIF_HSC_SetExpectedPattern(XMC_POSIF_t * const peripheral,const uint8_t pattern)697 __STATIC_INLINE void XMC_POSIF_HSC_SetExpectedPattern(XMC_POSIF_t *const peripheral, const uint8_t pattern)
698 {
699 peripheral->HALPS = ((peripheral->HALPS & ~(uint32_t)(POSIF_HALPS_HEPS_Msk)) |
700 (((uint32_t)pattern << POSIF_HALPS_HEPS_Pos) & (uint32_t)POSIF_HALPS_HEPS_Msk));
701 }
702
703 /**
704 * @param peripheral Pointer to an instance of POSIF module
705 * @param pattern_mask The hall sensor pattern mask [0-63] Format of mask: (expected_pattern << 3) | (current_pattern)
706 * @retval None
707 *
708 * \par<b>Description</b><br>
709 * Configures current and expected hall pattern of \a peripheral. \n
710 * Configures \a HALPS register with the Current and Expected hall sensor patterns in one operation.
711 * Applications can at any point in time program the current and expected hall sensor pattern by invoking this API.
712 *
713 * \par<b>Note</b><br>
714 * This is applicable only to the hall sensor mode of operation. It may be noted that the pattern is merely
715 * written to the shadow register. Transfer from the shadow register is based on a hardware transfer trigger
716 * or software trigger through API @ref XMC_POSIF_HSC_UpdateHallPattern().
717 *
718 * \par<b>Related APIs:</b><BR>
719 * XMC_POSIF_HSC_SetExpectedPattern(),XMC_POSIF_HSC_SetCurrentPattern() \n\n\n
720 */
XMC_POSIF_HSC_SetHallPatterns(XMC_POSIF_t * const peripheral,const uint8_t pattern_mask)721 __STATIC_INLINE void XMC_POSIF_HSC_SetHallPatterns(XMC_POSIF_t *const peripheral, const uint8_t pattern_mask)
722 {
723 peripheral->HALPS = (uint32_t)(pattern_mask & (POSIF_HALPS_HCPS_Msk | POSIF_HALPS_HEPS_Msk));
724 }
725
726 /**
727 * @param peripheral Pointer to an instance of POSIF module
728 * @retval None
729 *
730 * \par<b>Description</b><br>
731 * Manually performs shadow transfer of hall sensor patterns.\n
732 * Configures \a MCMS register's \a STHR bit field with 1.
733 * Setting this bit to 1 leads to an immediate update of the fields \a HALP.HCP(Current pattern) and \a HALP.HEP(Expected pattern).
734 *
735 * \par<b>Note</b><br>
736 * The transfer of hall sensor pattern shadow registers content to the sensor pattern register happens under two
737 * conditions. A hardware trigger starts the shadow transfer. Alternatively, the shadow transfer can be initiated
738 * by application software by means of invocation of this API.
739 *
740 * \par<b>Related APIs:</b><BR>
741 * XMC_POSIF_HSC_SetHallPatterns() \n\n\n
742 */
XMC_POSIF_HSC_UpdateHallPattern(XMC_POSIF_t * const peripheral)743 __STATIC_INLINE void XMC_POSIF_HSC_UpdateHallPattern(XMC_POSIF_t *const peripheral)
744 {
745 peripheral->MCMS = (uint32_t)POSIF_MCMS_STHR_Msk;
746 }
747
748 /**
749 * @param peripheral Pointer to an instance of POSIF module
750 * @param pattern The 16b multi-channel pattern [0-65535]
751 * @retval None
752 *
753 * \par<b>Description</b><br>
754 * Configures \a MCSM register with Multi-Channel Pattern.\n
755 * This 16b multi-channel pattern which controls the 16 outputs of all slices of a CCU8 module.
756 * Transfer from the shadow register is based on a hardware transfer trigger
757 * or software trigger through API @ref XMC_POSIF_MCM_UpdateMultiChannelPattern().
758 * Every time that a Multi-Channel pattern transfer is triggered, this value is passed into the field \a MCM.MCMP of \a peripheral
759 *
760 * \par<b>Note</b><br>
761 * It may be noted that the pattern is merely written to the shadow register.
762 *
763 * \par<b>Related APIs:</b><BR>
764 * XMC_POSIF_MCM_GetMultiChannelPattern() \n\n\n
765 */
XMC_POSIF_MCM_SetMultiChannelPattern(XMC_POSIF_t * const peripheral,const uint16_t pattern)766 __STATIC_INLINE void XMC_POSIF_MCM_SetMultiChannelPattern(XMC_POSIF_t *const peripheral, const uint16_t pattern)
767 {
768 peripheral->MCSM = pattern;
769 }
770
771 /**
772 * @param peripheral Pointer to an instance of POSIF module
773 * @retval uint16_t Returns configured multi channel pattern
774 *
775 * \par<b>Description</b><br>
776 * Returns configured multi channel pattern of \a peripheral. \n
777 * Retrieves the Multi-Channel Pattern from \a MCM register's MCMP bit field of \a peripheral
778 * Applications can at any point in time retrieve the multi-channel pattern by invoking this API.
779 *
780 * \par<b>Related APIs:</b><BR>
781 * XMC_POSIF_MCM_SetMultiChannelPattern() \n\n\n
782 */
XMC_POSIF_MCM_GetMultiChannelPattern(XMC_POSIF_t * const peripheral)783 __STATIC_INLINE uint16_t XMC_POSIF_MCM_GetMultiChannelPattern(XMC_POSIF_t *const peripheral)
784 {
785 return ((uint16_t)(peripheral->MCM & (uint32_t)POSIF_MCM_MCMP_Msk));
786 }
787
788 /**
789 * @param peripheral Pointer to an instance of POSIF module
790 * @retval uint16_t Returns configured multi channel pattern present in shadow transfer register
791 *
792 * \par<b>Description</b><br>
793 * Returns configured multi channel pattern in shadow register of \a peripheral. \n
794 * Retrieves the Multi-Channel Pattern from \a MCSM shadow register's \a MCMPS bit field.
795 * Applications can at any point in time retrieve the multi-channel pattern by invoking this API.
796 *
797 * It can be used when MCM is enabled.
798 *
799 * \par<b>Related APIs:</b><BR>
800 * XMC_POSIF_MCM_SetMultiChannelPattern() \n\n\n
801 */
XMC_POSIF_MCM_GetShadowMultiChannelPattern(XMC_POSIF_t * const peripheral)802 __STATIC_INLINE uint16_t XMC_POSIF_MCM_GetShadowMultiChannelPattern(XMC_POSIF_t *const peripheral)
803 {
804 return ((uint16_t)(peripheral->MCSM & (uint32_t)POSIF_MCSM_MCMPS_Msk));
805 }
806
807 /**
808 * @param peripheral Pointer to an instance of POSIF module
809 * @retval None
810 *
811 * \par<b>Description</b><br>
812 * Performs shadow transfer of the Multi-Channel Pattern register by configuring \a MCMS register's \a STMR bit field.
813 *
814 * \par<b>Note</b><br>
815 * Transfer multi-channel pattern shadow registers content to the actual pattern register of \a peripheral. \n
816 * The transfer of multi-channel pattern shadow registers content to the actual pattern register happens under two
817 * conditions. A hardware trigger starts the shadow transfer. Alternatively, the shadow transfer can be initiated
818 * by application software by means of invocation of this API.
819 *
820 * \par<b>Related APIs:</b><BR>
821 * XMC_POSIF_MCM_SetMultiChannelPattern() \n\n\n
822 */
XMC_POSIF_MCM_UpdateMultiChannelPattern(XMC_POSIF_t * const peripheral)823 __STATIC_INLINE void XMC_POSIF_MCM_UpdateMultiChannelPattern(XMC_POSIF_t *const peripheral)
824 {
825 peripheral->MCMS |= (uint32_t)POSIF_MCMS_STMR_Msk;
826 }
827
828 /**
829 * @param peripheral Pointer to an instance of POSIF module
830 * @retval None
831 *
832 * \par<b>Description</b><br>
833 * Enables update of the Multi-Channel Pattern by software in standalone multi-channel mode.\n
834 * Enabling update of multi-channel pattern happens under two conditions. A hardware trigger enables this update.
835 * Alternatively, this can be enabled by software by means of invocation of this API.
836 *
837 * \par<b>Note</b><br>
838 * The update is not done immediately due to the fact that the trigger that synchronizes the update with the PWM is
839 * still needed.
840 *
841 * \par<b>Related APIs:</b><BR>
842 * XMC_POSIF_MCM_UpdateMultiChannelPattern() \n\n\n
843 */
XMC_POSIF_MCM_EnableMultiChannelPatternUpdate(XMC_POSIF_t * const peripheral)844 __STATIC_INLINE void XMC_POSIF_MCM_EnableMultiChannelPatternUpdate(XMC_POSIF_t *const peripheral)
845 {
846 peripheral->MCMS |= (uint32_t)POSIF_MCMS_MNPS_Msk;
847 }
848
849 /**
850 * @param peripheral Pointer to an instance of POSIF module
851 * @retval XMC_POSIF_QD_DIR_t Return direction of revolution of the motor of type @ref XMC_POSIF_QD_DIR_t
852 *
853 * \par<b>Description</b><br>
854 * Returns the direction of revolution of the motor.\n
855 * Retrieves direction from \a QDC register's \a DVAL bit field in quadrature mode.
856 * Applications can at any point in time retrieve the direction of rotation by invoking this API.
857 *
858 * \par<b>Note</b><br>
859 * This is applicable only to the quadrature decoder mode of operation.
860 *
861 */
XMC_POSIF_QD_GetDirection(XMC_POSIF_t * const peripheral)862 __STATIC_INLINE XMC_POSIF_QD_DIR_t XMC_POSIF_QD_GetDirection(XMC_POSIF_t *const peripheral)
863 {
864 return ((XMC_POSIF_QD_DIR_t)((peripheral->QDC & POSIF_QDC_DVAL_Msk) >> POSIF_QDC_DVAL_Pos));
865 }
866
867 /**
868 * @param peripheral Pointer to an instance of POSIF module
869 * @retval uint8_t Returns current state of quadrature decoder[Phase B,Phase A]
870 *
871 * \par<b>Description</b><br>
872 * Returns the current state of phase signals in quadrature decoder mode of \a peripheral. \n
873 * Retrieves current state of the quadrature decoder from \a PDBG register's \a QCSV bit fields.
874 * Applications can at any point in time retrieve the current state of Phase A and Phase B signals
875 * by invoking this API.
876 *
877 * \par<b>Note</b><br>
878 * This is applicable only to the quadrature decoder mode of operation.
879 *
880 * \par<b>Related APIs:</b><BR>
881 * XMC_POSIF_QD_GetPreviousState() \n\n\n
882 */
XMC_POSIF_QD_GetCurrentState(XMC_POSIF_t * const peripheral)883 __STATIC_INLINE uint8_t XMC_POSIF_QD_GetCurrentState(XMC_POSIF_t *const peripheral)
884 {
885 return ((uint8_t)((peripheral->PDBG & POSIF_PDBG_QCSV_Msk) >> POSIF_PDBG_QCSV_Pos));
886 }
887
888 /**
889 * @param peripheral Pointer to an instance of POSIF module
890 * @retval uint8_t Returns previous state of quadrature decoder[Phase B,Phase A]
891 *
892 * \par<b>Description</b><br>
893 * Returns the previous state of phase signals in quadrature decoder mode of \a peripheral. \n
894 * Retrieves previous state of the quadrature decoder from \a PDBG register's \a QPSV bit fields.
895 * Applications can at any point in time retrieve the previous state of Phase A and Phase B signals
896 * by invoking this API.
897 *
898 * \par<b>Note</b><br>
899 * This is applicable only to the quadrature decoder mode of operation.
900 *
901 * \par<b>Related APIs:</b><BR>
902 * XMC_POSIF_QD_GetCurrentState() \n\n\n
903 */
XMC_POSIF_QD_GetPreviousState(XMC_POSIF_t * const peripheral)904 __STATIC_INLINE uint8_t XMC_POSIF_QD_GetPreviousState(XMC_POSIF_t *const peripheral)
905 {
906 return ((uint8_t)((peripheral->PDBG & POSIF_PDBG_QPSV_Msk) >> POSIF_PDBG_QPSV_Pos));
907 }
908
909 /**
910 * @param peripheral Pointer to an instance of POSIF module
911 * @retval uint8_t Returns the index value.[1 - New rotation started, 0 - In-between]
912 *
913 * \par<b>Description</b><br>
914 * Returns the current index value in quadrature decoder mode of \a peripheral. \n
915 * Retrieves current index signal value of the quadrature decoder from \a PDBG register's \a IVAL bit field.
916 * Applications can at any point in time retrieve the current index signal value of the quadrature decoder by
917 * invoking this API.
918 *
919 * \par<b>Note</b><br>
920 * This is applicable only to the quadrature decoder mode of operation.
921 *
922 */
XMC_POSIF_QD_GetCurrentIndexValue(XMC_POSIF_t * const peripheral)923 __STATIC_INLINE uint8_t XMC_POSIF_QD_GetCurrentIndexValue(XMC_POSIF_t *const peripheral)
924 {
925 return ((uint8_t)((peripheral->PDBG & POSIF_PDBG_IVAL_Msk) >> POSIF_PDBG_IVAL_Pos));
926 }
927
928 /**
929 * @param peripheral Pointer to an instance of POSIF module
930 * @param event Event to be enabled
931 * @retval None
932 *
933 * \par<b>Description</b><br>
934 * Enables \a event generation of \a peripheral. \n
935 * Enables an IRQ generation capable \a event by configuring 1 to \a PFLGE register's \a event bit field.
936 *
937 * \par<b>Related APIs:</b><BR>
938 * XMC_POSIF_DisableEvent() \n\n\n
939 */
XMC_POSIF_EnableEvent(XMC_POSIF_t * const peripheral,const XMC_POSIF_IRQ_EVENT_t event)940 __STATIC_INLINE void XMC_POSIF_EnableEvent(XMC_POSIF_t *const peripheral, const XMC_POSIF_IRQ_EVENT_t event)
941 {
942 peripheral->PFLGE |= (uint32_t)1 << (uint8_t)event;
943 }
944
945 /**
946 * @brief Disables an IRQ generation capable event
947 * @param peripheral Pointer to an instance of POSIF module
948 * @param event Event to be disabled
949 * @retval None
950 *
951 * \par<b>Description</b><br>
952 * Disables \a event generation of \a peripheral.\n
953 * Disables an IRQ generation capable \a event by configuring 0 to \a PFLGE register's \a event bit field.
954 *
955 * \par<b>Related APIs:</b><BR>
956 * XMC_POSIF_EnableEvent() \n\n\n
957 */
XMC_POSIF_DisableEvent(XMC_POSIF_t * const peripheral,const XMC_POSIF_IRQ_EVENT_t event)958 __STATIC_INLINE void XMC_POSIF_DisableEvent(XMC_POSIF_t *const peripheral, const XMC_POSIF_IRQ_EVENT_t event)
959 {
960 peripheral->PFLGE &= ~((uint32_t)1 << (uint8_t)event);
961 }
962
963 /**
964 * @param peripheral Pointer to an instance of POSIF module
965 * @param event Event to be manually asserted
966 * @retval None
967 *
968 * \par<b>Description</b><br>
969 * Manually generates \a event of \a peripheral. \n
970 * Manually asserts an IRQ generation capable event by configuring 1 to \a SPFLG register's \a event bit field.
971 *
972 * \par<b>Related APIs:</b><BR>
973 * XMC_POSIF_ClearEvent() \n\n\n
974 */
XMC_POSIF_SetEvent(XMC_POSIF_t * const peripheral,const XMC_POSIF_IRQ_EVENT_t event)975 __STATIC_INLINE void XMC_POSIF_SetEvent(XMC_POSIF_t *const peripheral, const XMC_POSIF_IRQ_EVENT_t event)
976 {
977 peripheral->SPFLG = (uint32_t)1 << (uint8_t)event;
978 }
979
980 /**
981 * @param peripheral Pointer to an instance of POSIF module
982 * @param event Event to be acknowledged
983 * @retval None
984 *
985 * \par<b>Description</b><br>
986 * Clears \a event by acknowledgment of \a peripheral. \n
987 * Acknowledges an IRQ event by configuring 1 to \a RPFLG register's \a event bit field.
988 *
989 * \par<b>Related APIs:</b><BR>
990 * XMC_POSIF_SetEvent() \n\n\n
991 */
XMC_POSIF_ClearEvent(XMC_POSIF_t * const peripheral,const XMC_POSIF_IRQ_EVENT_t event)992 __STATIC_INLINE void XMC_POSIF_ClearEvent(XMC_POSIF_t *const peripheral, const XMC_POSIF_IRQ_EVENT_t event)
993 {
994 peripheral->RPFLG = (uint32_t)1 << (uint8_t)event;
995 }
996
997 /**
998 * @param peripheral Pointer to an instance of POSIF module
999 * @param event Event ID to be checked for status
1000 * @retval uint8_t Returns event status
1001 *
1002 * \par<b>Description</b><br>
1003 * Returns \a event status of \a peripheral. \n
1004 * Determines if IRQ event is asserted by retrieving data from \a PFLG register's \a event bit field.
1005 *
1006 * \par<b>Related APIs:</b><BR>
1007 * XMC_POSIF_SetEvent(),XMC_POSIF_ClearEvent() \n\n\n
1008 */
XMC_POSIF_GetEventStatus(XMC_POSIF_t * const peripheral,const XMC_POSIF_IRQ_EVENT_t event)1009 __STATIC_INLINE uint8_t XMC_POSIF_GetEventStatus(XMC_POSIF_t *const peripheral, const XMC_POSIF_IRQ_EVENT_t event)
1010 {
1011 return ((uint8_t)((peripheral->PFLG >> (uint8_t)event) & 1U));
1012 }
1013
1014 /**
1015 * @param peripheral Pointer to an instance of POSIF module
1016 * @param event Event to be acknowledged of type @ref XMC_POSIF_IRQ_EVENT_t
1017 * @param sr Service request line of type @ref XMC_POSIF_SR_ID_t
1018 * @retval None
1019 *
1020 * \par<b>Description</b><br>
1021 * Configures \a event to generate \a sr (service request) of \a peripheral. \n
1022 * Binds an IRQ event to a service request line by configuring \a PFLGE register's \a event bit field.
1023 */
1024 void XMC_POSIF_SetInterruptNode(XMC_POSIF_t *const peripheral, const XMC_POSIF_IRQ_EVENT_t event, const XMC_POSIF_SR_ID_t sr);
1025
1026 #ifdef __cplusplus
1027 }
1028 #endif
1029
1030 /**
1031 * @}
1032 */
1033
1034 /**
1035 * @}
1036 */
1037
1038 #endif /* #if defined(POSIF0) */
1039
1040 #endif /* XMC_POSIF_H */
1041