Here is the list of APIs used for EnDAT encoder communication protocol
Functions | |
int32_t | endat_recvd_process (struct endat_priv *priv, int32_t cmd, union endat_format_data *u) |
process raw recieved data and format based on the command More... | |
uint32_t | endat_recvd_validate (struct endat_priv *priv, int32_t cmd, union endat_format_data *u) |
CRC result indicated in return value as follows, 0th bit high position/address/params/test CRC success 0th bit low position/address/params/test CRC failure 1st bit high if addinfo 1 present, addinfo 1 CRC success 1st bit low if addinfo 1 present, addinfo 1 CRC failure 2nd bit high if addinfo 2 present, addinfo 2 CRC success 2nd bit low if addinfo 2 present, addinfo 2 CRC failure. More... | |
int32_t | endat_command_process (struct endat_priv *priv, int32_t cmd, struct cmd_supplement *cmd_supplement) |
send the EnDat command and wait till firmware acknowledges More... | |
int32_t | endat_command_build (struct endat_priv *priv, int32_t cmd, struct cmd_supplement *cmd_supplement) |
setup the EnDat command in the PRU interface buffer More... | |
void | endat_command_send (struct endat_priv *priv) |
trigger sending the EnDat command in PRU More... | |
void | endat_command_wait (struct endat_priv *priv) |
wait till PRU finishes EnDat transaction More... | |
uint32_t | endat_get_recovery_time (struct endat_priv *priv) |
read RT from DMEM More... | |
int32_t | endat_get_encoder_info (struct endat_priv *priv) |
update priv with position resolution, id, serial number, encoder type and supported command set More... | |
uint32_t | endat_get_prop_delay (struct endat_priv *priv) |
get propagation delay automatically estimated by the firmware More... | |
void | endat_addinfo_track (struct endat_priv *priv, int32_t cmd, struct cmd_supplement *cmd_supplement) |
track presence of additional information in priv More... | |
void | endat_config_clock (struct endat_priv *priv, struct endat_clk_cfg *clk_cfg) |
configure EnDat clock More... | |
void | endat_config_tst_delay (struct endat_priv *priv, uint16_t delay) |
configure tST delay More... | |
void | endat_config_rx_arm_cnt (struct endat_priv *priv, uint16_t val) |
configure rx arm counter More... | |
void | endat_config_wire_delay (struct endat_priv *priv, uint16_t val) |
configure wire delay for the selected channel More... | |
void | endat_config_rx_clock_disable (struct endat_priv *priv, uint16_t val) |
configure clocks to be disabled at the end of rx to account for tD More... | |
int32_t | endat_start_continuous_mode (struct endat_priv *priv) |
start continuous mode More... | |
void | endat_stop_continuous_mode (struct endat_priv *priv) |
stop continuous mode More... | |
void | endat_config_host_trigger (struct endat_priv *priv) |
configure EnDat master for host trigger mode More... | |
void | endat_config_periodic_trigger (struct endat_priv *priv) |
configure EnDat master in periodic trigger mode More... | |
void | endat_config_syn_bits (struct endat_priv *priv, uint8_t mask) |
void | endat_config_primary_core_mask (struct endat_priv *priv, uint8_t mask) |
set a core as primay core for global configuration, clk configuration and TX_GLOBAL_INIT More... | |
void | endat_enable_load_share_mode (struct endat_priv *priv) |
enable load share mode if encoders has diffent make More... | |
void | endat_config_channel (struct endat_priv *priv, int32_t ch) |
select channel to be used by EnDat master More... | |
void | endat_config_multi_channel_mask (struct endat_priv *priv, uint8_t mask, uint8_t loadshare) |
select mask of channels to be used in multi channel configuration by EnDat master More... | |
uint8_t | endat_multi_channel_detected (struct endat_priv *priv) |
select channels detected in multi channel configuration by EnDat master. required to be invoked only if firmware indicates initialization failure to know the channels that has been detected. Initialization success implies that all channels indicated has been detected. More... | |
void | endat_multi_channel_set_cur (struct endat_priv *priv, int32_t ch) |
In multi channel configuration, select channel before receive processing in multi channel configuration. After receive is complete, select each channel and invoke rx API's to parse data recieved in each channel. More... | |
int32_t | endat_wait_initialization (struct endat_priv *priv, uint32_t timeout, uint8_t mask) |
wait for EnDat master firmware to initialize More... | |
struct endat_priv * | endat_init (struct endat_pruss_xchg *pruss_xchg, void *pruss_cfg, int32_t slice) |
Initialize EnDat firmware interface address and get the pointer to struct endat_priv instance. More... | |
int32_t | endat_get_2_2_angle (struct endat_priv *priv) |
Read EnDat 2.2 angular position in steps for rotary encoders (prior to invoking this, 2.2 position command has to be completed) This checks the CRC status (updated on-the-fly by firmware), checks the group alarm errors (F1/F2 bits) and the angle value recieved in reverse are reversed in a highly optimized way using inline assembly. Assumptions (that holds good for quite a few encoders): More... | |
int32_t endat_recvd_process | ( | struct endat_priv * | priv, |
int32_t | cmd, | ||
union endat_format_data * | u | ||
) |
process raw recieved data and format based on the command
[in] | priv | cookie returned by endat_init |
[in] | cmd | EnDat command number |
[out] | u | pointer to union for storing formatted data based on cmd |
0 | for success, -EINVAL for failure |
uint32_t endat_recvd_validate | ( | struct endat_priv * | priv, |
int32_t | cmd, | ||
union endat_format_data * | u | ||
) |
CRC result indicated in return value as follows,
0th bit high position/address/params/test CRC success
0th bit low position/address/params/test CRC failure
1st bit high if addinfo 1 present, addinfo 1 CRC success
1st bit low if addinfo 1 present, addinfo 1 CRC failure
2nd bit high if addinfo 2 present, addinfo 2 CRC success
2nd bit low if addinfo 2 present, addinfo 2 CRC failure.
[in] | priv | cookie returned by endat_init |
[in] | cmd | EnDat command number |
[in] | u | pointer to union having formatted data based on cmd |
status | position/address/params/test CRC status |
int32_t endat_command_process | ( | struct endat_priv * | priv, |
int32_t | cmd, | ||
struct cmd_supplement * | cmd_supplement | ||
) |
send the EnDat command and wait till firmware acknowledges
[in] | priv | cookie returned by endat_init |
[in] | cmd | EnDat command number |
[in] | cmd_supplement | Supplement information needed to setup EnDat cmd |
0 | for success, -EINVAL for failure |
int32_t endat_command_build | ( | struct endat_priv * | priv, |
int32_t | cmd, | ||
struct cmd_supplement * | cmd_supplement | ||
) |
setup the EnDat command in the PRU interface buffer
[in] | priv | cookie returned by endat_init |
[in] | cmd | EnDat command number |
[in] | cmd_supplement | Supplement information needed to setup EnDat cmd |
0 | for success, -EINVAL for failure |
void endat_command_send | ( | struct endat_priv * | priv | ) |
trigger sending the EnDat command in PRU
[in] | priv | cookie returned by endat_init |
void endat_command_wait | ( | struct endat_priv * | priv | ) |
wait till PRU finishes EnDat transaction
[in] | priv | cookie returned by endat_init |
uint32_t endat_get_recovery_time | ( | struct endat_priv * | priv | ) |
read RT from DMEM
[in] | priv | cookie returned by endat_init |
Value | of Recovery Time in nanoseconds |
int32_t endat_get_encoder_info | ( | struct endat_priv * | priv | ) |
update priv with position resolution, id, serial number, encoder type and supported command set
[in] | priv | cookie returned by endat_init |
0 | for success, -EINVAL for failure |
uint32_t endat_get_prop_delay | ( | struct endat_priv * | priv | ) |
get propagation delay automatically estimated by the firmware
[in] | priv | cookie returned by endat_init |
delay | estimated propogation delay |
void endat_addinfo_track | ( | struct endat_priv * | priv, |
int32_t | cmd, | ||
struct cmd_supplement * | cmd_supplement | ||
) |
track presence of additional information in priv
[in] | priv | cookie returned by endat_init |
[in] | cmd | EnDat command number |
[in] | cmd_supplement | Supplement information needed to setup EnDat cmd |
void endat_config_clock | ( | struct endat_priv * | priv, |
struct endat_clk_cfg * | clk_cfg | ||
) |
configure EnDat clock
[in] | priv | cookie returned by endat_init |
[in] | clk_cfg | pointer to structure containing clock configuration data |
void endat_config_tst_delay | ( | struct endat_priv * | priv, |
uint16_t | delay | ||
) |
configure tST delay
[in] | priv | cookie returned by endat_init |
[in] | delay | tST delay value |
void endat_config_rx_arm_cnt | ( | struct endat_priv * | priv, |
uint16_t | val | ||
) |
configure rx arm counter
[in] | priv | cookie returned by endat_init |
[in] | val | rx arm counter value in ns |
void endat_config_wire_delay | ( | struct endat_priv * | priv, |
uint16_t | val | ||
) |
configure wire delay for the selected channel
[in] | priv | cookie returned by endat_init |
[in] | val | wire delay in ns |
void endat_config_rx_clock_disable | ( | struct endat_priv * | priv, |
uint16_t | val | ||
) |
configure clocks to be disabled at the end of rx to account for tD
[in] | priv | cookie returned by endat_init |
[in] | val | number of clocks to be disabled |
int32_t endat_start_continuous_mode | ( | struct endat_priv * | priv | ) |
start continuous mode
[in] | priv | cookie returned by endat_init |
0 | success, -EINVAL for failure |
void endat_stop_continuous_mode | ( | struct endat_priv * | priv | ) |
stop continuous mode
[in] | priv | cookie returned by endat_init |
void endat_config_host_trigger | ( | struct endat_priv * | priv | ) |
configure EnDat master for host trigger mode
[in] | priv | cookie returned by endat_init |
void endat_config_periodic_trigger | ( | struct endat_priv * | priv | ) |
configure EnDat master in periodic trigger mode
[in] | priv | cookie returned by endat_init |
void endat_config_syn_bits | ( | struct endat_priv * | priv, |
uint8_t | mask | ||
) |
void endat_config_primary_core_mask | ( | struct endat_priv * | priv, |
uint8_t | mask | ||
) |
set a core as primay core for global configuration, clk configuration and TX_GLOBAL_INIT
[in] | priv | cookie returned by endat_init |
[in] | mask | channels mask |
void endat_enable_load_share_mode | ( | struct endat_priv * | priv | ) |
enable load share mode if encoders has diffent make
[in] | priv | cookie returned by endat_init |
void endat_config_channel | ( | struct endat_priv * | priv, |
int32_t | ch | ||
) |
select channel to be used by EnDat master
[in] | priv | cookie returned by endat_init |
[in] | ch | channel to be selected |
void endat_config_multi_channel_mask | ( | struct endat_priv * | priv, |
uint8_t | mask, | ||
uint8_t | loadshare | ||
) |
select mask of channels to be used in multi channel configuration by EnDat master
[in] | priv | cookie returned by endat_init |
[in] | mask | channel mask |
[in] | loadshare | value for loadshare mode enable. |
uint8_t endat_multi_channel_detected | ( | struct endat_priv * | priv | ) |
select channels detected in multi channel configuration by EnDat master.
required to be invoked only if firmware indicates initialization failure
to know the channels that has been detected. Initialization success implies
that all channels indicated has been detected.
[in] | priv | cookie returned by endat_init |
mask | mask of the detected channels |
void endat_multi_channel_set_cur | ( | struct endat_priv * | priv, |
int32_t | ch | ||
) |
In multi channel configuration, select channel before receive processing in
multi channel configuration. After receive is complete, select each channel
and invoke rx API's to parse data recieved in each channel.
[in] | priv | cookie returned by endat_init |
[in] | ch | channel number to be selected |
int32_t endat_wait_initialization | ( | struct endat_priv * | priv, |
uint32_t | timeout, | ||
uint8_t | mask | ||
) |
wait for EnDat master firmware to initialize
[in] | priv | cookie returned by endat_init |
[in] | timeout | timeout to wait for initialization |
[in] | mask | channel mask |
0 | for success, -EINVAL for failure |
struct endat_priv* endat_init | ( | struct endat_pruss_xchg * | pruss_xchg, |
void * | pruss_cfg, | ||
int32_t | slice | ||
) |
Initialize EnDat firmware interface address and get the pointer to struct endat_priv instance.
[in] | pruss_xchg | EnDat firmware interface address |
[in] | pruss_cfg | ICSS PRU config base address |
[in] | slice | ICSS PRU SLICE |
priv | pointer to struct endat_priv instance |
int32_t endat_get_2_2_angle | ( | struct endat_priv * | priv | ) |
Read EnDat 2.2 angular position in steps for rotary encoders
(prior to invoking this, 2.2 position command has to be completed)
This checks the CRC status (updated on-the-fly by firmware),
checks the group alarm errors (F1/F2 bits) and the angle value
recieved in reverse are reversed in a highly optimized way using
inline assembly.
Assumptions (that holds good for quite a few encoders):
[in] | priv | cookie returned by endat_init |
angle | for angular position in steps on success, -1 for failure |