EE445M RTOS
Taken at the University of Texas Spring 2015
Qei_api

Functions

void QEIEnable (uint32_t ui32Base)
 
void QEIDisable (uint32_t ui32Base)
 
void QEIConfigure (uint32_t ui32Base, uint32_t ui32Config, uint32_t ui32MaxPosition)
 
uint32_t QEIPositionGet (uint32_t ui32Base)
 
void QEIPositionSet (uint32_t ui32Base, uint32_t ui32Position)
 
int32_t QEIDirectionGet (uint32_t ui32Base)
 
bool QEIErrorGet (uint32_t ui32Base)
 
void QEIVelocityEnable (uint32_t ui32Base)
 
void QEIVelocityDisable (uint32_t ui32Base)
 
void QEIVelocityConfigure (uint32_t ui32Base, uint32_t ui32PreDiv, uint32_t ui32Period)
 
uint32_t QEIVelocityGet (uint32_t ui32Base)
 
static uint32_t _QEIIntNumberGet (uint32_t ui32Base)
 
void QEIIntRegister (uint32_t ui32Base, void(*pfnHandler)(void))
 
void QEIIntUnregister (uint32_t ui32Base)
 
void QEIIntEnable (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void QEIIntDisable (uint32_t ui32Base, uint32_t ui32IntFlags)
 
uint32_t QEIIntStatus (uint32_t ui32Base, bool bMasked)
 
void QEIIntClear (uint32_t ui32Base, uint32_t ui32IntFlags)
 

Detailed Description

Function Documentation

static uint32_t _QEIIntNumberGet ( uint32_t  ui32Base)
static

Returns the quadrature encoder interrupt number.

Parameters
ui32Baseis the base address of the selected quadrature encoder

This function returns the interrupt number for the quadrature encoder with the base address passed in the ui32Base parameter.

Returns
Returns a quadrature encoder interrupt number or 0 if the interrupt does not exist.

Definition at line 419 of file qei.c.

References ASSERT, CLASS_IS_TM4C123, CLASS_IS_TM4C129, INT_QEI0_TM4C123, INT_QEI0_TM4C129, INT_QEI1_TM4C123, QEI0_BASE, and QEI1_BASE.

Referenced by QEIIntRegister(), and QEIIntUnregister().

420 {
421  uint32_t ui32Int;
422 
423  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
424 
425  //
426  // Find the valid interrupt number for this quadrature encoder.
427  //
428  if(CLASS_IS_TM4C123)
429  {
430  if(ui32Base == QEI0_BASE)
431  {
432  ui32Int = INT_QEI0_TM4C123;
433  }
434  else
435  {
436  ui32Int = INT_QEI1_TM4C123;
437  }
438  }
439  else if(CLASS_IS_TM4C129)
440  {
441  if(ui32Base == QEI0_BASE)
442  {
443  ui32Int = INT_QEI0_TM4C129;
444  }
445  else
446  {
447  ui32Int = 0;
448  }
449  }
450  else
451  {
452  ui32Int = 0;
453  }
454 
455  return(ui32Int);
456 }
#define QEI0_BASE
Definition: hw_memmap.h:79
#define ASSERT(expr)
Definition: debug.h:67
#define INT_QEI0_TM4C123
Definition: hw_ints.h:77
#define INT_QEI0_TM4C129
Definition: hw_ints.h:189
#define CLASS_IS_TM4C123
Definition: hw_types.h:93
#define QEI1_BASE
Definition: hw_memmap.h:80
#define INT_QEI1_TM4C123
Definition: hw_ints.h:103
#define CLASS_IS_TM4C129
Definition: hw_types.h:99

Here is the caller graph for this function:

void QEIConfigure ( uint32_t  ui32Base,
uint32_t  ui32Config,
uint32_t  ui32MaxPosition 
)

Configures the quadrature encoder.

Parameters
ui32Baseis the base address of the quadrature encoder module.
ui32Configis the configuration for the quadrature encoder. See below for a description of this parameter.
ui32MaxPositionspecifies the maximum position value.

This function configures the operation of the quadrature encoder. The ui32Config parameter provides the configuration of the encoder and is the logical OR of several values:

  • QEI_CONFIG_CAPTURE_A or QEI_CONFIG_CAPTURE_A_B specify if edges on channel A or on both channels A and B should be counted by the position integrator and velocity accumulator.
  • QEI_CONFIG_NO_RESET or QEI_CONFIG_RESET_IDX specify if the position integrator should be reset when the index pulse is detected.
  • QEI_CONFIG_QUADRATURE or QEI_CONFIG_CLOCK_DIR specify if quadrature signals are being provided on ChA and ChB, or if a direction signal and a clock are being provided instead.
  • QEI_CONFIG_NO_SWAP or QEI_CONFIG_SWAP to specify if the signals provided on ChA and ChB should be swapped before being processed.

ui32MaxPosition is the maximum value of the position integrator and is the value used to reset the position capture when in index reset mode and moving in the reverse (negative) direction.

Returns
None.

Definition at line 143 of file qei.c.

References ASSERT, HWREG, QEI0_BASE, QEI1_BASE, QEI_CTL_CAPMODE, QEI_CTL_RESMODE, QEI_CTL_SIGMODE, QEI_CTL_SWAP, QEI_O_CTL, and QEI_O_MAXPOS.

145 {
146  //
147  // Check the arguments.
148  //
149  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
150 
151  //
152  // Write the new configuration to the hardware.
153  //
154  HWREG(ui32Base + QEI_O_CTL) = ((HWREG(ui32Base + QEI_O_CTL) &
157  ui32Config);
158 
159  //
160  // Set the maximum position.
161  //
162  HWREG(ui32Base + QEI_O_MAXPOS) = ui32MaxPosition;
163 }
#define QEI0_BASE
Definition: hw_memmap.h:79
#define HWREG(x)
Definition: hw_types.h:48
#define QEI_O_CTL
Definition: hw_qei.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define QEI_CTL_SIGMODE
Definition: hw_qei.h:83
#define QEI_O_MAXPOS
Definition: hw_qei.h:51
#define QEI1_BASE
Definition: hw_memmap.h:80
#define QEI_CTL_SWAP
Definition: hw_qei.h:84
#define QEI_CTL_CAPMODE
Definition: hw_qei.h:82
#define QEI_CTL_RESMODE
Definition: hw_qei.h:81
int32_t QEIDirectionGet ( uint32_t  ui32Base)

Gets the current direction of rotation.

Parameters
ui32Baseis the base address of the quadrature encoder module.

This function returns the current direction of rotation. In this case, current means the most recently detected direction of the encoder; it may not be presently moving but this is the direction it last moved before it stopped.

Returns
Returns 1 if moving in the forward direction or -1 if moving in the reverse direction.

Definition at line 237 of file qei.c.

References ASSERT, HWREG, QEI0_BASE, QEI1_BASE, QEI_O_STAT, and QEI_STAT_DIRECTION.

238 {
239  //
240  // Check the arguments.
241  //
242  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
243 
244  //
245  // Return the direction of rotation.
246  //
247  return((HWREG(ui32Base + QEI_O_STAT) & QEI_STAT_DIRECTION) ? -1 : 1);
248 }
#define QEI_O_STAT
Definition: hw_qei.h:49
#define QEI0_BASE
Definition: hw_memmap.h:79
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define QEI1_BASE
Definition: hw_memmap.h:80
#define QEI_STAT_DIRECTION
Definition: hw_qei.h:93
void QEIDisable ( uint32_t  ui32Base)

Disables the quadrature encoder.

Parameters
ui32Baseis the base address of the quadrature encoder module.

This function disables operation of the quadrature encoder module.

Returns
None.

Definition at line 98 of file qei.c.

References ASSERT, HWREG, QEI0_BASE, QEI1_BASE, QEI_CTL_ENABLE, and QEI_O_CTL.

99 {
100  //
101  // Check the arguments.
102  //
103  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
104 
105  //
106  // Disable the QEI module.
107  //
108  HWREG(ui32Base + QEI_O_CTL) &= ~(QEI_CTL_ENABLE);
109 }
#define QEI0_BASE
Definition: hw_memmap.h:79
#define HWREG(x)
Definition: hw_types.h:48
#define QEI_O_CTL
Definition: hw_qei.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define QEI_CTL_ENABLE
Definition: hw_qei.h:85
#define QEI1_BASE
Definition: hw_memmap.h:80
void QEIEnable ( uint32_t  ui32Base)

Enables the quadrature encoder.

Parameters
ui32Baseis the base address of the quadrature encoder module.

This function enables operation of the quadrature encoder module. The module must be configured before it is enabled.

See also
QEIConfigure()
Returns
None.

Definition at line 73 of file qei.c.

References ASSERT, HWREG, QEI0_BASE, QEI1_BASE, QEI_CTL_ENABLE, and QEI_O_CTL.

74 {
75  //
76  // Check the arguments.
77  //
78  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
79 
80  //
81  // Enable the QEI module.
82  //
83  HWREG(ui32Base + QEI_O_CTL) |= QEI_CTL_ENABLE;
84 }
#define QEI0_BASE
Definition: hw_memmap.h:79
#define HWREG(x)
Definition: hw_types.h:48
#define QEI_O_CTL
Definition: hw_qei.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define QEI_CTL_ENABLE
Definition: hw_qei.h:85
#define QEI1_BASE
Definition: hw_memmap.h:80
bool QEIErrorGet ( uint32_t  ui32Base)

Gets the encoder error indicator.

Parameters
ui32Baseis the base address of the quadrature encoder module.

This function returns the error indicator for the quadrature encoder. It is an error for both of the signals of the quadrature input to change at the same time.

Returns
Returns true if an error has occurred and false otherwise.

Definition at line 264 of file qei.c.

References ASSERT, HWREG, QEI0_BASE, QEI1_BASE, QEI_O_STAT, and QEI_STAT_ERROR.

265 {
266  //
267  // Check the arguments.
268  //
269  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
270 
271  //
272  // Return the error indicator.
273  //
274  return((HWREG(ui32Base + QEI_O_STAT) & QEI_STAT_ERROR) ? true : false);
275 }
#define QEI_O_STAT
Definition: hw_qei.h:49
#define QEI0_BASE
Definition: hw_memmap.h:79
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define QEI1_BASE
Definition: hw_memmap.h:80
#define QEI_STAT_ERROR
Definition: hw_qei.h:94
void QEIIntClear ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Clears quadrature encoder interrupt sources.

Parameters
ui32Baseis the base address of the quadrature encoder module.
ui32IntFlagsis a bit mask of the interrupt sources to be cleared. This parameter can be any of the QEI_INTERROR, QEI_INTDIR, QEI_INTTIMER, or QEI_INTINDEX values.

The specified quadrature encoder interrupt sources are cleared, so that they no longer assert. This function must be called in the interrupt handler to keep the interrupt from being triggered again immediately upon exit.

Note
Because there is a write buffer in the Cortex-M processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).
Returns
None.

Definition at line 675 of file qei.c.

References ASSERT, HWREG, QEI0_BASE, QEI1_BASE, and QEI_O_ISC.

676 {
677  //
678  // Check the arguments.
679  //
680  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
681 
682  //
683  // Clear the requested interrupt sources.
684  //
685  HWREG(ui32Base + QEI_O_ISC) = ui32IntFlags;
686 }
#define QEI0_BASE
Definition: hw_memmap.h:79
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define QEI1_BASE
Definition: hw_memmap.h:80
#define QEI_O_ISC
Definition: hw_qei.h:58
void QEIIntDisable ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Disables individual quadrature encoder interrupt sources.

Parameters
ui32Baseis the base address of the quadrature encoder module.
ui32IntFlagsis a bit mask of the interrupt sources to be disabled. This parameter can be any of the QEI_INTERROR, QEI_INTDIR, QEI_INTTIMER, or QEI_INTINDEX values.

This function disables the indicated quadrature encoder interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

Returns
None.

Definition at line 597 of file qei.c.

References ASSERT, HWREG, QEI0_BASE, QEI1_BASE, and QEI_O_INTEN.

598 {
599  //
600  // Check the arguments.
601  //
602  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
603 
604  //
605  // Disable the specified interrupts.
606  //
607  HWREG(ui32Base + QEI_O_INTEN) &= ~(ui32IntFlags);
608 }
#define QEI0_BASE
Definition: hw_memmap.h:79
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define QEI1_BASE
Definition: hw_memmap.h:80
#define QEI_O_INTEN
Definition: hw_qei.h:56
void QEIIntEnable ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Enables individual quadrature encoder interrupt sources.

Parameters
ui32Baseis the base address of the quadrature encoder module.
ui32IntFlagsis a bit mask of the interrupt sources to be enabled. Can be any of the QEI_INTERROR, QEI_INTDIR, QEI_INTTIMER, or QEI_INTINDEX values.

This function enables the indicated quadrature encoder interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

Returns
None.

Definition at line 567 of file qei.c.

References ASSERT, HWREG, QEI0_BASE, QEI1_BASE, and QEI_O_INTEN.

568 {
569  //
570  // Check the arguments.
571  //
572  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
573 
574  //
575  // Enable the specified interrupts.
576  //
577  HWREG(ui32Base + QEI_O_INTEN) |= ui32IntFlags;
578 }
#define QEI0_BASE
Definition: hw_memmap.h:79
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define QEI1_BASE
Definition: hw_memmap.h:80
#define QEI_O_INTEN
Definition: hw_qei.h:56
void QEIIntRegister ( uint32_t  ui32Base,
void(*)(void)  pfnHandler 
)

Registers an interrupt handler for the quadrature encoder interrupt.

Parameters
ui32Baseis the base address of the quadrature encoder module.
pfnHandleris a pointer to the function to be called when the quadrature encoder interrupt occurs.

This function registers the handler to be called when a quadrature encoder interrupt occurs. This function enables the global interrupt in the interrupt controller; specific quadrature encoder interrupts must be enabled via QEIIntEnable(). It is the interrupt handler's responsibility to clear the interrupt source via QEIIntClear().

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.

Definition at line 479 of file qei.c.

References _QEIIntNumberGet(), ASSERT, IntEnable(), IntRegister(), QEI0_BASE, and QEI1_BASE.

480 {
481  uint32_t ui32Int;
482 
483  //
484  // Check the arguments.
485  //
486  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
487 
488  //
489  // Determine the interrupt number based on the QEI module.
490  //
491  ui32Int = _QEIIntNumberGet(ui32Base);
492 
493  ASSERT(ui32Int != 0);
494 
495  //
496  // Register the interrupt handler, returning an error if an error occurs.
497  //
498  IntRegister(ui32Int, pfnHandler);
499 
500  //
501  // Enable the quadrature encoder interrupt.
502  //
503  IntEnable(ui32Int);
504 }
#define QEI0_BASE
Definition: hw_memmap.h:79
#define ASSERT(expr)
Definition: debug.h:67
static uint32_t _QEIIntNumberGet(uint32_t ui32Base)
Definition: qei.c:419
#define QEI1_BASE
Definition: hw_memmap.h:80
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Definition: interrupt.c:309
void IntEnable(uint32_t ui32Interrupt)
Definition: interrupt.c:610

Here is the call graph for this function:

uint32_t QEIIntStatus ( uint32_t  ui32Base,
bool  bMasked 
)

Gets the current interrupt status.

Parameters
ui32Baseis the base address of the quadrature encoder module.
bMaskedis false if the raw interrupt status is required and true if the masked interrupt status is required.

This function returns the interrupt status for the quadrature encoder module. Either the raw interrupt status or the status of interrupts that are allowed to reflect to the processor can be returned.

Returns
Returns the current interrupt status, enumerated as a bit field of QEI_INTERROR, QEI_INTDIR, QEI_INTTIMER, and QEI_INTINDEX.

Definition at line 627 of file qei.c.

References ASSERT, HWREG, QEI0_BASE, QEI1_BASE, QEI_O_ISC, and QEI_O_RIS.

628 {
629  //
630  // Check the arguments.
631  //
632  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
633 
634  //
635  // Return either the interrupt status or the raw interrupt status as
636  // requested.
637  //
638  if(bMasked)
639  {
640  return(HWREG(ui32Base + QEI_O_ISC));
641  }
642  else
643  {
644  return(HWREG(ui32Base + QEI_O_RIS));
645  }
646 }
#define QEI_O_RIS
Definition: hw_qei.h:57
#define QEI0_BASE
Definition: hw_memmap.h:79
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define QEI1_BASE
Definition: hw_memmap.h:80
#define QEI_O_ISC
Definition: hw_qei.h:58
void QEIIntUnregister ( uint32_t  ui32Base)

Unregisters an interrupt handler for the quadrature encoder interrupt.

Parameters
ui32Baseis the base address of the quadrature encoder module.

This function unregisters the handler to be called when a quadrature encoder interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler no longer is called.

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.

Definition at line 523 of file qei.c.

References _QEIIntNumberGet(), ASSERT, IntDisable(), IntUnregister(), QEI0_BASE, and QEI1_BASE.

524 {
525  uint32_t ui32Int;
526 
527  //
528  // Check the arguments.
529  //
530  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
531 
532  //
533  // Determine the interrupt number based on the QEI module.
534  //
535  ui32Int = _QEIIntNumberGet(ui32Base);
536 
537  ASSERT(ui32Int != 0);
538 
539  //
540  // Disable the interrupt.
541  //
542  IntDisable(ui32Int);
543 
544  //
545  // Unregister the interrupt handler.
546  //
547  IntUnregister(ui32Int);
548 }
#define QEI0_BASE
Definition: hw_memmap.h:79
#define ASSERT(expr)
Definition: debug.h:67
static uint32_t _QEIIntNumberGet(uint32_t ui32Base)
Definition: qei.c:419
#define QEI1_BASE
Definition: hw_memmap.h:80
void IntUnregister(uint32_t ui32Interrupt)
Definition: interrupt.c:381
void IntDisable(uint32_t ui32Interrupt)
Definition: interrupt.c:684

Here is the call graph for this function:

uint32_t QEIPositionGet ( uint32_t  ui32Base)

Gets the current encoder position.

Parameters
ui32Baseis the base address of the quadrature encoder module.

This function returns the current position of the encoder. Depending upon the configuration of the encoder, and the incident of an index pulse, this value may or may not contain the expected data (that is, if in reset on index mode, if an index pulse has not been encountered, the position counter is not yet aligned with the index pulse).

Returns
The current position of the encoder.

Definition at line 181 of file qei.c.

References ASSERT, HWREG, QEI0_BASE, QEI1_BASE, and QEI_O_POS.

182 {
183  //
184  // Check the arguments.
185  //
186  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
187 
188  //
189  // Return the current position counter.
190  //
191  return(HWREG(ui32Base + QEI_O_POS));
192 }
#define QEI0_BASE
Definition: hw_memmap.h:79
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define QEI_O_POS
Definition: hw_qei.h:50
#define QEI1_BASE
Definition: hw_memmap.h:80
void QEIPositionSet ( uint32_t  ui32Base,
uint32_t  ui32Position 
)

Sets the current encoder position.

Parameters
ui32Baseis the base address of the quadrature encoder module.
ui32Positionis the new position for the encoder.

This function sets the current position of the encoder; the encoder position is then measured relative to this value.

Returns
None.

Definition at line 208 of file qei.c.

References ASSERT, HWREG, QEI0_BASE, QEI1_BASE, and QEI_O_POS.

209 {
210  //
211  // Check the arguments.
212  //
213  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
214 
215  //
216  // Set the position counter.
217  //
218  HWREG(ui32Base + QEI_O_POS) = ui32Position;
219 }
#define QEI0_BASE
Definition: hw_memmap.h:79
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define QEI_O_POS
Definition: hw_qei.h:50
#define QEI1_BASE
Definition: hw_memmap.h:80
void QEIVelocityConfigure ( uint32_t  ui32Base,
uint32_t  ui32PreDiv,
uint32_t  ui32Period 
)

Configures the velocity capture.

Parameters
ui32Baseis the base address of the quadrature encoder module.
ui32PreDivspecifies the predivider applied to the input quadrature signal before it is counted; can be one of QEI_VELDIV_1, QEI_VELDIV_2, QEI_VELDIV_4, QEI_VELDIV_8, QEI_VELDIV_16, QEI_VELDIV_32, QEI_VELDIV_64, or QEI_VELDIV_128.
ui32Periodspecifies the number of clock ticks over which to measure the velocity; must be non-zero.

This function configures the operation of the velocity capture portion of the quadrature encoder. The position increment signal is predivided as specified by ui32PreDiv before being accumulated by the velocity capture. The divided signal is accumulated over ui32Period system clock before being saved and resetting the accumulator.

Returns
None.

Definition at line 354 of file qei.c.

References ASSERT, HWREG, QEI0_BASE, QEI1_BASE, QEI_CTL_VELDIV_M, QEI_O_CTL, and QEI_O_LOAD.

356 {
357  //
358  // Check the arguments.
359  //
360  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
361  ASSERT(!(ui32PreDiv & ~(QEI_CTL_VELDIV_M)));
362  ASSERT(ui32Period != 0);
363 
364  //
365  // Set the velocity predivider.
366  //
367  HWREG(ui32Base + QEI_O_CTL) = ((HWREG(ui32Base + QEI_O_CTL) &
368  ~(QEI_CTL_VELDIV_M)) | ui32PreDiv);
369 
370  //
371  // Set the timer period.
372  //
373  HWREG(ui32Base + QEI_O_LOAD) = ui32Period - 1;
374 }
#define QEI_O_LOAD
Definition: hw_qei.h:52
#define QEI0_BASE
Definition: hw_memmap.h:79
#define HWREG(x)
Definition: hw_types.h:48
#define QEI_O_CTL
Definition: hw_qei.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define QEI_CTL_VELDIV_M
Definition: hw_qei.h:71
#define QEI1_BASE
Definition: hw_memmap.h:80
void QEIVelocityDisable ( uint32_t  ui32Base)

Disables the velocity capture.

Parameters
ui32Baseis the base address of the quadrature encoder module.

This function disables operation of the velocity capture in the quadrature encoder module.

Returns
None.

Definition at line 319 of file qei.c.

References ASSERT, HWREG, QEI0_BASE, QEI1_BASE, QEI_CTL_VELEN, and QEI_O_CTL.

320 {
321  //
322  // Check the arguments.
323  //
324  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
325 
326  //
327  // Disable the velocity capture.
328  //
329  HWREG(ui32Base + QEI_O_CTL) &= ~(QEI_CTL_VELEN);
330 }
#define QEI0_BASE
Definition: hw_memmap.h:79
#define HWREG(x)
Definition: hw_types.h:48
#define QEI_O_CTL
Definition: hw_qei.h:48
#define QEI_CTL_VELEN
Definition: hw_qei.h:80
#define ASSERT(expr)
Definition: debug.h:67
#define QEI1_BASE
Definition: hw_memmap.h:80
void QEIVelocityEnable ( uint32_t  ui32Base)

Enables the velocity capture.

Parameters
ui32Baseis the base address of the quadrature encoder module.

This function enables operation of the velocity capture in the quadrature encoder module. The module must be configured before velocity capture is enabled.

See also
QEIVelocityConfigure() and QEIEnable()
Returns
None.

Definition at line 293 of file qei.c.

References ASSERT, HWREG, QEI0_BASE, QEI1_BASE, QEI_CTL_VELEN, and QEI_O_CTL.

294 {
295  //
296  // Check the arguments.
297  //
298  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
299 
300  //
301  // Enable the velocity capture.
302  //
303  HWREG(ui32Base + QEI_O_CTL) |= QEI_CTL_VELEN;
304 }
#define QEI0_BASE
Definition: hw_memmap.h:79
#define HWREG(x)
Definition: hw_types.h:48
#define QEI_O_CTL
Definition: hw_qei.h:48
#define QEI_CTL_VELEN
Definition: hw_qei.h:80
#define ASSERT(expr)
Definition: debug.h:67
#define QEI1_BASE
Definition: hw_memmap.h:80
uint32_t QEIVelocityGet ( uint32_t  ui32Base)

Gets the current encoder speed.

Parameters
ui32Baseis the base address of the quadrature encoder module.

This function returns the current speed of the encoder. The value returned is the number of pulses detected in the specified time period; this number can be multiplied by the number of time periods per second and divided by the number of pulses per revolution to obtain the number of revolutions per second.

Returns
Returns the number of pulses captured in the given time period.

Definition at line 392 of file qei.c.

References ASSERT, HWREG, QEI0_BASE, QEI1_BASE, and QEI_O_SPEED.

393 {
394  //
395  // Check the arguments.
396  //
397  ASSERT((ui32Base == QEI0_BASE) || (ui32Base == QEI1_BASE));
398 
399  //
400  // Return the speed capture value.
401  //
402  return(HWREG(ui32Base + QEI_O_SPEED));
403 }
#define QEI0_BASE
Definition: hw_memmap.h:79
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define QEI1_BASE
Definition: hw_memmap.h:80
#define QEI_O_SPEED
Definition: hw_qei.h:55