AM243x MCU+ SDK  08.04.00
APIs for ENDAT Encoder

Introduction

Here is the list of APIs used for EnDAT encoder communication protocol

Functions

int endat_recvd_process (struct endat_priv *priv, int cmd, union endat_format_data *u)
 process raw recieved data and format based on the command More...
 
unsigned endat_recvd_validate (struct endat_priv *priv, int 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...
 
int endat_command_process (struct endat_priv *priv, int cmd, struct cmd_supplement *cmd_supplement)
 send the EnDat command and wait till firmware acknowledges More...
 
int endat_command_build (struct endat_priv *priv, int 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...
 
int endat_get_encoder_info (struct endat_priv *priv)
 update priv with position resolution, id, serial number, encoder type and supported command set More...
 
unsigned int 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, int 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, unsigned short delay)
 configure tST delay More...
 
void endat_config_rx_arm_cnt (struct endat_priv *priv, unsigned short val)
 configure rx arm counter More...
 
void endat_config_wire_delay (struct endat_priv *priv, unsigned short val)
 configure wire delay for the selected channel More...
 
void endat_config_rx_clock_disable (struct endat_priv *priv, unsigned short val)
 configure clocks to be disabled at the end of rx to account for tD More...
 
int 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_channel (struct endat_priv *priv, int ch)
 select channel to be used by EnDat master More...
 
void endat_config_multi_channel_mask (struct endat_priv *priv, unsigned char mask)
 select mask of channels to be used in multi channel configuration by EnDat master More...
 
unsigned char 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, int 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...
 
int endat_wait_initialization (struct endat_priv *priv, unsigned timeout)
 wait for EnDat master firmware to initialize More...
 
struct endat_privendat_init (struct endat_pruss_xchg *pruss_xchg, void *pruss_cfg)
 Initialize EnDat firmware interface address and get the pointer to struct endat_priv instance. More...
 
int 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...
 

Function Documentation

◆ endat_recvd_process()

int endat_recvd_process ( struct endat_priv priv,
int  cmd,
union endat_format_data u 
)

process raw recieved data and format based on the command

Parameters
[in]privcookie returned by endat_init
[in]cmdEnDat command number
[out]upointer to union for storing formatted data based on cmd
Return values
0for success, -EINVAL for failure

◆ endat_recvd_validate()

unsigned endat_recvd_validate ( struct endat_priv priv,
int  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.

Parameters
[in]privcookie returned by endat_init
[in]cmdEnDat command number
[in]upointer to union having formatted data based on cmd
Return values
statusposition/address/params/test CRC status

◆ endat_command_process()

int endat_command_process ( struct endat_priv priv,
int  cmd,
struct cmd_supplement cmd_supplement 
)

send the EnDat command and wait till firmware acknowledges

Parameters
[in]privcookie returned by endat_init
[in]cmdEnDat command number
[in]cmd_supplementSupplement information needed to setup EnDat cmd
Return values
0for success, -EINVAL for failure

◆ endat_command_build()

int endat_command_build ( struct endat_priv priv,
int  cmd,
struct cmd_supplement cmd_supplement 
)

setup the EnDat command in the PRU interface buffer

Parameters
[in]privcookie returned by endat_init
[in]cmdEnDat command number
[in]cmd_supplementSupplement information needed to setup EnDat cmd
Return values
0for success, -EINVAL for failure

◆ endat_command_send()

void endat_command_send ( struct endat_priv priv)

trigger sending the EnDat command in PRU

Parameters
[in]privcookie returned by endat_init

◆ endat_command_wait()

void endat_command_wait ( struct endat_priv priv)

wait till PRU finishes EnDat transaction

Parameters
[in]privcookie returned by endat_init

◆ endat_get_encoder_info()

int endat_get_encoder_info ( struct endat_priv priv)

update priv with position resolution, id, serial number, encoder type and supported command set

Parameters
[in]privcookie returned by endat_init
Return values
0for success, -EINVAL for failure

◆ endat_get_prop_delay()

unsigned int endat_get_prop_delay ( struct endat_priv priv)

get propagation delay automatically estimated by the firmware

Parameters
[in]privcookie returned by endat_init
Return values
delayestimated propogation delay

◆ endat_addinfo_track()

void endat_addinfo_track ( struct endat_priv priv,
int  cmd,
struct cmd_supplement cmd_supplement 
)

track presence of additional information in priv

Parameters
[in]privcookie returned by endat_init
[in]cmdEnDat command number
[in]cmd_supplementSupplement information needed to setup EnDat cmd

◆ endat_config_clock()

void endat_config_clock ( struct endat_priv priv,
struct endat_clk_cfg clk_cfg 
)

configure EnDat clock

Parameters
[in]privcookie returned by endat_init
[in]clk_cfgpointer to structure containing clock configuration data

◆ endat_config_tst_delay()

void endat_config_tst_delay ( struct endat_priv priv,
unsigned short  delay 
)

configure tST delay

Parameters
[in]privcookie returned by endat_init
[in]delaytST delay value

◆ endat_config_rx_arm_cnt()

void endat_config_rx_arm_cnt ( struct endat_priv priv,
unsigned short  val 
)

configure rx arm counter

Parameters
[in]privcookie returned by endat_init
[in]valrx arm counter value in ns

◆ endat_config_wire_delay()

void endat_config_wire_delay ( struct endat_priv priv,
unsigned short  val 
)

configure wire delay for the selected channel

Parameters
[in]privcookie returned by endat_init
[in]valwire delay in ns

◆ endat_config_rx_clock_disable()

void endat_config_rx_clock_disable ( struct endat_priv priv,
unsigned short  val 
)

configure clocks to be disabled at the end of rx to account for tD

Parameters
[in]privcookie returned by endat_init
[in]valnumber of clocks to be disabled

◆ endat_start_continuous_mode()

int endat_start_continuous_mode ( struct endat_priv priv)

start continuous mode

Parameters
[in]privcookie returned by endat_init
Return values
0success, -EINVAL for failure

◆ endat_stop_continuous_mode()

void endat_stop_continuous_mode ( struct endat_priv priv)

stop continuous mode

Parameters
[in]privcookie returned by endat_init

◆ endat_config_host_trigger()

void endat_config_host_trigger ( struct endat_priv priv)

configure EnDat master for host trigger mode

Parameters
[in]privcookie returned by endat_init

◆ endat_config_periodic_trigger()

void endat_config_periodic_trigger ( struct endat_priv priv)

configure EnDat master in periodic trigger mode

Parameters
[in]privcookie returned by endat_init

◆ endat_config_channel()

void endat_config_channel ( struct endat_priv priv,
int  ch 
)

select channel to be used by EnDat master

Parameters
[in]privcookie returned by endat_init
[in]chchannel to be selected

◆ endat_config_multi_channel_mask()

void endat_config_multi_channel_mask ( struct endat_priv priv,
unsigned char  mask 
)

select mask of channels to be used in multi channel configuration by EnDat master

Parameters
[in]privcookie returned by endat_init
[in]maskchannel mask

◆ endat_multi_channel_detected()

unsigned char 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.

Parameters
[in]privcookie returned by endat_init
Return values
maskmask of the detected channels

◆ endat_multi_channel_set_cur()

void endat_multi_channel_set_cur ( struct endat_priv priv,
int  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.

Parameters
[in]privcookie returned by endat_init
[in]chchannel number to be selected

◆ endat_wait_initialization()

int endat_wait_initialization ( struct endat_priv priv,
unsigned  timeout 
)

wait for EnDat master firmware to initialize

Parameters
[in]privcookie returned by endat_init
[in]timeouttimeout to wait for initialization
Return values
0for success, -EINVAL for failure

◆ endat_init()

struct endat_priv* endat_init ( struct endat_pruss_xchg *  pruss_xchg,
void *  pruss_cfg 
)

Initialize EnDat firmware interface address and get the pointer to struct endat_priv instance.

Parameters
[in]pruss_xchgEnDat firmware interface address
[in]pruss_cfgICSS PRU config base address
Return values
privpointer to struct endat_priv instance

◆ endat_get_2_2_angle()

int 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):

  1. Total resolution >= 25
  2. Single turn resolution <= 30
Parameters
[in]privcookie returned by endat_init
Return values
anglefor angular position in steps on success, -1 for failure