G32R430 Device Driver Layer v1.0.4
G32R4xx Device Driver Layer API Reference
g32r4xx_ddl_tmr.c
Go to the documentation of this file.
1
43#if defined(USE_FULL_DDL_DRIVER)
44
45/* Includes ------------------------------------------------------------------*/
46#include "g32r4xx_ddl_tmr.h"
47#include "g32r4xx_ddl_rcm.h"
48
49#ifdef USE_FULL_ASSERT
50#include "g32_assert.h"
51#else
52#define ASSERT_PARAM(_PARAM_) ((void)0U)
53#endif /* USE_FULL_ASSERT */
54
58
59#if defined (TMR1) || defined (TMR2) || defined (TMR3) || defined (TMR4)
60
64
65/* Private types -------------------------------------------------------------*/
66/* Private variables ---------------------------------------------------------*/
67/* Private constants ---------------------------------------------------------*/
68/* Private macros ------------------------------------------------------------*/
72#define IS_DDL_TMR_COUNTERMODE(__VALUE__) (((__VALUE__) == DDL_TMR_COUNTERMODE_UP) \
73 || ((__VALUE__) == DDL_TMR_COUNTERMODE_DOWN) \
74 || ((__VALUE__) == DDL_TMR_COUNTERMODE_CENTER_UP) \
75 || ((__VALUE__) == DDL_TMR_COUNTERMODE_CENTER_DOWN) \
76 || ((__VALUE__) == DDL_TMR_COUNTERMODE_CENTER_UP_DOWN))
77
78#define IS_DDL_TMR_CLOCKDIVISION(__VALUE__) (((__VALUE__) == DDL_TMR_CLOCKDIVISION_DIV1) \
79 || ((__VALUE__) == DDL_TMR_CLOCKDIVISION_DIV2) \
80 || ((__VALUE__) == DDL_TMR_CLOCKDIVISION_DIV4))
81
82#define IS_DDL_TMR_OCMODE(__VALUE__) (((__VALUE__) == DDL_TMR_OCMODE_FROZEN) \
83 || ((__VALUE__) == DDL_TMR_OCMODE_ACTIVE) \
84 || ((__VALUE__) == DDL_TMR_OCMODE_INACTIVE) \
85 || ((__VALUE__) == DDL_TMR_OCMODE_TOGGLE) \
86 || ((__VALUE__) == DDL_TMR_OCMODE_FORCED_INACTIVE) \
87 || ((__VALUE__) == DDL_TMR_OCMODE_FORCED_ACTIVE) \
88 || ((__VALUE__) == DDL_TMR_OCMODE_PWM1) \
89 || ((__VALUE__) == DDL_TMR_OCMODE_PWM2))
90
91#define IS_DDL_TMR_OCSTATE(__VALUE__) (((__VALUE__) == DDL_TMR_OCSTATE_DISABLE) \
92 || ((__VALUE__) == DDL_TMR_OCSTATE_ENABLE))
93
94#define IS_DDL_TMR_OCPOLARITY(__VALUE__) (((__VALUE__) == DDL_TMR_OCPOLARITY_HIGH) \
95 || ((__VALUE__) == DDL_TMR_OCPOLARITY_LOW))
96
97#define IS_DDL_TMR_OCIDLESTATE(__VALUE__) (((__VALUE__) == DDL_TMR_OCIDLESTATE_LOW) \
98 || ((__VALUE__) == DDL_TMR_OCIDLESTATE_HIGH))
99
100#define IS_DDL_TMR_ACTIVEINPUT(__VALUE__) (((__VALUE__) == DDL_TMR_ACTIVEINPUT_DIRECTTI) \
101 || ((__VALUE__) == DDL_TMR_ACTIVEINPUT_INDIRECTTI) \
102 || ((__VALUE__) == DDL_TMR_ACTIVEINPUT_TRC))
103
104#define IS_DDL_TMR_ICPSC(__VALUE__) (((__VALUE__) == DDL_TMR_ICPSC_DIV1) \
105 || ((__VALUE__) == DDL_TMR_ICPSC_DIV2) \
106 || ((__VALUE__) == DDL_TMR_ICPSC_DIV4) \
107 || ((__VALUE__) == DDL_TMR_ICPSC_DIV8))
108
109#define IS_DDL_TMR_IC_FILTER(__VALUE__) (((__VALUE__) == DDL_TMR_IC_FILTER_FDIV1) \
110 || ((__VALUE__) == DDL_TMR_IC_FILTER_FDIV1_N2) \
111 || ((__VALUE__) == DDL_TMR_IC_FILTER_FDIV1_N4) \
112 || ((__VALUE__) == DDL_TMR_IC_FILTER_FDIV1_N8) \
113 || ((__VALUE__) == DDL_TMR_IC_FILTER_FDIV2_N6) \
114 || ((__VALUE__) == DDL_TMR_IC_FILTER_FDIV2_N8) \
115 || ((__VALUE__) == DDL_TMR_IC_FILTER_FDIV4_N6) \
116 || ((__VALUE__) == DDL_TMR_IC_FILTER_FDIV4_N8) \
117 || ((__VALUE__) == DDL_TMR_IC_FILTER_FDIV8_N6) \
118 || ((__VALUE__) == DDL_TMR_IC_FILTER_FDIV8_N8) \
119 || ((__VALUE__) == DDL_TMR_IC_FILTER_FDIV16_N5) \
120 || ((__VALUE__) == DDL_TMR_IC_FILTER_FDIV16_N6) \
121 || ((__VALUE__) == DDL_TMR_IC_FILTER_FDIV16_N8) \
122 || ((__VALUE__) == DDL_TMR_IC_FILTER_FDIV32_N5) \
123 || ((__VALUE__) == DDL_TMR_IC_FILTER_FDIV32_N6) \
124 || ((__VALUE__) == DDL_TMR_IC_FILTER_FDIV32_N8))
125
126#define IS_DDL_TMR_IC_POLARITY(__VALUE__) (((__VALUE__) == DDL_TMR_IC_POLARITY_RISING) \
127 || ((__VALUE__) == DDL_TMR_IC_POLARITY_FALLING) \
128 || ((__VALUE__) == DDL_TMR_IC_POLARITY_BOTHEDGE))
129
130#define IS_DDL_TMR_ENCODERMODE(__VALUE__) (((__VALUE__) == DDL_TMR_ENCODERMODE_X2_TI1) \
131 || ((__VALUE__) == DDL_TMR_ENCODERMODE_X2_TI2) \
132 || ((__VALUE__) == DDL_TMR_ENCODERMODE_X4_TI12))
133
134#define IS_DDL_TMR_IC_POLARITY_ENCODER(__VALUE__) (((__VALUE__) == DDL_TMR_IC_POLARITY_RISING) \
135 || ((__VALUE__) == DDL_TMR_IC_POLARITY_FALLING))
136
137#define IS_DDL_TMR_OSSR_STATE(__VALUE__) (((__VALUE__) == DDL_TMR_OSSR_DISABLE) \
138 || ((__VALUE__) == DDL_TMR_OSSR_ENABLE))
139
140#define IS_DDL_TMR_OSSI_STATE(__VALUE__) (((__VALUE__) == DDL_TMR_OSSI_DISABLE) \
141 || ((__VALUE__) == DDL_TMR_OSSI_ENABLE))
142
143#define IS_DDL_TMR_LOCK_LEVEL(__VALUE__) (((__VALUE__) == DDL_TMR_LOCKLEVEL_OFF) \
144 || ((__VALUE__) == DDL_TMR_LOCKLEVEL_1) \
145 || ((__VALUE__) == DDL_TMR_LOCKLEVEL_2) \
146 || ((__VALUE__) == DDL_TMR_LOCKLEVEL_3))
147
148#define IS_DDL_TMR_BREAK_STATE(__VALUE__) (((__VALUE__) == DDL_TMR_BREAK_DISABLE) \
149 || ((__VALUE__) == DDL_TMR_BREAK_ENABLE))
150
151#define IS_DDL_TMR_BREAK_POLARITY(__VALUE__) (((__VALUE__) == DDL_TMR_BREAK_POLARITY_LOW) \
152 || ((__VALUE__) == DDL_TMR_BREAK_POLARITY_HIGH))
153
154#define IS_DDL_TMR_AUTOMATIC_OUTPUT_STATE(__VALUE__) (((__VALUE__) == DDL_TMR_AUTOMATICOUTPUT_DISABLE) \
155 || ((__VALUE__) == DDL_TMR_AUTOMATICOUTPUT_ENABLE))
156
159
160
161/* Private function prototypes -----------------------------------------------*/
165static ErrorStatus OC1Config(TMR_TypeDef *TMRx, DDL_TMR_OC_InitTypeDef *TMR_OCInitStruct);
166static ErrorStatus OC2Config(TMR_TypeDef *TMRx, DDL_TMR_OC_InitTypeDef *TMR_OCInitStruct);
167static ErrorStatus OC3Config(TMR_TypeDef *TMRx, DDL_TMR_OC_InitTypeDef *TMR_OCInitStruct);
168static ErrorStatus OC4Config(TMR_TypeDef *TMRx, DDL_TMR_OC_InitTypeDef *TMR_OCInitStruct);
169static ErrorStatus IC1Config(TMR_TypeDef *TMRx, DDL_TMR_IC_InitTypeDef *TMR_ICInitStruct);
170static ErrorStatus IC2Config(TMR_TypeDef *TMRx, DDL_TMR_IC_InitTypeDef *TMR_ICInitStruct);
171static ErrorStatus IC3Config(TMR_TypeDef *TMRx, DDL_TMR_IC_InitTypeDef *TMR_ICInitStruct);
172static ErrorStatus IC4Config(TMR_TypeDef *TMRx, DDL_TMR_IC_InitTypeDef *TMR_ICInitStruct);
176
177/* Exported functions --------------------------------------------------------*/
181
185
193ErrorStatus DDL_TMR_DeInit(TMR_TypeDef *TMRx)
194{
195 ErrorStatus result = SUCCESS;
196
197 /* Check the parameters */
198 ASSERT_PARAM(IS_TMR_INSTANCE(TMRx));
199
201
202 if (TMRx == TMR1)
203 {
206 }
207
208#if defined(TMR2)
209 if (TMRx == TMR2)
210 {
213 }
214#endif /* TMR3 */
215#if defined(TMR3)
216 else if (TMRx == TMR3)
217 {
220 }
221#endif /* TMR3 */
222#if defined(TMR4)
223 else if (TMRx == TMR4)
224 {
227 }
228#endif /* TMR4 */
229 else
230 {
231 result = ERROR;
232 }
233
234 return result;
235}
236
244{
245 /* Set the default configuration */
246 TMR_InitStruct->Prescaler = (uint16_t)0x0000;
247 TMR_InitStruct->CounterMode = DDL_TMR_COUNTERMODE_UP;
248 TMR_InitStruct->Autoreload = 0xFFFFFFFFU;
250 TMR_InitStruct->RepetitionCounter = 0x00000000U;
251}
252
262ErrorStatus DDL_TMR_Init(TMR_TypeDef *TMRx, DDL_TMR_InitTypeDef *TMR_InitStruct)
263{
264 uint32_t tmpcr1;
265
266 /* Check the parameters */
267 ASSERT_PARAM(IS_TMR_INSTANCE(TMRx));
270
271 tmpcr1 = DDL_TMR_ReadReg(TMRx, CTRL1);
272
273 if (IS_TMR_COUNTER_MODE_SELECT_INSTANCE(TMRx))
274 {
275 /* Select the Counter Mode */
276 MODIFY_REG(tmpcr1, (TMR_CTRL1_CNTDIR | TMR_CTRL1_CAMSEL), TMR_InitStruct->CounterMode);
277 }
278
279 if (IS_TMR_CLOCK_DIVISION_INSTANCE(TMRx))
280 {
281 /* Set the clock division */
282 MODIFY_REG(tmpcr1, TMR_CTRL1_CLKDIV, TMR_InitStruct->ClockDivision);
283 }
284
285 /* Write to TMRx CTRL1 */
286 DDL_TMR_WriteReg(TMRx, CTRL1, tmpcr1);
287
288 /* Set the Autoreload value */
289 DDL_TMR_SetAutoReload(TMRx, TMR_InitStruct->Autoreload);
290
291 /* Set the Prescaler value */
292 DDL_TMR_SetPrescaler(TMRx, TMR_InitStruct->Prescaler);
293
294 if (IS_TMR_REPETITION_COUNTER_INSTANCE(TMRx))
295 {
296 /* Set the Repetition Counter value */
297 DDL_TMR_SetRepetitionCounter(TMRx, TMR_InitStruct->RepetitionCounter);
298 }
299
300 /* Generate an update event to reload the Prescaler
301 and the repetition counter value immediately */
303
304 return SUCCESS;
305}
306
315{
316 /* Set the default configuration */
317 TMR_OC_InitStruct->OCMode = DDL_TMR_OCMODE_FROZEN;
318 TMR_OC_InitStruct->OCState = DDL_TMR_OCSTATE_DISABLE;
319 TMR_OC_InitStruct->OCNState = DDL_TMR_OCSTATE_DISABLE;
320 TMR_OC_InitStruct->CompareValue = 0x00000000U;
321 TMR_OC_InitStruct->OCPolarity = DDL_TMR_OCPOLARITY_HIGH;
322 TMR_OC_InitStruct->OCNPolarity = DDL_TMR_OCPOLARITY_HIGH;
323 TMR_OC_InitStruct->OCIdleState = DDL_TMR_OCIDLESTATE_LOW;
324 TMR_OC_InitStruct->OCNIdleState = DDL_TMR_OCIDLESTATE_LOW;
325}
326
341ErrorStatus DDL_TMR_OC_Init(TMR_TypeDef *TMRx, uint32_t Channel, DDL_TMR_OC_InitTypeDef *TMR_OC_InitStruct)
342{
343 ErrorStatus result = ERROR;
344
345 switch (Channel)
346 {
348 result = OC1Config(TMRx, TMR_OC_InitStruct);
349 break;
351 result = OC2Config(TMRx, TMR_OC_InitStruct);
352 break;
354 result = OC3Config(TMRx, TMR_OC_InitStruct);
355 break;
357 result = OC4Config(TMRx, TMR_OC_InitStruct);
358 break;
359 default:
360 break;
361 }
362
363 return result;
364}
365
374{
375 /* Set the default configuration */
376 TMR_ICInitStruct->ICPolarity = DDL_TMR_IC_POLARITY_RISING;
378 TMR_ICInitStruct->ICPrescaler = DDL_TMR_ICPSC_DIV1;
379 TMR_ICInitStruct->ICFilter = DDL_TMR_IC_FILTER_FDIV1;
380}
381
396ErrorStatus DDL_TMR_IC_Init(TMR_TypeDef *TMRx, uint32_t Channel, DDL_TMR_IC_InitTypeDef *TMR_IC_InitStruct)
397{
398 ErrorStatus result = ERROR;
399
400 switch (Channel)
401 {
403 result = IC1Config(TMRx, TMR_IC_InitStruct);
404 break;
406 result = IC2Config(TMRx, TMR_IC_InitStruct);
407 break;
409 result = IC3Config(TMRx, TMR_IC_InitStruct);
410 break;
412 result = IC4Config(TMRx, TMR_IC_InitStruct);
413 break;
414 default:
415 break;
416 }
417
418 return result;
419}
420
428{
429 /* Set the default configuration */
430 TMR_EncoderInitStruct->EncoderMode = DDL_TMR_ENCODERMODE_X2_TI1;
431 TMR_EncoderInitStruct->IC1Polarity = DDL_TMR_IC_POLARITY_RISING;
432 TMR_EncoderInitStruct->IC1ActiveInput = DDL_TMR_ACTIVEINPUT_DIRECTTI;
433 TMR_EncoderInitStruct->IC1Prescaler = DDL_TMR_ICPSC_DIV1;
434 TMR_EncoderInitStruct->IC1Filter = DDL_TMR_IC_FILTER_FDIV1;
435 TMR_EncoderInitStruct->IC2Polarity = DDL_TMR_IC_POLARITY_RISING;
436 TMR_EncoderInitStruct->IC2ActiveInput = DDL_TMR_ACTIVEINPUT_DIRECTTI;
437 TMR_EncoderInitStruct->IC2Prescaler = DDL_TMR_ICPSC_DIV1;
438 TMR_EncoderInitStruct->IC2Filter = DDL_TMR_IC_FILTER_FDIV1;
439}
440
450ErrorStatus DDL_TMR_ENCODER_Init(TMR_TypeDef *TMRx, DDL_TMR_ENCODER_InitTypeDef *TMR_EncoderInitStruct)
451{
452 uint32_t tmpccmr1;
453 uint32_t tmpccer;
454
455 /* Check the parameters */
456 ASSERT_PARAM(IS_TMR_ENCODER_INTERFACE_INSTANCE(TMRx));
457 ASSERT_PARAM(IS_DDL_TMR_ENCODERMODE(TMR_EncoderInitStruct->EncoderMode));
459 ASSERT_PARAM(IS_DDL_TMR_ACTIVEINPUT(TMR_EncoderInitStruct->IC1ActiveInput));
460 ASSERT_PARAM(IS_DDL_TMR_ICPSC(TMR_EncoderInitStruct->IC1Prescaler));
461 ASSERT_PARAM(IS_DDL_TMR_IC_FILTER(TMR_EncoderInitStruct->IC1Filter));
463 ASSERT_PARAM(IS_DDL_TMR_ACTIVEINPUT(TMR_EncoderInitStruct->IC2ActiveInput));
464 ASSERT_PARAM(IS_DDL_TMR_ICPSC(TMR_EncoderInitStruct->IC2Prescaler));
465 ASSERT_PARAM(IS_DDL_TMR_IC_FILTER(TMR_EncoderInitStruct->IC2Filter));
466
467 /* Disable the CC1 and CC2: Reset the CC1EN and CC2EN Bits */
468 TMRx->CCEN &= (uint32_t)~(TMR_CCEN_CC1EN | TMR_CCEN_CC2EN);
469
470 /* Get the TMRx CCM1 register value */
471 tmpccmr1 = DDL_TMR_ReadReg(TMRx, CCM1);
472
473 /* Get the TMRx CCEN register value */
474 tmpccer = DDL_TMR_ReadReg(TMRx, CCEN);
475
476 /* Configure TI1 */
477 tmpccmr1 &= (uint32_t)~(TMR_CCM1_CC1SEL | TMR_CCM1_IC1F | TMR_CCM1_IC1PSC);
478 tmpccmr1 |= (uint32_t)(TMR_EncoderInitStruct->IC1ActiveInput);
479 tmpccmr1 |= (uint32_t)(TMR_EncoderInitStruct->IC1Filter);
480 tmpccmr1 |= (uint32_t)(TMR_EncoderInitStruct->IC1Prescaler);
481
482 /* Configure TI2 */
483 tmpccmr1 &= (uint32_t)~(TMR_CCM1_CC2SEL | TMR_CCM1_IC2F | TMR_CCM1_IC2PSC);
484 tmpccmr1 |= (uint32_t)(TMR_EncoderInitStruct->IC2ActiveInput << 8U);
485 tmpccmr1 |= (uint32_t)(TMR_EncoderInitStruct->IC2Filter << 8U);
486 tmpccmr1 |= (uint32_t)(TMR_EncoderInitStruct->IC2Prescaler << 8U);
487
488 /* Set TI1 and TI2 polarity and enable TI1 and TI2 */
489 tmpccer &= (uint32_t)~(TMR_CCEN_CC1POL | TMR_CCEN_CC1NPOL | TMR_CCEN_CC2POL | TMR_CCEN_CC2NPOL);
490 tmpccer |= (uint32_t)(TMR_EncoderInitStruct->IC1Polarity);
491 tmpccer |= (uint32_t)(TMR_EncoderInitStruct->IC2Polarity << 4U);
492 tmpccer |= (uint32_t)(TMR_CCEN_CC1EN | TMR_CCEN_CC2EN);
493
494 /* Set encoder mode */
495 DDL_TMR_SetEncoderMode(TMRx, TMR_EncoderInitStruct->EncoderMode);
496
497 /* Write to TMRx CCM1 */
498 DDL_TMR_WriteReg(TMRx, CCM1, tmpccmr1);
499
500 /* Write to TMRx CCEN */
501 DDL_TMR_WriteReg(TMRx, CCEN, tmpccer);
502
503 return SUCCESS;
504}
505
514{
515 /* Set the default configuration */
516 TMR_HallSensorInitStruct->IC1Polarity = DDL_TMR_IC_POLARITY_RISING;
517 TMR_HallSensorInitStruct->IC1Prescaler = DDL_TMR_ICPSC_DIV1;
518 TMR_HallSensorInitStruct->IC1Filter = DDL_TMR_IC_FILTER_FDIV1;
519 TMR_HallSensorInitStruct->CommutationDelay = 0U;
520}
521
543ErrorStatus DDL_TMR_HALLSENSOR_Init(TMR_TypeDef *TMRx, DDL_TMR_HALLSENSOR_InitTypeDef *TMR_HallSensorInitStruct)
544{
545 uint32_t tmpcr2;
546 uint32_t tmpccmr1;
547 uint32_t tmpccer;
548 uint32_t tmpsmcr;
549
550 /* Check the parameters */
551 ASSERT_PARAM(IS_TMR_HALL_SENSOR_INTERFACE_INSTANCE(TMRx));
552 ASSERT_PARAM(IS_DDL_TMR_IC_POLARITY_ENCODER(TMR_HallSensorInitStruct->IC1Polarity));
553 ASSERT_PARAM(IS_DDL_TMR_ICPSC(TMR_HallSensorInitStruct->IC1Prescaler));
554 ASSERT_PARAM(IS_DDL_TMR_IC_FILTER(TMR_HallSensorInitStruct->IC1Filter));
555
556 /* Disable the CC1 and CC2: Reset the CC1E and CC2E Bits */
557 TMRx->CCEN &= (uint32_t)~(TMR_CCEN_CC1EN | TMR_CCEN_CC2EN);
558
559 /* Get the TMRx CTRL2 register value */
560 tmpcr2 = DDL_TMR_ReadReg(TMRx, CTRL2);
561
562 /* Get the TMRx CCM1 register value */
563 tmpccmr1 = DDL_TMR_ReadReg(TMRx, CCM1);
564
565 /* Get the TMRx CCEN register value */
566 tmpccer = DDL_TMR_ReadReg(TMRx, CCEN);
567
568 /* Get the TMRx SMCTRL register value */
569 tmpsmcr = DDL_TMR_ReadReg(TMRx, SMCTRL);
570
571 /* Connect TMRx_CH1, CH2 and CH3 pins to the TI1 input */
572 tmpcr2 |= TMR_CTRL2_TI1SEL;
573
574 /* OC2REF signal is used as trigger output (TRGO) */
575 tmpcr2 |= DDL_TMR_TRGO_OC2REF;
576
577 /* Configure the slave mode controller */
578 tmpsmcr &= (uint32_t)~(TMR_SMCTRL_TRGSEL | TMR_SMCTRL_SMFSEL);
579 tmpsmcr |= DDL_TMR_TS_TI1F_ED;
580 tmpsmcr |= DDL_TMR_SLAVEMODE_RESET;
581
582 /* Configure input channel 1 */
583 tmpccmr1 &= (uint32_t)~(TMR_CCM1_CC1SEL | TMR_CCM1_IC1F | TMR_CCM1_IC1PSC);
584 tmpccmr1 |= (uint32_t)(DDL_TMR_ACTIVEINPUT_TRC >> 16U);
585 tmpccmr1 |= (uint32_t)(TMR_HallSensorInitStruct->IC1Filter >> 16U);
586 tmpccmr1 |= (uint32_t)(TMR_HallSensorInitStruct->IC1Prescaler >> 16U);
587
588 /* Configure input channel 2 */
589 tmpccmr1 &= (uint32_t)~(TMR_CCM1_OC2MOD | TMR_CCM1_OC2FEN | TMR_CCM1_OC2PEN | TMR_CCM1_OC2CEN);
590 tmpccmr1 |= (uint32_t)(DDL_TMR_OCMODE_PWM2 << 8U);
591
592 /* Set Channel 1 polarity and enable Channel 1 and Channel2 */
593 tmpccer &= (uint32_t)~(TMR_CCEN_CC1POL | TMR_CCEN_CC1NPOL | TMR_CCEN_CC2POL | TMR_CCEN_CC2NPOL);
594 tmpccer |= (uint32_t)(TMR_HallSensorInitStruct->IC1Polarity);
595 tmpccer |= (uint32_t)(TMR_CCEN_CC1EN | TMR_CCEN_CC2EN);
596
597 /* Write to TMRx CTRL2 */
598 DDL_TMR_WriteReg(TMRx, CTRL2, tmpcr2);
599
600 /* Write to TMRx SMCTRL */
601 DDL_TMR_WriteReg(TMRx, SMCTRL, tmpsmcr);
602
603 /* Write to TMRx CCM1 */
604 DDL_TMR_WriteReg(TMRx, CCM1, tmpccmr1);
605
606 /* Write to TMRx CCEN */
607 DDL_TMR_WriteReg(TMRx, CCEN, tmpccer);
608
609 /* Write to TMRx CC2 */
610 DDL_TMR_OC_SetCompareCH2(TMRx, TMR_HallSensorInitStruct->CommutationDelay);
611
612 return SUCCESS;
613}
614
623{
624 /* Set the default configuration */
625 TMR_BDTInitStruct->OSSRState = DDL_TMR_OSSR_DISABLE;
626 TMR_BDTInitStruct->OSSIState = DDL_TMR_OSSI_DISABLE;
627 TMR_BDTInitStruct->LockLevel = DDL_TMR_LOCKLEVEL_OFF;
628 TMR_BDTInitStruct->DeadTime = (uint8_t)0x00;
629 TMR_BDTInitStruct->BreakState = DDL_TMR_BREAK_DISABLE;
630 TMR_BDTInitStruct->BreakPolarity = DDL_TMR_BREAK_POLARITY_LOW;
632}
633
648ErrorStatus DDL_TMR_BDT_Init(TMR_TypeDef *TMRx, DDL_TMR_BDT_InitTypeDef *TMR_BDTInitStruct)
649{
650 uint32_t tmpbdtr = 0;
651
652 /* Check the parameters */
653 ASSERT_PARAM(IS_TMR_BREAK_INSTANCE(TMRx));
654 ASSERT_PARAM(IS_DDL_TMR_OSSR_STATE(TMR_BDTInitStruct->OSSRState));
655 ASSERT_PARAM(IS_DDL_TMR_OSSI_STATE(TMR_BDTInitStruct->OSSIState));
656 ASSERT_PARAM(IS_DDL_TMR_LOCK_LEVEL(TMR_BDTInitStruct->LockLevel));
660
661 /* Set the Lock level, the Break enable Bit and the Polarity, the OSSR State,
662 the OSSI State, the dead time value and the Automatic Output Enable Bit */
663
664 /* Set the BDT bits */
665 MODIFY_REG(tmpbdtr, TMR_BDT_DTS, TMR_BDTInitStruct->DeadTime);
666 MODIFY_REG(tmpbdtr, TMR_BDT_LOCKCFG, TMR_BDTInitStruct->LockLevel);
667 MODIFY_REG(tmpbdtr, TMR_BDT_IMOS, TMR_BDTInitStruct->OSSIState);
668 MODIFY_REG(tmpbdtr, TMR_BDT_RMOS, TMR_BDTInitStruct->OSSRState);
669 MODIFY_REG(tmpbdtr, TMR_BDT_BRKEN, TMR_BDTInitStruct->BreakState);
670 MODIFY_REG(tmpbdtr, TMR_BDT_BRKPOL, TMR_BDTInitStruct->BreakPolarity);
671 MODIFY_REG(tmpbdtr, TMR_BDT_AOEN, TMR_BDTInitStruct->AutomaticOutput);
672 MODIFY_REG(tmpbdtr, TMR_BDT_MOEN, TMR_BDTInitStruct->AutomaticOutput);
673
674 /* Set TMRx_BDT */
675 DDL_TMR_WriteReg(TMRx, BDT, tmpbdtr);
676
677 return SUCCESS;
678}
679
682
686
699static ErrorStatus OC1Config(TMR_TypeDef *TMRx, DDL_TMR_OC_InitTypeDef *TMR_OCInitStruct)
700{
701 uint32_t tmpccmr1;
702 uint32_t tmpccer;
703 uint32_t tmpcr2;
704
705 /* Check the parameters */
706 ASSERT_PARAM(IS_TMR_CC1_INSTANCE(TMRx));
707 ASSERT_PARAM(IS_DDL_TMR_OCMODE(TMR_OCInitStruct->OCMode));
708 ASSERT_PARAM(IS_DDL_TMR_OCSTATE(TMR_OCInitStruct->OCState));
710 ASSERT_PARAM(IS_DDL_TMR_OCSTATE(TMR_OCInitStruct->OCNState));
712
713 /* Disable the Channel 1: Reset the CC1E Bit */
714 CLEAR_BIT(TMRx->CCEN, TMR_CCEN_CC1EN);
715
716 /* Get the TMRx CCEN register value */
717 tmpccer = DDL_TMR_ReadReg(TMRx, CCEN);
718
719 /* Get the TMRx CTRL2 register value */
720 tmpcr2 = DDL_TMR_ReadReg(TMRx, CTRL2);
721
722 /* Get the TMRx CCM1 register value */
723 tmpccmr1 = DDL_TMR_ReadReg(TMRx, CCM1);
724
725 /* Reset Capture/Compare selection Bits */
726 CLEAR_BIT(tmpccmr1, TMR_CCM1_CC1SEL);
727
728 /* Set the Output Compare Mode */
729 MODIFY_REG(tmpccmr1, TMR_CCM1_OC1MOD, TMR_OCInitStruct->OCMode);
730
731 /* Set the Output Compare Polarity */
732 MODIFY_REG(tmpccer, TMR_CCEN_CC1POL, TMR_OCInitStruct->OCPolarity);
733
734 /* Set the Output State */
735 MODIFY_REG(tmpccer, TMR_CCEN_CC1EN, TMR_OCInitStruct->OCState);
736
737 if (IS_TMR_BREAK_INSTANCE(TMRx))
738 {
741
742 /* Set the complementary output Polarity */
743 MODIFY_REG(tmpccer, TMR_CCEN_CC1NPOL, TMR_OCInitStruct->OCNPolarity << 2U);
744
745 /* Set the complementary output State */
746 MODIFY_REG(tmpccer, TMR_CCEN_CC1NEN, TMR_OCInitStruct->OCNState << 2U);
747
748 /* Set the Output Idle state */
749 MODIFY_REG(tmpcr2, TMR_CTRL2_OC1OIS, TMR_OCInitStruct->OCIdleState);
750
751 /* Set the complementary output Idle state */
752 MODIFY_REG(tmpcr2, TMR_CTRL2_OC1NOIS, TMR_OCInitStruct->OCNIdleState << 1U);
753 }
754
755 /* Write to TMRx CTRL2 */
756 DDL_TMR_WriteReg(TMRx, CTRL2, tmpcr2);
757
758 /* Write to TMRx CCM1 */
759 DDL_TMR_WriteReg(TMRx, CCM1, tmpccmr1);
760
761 /* Set the Capture Compare Register value */
762 DDL_TMR_OC_SetCompareCH1(TMRx, TMR_OCInitStruct->CompareValue);
763
764 /* Write to TMRx CCEN */
765 DDL_TMR_WriteReg(TMRx, CCEN, tmpccer);
766
767 return SUCCESS;
768}
769
778static ErrorStatus OC2Config(TMR_TypeDef *TMRx, DDL_TMR_OC_InitTypeDef *TMR_OCInitStruct)
779{
780 uint32_t tmpccmr1;
781 uint32_t tmpccer;
782 uint32_t tmpcr2;
783
784 /* Check the parameters */
785 ASSERT_PARAM(IS_TMR_CC2_INSTANCE(TMRx));
786 ASSERT_PARAM(IS_DDL_TMR_OCMODE(TMR_OCInitStruct->OCMode));
787 ASSERT_PARAM(IS_DDL_TMR_OCSTATE(TMR_OCInitStruct->OCState));
789 ASSERT_PARAM(IS_DDL_TMR_OCSTATE(TMR_OCInitStruct->OCNState));
791
792 /* Disable the Channel 2: Reset the CC2E Bit */
793 CLEAR_BIT(TMRx->CCEN, TMR_CCEN_CC2EN);
794
795 /* Get the TMRx CCEN register value */
796 tmpccer = DDL_TMR_ReadReg(TMRx, CCEN);
797
798 /* Get the TMRx CTRL2 register value */
799 tmpcr2 = DDL_TMR_ReadReg(TMRx, CTRL2);
800
801 /* Get the TMRx CCM1 register value */
802 tmpccmr1 = DDL_TMR_ReadReg(TMRx, CCM1);
803
804 /* Reset Capture/Compare selection Bits */
805 CLEAR_BIT(tmpccmr1, TMR_CCM1_CC2SEL);
806
807 /* Select the Output Compare Mode */
808 MODIFY_REG(tmpccmr1, TMR_CCM1_OC2MOD, TMR_OCInitStruct->OCMode << 8U);
809
810 /* Set the Output Compare Polarity */
811 MODIFY_REG(tmpccer, TMR_CCEN_CC2POL, TMR_OCInitStruct->OCPolarity << 4U);
812
813 /* Set the Output State */
814 MODIFY_REG(tmpccer, TMR_CCEN_CC2EN, TMR_OCInitStruct->OCState << 4U);
815
816 if (IS_TMR_BREAK_INSTANCE(TMRx))
817 {
820
821 /* Set the complementary output Polarity */
822 MODIFY_REG(tmpccer, TMR_CCEN_CC2NPOL, TMR_OCInitStruct->OCNPolarity << 6U);
823
824 /* Set the complementary output State */
825 MODIFY_REG(tmpccer, TMR_CCEN_CC2NEN, TMR_OCInitStruct->OCNState << 6U);
826
827 /* Set the Output Idle state */
828 MODIFY_REG(tmpcr2, TMR_CTRL2_OC2OIS, TMR_OCInitStruct->OCIdleState << 2U);
829
830 /* Set the complementary output Idle state */
831 MODIFY_REG(tmpcr2, TMR_CTRL2_OC2NOIS, TMR_OCInitStruct->OCNIdleState << 3U);
832 }
833
834 /* Write to TMRx CTRL2 */
835 DDL_TMR_WriteReg(TMRx, CTRL2, tmpcr2);
836
837 /* Write to TMRx CCM1 */
838 DDL_TMR_WriteReg(TMRx, CCM1, tmpccmr1);
839
840 /* Set the Capture Compare Register value */
841 DDL_TMR_OC_SetCompareCH2(TMRx, TMR_OCInitStruct->CompareValue);
842
843 /* Write to TMRx CCEN */
844 DDL_TMR_WriteReg(TMRx, CCEN, tmpccer);
845
846 return SUCCESS;
847}
848
857static ErrorStatus OC3Config(TMR_TypeDef *TMRx, DDL_TMR_OC_InitTypeDef *TMR_OCInitStruct)
858{
859 uint32_t tmpccmr2;
860 uint32_t tmpccer;
861 uint32_t tmpcr2;
862
863 /* Check the parameters */
864 ASSERT_PARAM(IS_TMR_CC3_INSTANCE(TMRx));
865 ASSERT_PARAM(IS_DDL_TMR_OCMODE(TMR_OCInitStruct->OCMode));
866 ASSERT_PARAM(IS_DDL_TMR_OCSTATE(TMR_OCInitStruct->OCState));
868 ASSERT_PARAM(IS_DDL_TMR_OCSTATE(TMR_OCInitStruct->OCNState));
870
871 /* Disable the Channel 3: Reset the CC3E Bit */
872 CLEAR_BIT(TMRx->CCEN, TMR_CCEN_CC3EN);
873
874 /* Get the TMRx CCEN register value */
875 tmpccer = DDL_TMR_ReadReg(TMRx, CCEN);
876
877 /* Get the TMRx CTRL2 register value */
878 tmpcr2 = DDL_TMR_ReadReg(TMRx, CTRL2);
879
880 /* Get the TMRx CCM2 register value */
881 tmpccmr2 = DDL_TMR_ReadReg(TMRx, CCM2);
882
883 /* Reset Capture/Compare selection Bits */
884 CLEAR_BIT(tmpccmr2, TMR_CCM2_CC3SEL);
885
886 /* Select the Output Compare Mode */
887 MODIFY_REG(tmpccmr2, TMR_CCM2_OC3MOD, TMR_OCInitStruct->OCMode);
888
889 /* Set the Output Compare Polarity */
890 MODIFY_REG(tmpccer, TMR_CCEN_CC3POL, TMR_OCInitStruct->OCPolarity << 8U);
891
892 /* Set the Output State */
893 MODIFY_REG(tmpccer, TMR_CCEN_CC3EN, TMR_OCInitStruct->OCState << 8U);
894
895 if (IS_TMR_BREAK_INSTANCE(TMRx))
896 {
899
900 /* Set the complementary output Polarity */
901 MODIFY_REG(tmpccer, TMR_CCEN_CC3NPOL, TMR_OCInitStruct->OCNPolarity << 10U);
902
903 /* Set the complementary output State */
904 MODIFY_REG(tmpccer, TMR_CCEN_CC3NEN, TMR_OCInitStruct->OCNState << 10U);
905
906 /* Set the Output Idle state */
907 MODIFY_REG(tmpcr2, TMR_CTRL2_OC3OIS, TMR_OCInitStruct->OCIdleState << 4U);
908
909 /* Set the complementary output Idle state */
910 MODIFY_REG(tmpcr2, TMR_CTRL2_OC3NOIS, TMR_OCInitStruct->OCNIdleState << 5U);
911 }
912
913 /* Write to TMRx CTRL2 */
914 DDL_TMR_WriteReg(TMRx, CTRL2, tmpcr2);
915
916 /* Write to TMRx CCM2 */
917 DDL_TMR_WriteReg(TMRx, CCM2, tmpccmr2);
918
919 /* Set the Capture Compare Register value */
920 DDL_TMR_OC_SetCompareCH3(TMRx, TMR_OCInitStruct->CompareValue);
921
922 /* Write to TMRx CCEN */
923 DDL_TMR_WriteReg(TMRx, CCEN, tmpccer);
924
925 return SUCCESS;
926}
927
936static ErrorStatus OC4Config(TMR_TypeDef *TMRx, DDL_TMR_OC_InitTypeDef *TMR_OCInitStruct)
937{
938 uint32_t tmpccmr2;
939 uint32_t tmpccer;
940 uint32_t tmpcr2;
941
942 /* Check the parameters */
943 ASSERT_PARAM(IS_TMR_CC4_INSTANCE(TMRx));
944 ASSERT_PARAM(IS_DDL_TMR_OCMODE(TMR_OCInitStruct->OCMode));
945 ASSERT_PARAM(IS_DDL_TMR_OCSTATE(TMR_OCInitStruct->OCState));
948 ASSERT_PARAM(IS_DDL_TMR_OCSTATE(TMR_OCInitStruct->OCNState));
949
950 /* Disable the Channel 4: Reset the CC4E Bit */
951 CLEAR_BIT(TMRx->CCEN, TMR_CCEN_CC4EN);
952
953 /* Get the TMRx CCEN register value */
954 tmpccer = DDL_TMR_ReadReg(TMRx, CCEN);
955
956 /* Get the TMRx CTRL2 register value */
957 tmpcr2 = DDL_TMR_ReadReg(TMRx, CTRL2);
958
959 /* Get the TMRx CCM2 register value */
960 tmpccmr2 = DDL_TMR_ReadReg(TMRx, CCM2);
961
962 /* Reset Capture/Compare selection Bits */
963 CLEAR_BIT(tmpccmr2, TMR_CCM2_CC4SEL);
964
965 /* Select the Output Compare Mode */
966 MODIFY_REG(tmpccmr2, TMR_CCM2_OC4MOD, TMR_OCInitStruct->OCMode << 8U);
967
968 /* Set the Output Compare Polarity */
969 MODIFY_REG(tmpccer, TMR_CCEN_CC4POL, TMR_OCInitStruct->OCPolarity << 12U);
970
971 /* Set the Output State */
972 MODIFY_REG(tmpccer, TMR_CCEN_CC4EN, TMR_OCInitStruct->OCState << 12U);
973
974 if (IS_TMR_BREAK_INSTANCE(TMRx))
975 {
978
979 /* Set the Output Idle state */
980 MODIFY_REG(tmpcr2, TMR_CTRL2_OC4OIS, TMR_OCInitStruct->OCIdleState << 6U);
981 }
982
983 /* Write to TMRx CTRL2 */
984 DDL_TMR_WriteReg(TMRx, CTRL2, tmpcr2);
985
986 /* Write to TMRx CCM2 */
987 DDL_TMR_WriteReg(TMRx, CCM2, tmpccmr2);
988
989 /* Set the Capture Compare Register value */
990 DDL_TMR_OC_SetCompareCH4(TMRx, TMR_OCInitStruct->CompareValue);
991
992 /* Write to TMRx CCEN */
993 DDL_TMR_WriteReg(TMRx, CCEN , tmpccer);
994
995 return SUCCESS;
996}
997
998
1007static ErrorStatus IC1Config(TMR_TypeDef *TMRx, DDL_TMR_IC_InitTypeDef *TMR_ICInitStruct)
1008{
1009 /* Check the parameters */
1010 ASSERT_PARAM(IS_TMR_CC1_INSTANCE(TMRx));
1013 ASSERT_PARAM(IS_DDL_TMR_ICPSC(TMR_ICInitStruct->ICPrescaler));
1014 ASSERT_PARAM(IS_DDL_TMR_IC_FILTER(TMR_ICInitStruct->ICFilter));
1015
1016 /* Disable the Channel 1: Reset the CC1E Bit */
1017 TMRx->CCEN &= (uint32_t)~TMR_CCEN_CC1EN;
1018
1019 /* Select the Input and set the filter and the prescaler value */
1020 MODIFY_REG(TMRx->CCM1,
1021 (TMR_CCM1_CC1SEL | TMR_CCM1_IC1F | TMR_CCM1_IC1PSC),
1022 (TMR_ICInitStruct->ICActiveInput | TMR_ICInitStruct->ICFilter | TMR_ICInitStruct->ICPrescaler));
1023
1024 /* Select the Polarity and set the CC1E Bit */
1025 MODIFY_REG(TMRx->CCEN,
1026 (TMR_CCEN_CC1POL | TMR_CCEN_CC1NPOL),
1027 (TMR_ICInitStruct->ICPolarity | TMR_CCEN_CC1EN));
1028
1029 return SUCCESS;
1030}
1031
1040static ErrorStatus IC2Config(TMR_TypeDef *TMRx, DDL_TMR_IC_InitTypeDef *TMR_ICInitStruct)
1041{
1042 /* Check the parameters */
1043 ASSERT_PARAM(IS_TMR_CC2_INSTANCE(TMRx));
1046 ASSERT_PARAM(IS_DDL_TMR_ICPSC(TMR_ICInitStruct->ICPrescaler));
1047 ASSERT_PARAM(IS_DDL_TMR_IC_FILTER(TMR_ICInitStruct->ICFilter));
1048
1049 /* Disable the Channel 2: Reset the CC2E Bit */
1050 TMRx->CCEN &= (uint32_t)~TMR_CCEN_CC2EN;
1051
1052 /* Select the Input and set the filter and the prescaler value */
1053 MODIFY_REG(TMRx->CCM1,
1054 (TMR_CCM1_CC2SEL | TMR_CCM1_IC2F | TMR_CCM1_IC2PSC),
1055 (TMR_ICInitStruct->ICActiveInput | TMR_ICInitStruct->ICFilter | TMR_ICInitStruct->ICPrescaler) << 8);
1056
1057 /* Select the Polarity and set the CC2E Bit */
1058 MODIFY_REG(TMRx->CCEN,
1059 (TMR_CCEN_CC2POL | TMR_CCEN_CC2NPOL),
1060 ((TMR_ICInitStruct->ICPolarity << 4U) | TMR_CCEN_CC2EN));
1061
1062 return SUCCESS;
1063}
1064
1073static ErrorStatus IC3Config(TMR_TypeDef *TMRx, DDL_TMR_IC_InitTypeDef *TMR_ICInitStruct)
1074{
1075 /* Check the parameters */
1076 ASSERT_PARAM(IS_TMR_CC3_INSTANCE(TMRx));
1079 ASSERT_PARAM(IS_DDL_TMR_ICPSC(TMR_ICInitStruct->ICPrescaler));
1080 ASSERT_PARAM(IS_DDL_TMR_IC_FILTER(TMR_ICInitStruct->ICFilter));
1081
1082 /* Disable the Channel 3: Reset the CC3E Bit */
1083 TMRx->CCEN &= (uint32_t)~TMR_CCEN_CC3EN;
1084
1085 /* Select the Input and set the filter and the prescaler value */
1086 MODIFY_REG(TMRx->CCM2,
1087 (TMR_CCM2_CC3SEL | TMR_CCM2_IC3F | TMR_CCM2_IC3PSC),
1088 (TMR_ICInitStruct->ICActiveInput | TMR_ICInitStruct->ICFilter | TMR_ICInitStruct->ICPrescaler));
1089
1090 /* Select the Polarity and set the CC3E Bit */
1091 MODIFY_REG(TMRx->CCEN,
1092 (TMR_CCEN_CC3POL | TMR_CCEN_CC3NPOL),
1093 ((TMR_ICInitStruct->ICPolarity << 8U) | TMR_CCEN_CC3EN));
1094
1095 return SUCCESS;
1096}
1097
1106static ErrorStatus IC4Config(TMR_TypeDef *TMRx, DDL_TMR_IC_InitTypeDef *TMR_ICInitStruct)
1107{
1108 /* Check the parameters */
1109 ASSERT_PARAM(IS_TMR_CC4_INSTANCE(TMRx));
1112 ASSERT_PARAM(IS_DDL_TMR_ICPSC(TMR_ICInitStruct->ICPrescaler));
1113 ASSERT_PARAM(IS_DDL_TMR_IC_FILTER(TMR_ICInitStruct->ICFilter));
1114
1115 /* Disable the Channel 4: Reset the CC4E Bit */
1116 TMRx->CCEN &= (uint32_t)~TMR_CCEN_CC4EN;
1117
1118 /* Select the Input and set the filter and the prescaler value */
1119 MODIFY_REG(TMRx->CCM2,
1120 (TMR_CCM2_CC4SEL | TMR_CCM2_IC4F | TMR_CCM2_IC4PSC),
1121 (TMR_ICInitStruct->ICActiveInput | TMR_ICInitStruct->ICFilter | TMR_ICInitStruct->ICPrescaler) << 8U);
1122
1123 /* Select the Polarity and set the CC4E Bit */
1124 MODIFY_REG(TMRx->CCEN,
1125 (TMR_CCEN_CC4POL),
1126 ((TMR_ICInitStruct->ICPolarity << 12U) | TMR_CCEN_CC4EN));
1127
1128 return SUCCESS;
1129}
1130
1131
1135
1139
1140#endif /* TMR1 || TMR2 || TMR3 || TMR4 */
1141
1145
1146#endif /* USE_FULL_DDL_DRIVER */
1147
G32 assert template file. This file should be copied to the application folder and renamed to g32_ass...
#define ASSERT_PARAM(_PARAM_)
Definition g32_assert.h:58
Header file of RCM DDL module.
Header file of TMR DDL module.
#define DDL_RCM_APB_RESET_TMR2
#define DDL_RCM_APB_RESET_TMR3
#define DDL_RCM_APB_RESET_TMR4
#define DDL_RCM_APB_RESET_TMR1
__STATIC_INLINE void DDL_RCM_Unlock(void)
Unlock the RCM register.
__STATIC_INLINE void DDL_RCM_EnableAPBReset(uint32_t Peripheral)
Enable the APB peripheral reset.
__STATIC_INLINE void DDL_RCM_DisableAPBReset(uint32_t Peripheral)
Disable the APB peripheral reset.
#define DDL_TMR_ACTIVEINPUT_TRC
#define DDL_TMR_ACTIVEINPUT_DIRECTTI
#define DDL_TMR_AUTOMATICOUTPUT_DISABLE
#define DDL_TMR_BREAK_DISABLE
#define DDL_TMR_BREAK_POLARITY_LOW
#define DDL_TMR_CHANNEL_CH1
#define DDL_TMR_CHANNEL_CH2
#define DDL_TMR_CHANNEL_CH3
#define DDL_TMR_CHANNEL_CH4
#define DDL_TMR_CLOCKDIVISION_DIV1
#define DDL_TMR_COUNTERMODE_UP
#define DDL_TMR_ENCODERMODE_X2_TI1
#define DDL_TMR_ICPSC_DIV1
#define DDL_TMR_IC_FILTER_FDIV1
#define DDL_TMR_IC_POLARITY_RISING
#define DDL_TMR_LOCKLEVEL_OFF
#define DDL_TMR_OCIDLESTATE_LOW
#define DDL_TMR_OCMODE_PWM2
#define DDL_TMR_OCMODE_FROZEN
#define DDL_TMR_OCPOLARITY_HIGH
#define DDL_TMR_OCSTATE_DISABLE
#define DDL_TMR_OSSI_DISABLE
#define DDL_TMR_OSSR_DISABLE
#define DDL_TMR_SLAVEMODE_RESET
#define DDL_TMR_TRGO_OC2REF
#define DDL_TMR_TS_TI1F_ED
__STATIC_INLINE void DDL_TMR_SetEncoderMode(TMR_TypeDef *TMRx, uint32_t EncoderMode)
Set the encoder interface mode.
__STATIC_INLINE void DDL_TMR_GenerateEvent_UPDATE(TMR_TypeDef *TMRx)
Generate an update event.
void DDL_TMR_StructInit(DDL_TMR_InitTypeDef *TMR_InitStruct)
Set the fields of the time base unit configuration data structure to their default values.
ErrorStatus DDL_TMR_Init(TMR_TypeDef *TMRx, DDL_TMR_InitTypeDef *TMR_InitStruct)
Configure the TMRx time base unit.
ErrorStatus DDL_TMR_BDT_Init(TMR_TypeDef *TMRx, DDL_TMR_BDT_InitTypeDef *TMR_BDTInitStruct)
Configure the Break and Dead Time feature of the timer instance.
void DDL_TMR_OC_StructInit(DDL_TMR_OC_InitTypeDef *TMR_OC_InitStruct)
Set the fields of the TMRx output channel configuration data structure to their default values.
ErrorStatus DDL_TMR_ENCODER_Init(TMR_TypeDef *TMRx, DDL_TMR_ENCODER_InitTypeDef *TMR_EncoderInitStruct)
Configure the encoder interface of the timer instance.
void DDL_TMR_HALLSENSOR_StructInit(DDL_TMR_HALLSENSOR_InitTypeDef *TMR_HallSensorInitStruct)
Set the fields of the TMRx Hall sensor interface configuration data structure to their default values...
void DDL_TMR_ENCODER_StructInit(DDL_TMR_ENCODER_InitTypeDef *TMR_EncoderInitStruct)
Fills each TMR_EncoderInitStruct field with its default value.
ErrorStatus DDL_TMR_OC_Init(TMR_TypeDef *TMRx, uint32_t Channel, DDL_TMR_OC_InitTypeDef *TMR_OC_InitStruct)
Configure the TMRx output channel.
void DDL_TMR_IC_StructInit(DDL_TMR_IC_InitTypeDef *TMR_ICInitStruct)
Set the fields of the TMRx input channel configuration data structure to their default values.
ErrorStatus DDL_TMR_HALLSENSOR_Init(TMR_TypeDef *TMRx, DDL_TMR_HALLSENSOR_InitTypeDef *TMR_HallSensorInitStruct)
Configure the Hall sensor interface of the timer instance.
ErrorStatus DDL_TMR_DeInit(TMR_TypeDef *TMRx)
Set TMRx registers to their reset values.
ErrorStatus DDL_TMR_IC_Init(TMR_TypeDef *TMRx, uint32_t Channel, DDL_TMR_IC_InitTypeDef *TMR_IC_InitStruct)
Configure the TMRx input channel.
void DDL_TMR_BDT_StructInit(DDL_TMR_BDT_InitTypeDef *TMR_BDTInitStruct)
Set the fields of the Break and Dead Time configuration data structure to their default values.
__STATIC_INLINE void DDL_TMR_OC_SetCompareCH2(TMR_TypeDef *TMRx, uint32_t CompareValue)
Set compare value for output channel 2 (TMRx_CC2).
__STATIC_INLINE void DDL_TMR_OC_SetCompareCH3(TMR_TypeDef *TMRx, uint32_t CompareValue)
Set compare value for output channel 3 (TMRx_CC3).
__STATIC_INLINE void DDL_TMR_OC_SetCompareCH1(TMR_TypeDef *TMRx, uint32_t CompareValue)
Set compare value for output channel 1 (TMRx_CC1).
__STATIC_INLINE void DDL_TMR_OC_SetCompareCH4(TMR_TypeDef *TMRx, uint32_t CompareValue)
Set compare value for output channel 4 (TMRx_CC4).
__STATIC_INLINE void DDL_TMR_SetAutoReload(TMR_TypeDef *TMRx, uint32_t AutoReload)
Set the auto-reload value.
__STATIC_INLINE void DDL_TMR_SetPrescaler(TMR_TypeDef *TMRx, uint32_t Prescaler)
Set the prescaler value.
__STATIC_INLINE void DDL_TMR_SetRepetitionCounter(TMR_TypeDef *TMRx, uint32_t RepetitionCounter)
Set the repetition counter value.
#define DDL_TMR_WriteReg(__INSTANCE__, __REG__, __VALUE__)
Write a value in TMR register.
#define DDL_TMR_ReadReg(__INSTANCE__, __REG__)
Read a value in TMR register.
static ErrorStatus OC4Config(TMR_TypeDef *TMRx, DDL_TMR_OC_InitTypeDef *TMR_OCInitStruct)
Configure the TMRx output channel 4.
static ErrorStatus IC4Config(TMR_TypeDef *TMRx, DDL_TMR_IC_InitTypeDef *TMR_ICInitStruct)
Configure the TMRx input channel 4.
static ErrorStatus OC2Config(TMR_TypeDef *TMRx, DDL_TMR_OC_InitTypeDef *TMR_OCInitStruct)
Configure the TMRx output channel 2.
static ErrorStatus IC1Config(TMR_TypeDef *TMRx, DDL_TMR_IC_InitTypeDef *TMR_ICInitStruct)
Configure the TMRx input channel 1.
static ErrorStatus OC1Config(TMR_TypeDef *TMRx, DDL_TMR_OC_InitTypeDef *TMR_OCInitStruct)
Configure the TMRx output channel 1.
static ErrorStatus IC2Config(TMR_TypeDef *TMRx, DDL_TMR_IC_InitTypeDef *TMR_ICInitStruct)
Configure the TMRx input channel 2.
static ErrorStatus IC3Config(TMR_TypeDef *TMRx, DDL_TMR_IC_InitTypeDef *TMR_ICInitStruct)
Configure the TMRx input channel 3.
static ErrorStatus OC3Config(TMR_TypeDef *TMRx, DDL_TMR_OC_InitTypeDef *TMR_OCInitStruct)
Configure the TMRx output channel 3.
#define IS_DDL_TMR_IC_POLARITY_ENCODER(__VALUE__)
#define IS_DDL_TMR_OCPOLARITY(__VALUE__)
#define IS_DDL_TMR_OCMODE(__VALUE__)
#define IS_DDL_TMR_BREAK_POLARITY(__VALUE__)
#define IS_DDL_TMR_OSSI_STATE(__VALUE__)
#define IS_DDL_TMR_BREAK_STATE(__VALUE__)
#define IS_DDL_TMR_ACTIVEINPUT(__VALUE__)
#define IS_DDL_TMR_IC_FILTER(__VALUE__)
#define IS_DDL_TMR_AUTOMATIC_OUTPUT_STATE(__VALUE__)
#define IS_DDL_TMR_ENCODERMODE(__VALUE__)
#define IS_DDL_TMR_OCSTATE(__VALUE__)
#define IS_DDL_TMR_CLOCKDIVISION(__VALUE__)
#define IS_DDL_TMR_IC_POLARITY(__VALUE__)
#define IS_DDL_TMR_COUNTERMODE(__VALUE__)
#define IS_DDL_TMR_OSSR_STATE(__VALUE__)
#define IS_DDL_TMR_OCIDLESTATE(__VALUE__)
#define IS_DDL_TMR_ICPSC(__VALUE__)
#define IS_DDL_TMR_LOCK_LEVEL(__VALUE__)
BDTR (Break and Dead Time) structure definition.
TMR Encoder interface configuration structure definition.
TMR Hall sensor interface configuration structure definition.
TMR Input Capture configuration structure definition.
TMR Time Base configuration structure definition.
TMR Output Compare configuration structure definition.