/* * ltcusb_raw_rw.h * * Created on: 14-Apr-2023 * Author: pushpkant */ /** * @file ltcusb_raw_rw.h * @brief Read and Write raw register values. */ #ifndef INCLUDE_LTCUSB_RAW_RW_H_ #define INCLUDE_LTCUSB_RAW_RW_H_ #pragma pack(1) #include "ltcusb.h" #include /** * @brief Structure to hold the raw register for USB Controller. */ typedef struct LtcUSB_reg_struct { /**@brief Address of register of USB controller.*/ uintptr_t address; /**@brief Value at the register.*/ uint32_t value; }LtcUSB_reg; /** * To read and write from the controller, set the address to this raw access * register and call the corresponding function. Read back the data from the * register value. */ extern LtcUSB_reg ltcUSB_raw_reg; /** * @brief Read the data from the USB controller at the address specified * in the reg and put it into the value of the reg. * @return 0 When successful. * @retval -1 register address is greater than maximum register address value */ extern int ltcusb_raw_read(); /** * @brief Write the data in value of reg to the USB controller at * the address specified in the reg. * @return 0 When successful. Negative on error. * @retval -1 register address is greater than maximum register address value */ extern int ltcusb_raw_write(); /** * @brief Setup the Register for accessing the data from USB controller. */ extern void *reg_setup(); /** * @brief Write data to FIFO. * @param fifo_addr The address of FIFO * @param data The data to be written. * @return 0 When success. * @retval -1 fifo_address is zero. */ extern int ltcusb_fifo_write(uintptr_t fifo_addr, uint32_t data); /** * @brief Read data from FIFO. * @param fifo_addr The address of FIFO. * @param data The data read from FIFO. * @return 0 When success. * @retval-1 fifo_address is zero. */ extern int ltcusb_fifo_read(uintptr_t fifo_addr, uint32_t* data); /** * @brief Read data from memory. * @param addr The address of memory. * @param data The data read from memory. * @return 0 When success. */ extern int ltcusb_mem_read(uintptr_t addr, uint32_t* data); /** * @brief Write data from memory. * @param addr The address of memory. * @param data The data write into the memory. * @return 0 When success. */ extern int ltcusb_mem_write(uintptr_t addr, uint32_t data); /** * @brief Write data from memory. * @param addr The address of memory. * @param data The data write into the memory. * @return 0 When success. */ extern int ltcusb_mem_write2(uintptr_t addr, void* data); /** * @brief Read data from memory. * @param addr The address of memory. * @param data The data read from memory. * @return 0 When success. */ extern int ltcusb_mem_read2(uintptr_t addr, void* data); #endif /* INCLUDE_LTCUSB_RAW_RW_H_ */