AM243x Motor Control SDK  09.01.00
APIs for Tamagawa Encoder

Introduction

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

Data Structures

struct  tamagawa_ch_info
 Structure defining tamagawa per channel interface. More...
 
struct  tamagawa_cmd
 Structure defining Tamagawa command interface. More...
 
struct  tamagawa_config
 Structure defining Tamagawa configuration interface. More...
 
struct  rx_frames_received
 Tamagawa Interface Received data. More...
 
struct  tamagawa_interface
 Tamagawa Interface. More...
 
struct  config
 
struct  tamagawa_eeprom_interface
 Tamagawa EEPROM Interface. More...
 
struct  tamagawa_xchg
 Structure defining Tamagawa interface. More...
 
struct  tamagawa_clk_cfg
 Used to configure the Tamagawa Clock. More...
 
struct  register_offsets
 Used to store the register offsets depending on different PRU slices. More...
 
struct  tamagawa_priv
 Used to structures defining the Tamagawa interface, PRU slice and register offsets. More...
 

Functions

int32_t tamagawa_command_process (struct tamagawa_priv *priv, int32_t cmd, uint8_t gTamagawa_multi_ch_mask)
 send the tamagawa command and wait till firmware acknowledges More...
 
int32_t tamagawa_command_build (struct tamagawa_priv *priv, int32_t cmd, uint8_t gTamagawa_multi_ch_mask)
 setup the tamagawa command in the PRU interface buffer More...
 
void tamagawa_command_send (struct tamagawa_priv *priv)
 trigger sending the tamagawa command in PRU More...
 
void tamagawa_command_wait (struct tamagawa_priv *priv)
 wait till PRU finishes tamagawa transaction More...
 
void tamagawa_config_clock (struct tamagawa_priv *priv, struct tamagawa_clk_cfg *clk_cfg)
 configure tamagawa clock More...
 
void tamagawa_config_host_trigger (struct tamagawa_priv *priv)
 configure tamagawa master for host trigger mode More...
 
void tamagawa_config_periodic_trigger (struct tamagawa_priv *priv)
 configure tamagawa master in periodic trigger mode More...
 
void tamagawa_config_channel (struct tamagawa_priv *priv, uint32_t ch)
 select channel to be used by tamagawa master More...
 
void tamagawa_config_multi_channel_mask (struct tamagawa_priv *priv, uint8_t mask)
 select mask of channels to be used in multi channel configuration by tamagawa master More...
 
uint8_t tamagawa_multi_channel_detected (struct tamagawa_priv *priv)
 select channels detected in multi channel configuration by tamagawa 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 tamagawa_multi_channel_set_cur (struct tamagawa_priv *priv, uint32_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...
 
struct tamagawa_privtamagawa_init (struct tamagawa_xchg *tamagawa_xchg, void *pruss_cfg, void *pruss_iep, uint32_t slice_value)
 Initialize tamagawa firmware interface address and get the pointer to struct tamagawa_priv instance. More...
 
void tamagawa_update_data_id (struct tamagawa_priv *priv, int32_t cmd)
 update the current requested command id in tamagawa interface.
More...
 
void tamagawa_update_adf (struct tamagawa_priv *priv, uint32_t val, uint32_t ch)
 update the adf(address of EEPROM) field entered by user for EEPROM command in tamagawa interface.
More...
 
void tamagawa_update_edf (struct tamagawa_priv *priv, uint32_t val, uint32_t ch)
 update the edf(data for EEPROM) field entered by user for EEPROM command in tamagawa interface.
More...
 
int32_t tamagawa_parse (int32_t cmd, struct tamagawa_priv *priv)
 Parse the data in tamagawa interface.
More...
 
int32_t tamagawa_crc_verify (struct tamagawa_priv *priv)
 verify the CRC computed with the encoder crc.
More...
 
void tamagawa_update_crc (struct tamagawa_priv *priv, int32_t cmd, uint32_t ch)
 Pass the values of CF(Control Field), ADF(address of EEPROM) and EDF(data for EEPROM) to the CRC calculator fucntion and update the CRC field.
More...
 
void tamagawa_set_baudrate (struct tamagawa_priv *priv, double baudrate)
 Update the values for oversample rate and division factor for Tx and Rx.
More...
 
void tamagawa_eeprom_crc_reinit (struct tamagawa_priv *priv)
 Reset the values of the variables used in CRC calculation to 0.
More...
 
uint32_t tamagawa_reverse_bits (int8_t data)
 Reverse the bits of a number.
More...
 
uint64_t tamagawa_prepare_eeprom_tx_data (uint64_t eeprom_tx_data, volatile uint32_t data)
 Add the start and the stop bit to the reversed data.
More...
 
void tamagawa_prepare_eeprom_command (struct tamagawa_priv *priv, int32_t cmd, uint32_t ch)
 Prepare the required EEPROM command from the CF(Control Field), ADF(address of EEPROM) and EDF(data for EEPROM).
More...
 

Enumerations

enum  data_id {
  DATA_ID_0, DATA_ID_1, DATA_ID_2, DATA_ID_3,
  DATA_ID_6, DATA_ID_7, DATA_ID_8, DATA_ID_C,
  DATA_ID_D, PERIODIC_TRIGGER_CMD, DATA_ID_NUM
}
 Data ID codes. More...
 

Macros

#define TAMAGAWA_MULTI_CH0   (1 << 0)
 Used to set the value of Tamagawa multi-channel mask based on the whether the Channel 0 is selected or not. More...
 
#define TAMAGAWA_MULTI_CH1   (1 << 1)
 Used to set the value of Tamagawa multi-channel mask based on the whether the Channel 1 is selected or not. More...
 
#define TAMAGAWA_MULTI_CH2   (1 << 2)
 Used to set the value of Tamagawa multi-channel mask based on the whether the Channel 2 is selected or not. More...
 
#define MAX_CHANNELS   (3)
 Used to set the maximum channels supported. More...
 
#define MAX_EEPROM_ADDRESS   (127)
 Used to set the maximum address that can be used for EEPROM Read/Write. More...
 
#define MAX_EEPROM_WRITE_DATA   (255)
 Used to set the maximum value that can be written in EEPROM. More...
 

Macro Definition Documentation

◆ TAMAGAWA_MULTI_CH0

#define TAMAGAWA_MULTI_CH0   (1 << 0)

Used to set the value of Tamagawa multi-channel mask based on the whether the Channel 0 is selected or not.

◆ TAMAGAWA_MULTI_CH1

#define TAMAGAWA_MULTI_CH1   (1 << 1)

Used to set the value of Tamagawa multi-channel mask based on the whether the Channel 1 is selected or not.

◆ TAMAGAWA_MULTI_CH2

#define TAMAGAWA_MULTI_CH2   (1 << 2)

Used to set the value of Tamagawa multi-channel mask based on the whether the Channel 2 is selected or not.

◆ MAX_CHANNELS

#define MAX_CHANNELS   (3)

Used to set the maximum channels supported.

◆ MAX_EEPROM_ADDRESS

#define MAX_EEPROM_ADDRESS   (127)

Used to set the maximum address that can be used for EEPROM Read/Write.

◆ MAX_EEPROM_WRITE_DATA

#define MAX_EEPROM_WRITE_DATA   (255)

Used to set the maximum value that can be written in EEPROM.

Enumeration Type Documentation

◆ data_id

enum data_id

Data ID codes.

Enumerator
DATA_ID_0 

Data readout data in one revolution

DATA_ID_1 

Data readout multi-turn data

DATA_ID_2 

Data readout encoder ID

DATA_ID_3 

Data readout data in one revolution, encoder ID, multi-turn, encoder error

DATA_ID_6 

EEPROM write

DATA_ID_7 

Reset

DATA_ID_8 

Reset

DATA_ID_C 

Reset

DATA_ID_D 

EEPROM read

PERIODIC_TRIGGER_CMD 

periodic trigger command

DATA_ID_NUM 

Number of Data ID codes

Function Documentation

◆ tamagawa_command_process()

int32_t tamagawa_command_process ( struct tamagawa_priv priv,
int32_t  cmd,
uint8_t  gTamagawa_multi_ch_mask 
)

send the tamagawa command and wait till firmware acknowledges

Parameters
[in]privcookie returned by tamagawa_init
[in]cmdtamagawa command number
[in]gTamagawa_multi_ch_maskMulti-channel mask to keep track of which channels are selected
Return values
0success
-EINVALfailure

◆ tamagawa_command_build()

int32_t tamagawa_command_build ( struct tamagawa_priv priv,
int32_t  cmd,
uint8_t  gTamagawa_multi_ch_mask 
)

setup the tamagawa command in the PRU interface buffer

Parameters
[in]privcookie returned by tamagawa_init
[in]cmdtamagawa command number
[in]gTamagawa_multi_ch_maskMulti-channel mask to keep track of which channels are selected
Return values
0success
-EINVALfailure

◆ tamagawa_command_send()

void tamagawa_command_send ( struct tamagawa_priv priv)

trigger sending the tamagawa command in PRU

Parameters
[in]privcookie returned by tamagawa_init

◆ tamagawa_command_wait()

void tamagawa_command_wait ( struct tamagawa_priv priv)

wait till PRU finishes tamagawa transaction

Parameters
[in]privcookie returned by tamagawa_init

◆ tamagawa_config_clock()

void tamagawa_config_clock ( struct tamagawa_priv priv,
struct tamagawa_clk_cfg clk_cfg 
)

configure tamagawa clock

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

◆ tamagawa_config_host_trigger()

void tamagawa_config_host_trigger ( struct tamagawa_priv priv)

configure tamagawa master for host trigger mode

Parameters
[in]privcookie returned by tamagawa_init

◆ tamagawa_config_periodic_trigger()

void tamagawa_config_periodic_trigger ( struct tamagawa_priv priv)

configure tamagawa master in periodic trigger mode

Parameters
[in]privcookie returned by tamagawa_init

◆ tamagawa_config_channel()

void tamagawa_config_channel ( struct tamagawa_priv priv,
uint32_t  ch 
)

select channel to be used by tamagawa master

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

◆ tamagawa_config_multi_channel_mask()

void tamagawa_config_multi_channel_mask ( struct tamagawa_priv priv,
uint8_t  mask 
)

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

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

◆ tamagawa_multi_channel_detected()

uint8_t tamagawa_multi_channel_detected ( struct tamagawa_priv priv)

select channels detected in multi channel configuration by tamagawa 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 tamagawa_init
Return values
maskmask of the detected channels

◆ tamagawa_multi_channel_set_cur()

void tamagawa_multi_channel_set_cur ( struct tamagawa_priv priv,
uint32_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.

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

◆ tamagawa_init()

struct tamagawa_priv* tamagawa_init ( struct tamagawa_xchg tamagawa_xchg,
void *  pruss_cfg,
void *  pruss_iep,
uint32_t  slice_value 
)

Initialize tamagawa firmware interface address and get the pointer to struct tamagawa_priv instance.

Parameters
[in]tamagawa_xchgtamagawa firmware interface address
[in]pruss_cfgICSS PRU config base address
[in]pruss_iepICSS PRU IEP base address
[in]slice_valuePRUx slice value : 0 for PRU0 and 1 for PRU1
Return values
privpointer to struct tamagawa_priv instance

◆ tamagawa_update_data_id()

void tamagawa_update_data_id ( struct tamagawa_priv priv,
int32_t  cmd 
)

update the current requested command id in tamagawa interface.

Parameters
[in]privcookie returned by tamagawa_init
[in]cmdtamagawa command number

◆ tamagawa_update_adf()

void tamagawa_update_adf ( struct tamagawa_priv priv,
uint32_t  val,
uint32_t  ch 
)

update the adf(address of EEPROM) field entered by user for EEPROM command in tamagawa interface.

Parameters
[in]privcookie returned by tamagawa_init
[in]valADF value to be updated
[in]chchannel number that is currently selected

◆ tamagawa_update_edf()

void tamagawa_update_edf ( struct tamagawa_priv priv,
uint32_t  val,
uint32_t  ch 
)

update the edf(data for EEPROM) field entered by user for EEPROM command in tamagawa interface.

Parameters
[in]privcookie returned by tamagawa_init
[in]valEDF value to be updated
[in]chchannel number that is currently selected

◆ tamagawa_parse()

int32_t tamagawa_parse ( int32_t  cmd,
struct tamagawa_priv priv 
)

Parse the data in tamagawa interface.

Parameters
[in]cmdtamagawa command number
[in]privcookie returned by tamagawa_init

◆ tamagawa_crc_verify()

int32_t tamagawa_crc_verify ( struct tamagawa_priv priv)

verify the CRC computed with the encoder crc.

Parameters
[in]privcookie returned by tamagawa_init
Return values
1/0if verify correctly, return 1 else return 0.

◆ tamagawa_update_crc()

void tamagawa_update_crc ( struct tamagawa_priv priv,
int32_t  cmd,
uint32_t  ch 
)

Pass the values of CF(Control Field), ADF(address of EEPROM) and EDF(data for EEPROM) to the CRC calculator fucntion and update the CRC field.

Parameters
[in]privcookie returned by tamagawa_init
[in]cmdtamagawa command number
[in]chchannel number that is currently selected

◆ tamagawa_set_baudrate()

void tamagawa_set_baudrate ( struct tamagawa_priv priv,
double  baudrate 
)

Update the values for oversample rate and division factor for Tx and Rx.

Parameters
[in]privcookie returned by tamagawa_init
[in]baudratebaud rate of the tamagawa encoder

◆ tamagawa_eeprom_crc_reinit()

void tamagawa_eeprom_crc_reinit ( struct tamagawa_priv priv)

Reset the values of the variables used in CRC calculation to 0.

Parameters
[in]privcookie returned by tamagawa_init

◆ tamagawa_reverse_bits()

uint32_t tamagawa_reverse_bits ( int8_t  data)

Reverse the bits of a number.

Parameters
[in]data8 bit value for any of CF(Control Field), ADF(address of EEPROM) or EDF(data for EEPROM)
Return values
reversed_numnumber obtained after reversing the bits of data provided

◆ tamagawa_prepare_eeprom_tx_data()

uint64_t tamagawa_prepare_eeprom_tx_data ( uint64_t  eeprom_tx_data,
volatile uint32_t  data 
)

Add the start and the stop bit to the reversed data.

Parameters
[in]eeprom_tx_dataholds the value of the Tx data to be sent
[in]dataholds the value of CF(Control Field), ADF(address of EEPROM) or EDF(data for EEPROM)
Return values
eeprom_tx_data64 bit integer that holds the value of the Tx data to be sent

◆ tamagawa_prepare_eeprom_command()

void tamagawa_prepare_eeprom_command ( struct tamagawa_priv priv,
int32_t  cmd,
uint32_t  ch 
)

Prepare the required EEPROM command from the CF(Control Field), ADF(address of EEPROM) and EDF(data for EEPROM).

Parameters
[in]privcookie returned by tamagawa_init
[in]cmdtamagawa command number
[in]chchannel number that is currently selected