AM261x Motor Control SDK  10.02.00
nikon_api.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024-25 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 NIKON_API_H_
34 #define NIKON_API_H_
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 #include "nikon_drv.h"
40 
58 int32_t nikon_command_wait(struct nikon_priv *priv);
59 
67 int32_t nikon_get_pos(struct nikon_priv *priv, uint32_t cmd);
68 
76 void nikon_config_clock(struct nikon_priv *priv,
77  struct nikon_clk_cfg *clk_cfg);
78 
95 struct nikon_priv *nikon_init(PRUICSS_Handle gPruIcssXHandle,
96  uint32_t slice,
97  float_t frequency,
98  uint32_t core_clk_freq,
99  uint32_t uart_clk_freq,
100  uint32_t tx_rx_clock_source,
101  uint32_t mask,
102  uint32_t totalch,
103  uint32_t protocol_version);
104 
111 
118 int32_t nikon_calc_clock(struct nikon_priv *priv, struct nikon_clk_cfg *clk_cfg);
119 
126 void nikon_generate_cdf(struct nikon_priv *priv, uint32_t cmd);
127 
136 uint64_t nikon_reverse_bits(uint64_t bits, uint32_t num_bits);
137 
144 uint32_t nikon_calc_3bitcrc(struct nikon_priv *priv, uint32_t cmd);
145 
153 void nikon_config_load_share(struct nikon_priv *priv, uint8_t mask);
154 
161 
168 
175 
187  uint32_t num_encoders,
188  uint32_t single_turn_len[],
189  uint32_t multi_turn_len[],
190  uint32_t ch);
191 
199 void nikon_update_clock_freq(struct nikon_priv *priv, float_t frequency);
200 
208 uint32_t nikon_get_current_channel(struct nikon_priv *priv, uint32_t ch_idx);
209 
216 uint32_t nikon_get_totalchannels(struct nikon_priv *priv);
217 
225 void nikon_update_enc_addr(struct nikon_priv *priv, uint32_t enc_addr, uint32_t ls_ch);
226 
234 void nikon_update_eeprom_addr(struct nikon_priv *priv, uint8_t addr, uint32_t ls_ch);
235 
243 void nikon_update_eeprom_data(struct nikon_priv *priv, uint16_t data, uint32_t ls_ch);
244 
252 void nikon_update_id_code(struct nikon_priv *priv, uint32_t data, uint32_t ls_ch);
253 
261 void nikon_update_velocity_coefficient(struct nikon_priv *priv, uint32_t data, uint32_t ls_ch);
262 
270 void nikon_update_eeprom_bank(struct nikon_priv *priv, uint8_t bank, uint32_t ls_ch);
271 
273 #ifdef __cplusplus
274 }
275 #endif
276 
277 #endif
nikon_priv::uart_clk_freq
uint32_t uart_clk_freq
Definition: nikon_drv.h:420
nikon_update_eeprom_addr
void nikon_update_eeprom_addr(struct nikon_priv *priv, uint8_t addr, uint32_t ls_ch)
Access encoder's EEPROM location specified by the user.
nikon_drv.h
nikon_reverse_bits
uint64_t nikon_reverse_bits(uint64_t bits, uint32_t num_bits)
Reverse the bits (LSB to be sent out first) provided as parameters.
nikon_config_clock
void nikon_config_clock(struct nikon_priv *priv, struct nikon_clk_cfg *clk_cfg)
Configure Nikon clock.
nikon_priv::tx_rx_clock_source
uint32_t tx_rx_clock_source
Definition: nikon_drv.h:422
nikon_get_pos
int32_t nikon_get_pos(struct nikon_priv *priv, uint32_t cmd)
Get single cycle Nikon position data.
nikon_update_enc_addr
void nikon_update_enc_addr(struct nikon_priv *priv, uint32_t enc_addr, uint32_t ls_ch)
Update encoder address as specified by the user. Default initial address is 0.
nikon_get_totalchannels
uint32_t nikon_get_totalchannels(struct nikon_priv *priv)
Retrives total number of channels configured.
nikon_priv::protocol_version
uint8_t protocol_version
Definition: nikon_drv.h:462
nikon_config_host_trigger
void nikon_config_host_trigger(struct nikon_priv *priv)
Configure host trigger operation mode.
nikon_priv::core_clk_freq
uint32_t core_clk_freq
Definition: nikon_drv.h:418
nikon_calc_3bitcrc
uint32_t nikon_calc_3bitcrc(struct nikon_priv *priv, uint32_t cmd)
Calculate 3 bit otf crc and generate tx command.
nikon_update_clock_freq
void nikon_update_clock_freq(struct nikon_priv *priv, float_t frequency)
Update the operating baud rate as user specified baud rate through UART menu.
nikon_wait_for_encoder_detection
int32_t nikon_wait_for_encoder_detection(struct nikon_priv *priv)
Detect whether the connected encoder is of selected frequency.
nikon_command_wait
int32_t nikon_command_wait(struct nikon_priv *priv)
Wait till PRU finishes Nikon transaction.
nikon_priv
Initialize NIKON firmware interface address and get the pointer to struct nikon_priv instance.
Definition: nikon_drv.h:387
nikon_update_enc_len
void nikon_update_enc_len(struct nikon_priv *priv, uint32_t num_encoders, uint32_t single_turn_len[], uint32_t multi_turn_len[], uint32_t ch)
Update number of encoders connected in bus or one-to-one and update data lengths of those encoders.
nikon_priv::single_turn_len
uint32_t single_turn_len[NUM_ED_CH_MAX][NUM_ENCODERS_MAX]
Definition: nikon_drv.h:398
nikon_calc_clock
int32_t nikon_calc_clock(struct nikon_priv *priv, struct nikon_clk_cfg *clk_cfg)
Calculate Rx and Tx divisors for given frequency.
nikon_clk_cfg
Structure defining 3-ch peripheral interface clock configuration for selected frequency.
Definition: nikon_drv.h:249
nikon_priv::multi_turn_len
uint32_t multi_turn_len[NUM_ED_CH_MAX][NUM_ENCODERS_MAX]
Definition: nikon_drv.h:400
nikon_config_clr_cfg0
void nikon_config_clr_cfg0(struct nikon_priv *priv)
Clear the channel specific frame size cfg registers.
nikon_config_load_share
void nikon_config_load_share(struct nikon_priv *priv, uint8_t mask)
Configure Load Share mode for Nikon receiver.
nikon_update_velocity_coefficient
void nikon_update_velocity_coefficient(struct nikon_priv *priv, uint32_t data, uint32_t ls_ch)
Assign the specified 19 bits as velocity coefficient of encoder.
nikon_priv::num_encoders
uint32_t num_encoders[NUM_ED_CH_MAX]
Definition: nikon_drv.h:394
nikon_get_current_channel
uint32_t nikon_get_current_channel(struct nikon_priv *priv, uint32_t ch_idx)
Retrives the current channel in use.
nikon_init
struct nikon_priv * nikon_init(PRUICSS_Handle gPruIcssXHandle, uint32_t slice, float_t frequency, uint32_t core_clk_freq, uint32_t uart_clk_freq, uint32_t tx_rx_clock_source, uint32_t mask, uint32_t totalch, uint32_t protocol_version)
Initialize Nikon firmware interface address and get the pointer to struct nikon_priv instance.
nikon_update_id_code
void nikon_update_id_code(struct nikon_priv *priv, uint32_t data, uint32_t ls_ch)
Assign the specified 24bits as Identification code of encoder.
nikon_update_eeprom_bank
void nikon_update_eeprom_bank(struct nikon_priv *priv, uint8_t bank, uint32_t ls_ch)
Configure bank for memory operations in Nikon 3.0.
nikon_config_periodic_trigger
void nikon_config_periodic_trigger(struct nikon_priv *priv)
Configure periodic trigger operation mode.
nikon_generate_cdf
void nikon_generate_cdf(struct nikon_priv *priv, uint32_t cmd)
Generate CDF command to be sent to encoder. Update encoder ID appropriately with nikon_update_enc_add...
nikon_update_eeprom_data
void nikon_update_eeprom_data(struct nikon_priv *priv, uint16_t data, uint32_t ls_ch)
Write data at specified EEPROM location.