AM243x Motor Control SDK  09.02.00
nikon_api.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 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, int8_t cmd);
68 
76 void nikon_config_clock(struct nikon_priv *priv,
77  struct nikon_clk_cfg *clk_cfg);
78 
93 struct nikon_priv *nikon_init(PRUICSS_Handle gPruIcssXHandle,
94  int32_t slice,
95  float_t frequency,
96  uint32_t core_clk_freq,
97  uint32_t uart_clk_freq,
98  uint32_t mask,
99  uint32_t totalch);
100 
113 int32_t nikon_calc_clock(struct nikon_priv *priv, struct nikon_clk_cfg *clk_cfg);
120 void nikon_generate_cdf(struct nikon_priv *priv, int32_t cmd);
121 
130 int32_t nikon_reverse_bits(uint64_t bits, int32_t num_bits);
131 
138 uint32_t nikon_calc_3bitcrc(struct nikon_priv *priv, uint32_t cmd);
146 void nikon_config_load_share(struct nikon_priv *priv, int32_t mask);
147 
177  uint32_t num_encoders,
178  uint32_t single_turn_len[],
179  uint32_t multi_turn_len[],
180  uint32_t ch);
188 void nikon_update_clock_freq(struct nikon_priv *priv, float_t frequency);
196 uint32_t nikon_get_current_channel(struct nikon_priv *priv, uint32_t ch_idx);
203 uint32_t nikon_get_totalchannels(struct nikon_priv *priv);
211 void nikon_update_enc_addr(struct nikon_priv *priv, uint32_t enc_addr, uint32_t ls_ch);
218 void nikon_update_eeprom_addr(struct nikon_priv *priv, uint32_t addr);
226 void nikon_update_eeprom_data(struct nikon_priv *priv, uint32_t data_high, uint32_t data_low);
235 void nikon_update_id_code(struct nikon_priv *priv, uint32_t data_high, uint32_t data_mid, uint32_t data_low);
237 #ifdef __cplusplus
238 }
239 #endif
240 
241 #endif
nikon_priv::uart_clk_freq
uint32_t uart_clk_freq
Definition: nikon_drv.h:339
nikon_drv.h
nikon_config_clock
void nikon_config_clock(struct nikon_priv *priv, struct nikon_clk_cfg *clk_cfg)
Configure Nikon clock.
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.
nikon_get_totalchannels
uint32_t nikon_get_totalchannels(struct nikon_priv *priv)
Retrives total number of channels configured.
nikon_update_eeprom_addr
void nikon_update_eeprom_addr(struct nikon_priv *priv, uint32_t addr)
Access encoder's EEPROM location specified by the user.
nikon_config_host_trigger
void nikon_config_host_trigger(struct nikon_priv *priv)
Configure host trigger operation mode.
nikon_update_eeprom_data
void nikon_update_eeprom_data(struct nikon_priv *priv, uint32_t data_high, uint32_t data_low)
Write data at specified EEPROM location.
nikon_get_pos
int32_t nikon_get_pos(struct nikon_priv *priv, int8_t cmd)
Get single cycle Nikon position data.
nikon_priv::core_clk_freq
uint32_t core_clk_freq
Definition: nikon_drv.h:337
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 speciefied 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:304
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:315
nikon_reverse_bits
int32_t nikon_reverse_bits(uint64_t bits, int32_t num_bits)
Reverse the bits (LSB to be sent out first) provided as parameters.
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:206
nikon_generate_cdf
void nikon_generate_cdf(struct nikon_priv *priv, int32_t cmd)
Generate CDF command to be passed in Tx fifo.
nikon_priv::multi_turn_len
uint32_t multi_turn_len[NUM_ED_CH_MAX][NUM_ENCODERS_MAX]
Definition: nikon_drv.h:317
nikon_config_clr_cfg0
void nikon_config_clr_cfg0(struct nikon_priv *priv)
Clear the channel specific frame size cfg registers.
nikon_priv::num_encoders
uint32_t num_encoders[NUM_ED_CH_MAX]
Definition: nikon_drv.h:311
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_update_id_code
void nikon_update_id_code(struct nikon_priv *priv, uint32_t data_high, uint32_t data_mid, uint32_t data_low)
Assign the specified 24bits as Identification code of encoder.
nikon_config_load_share
void nikon_config_load_share(struct nikon_priv *priv, int32_t mask)
Configure Load Share mode for Nikon receiver.
nikon_config_periodic_trigger
void nikon_config_periodic_trigger(struct nikon_priv *priv)
Configure periodic trigger operation mode.
nikon_init
struct nikon_priv * nikon_init(PRUICSS_Handle gPruIcssXHandle, int32_t slice, float_t frequency, uint32_t core_clk_freq, uint32_t uart_clk_freq, uint32_t mask, uint32_t totalch)
Initialize Nikon firmware interface address and get the pointer to struct nikon_priv instance.