RTEMS 6.1-rc2
Loading...
Searching...
No Matches
Functions
qep.c File Reference

Support for eQEP for the BeagleBone Black. More...

#include <libcpu/am335x.h>
#include <stdio.h>
#include <stdlib.h>
#include <bsp/gpio.h>
#include <bsp/bbb-gpio.h>
#include <bsp.h>
#include <bsp/pwmss.h>
#include <bsp/qep.h>
#include <bsp/beagleboneblack.h>

Functions

rtems_status_code beagle_qep_init (BBB_PWMSS pwmss_id)
 Initialises the eQEP module of the specified PWMSS unit. This configures the clocks, sets up the interrupt handler and unit timer, The module is configured in Quadrature decode mode using absolute position by default.
 
rtems_status_code beagle_qep_enable (BBB_PWMSS pwmss_id)
 Enables the eQEP module of the specified PWMSS unit.
 
rtems_status_code beagle_qep_disable (BBB_PWMSS pwmss_id)
 Disables the eQEP module of the specified PWMSS unit.
 
rtems_status_code beagle_qep_pinmux_setup (bbb_qep_pin pin_no, BBB_PWMSS pwmss_id, bool pullup_enable)
 Configures a given pin for use with the eQEP function of the supplied PWMSS module.
 
int32_t beagle_qep_get_position (BBB_PWMSS pwmss_id)
 Returns the current position value of the eQEP function for the specified PWMSS module.
 
rtems_status_code beagle_qep_set_position (BBB_PWMSS pwmss_id, uint32_t position)
 Sets the initial position value of the eQEP function for the specified PWMSS module.
 
rtems_status_code beagle_qep_set_count_mode (BBB_PWMSS pwmss_id, BBB_QEP_COUNT_MODE mode)
 Sets the count mode for the eQEP module.
 
BBB_QEP_COUNT_MODE beagle_qep_get_count_mode (BBB_PWMSS pwmss_id)
 Gets the currently configured count mode for the eQEP module.
 
rtems_status_code beagle_qep_set_quadrature_mode (BBB_PWMSS pwmss_id, BBB_QEP_QUADRATURE_MODE mode)
 Sets the quadrature mode to either absolute or relative.
 
BBB_QEP_QUADRATURE_MODE beagle_qep_get_quadrature_mode (BBB_PWMSS pwmss_id)
 Returns the currently configured quadrature mode - either absolute, or relative.
 
uint32_t beagle_eqep_get_timer_period (BBB_PWMSS pwmss_id)
 Returns the the currently configured unit timer period.
 
rtems_status_code beagle_eqep_set_timer_period (BBB_PWMSS pwmss_id, uint64_t period, bbb_eqep_timer_callback timer_callback, void *user)
 Sets the unit timer period for the eQEP module. 0 = off, greater than zero sets the period.
 

Detailed Description

Support for eQEP for the BeagleBone Black.

Function Documentation

◆ beagle_eqep_get_timer_period()

uint32_t beagle_eqep_get_timer_period ( BBB_PWMSS  pwmss_id)

Returns the the currently configured unit timer period.

Parameters
pwmss_idIdentifies which PWMSS module to get the eQEP timer value for
Returns
uint32_t The current unit timer value in nanoseconds

◆ beagle_eqep_set_timer_period()

rtems_status_code beagle_eqep_set_timer_period ( BBB_PWMSS  pwmss_id,
uint64_t  period,
bbb_eqep_timer_callback  timer_callback,
void *  user 
)

Sets the unit timer period for the eQEP module. 0 = off, greater than zero sets the period.

Parameters
pwmss_idIdentifies which PWMSS module to set the eQEP unit timer for.
periodThe value in nanoseconds to set the unit timer period to.
timer_callbackThis is the user provided callback function that will be called by the interrupt event handler on expiry of the unit timer. The user can provide NULL if they don't require a call back.
userThis is a pointer to a user provided data structure that will be handed back as an argument to the timer callback. The driver does not touch this value.
Returns
RTEMS_SUCCESSFUL if ok, RTEMS_INVALID_ID if an invalid pwmss_id is supplied.

◆ beagle_qep_disable()

rtems_status_code beagle_qep_disable ( BBB_PWMSS  pwmss_id)

Disables the eQEP module of the specified PWMSS unit.

Parameters
pwmss_idThe PWMSS module which will have the eQEP function disabled.
Returns
RTEMS_SUCCESSFUL if ok, RTEMS_INVALID_ID if an invalid pwmss_id is supplied.

◆ beagle_qep_enable()

rtems_status_code beagle_qep_enable ( BBB_PWMSS  pwmss_id)

Enables the eQEP module of the specified PWMSS unit.

Parameters
pwmss_idThe PWMSS module which will have the eQEP function enabled.
Returns
RTEMS_SUCCESSFUL if ok, RTEMS_INVALID_ID if an invalid pwmss_id is supplied.

◆ beagle_qep_get_count_mode()

BBB_QEP_COUNT_MODE beagle_qep_get_count_mode ( BBB_PWMSS  pwmss_id)

Gets the currently configured count mode for the eQEP module.

Parameters
pwmss_idIdentifies which PWMSS module to set the eQEP count mode for.
Returns
An enum value representing the current count mode.

◆ beagle_qep_get_position()

int32_t beagle_qep_get_position ( BBB_PWMSS  pwmss_id)

Returns the current position value of the eQEP function for the specified PWMSS module.

Parameters
pwmss_idIdentifies which PWMSS module to return the eQEP position for
Returns
int32_t The current position value.

◆ beagle_qep_get_quadrature_mode()

BBB_QEP_QUADRATURE_MODE beagle_qep_get_quadrature_mode ( BBB_PWMSS  pwmss_id)

Returns the currently configured quadrature mode - either absolute, or relative.

Parameters
pwmss_idIdentifies which PWMSS module to get the eQEP quadrature mode for.
Returns
BBB_QEP_QUADRATURE_MODE The currently configured quadrature mode.

◆ beagle_qep_init()

rtems_status_code beagle_qep_init ( BBB_PWMSS  pwmss_id)

Initialises the eQEP module of the specified PWMSS unit. This configures the clocks, sets up the interrupt handler and unit timer, The module is configured in Quadrature decode mode using absolute position by default.

Parameters
pwmss_idThe PWMSS module to configure the eQEP for.
Returns
RTEMS_SUCCESSFUL if ok, RTEMS_INVALID_ID if an invalid pwmss_id is supplied.

◆ beagle_qep_pinmux_setup()

rtems_status_code beagle_qep_pinmux_setup ( bbb_qep_pin  pin_no,
BBB_PWMSS  pwmss_id,
bool  pullup_enable 
)

Configures a given pin for use with the eQEP function of the supplied PWMSS module.

Parameters
pin_noThe P9 or P8 header pin to be configured for the eQEP function.
pwmss_idThe PWMSS module which will have the eQEP function enabled.
pullup_enableIf true then the internal pull up resistor on the specified pin will be enabled, if false the pull down will be enabled.
Returns
RTEMS_SUCCESSFUL if ok, RTEMS_INVALID_ID if an invalid pwmss_id is supplied.

◆ beagle_qep_set_count_mode()

rtems_status_code beagle_qep_set_count_mode ( BBB_PWMSS  pwmss_id,
BBB_QEP_COUNT_MODE  mode 
)

Sets the count mode for the eQEP module.

Parameters
pwmss_idIdentifies which PWMSS module to set the eQEP count mode for.
modeOne of the above modes to configure the eQEP module for.
Returns
RTEMS_SUCCESSFUL if ok, RTEMS_INVALID_ID if an invalid pwmss_id is supplied.

◆ beagle_qep_set_position()

rtems_status_code beagle_qep_set_position ( BBB_PWMSS  pwmss_id,
uint32_t  position 
)

Sets the initial position value of the eQEP function for the specified PWMSS module.

Parameters
pwmss_idIdentifies which PWMSS module to set the eQEP position for
positionThe value to initialise the position register with.
Returns
RTEMS_SUCCESSFUL if ok, RTEMS_INVALID_ID if an invalid pwmss_id is supplied.

◆ beagle_qep_set_quadrature_mode()

rtems_status_code beagle_qep_set_quadrature_mode ( BBB_PWMSS  pwmss_id,
BBB_QEP_QUADRATURE_MODE  mode 
)

Sets the quadrature mode to either absolute or relative.

Parameters
pwmss_idIdentifies which PWMSS module to set the eQEP quadrature mode for.
modeBBB_QEP_QUADRATURE_MODE Set the mode of the eQEP to either absolute or relative.
Returns
RTEMS_SUCCESSFUL if ok, RTEMS_INVALID_ID if an invalid pwmss_id is supplied.