This module contains structures that define the PRU-ICSS firmware interface for Tamagawa encoder communication. These structures are mapped to PRU DRAM and provide the communication interface between ARM and PRU cores.
Data Structures | |
| struct | tamagawa_ch_info |
| Structure defining Tamagawa per channel interface. More... | |
| struct | tamagawa_cmd |
| Structure defining Tamagawa command interface. More... | |
| struct | tamagawa_fw_config |
| Structure defining Tamagawa configuration interface. More... | |
| struct | tamagawa_rx_frames |
| Tamagawa received frame data. More... | |
| struct | tamagawa_interface |
| Tamagawa main interface structure. More... | |
| struct | tamagawa_channel_config |
| Tamagawa channel configuration structure. More... | |
| struct | tamagawa_periodic_trigger_cfg |
| Tamagawa periodic trigger configuration structure. More... | |
| struct | tamagawa_eeprom_interface |
| Tamagawa EEPROM interface structure. More... | |
| struct | tamagawa_xchg |
| Structure defining complete Tamagawa PRU-ICSS exchange interface. More... | |
| struct | tamagawa_clk_cfg |
| Tamagawa clock configuration structure. More... | |
| struct | tamagawa_attrs |
| Tamagawa attributes structure. More... | |
| struct | tamagawa_priv |
| Tamagawa private runtime state structure. More... | |
| struct | tamagawa_config |
| Tamagawa configuration structure (handle) More... | |
| struct | tamagawa_params |
| Tamagawa initialization parameters structure. More... | |
Functions | |
| void | tamagawa_params_init (tamagawa_params *params) |
| Initialize Tamagawa parameters structure with default values. More... | |
| tamagawa_handle | tamagawa_init (uint32_t index, const tamagawa_params *params) |
| Initialize a Tamagawa instance. More... | |
| void | tamagawa_deinit (tamagawa_handle handle) |
| Deinitialize Tamagawa interface and release resources. More... | |
| int32_t | tamagawa_command_process (tamagawa_handle handle, int32_t cmd) |
| Process a Tamagawa command (build, send, and wait for completion) More... | |
| int32_t | tamagawa_command_build (tamagawa_handle handle, int32_t cmd) |
| Build a Tamagawa command in the PRU interface. More... | |
| int32_t | tamagawa_command_send (tamagawa_handle handle) |
| Trigger sending the Tamagawa command in PRU. More... | |
| int32_t | tamagawa_command_wait (tamagawa_handle handle) |
| Wait until PRU finishes Tamagawa transaction. More... | |
| int32_t | tamagawa_config_global_rx_arm_cnt (tamagawa_handle handle, uint16_t rx_en_cnt) |
| Configure global RX auto arm counter for Tamagawa interface. More... | |
| int32_t | tamagawa_config_clock (tamagawa_handle handle, tamagawa_clk_cfg *clk_cfg) |
| Configure Tamagawa clock dividers and source selection. More... | |
| int32_t | tamagawa_config_host_trigger (tamagawa_handle handle) |
| Configure Tamagawa interface for host trigger mode. More... | |
| int32_t | tamagawa_config_periodic_trigger_cmp_mode (tamagawa_handle handle) |
| Configure Tamagawa interface for periodic trigger using IEP compare mode. More... | |
| int32_t | tamagawa_config_channel (tamagawa_handle handle, uint8_t mask) |
| Configure channel mask for Tamagawa interface. More... | |
| int32_t | tamagawa_multi_channel_set_cur (tamagawa_handle handle, uint8_t ch) |
| Set current channel for receive processing in multi-channel mode. More... | |
| int32_t | tamagawa_update_data_id (tamagawa_handle handle, int32_t cmd) |
| Update the current requested command ID in Tamagawa interface. More... | |
| int32_t | tamagawa_update_adf (tamagawa_handle handle, uint32_t val, uint8_t ch) |
| Update the ADF (EEPROM address) field for EEPROM command. More... | |
| int32_t | tamagawa_update_edf (tamagawa_handle handle, uint32_t val, uint8_t ch) |
| Update the EDF (EEPROM data) field for EEPROM Write command. More... | |
| int32_t | tamagawa_parse (tamagawa_handle handle, int32_t cmd) |
| Parse the data in Tamagawa interface received from the encoder. More... | |
| int32_t | tamagawa_crc_verify (tamagawa_handle handle) |
| Verify the CRC computed by PRU firmware against encoder CRC. More... | |
| int32_t | tamagawa_update_crc (tamagawa_handle handle, int32_t cmd, uint8_t ch) |
| Update CRC field for EEPROM command. More... | |
| int32_t | tamagawa_set_baudrate (tamagawa_handle handle, double baud_rate) |
| Set Tamagawa communication baud rate. More... | |
| const tamagawa_attrs * | tamagawa_get_attrs (tamagawa_handle handle) |
| Get pointer to Tamagawa attributes structure. More... | |
| tamagawa_priv * | tamagawa_get_priv (tamagawa_handle handle) |
| Get pointer to Tamagawa private structure. More... | |
| int32_t | tamagawa_config_iep_cmp_event (tamagawa_handle handle, uint8_t channel, uint8_t event_num) |
| Configure IEP CMP event for periodic trigger (DMEM configuration only) More... | |
| int32_t | tamagawa_config_iep_cap_event (tamagawa_handle handle, uint8_t channel, uint8_t event_num) |
| Configure IEP CAP event for periodic trigger (DMEM configuration only) More... | |
| int32_t | tamagawa_config_periodic_trigger_cap_mode (tamagawa_handle handle) |
| Configure Tamagawa interface for periodic trigger using IEP capture mode. More... | |
Typedefs | |
| typedef tamagawa_config * | tamagawa_handle |
| Tamagawa handle type. More... | |
Enumerations | |
| enum | tamagawa_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_CMP_CMD, PERIODIC_TRIGGER_CAP_CMD, DATA_ID_NUM } |
| Tamagawa Data ID codes. More... | |
Macros | |
| #define | TAMAGAWA_MAX_CHANNELS_PER_SLICE (3) |
| Maximum number of channels supported per PRU slice. More... | |
| #define | TAMAGAWA_MODE_SINGLE_CHANNEL_SINGLE_PRU (0U) |
| Single PRU - Single channel configuration mode. More... | |
| #define | TAMAGAWA_MODE_MULTI_CHANNEL_SINGLE_PRU (1U) |
| Single PRU - Multichannel configuration mode. More... | |
| #define | TAMAGAWA_MODE_MULTI_CHANNEL_MULTI_PRU (2U) |
| Multi PRU - Load share configuration mode. More... | |
| #define | TAMAGAWA_OPMODE_PERIODIC_CMP (0x0U) |
| Tamagawa operation mode: Periodic trigger mode using iep compare event. More... | |
| #define | TAMAGAWA_OPMODE_HOST_TRIGGER (0x1U) |
| Tamagawa operation mode: Host trigger. More... | |
| #define | TAMAGAWA_OPMODE_PERIODIC_CAP (0x2U) |
| Tamagawa operation mode: Periodic trigger mode using iep capture event. More... | |
| #define | TAMAGAWA_ENABLE_CYCLE_TRIGGER (0x1) |
| Enable cycle trigger for firmware. More... | |
| #define | TAMAGAWA_DISABLE_CYCLE_TRIGGER (0x0) |
| Disable cycle trigger for firmware. More... | |
| #define | TAMAGAWA_FREQ_2_5_MHZ (2500000U) |
| Allowed Tamagawa communication frequency: 2.5 MHz. More... | |
| #define | TAMAGAWA_FREQ_5_MHZ (5000000U) |
| Allowed Tamagawa communication frequency: 5 MHz. More... | |
| #define | TAMAGAWA_IEP_MAX_CAP_EVENT (0x8U) |
| Maximum IEP CAP event number (0-7) More... | |
| #define | TAMAGAWA_IEP_MAX_CMP_EVENT (0x10U) |
| Maximum IEP CMP event number (0-15) More... | |
| #define | TAMAGAWA_MAX_EEPROM_ADDRESS (127) |
| Maximum EEPROM address that can be used for EEPROM Read/Write. More... | |
| #define | TAMAGAWA_MAX_EEPROM_WRITE_DATA (255) |
| Maximum value that can be written to EEPROM. More... | |
| #define | TAMAGAWA_RX_OVERSAMPLING_RATE (7) |
| RX oversampling rate. Set 7 for 8x oversampling. More... | |
| #define | TAMAGAWA_DELAY_COUNTER_INCREMENT (5) |
| Delay counter increment value. 5 ns based on 200 MHz clock, as Three Channel Peripheral interface needs this value in 200 MHz clock units. More... | |
| #define | TAMAGAWA_EEPROM_WRITE_CRC_BYTES (3) |
| Number of bytes in CRC calculation for EEPROM Write (CF + ADF + EDF) More... | |
| #define | TAMAGAWA_EEPROM_READ_CRC_BYTES (2) |
| Number of bytes in CRC calculation for EEPROM Read (CF + ADF) More... | |
| #define | TAMAGAWA_BITS_PER_BYTE (8) |
| Number of bits in a byte. More... | |
| #define | TAMAGAWA_CRC_DATA_ARRAY_SIZE (12) |
| CRC calculation array size for storing frame data. More... | |
| #define | TAMAGAWA_DEFAULT_CMD_WAIT_DELAY_US (100) |
| Default command process delay in microseconds. More... | |
| #define | TAMAGAWA_DEFAULT_MAX_WAIT_LOOP_COUNT (50U) |
| Default maximum wait loop count. More... | |
| #define | TAMAGAWA_CF_EEPROM_WRITE (0x32U) |
| Tamagawa EEPROM Control Field value for Write operation. More... | |
| #define | TAMAGAWA_CF_EEPROM_READ (0xEAU) |
| Tamagawa EEPROM Control Field value for Read operation. More... | |
| #define | TAMAGAWA_CFG_REG_SIZE (4U) |
| IEP CAP0 register offset - cslr common file does not have defined cap registers FIXME: Remove these definitions once they are available in cslr_common.h. More... | |
| #define | TAMAGAWA_CSL_ICSS_PR1_IEP0_SLV_CAP0_REG0 (CSL_ICSS_PR1_IEP0_SLV_CAP_CFG_REG + 2U*TAMAGAWA_CFG_REG_SIZE) |
| #define | TAMAGAWA_8_BYTE_REG_OFFSET (8U) |
| 8-byte register offset for IEP registers More... | |
| #define TAMAGAWA_MAX_CHANNELS_PER_SLICE (3) |
Maximum number of channels supported per PRU slice.
| #define TAMAGAWA_MODE_SINGLE_CHANNEL_SINGLE_PRU (0U) |
Single PRU - Single channel configuration mode.
Only one channel (ch0, ch1, or ch2) is used with a single PRU core. This is the simplest configuration for single encoder applications.
| #define TAMAGAWA_MODE_MULTI_CHANNEL_SINGLE_PRU (1U) |
Single PRU - Multichannel configuration mode.
Multiple channels (up to 3: ch0, ch1, ch2) are managed by a single PRU core. All channels share the same PRU core resources without load sharing.
| #define TAMAGAWA_MODE_MULTI_CHANNEL_MULTI_PRU (2U) |
Multi PRU - Load share configuration mode.
Multiple channels are distributed across multiple PRU cores with load sharing. Each PRU core handles different channels with synchronized global reinit operations.
| #define TAMAGAWA_OPMODE_PERIODIC_CMP (0x0U) |
Tamagawa operation mode: Periodic trigger mode using iep compare event.
In periodic mode, the PRU firmware automatically triggers position readout based on IEP compare events.
| #define TAMAGAWA_OPMODE_HOST_TRIGGER (0x1U) |
Tamagawa operation mode: Host trigger.
In host trigger mode, the R5F host processor explicitly triggers each position readout by setting the trigger bit.
| #define TAMAGAWA_OPMODE_PERIODIC_CAP (0x2U) |
Tamagawa operation mode: Periodic trigger mode using iep capture event.
In periodic mode, the PRU firmware automatically triggers position readout based on IEP capture events.
| #define TAMAGAWA_ENABLE_CYCLE_TRIGGER (0x1) |
Enable cycle trigger for firmware.
| #define TAMAGAWA_DISABLE_CYCLE_TRIGGER (0x0) |
Disable cycle trigger for firmware.
| #define TAMAGAWA_FREQ_2_5_MHZ (2500000U) |
Allowed Tamagawa communication frequency: 2.5 MHz.
| #define TAMAGAWA_FREQ_5_MHZ (5000000U) |
Allowed Tamagawa communication frequency: 5 MHz.
| #define TAMAGAWA_IEP_MAX_CAP_EVENT (0x8U) |
Maximum IEP CAP event number (0-7)
IEP supports 8 capture events (CAP0-CAP7)
| #define TAMAGAWA_IEP_MAX_CMP_EVENT (0x10U) |
Maximum IEP CMP event number (0-15)
IEP supports 16 compare events (CMP0-CMP15)
| #define TAMAGAWA_MAX_EEPROM_ADDRESS (127) |
Maximum EEPROM address that can be used for EEPROM Read/Write.
| #define TAMAGAWA_MAX_EEPROM_WRITE_DATA (255) |
Maximum value that can be written to EEPROM.
| #define TAMAGAWA_RX_OVERSAMPLING_RATE (7) |
RX oversampling rate. Set 7 for 8x oversampling.
| #define TAMAGAWA_DELAY_COUNTER_INCREMENT (5) |
Delay counter increment value. 5 ns based on 200 MHz clock, as Three Channel Peripheral interface needs this value in 200 MHz clock units.
| #define TAMAGAWA_EEPROM_WRITE_CRC_BYTES (3) |
Number of bytes in CRC calculation for EEPROM Write (CF + ADF + EDF)
| #define TAMAGAWA_EEPROM_READ_CRC_BYTES (2) |
Number of bytes in CRC calculation for EEPROM Read (CF + ADF)
| #define TAMAGAWA_BITS_PER_BYTE (8) |
Number of bits in a byte.
| #define TAMAGAWA_CRC_DATA_ARRAY_SIZE (12) |
CRC calculation array size for storing frame data.
| #define TAMAGAWA_DEFAULT_CMD_WAIT_DELAY_US (100) |
Default command process delay in microseconds.
This delay is used in command wait loops to prevent busy-waiting and allow timeout detection. Can be overridden via tamagawa_params.
| #define TAMAGAWA_DEFAULT_MAX_WAIT_LOOP_COUNT (50U) |
Default maximum wait loop count.
Maximum number of wait loop iterations in tamagawa_command_wait to detect communication failures. The actual timeout is: max_wait_loop_count × cmd_wait_delay_us. With defaults (50 × 100 us = 5000 us). Can be overridden via tamagawa_params.
| #define TAMAGAWA_CF_EEPROM_WRITE (0x32U) |
Tamagawa EEPROM Control Field value for Write operation.
| #define TAMAGAWA_CF_EEPROM_READ (0xEAU) |
Tamagawa EEPROM Control Field value for Read operation.
| #define TAMAGAWA_CFG_REG_SIZE (4U) |
IEP CAP0 register offset - cslr common file does not have defined cap registers FIXME: Remove these definitions once they are available in cslr_common.h.
| #define TAMAGAWA_CSL_ICSS_PR1_IEP0_SLV_CAP0_REG0 (CSL_ICSS_PR1_IEP0_SLV_CAP_CFG_REG + 2U*TAMAGAWA_CFG_REG_SIZE) |
| #define TAMAGAWA_8_BYTE_REG_OFFSET (8U) |
8-byte register offset for IEP registers
| typedef tamagawa_config* tamagawa_handle |
Tamagawa handle type.
Opaque pointer to a Tamagawa configuration structure. Returned by tamagawa_init and used in all Tamagawa APIs.
| enum tamagawa_data_id |
Tamagawa Data ID codes.
| void tamagawa_params_init | ( | tamagawa_params * | params | ) |
Initialize Tamagawa parameters structure with default values.
This function initializes a tamagawa_params structure with default values. Call this function before setting custom parameters and passing to tamagawa_init.
| [out] | params | Pointer to tamagawa_params structure to initialize |
| tamagawa_handle tamagawa_init | ( | uint32_t | index, |
| const tamagawa_params * | params | ||
| ) |
Initialize a Tamagawa instance.
This function initializes a Tamagawa instance by setting up the firmware interface and configuring hardware based on tamagawa_attrs and tamagawa_params. The function validates all input parameters and initializes the PRU-ICSS interface.
This function performs the following operations:
Internal API calls (in order):
| [in] | index | Index of Tamagawa handle to use in the gTamagawaHandle handle array |
| [in] | params | Pointer to structure containing Tamagawa parameters. Use tamagawa_params_init to initialize with defaults before setting custom values. Must not be NULL. |
| handle | Pointer to initialized tamagawa_handle instance |
| NULL | On validation failure (invalid index, NULL params, invalid configuration, or internal API call failure) |
| void tamagawa_deinit | ( | tamagawa_handle | handle | ) |
Deinitialize Tamagawa interface and release resources.
This function deinitializes a Tamagawa instance by marking it as closed. It does not free memory as the handle is statically allocated via SysConfig. After calling this function, the handle should not be used until reinitialized with tamagawa_init.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| int32_t tamagawa_command_process | ( | tamagawa_handle | handle, |
| int32_t | cmd | ||
| ) |
Process a Tamagawa command (build, send, and wait for completion)
This function combines command setup, triggering, and waiting for completion in a single call. It internally calls:
For EEPROM commands (DATA_ID_6, DATA_ID_D), the function also resets the command ID for all channels after completion. The multi-channel mask for EEPROM operations is determined automatically from the enabled channels configured in the attrs structure.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| [in] | cmd | Tamagawa command number (see tamagawa_data_id) |
| SystemP_SUCCESS | Command processed successfully |
| SystemP_TIMEOUT | On timeout waiting for firmware acknowledgment (propagated from tamagawa_command_wait) |
| SystemP_FAILURE | Command processing failed (invalid handle or invalid command) |
| int32_t tamagawa_command_build | ( | tamagawa_handle | handle, |
| int32_t | cmd | ||
| ) |
Build a Tamagawa command in the PRU interface.
This function sets up the Tamagawa command parameters in the PRU interface based on the command type. The command is not sent until tamagawa_command_send is called. For EEPROM commands (DATA_ID_6, DATA_ID_D), this function prepares the TX data with CF, ADF, EDF, and CRC fields. The multi-channel mask for EEPROM operations is determined automatically from the enabled channels configured in the attrs structure.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| [in] | cmd | Tamagawa command number (see tamagawa_data_id) |
| SystemP_SUCCESS | Command built successfully |
| SystemP_FAILURE | Command build failed (invalid handle, unsupported command) |
| int32_t tamagawa_command_send | ( | tamagawa_handle | handle | ) |
Trigger sending the Tamagawa command in PRU.
This function triggers the PRU firmware to send the command that was previously set up using tamagawa_command_build. It sets the trigger bit in the PRU interface, which signals the firmware to start the transaction.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| SystemP_SUCCESS | Command trigger successful |
| SystemP_FAILURE | NULL handle provided |
| int32_t tamagawa_command_wait | ( | tamagawa_handle | handle | ) |
Wait until PRU finishes Tamagawa transaction.
This function waits in a polling loop until the PRU firmware clears the trigger bit, indicating that the command has been completed. This is a blocking call with timeout protection.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| SystemP_SUCCESS | Command completed successfully |
| SystemP_FAILURE | NULL handle provided |
| SystemP_TIMEOUT | Timeout occurred (configured via tamagawa_params.max_wait_loop_count before calling tamagawa_init, default: 5000 us = 50 loops × 100 us/loop) |
| int32_t tamagawa_config_global_rx_arm_cnt | ( | tamagawa_handle | handle, |
| uint16_t | rx_en_cnt | ||
| ) |
Configure global RX auto arm counter for Tamagawa interface.
This function configures the global RX auto arm counter register for all three channels. The counter value determines the timing for RX enable.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| [in] | rx_en_cnt | Value to be set in global RX auto arm counter register |
| SystemP_SUCCESS | Configuration successful |
| SystemP_FAILURE | NULL handle provided |
| int32_t tamagawa_config_clock | ( | tamagawa_handle | handle, |
| tamagawa_clk_cfg * | clk_cfg | ||
| ) |
Configure Tamagawa clock dividers and source selection.
This function configures the PRU Three Channel Peripheral Interface's RX and TX clock dividers and clock source selection. It writes to PRUx_ED_RXCFG and PRUx_ED_TXCFG registers.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| [in] | clk_cfg | Pointer to structure containing clock configuration data |
| SystemP_SUCCESS | Configuration successful |
| SystemP_FAILURE | NULL handle or NULL clk_cfg provided |
| int32_t tamagawa_config_host_trigger | ( | tamagawa_handle | handle | ) |
Configure Tamagawa interface for host trigger mode.
In this mode, commands are sent when explicitly triggered by the host using tamagawa_command_send.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| SystemP_SUCCESS | Configuration successful |
| SystemP_FAILURE | NULL handle provided |
| int32_t tamagawa_config_periodic_trigger_cmp_mode | ( | tamagawa_handle | handle | ) |
Configure Tamagawa interface for periodic trigger using IEP compare mode.
Configures the Tamagawa firmware to use IEP CMP (compare) events for periodic triggering. Position data is sampled automatically when the IEP compare event occurs.
Configuration requirements:
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| SystemP_SUCCESS | Configuration successful |
| SystemP_FAILURE | NULL handle provided |
| int32_t tamagawa_config_channel | ( | tamagawa_handle | handle, |
| uint8_t | mask | ||
| ) |
Configure channel mask for Tamagawa interface.
This function configures the channel mask for both single-channel and multi-channel modes. In single-channel mode, it also stores the specific channel index in priv->channel based on the channel enable flags (channel0_enabled, channel1_enabled, channel2_enabled).
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| [in] | mask | Channel mask (valid range 1-7 for up to 3 channels)
|
| SystemP_SUCCESS | Configuration successful |
| SystemP_FAILURE | NULL handle or invalid mask (mask == 0 or mask > 0x07) |
| int32_t tamagawa_multi_channel_set_cur | ( | tamagawa_handle | handle, |
| uint8_t | ch | ||
| ) |
Set current channel for receive processing in multi-channel mode.
In multi-channel configuration, after the receive transaction is complete, call this function to select each channel before invoking RX parsing APIs to process the data received on that channel.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| [in] | ch | Channel number to be selected (0-2, see TAMAGAWA_MAX_CHANNELS_PER_SLICE) |
| SystemP_SUCCESS | Configuration successful |
| SystemP_FAILURE | NULL handle or invalid channel (ch >= TAMAGAWA_MAX_CHANNELS_PER_SLICE) |
| int32_t tamagawa_update_data_id | ( | tamagawa_handle | handle, |
| int32_t | cmd | ||
| ) |
Update the current requested command ID in Tamagawa interface.
This function updates the data_id field in the Tamagawa interface structure. For EEPROM commands (DATA_ID_6, DATA_ID_D), it also sets the command ID for all three channels in the EEPROM interface.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| [in] | cmd | Tamagawa command number (see tamagawa_data_id) |
| SystemP_SUCCESS | Update successful |
| SystemP_FAILURE | NULL handle provided |
| int32_t tamagawa_update_adf | ( | tamagawa_handle | handle, |
| uint32_t | val, | ||
| uint8_t | ch | ||
| ) |
Update the ADF (EEPROM address) field for EEPROM command.
This function updates the ADF (Address Field) in the Tamagawa EEPROM interface for the specified channel. This is used for both EEPROM Read (DATA_ID_D) and EEPROM Write (DATA_ID_6) commands.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| [in] | val | ADF value to be updated (valid range 0-127, see TAMAGAWA_MAX_EEPROM_ADDRESS) |
| [in] | ch | Channel number that is currently selected (0-2, see TAMAGAWA_MAX_CHANNELS_PER_SLICE) |
| SystemP_SUCCESS | Update successful |
| SystemP_FAILURE | NULL handle, invalid channel (ch >= TAMAGAWA_MAX_CHANNELS_PER_SLICE), or invalid ADF value (val > TAMAGAWA_MAX_EEPROM_ADDRESS) |
| int32_t tamagawa_update_edf | ( | tamagawa_handle | handle, |
| uint32_t | val, | ||
| uint8_t | ch | ||
| ) |
Update the EDF (EEPROM data) field for EEPROM Write command.
This function updates the EDF (Encoder Data Field) in the Tamagawa EEPROM interface for the specified channel. This is used only for EEPROM Write (DATA_ID_6) commands.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| [in] | val | EDF value to be updated (valid range 0-255, see TAMAGAWA_MAX_EEPROM_WRITE_DATA) |
| [in] | ch | Channel number that is currently selected (0-2, see TAMAGAWA_MAX_CHANNELS_PER_SLICE) |
| SystemP_SUCCESS | Update successful |
| SystemP_FAILURE | NULL handle, invalid channel (ch >= TAMAGAWA_MAX_CHANNELS_PER_SLICE), or invalid EDF value (val > TAMAGAWA_MAX_EEPROM_WRITE_DATA) |
| int32_t tamagawa_parse | ( | tamagawa_handle | handle, |
| int32_t | cmd | ||
| ) |
Parse the data in Tamagawa interface received from the encoder.
This function extracts and parses the received frame data based on the command type. It populates the rx_frames_received structure in the Tamagawa interface with the parsed data (CF, SF, ABS, ABM, ENID, ALMC, ADF, EDF, CRC).
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| [in] | cmd | Tamagawa command number (see tamagawa_data_id) |
| SystemP_SUCCESS | Data parsed successfully |
| SystemP_FAILURE | Parsing failed (invalid handle or unsupported command) |
| int32_t tamagawa_crc_verify | ( | tamagawa_handle | handle | ) |
Verify the CRC computed by PRU firmware against encoder CRC.
This function checks the CRC verification result computed by the PRU firmware. The firmware calculates CRC and stores the result in cal_crc field. A value of 1 indicates successful CRC verification.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| SystemP_SUCCESS | CRC verification passed |
| SystemP_FAILURE | CRC verification failed or NULL handle |
| int32_t tamagawa_update_crc | ( | tamagawa_handle | handle, |
| int32_t | cmd, | ||
| uint8_t | ch | ||
| ) |
Update CRC field for EEPROM command.
This function calculates and updates the CRC field for EEPROM commands based on CF, ADF, and EDF values. It internally calls the CRC calculation function. For EEPROM Write (DATA_ID_6), CRC is calculated over 3 bytes (CF + ADF + EDF). For EEPROM Read (DATA_ID_D), CRC is calculated over 2 bytes (CF + ADF).
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| [in] | cmd | Tamagawa command number (DATA_ID_6 or DATA_ID_D) |
| [in] | ch | Channel number that is currently selected (0-2, see TAMAGAWA_MAX_CHANNELS_PER_SLICE) |
| SystemP_SUCCESS | CRC update successful |
| SystemP_FAILURE | NULL handle or invalid channel (ch >= TAMAGAWA_MAX_CHANNELS_PER_SLICE) |
| int32_t tamagawa_set_baudrate | ( | tamagawa_handle | handle, |
| double | baud_rate | ||
| ) |
Set Tamagawa communication baud rate.
This function calculates and configures the RX/TX division factors and oversampling rate based on the specified baud rate. It internally calls:
The function also updates the firmware interface with the calculated division factors and oversampling rate.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| [in] | baud_rate | Baud rate of the Tamagawa encoder in Hz (2.5 MHz or 5 MHz) |
| SystemP_SUCCESS | Configuration successful |
| SystemP_FAILURE | NULL handle provided |
| const tamagawa_attrs* tamagawa_get_attrs | ( | tamagawa_handle | handle | ) |
Get pointer to Tamagawa attributes structure.
This function returns a const pointer to the attributes structure containing compile-time configuration parameters from SysConfig. The attrs structure is read-only and should not be modified.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| attrs | Pointer to const tamagawa_attrs structure |
| NULL | If handle is NULL |
| tamagawa_priv* tamagawa_get_priv | ( | tamagawa_handle | handle | ) |
Get pointer to Tamagawa private structure.
This function returns a pointer to the private structure containing runtime state information. This is typically used for advanced operations or debugging.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| priv | Pointer to tamagawa_priv structure |
| NULL | If handle is NULL |
| int32_t tamagawa_config_iep_cmp_event | ( | tamagawa_handle | handle, |
| uint8_t | channel, | ||
| uint8_t | event_num | ||
| ) |
Configure IEP CMP event for periodic trigger (DMEM configuration only)
This function configures the IEP compare event information in PRU shared memory (DMEM) for firmware access. It writes the event number to trigger_params structure. This function does NOT configure IEP hardware registers.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| [in] | channel | Tamagawa channel number (0-2). Used in load share mode, ignored in single PRU mode (always uses index 0). |
| [in] | event_num | CMP event number (0-15) |
| SystemP_SUCCESS | CMP event configured successfully |
| SystemP_FAILURE | On NULL handle or invalid event_num/channel |
| int32_t tamagawa_config_iep_cap_event | ( | tamagawa_handle | handle, |
| uint8_t | channel, | ||
| uint8_t | event_num | ||
| ) |
Configure IEP CAP event for periodic trigger (DMEM configuration only)
This function configures the IEP capture event information in PRU shared memory (DMEM) for firmware access. It writes the capture register address and event number to trigger_params structure. This function does NOT configure IEP hardware registers.
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| [in] | channel | Tamagawa channel number (0-2). Used in load share mode, ignored in single PRU mode (always uses index 0). |
| [in] | event_num | CAP event number (0-7) |
| SystemP_SUCCESS | CAP event configured successfully |
| SystemP_FAILURE | On NULL handle, invalid event_num/channel, or NULL IEP base address |
| int32_t tamagawa_config_periodic_trigger_cap_mode | ( | tamagawa_handle | handle | ) |
Configure Tamagawa interface for periodic trigger using IEP capture mode.
Configures the Tamagawa firmware to use IEP CAP (capture) events for periodic triggering. Position data is sampled automatically when an external signal triggers the IEP capture event.
Configuration requirements:
| [in] | handle | Tamagawa handle returned by tamagawa_init |
| SystemP_SUCCESS | CAP mode configured successfully |
| SystemP_FAILURE | On NULL handle |