AM243x Motor Control SDK  09.01.00
endat_api.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021-23 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef ENDAT_API_H_
34 #define ENDAT_API_H_
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
65 int32_t endat_recvd_process(struct endat_priv *priv, int32_t cmd,
66  union endat_format_data *u);
67 
84 uint32_t endat_recvd_validate(struct endat_priv *priv, int32_t cmd,
85  union endat_format_data *u);
86 
97 int32_t endat_command_process(struct endat_priv *priv, int32_t cmd,
99 
110 int32_t endat_command_build(struct endat_priv *priv, int32_t cmd,
112 
120 void endat_command_send(struct endat_priv *priv);
121 
129 void endat_command_wait(struct endat_priv *priv);
130 
131 
140 uint32_t endat_get_recovery_time(struct endat_priv *priv);
141 
151 int32_t endat_get_encoder_info(struct endat_priv *priv);
152 
161 uint32_t endat_get_prop_delay(struct endat_priv *priv);
162 
172 void endat_addinfo_track(struct endat_priv *priv, int32_t cmd,
174 
183 void endat_config_clock(struct endat_priv *priv,
184  struct endat_clk_cfg *clk_cfg);
185 
194 void endat_config_tst_delay(struct endat_priv *priv, uint16_t delay);
195 
204 void endat_config_rx_arm_cnt(struct endat_priv *priv, uint16_t val);
205 
214 void endat_config_wire_delay(struct endat_priv *priv, uint16_t val);
215 
225  uint16_t val);
226 
236 
245 
254 
263 /* brief set syn_bits of all connected channels for synchronization before global_TX_init
264  *
265  * \param[in] priv cookie returned by endat_init
266  * \param[in] mask channels mask
267  *
268  */
269 void endat_config_syn_bits(struct endat_priv *priv, uint8_t mask);
278 void endat_config_primary_core_mask(struct endat_priv *priv, uint8_t mask);
294 void endat_config_channel(struct endat_priv *priv, int32_t ch);
304  uint8_t mask,
305  uint8_t loadshare);
318 
329 void endat_multi_channel_set_cur(struct endat_priv *priv, int32_t ch);
339 int32_t endat_wait_initialization(struct endat_priv *priv, uint32_t timeout, uint8_t mask);
340 
355 struct endat_priv *endat_init(struct endat_pruss_xchg *pruss_xchg, struct endatChRxInfo *endatRxInfo, uint64_t endatChInfoGlobalAddr,
356  void *pruss_cfg, void *pruss_iep, int32_t slice);
357 
374 int32_t endat_get_2_2_angle(struct endat_priv *priv);
375 
378 #ifdef __cplusplus
379 }
380 #endif
381 
382 #endif
endat_command_send
void endat_command_send(struct endat_priv *priv)
trigger sending the EnDat command in PRU
endat_config_multi_channel_mask
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
endat_config_primary_core_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
endat_wait_initialization
int32_t endat_wait_initialization(struct endat_priv *priv, uint32_t timeout, uint8_t mask)
wait for EnDat master firmware to initialize
endat_get_2_2_angle
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,...
endat_multi_channel_set_cur
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 configura...
endat_addinfo_track
void endat_addinfo_track(struct endat_priv *priv, int32_t cmd, struct cmd_supplement *cmd_supplement)
track presence of additional information in priv
endat_priv::pruss_iep
void * pruss_iep
Definition: endat_drv.h:155
endat_priv
Definition: endat_drv.h:131
endat_config_channel
void endat_config_channel(struct endat_priv *priv, int32_t ch)
select channel to be used by EnDat master
endat_recvd_validate
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 succ...
endat_command_process
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
endat_stop_continuous_mode
void endat_stop_continuous_mode(struct endat_priv *priv)
stop continuous mode
endat_format_data
Definition: endat_drv.h:227
endat_config_syn_bits
void endat_config_syn_bits(struct endat_priv *priv, uint8_t mask)
endat_start_continuous_mode
int32_t endat_start_continuous_mode(struct endat_priv *priv)
start continuous mode
endat_priv::pruss_xchg
struct endat_pruss_xchg * pruss_xchg
Definition: endat_drv.h:151
endat_config_tst_delay
void endat_config_tst_delay(struct endat_priv *priv, uint16_t delay)
configure tST delay
endat_clk_cfg
Definition: endat_drv.h:102
endat_enable_load_share_mode
void endat_enable_load_share_mode(struct endat_priv *priv)
enable load share mode if encoders has diffent make
endat_init
struct endat_priv * endat_init(struct endat_pruss_xchg *pruss_xchg, struct endatChRxInfo *endatRxInfo, uint64_t endatChInfoGlobalAddr, void *pruss_cfg, void *pruss_iep, int32_t slice)
Initialize EnDat firmware interface address and get the pointer to struct endat_priv instance.
endat_recvd_process
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
endat_get_prop_delay
uint32_t endat_get_prop_delay(struct endat_priv *priv)
get propagation delay automatically estimated by the firmware
endat_config_clock
void endat_config_clock(struct endat_priv *priv, struct endat_clk_cfg *clk_cfg)
configure EnDat clock
endat_config_rx_arm_cnt
void endat_config_rx_arm_cnt(struct endat_priv *priv, uint16_t val)
configure rx arm counter
endat_get_recovery_time
uint32_t endat_get_recovery_time(struct endat_priv *priv)
read RT from DMEM
endat_command_build
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
endat_command_wait
void endat_command_wait(struct endat_priv *priv)
wait till PRU finishes EnDat transaction
endat_priv::endatChRxInfo
struct endatChRxInfo * endatChRxInfo
Definition: endat_drv.h:152
endat_priv::pruss_cfg
void * pruss_cfg
Definition: endat_drv.h:154
endat_get_encoder_info
int32_t endat_get_encoder_info(struct endat_priv *priv)
update priv with position resolution, id, serial number, encoder type and supported command set
endat_config_periodic_trigger
void endat_config_periodic_trigger(struct endat_priv *priv)
configure EnDat master in periodic trigger mode
endat_config_host_trigger
void endat_config_host_trigger(struct endat_priv *priv)
configure EnDat master for host trigger mode
cmd_supplement
Definition: endat_drv.h:163
endat_config_wire_delay
void endat_config_wire_delay(struct endat_priv *priv, uint16_t val)
configure wire delay for the selected channel
endat_config_rx_clock_disable
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
endat_multi_channel_detected
uint8_t endat_multi_channel_detected(struct endat_priv *priv)
select channels detected in multi channel configuration by EnDat master. required to be invoked onl...