/** * @file ltcusb_raw_rw.h * @brief Read and Write raw register values. * @note * * ------------------------------------------------------------------ Copyright (c) 2023 by Lattice Semiconductor Corporation ALL RIGHTS RESERVED ------------------------------------------------------------------ DISCLAIMER: LATTICE MAKES NO WARRANTIES ON THIS FILE OR ITS CONTENTS, WHETHER EXPRESSED, IMPLIED, STATUTORY, OR IN ANY PROVISION OF THE LATTICE PROPEL LICENSE AGREEMENT OR COMMUNICATION WITH LICENSEE, AND LATTICE SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. LATTICE DOES NOT WARRANT THAT THE FUNCTIONS CONTAINED HEREIN WILL MEET LICENSEE 'S REQUIREMENTS, OR THAT LICENSEE' S OPERATION OF ANY DEVICE, SOFTWARE OR SYSTEM USING THIS FILE OR ITS CONTENTS WILL BE UNINTERRUPTED OR ERROR FREE, OR THAT DEFECTS HEREIN WILL BE CORRECTED. LICENSEE ASSUMES RESPONSIBILITY FOR SELECTION OF MATERIALS TO ACHIEVE ITS INTENDED RESULTS, AND FOR THE PROPER INSTALLATION, USE, AND RESULTS OBTAINED THEREFROM. LICENSEE ASSUMES THE ENTIRE RISK OF THE FILE AND ITS CONTENTS PROVING DEFECTIVE OR FAILING TO PERFORM PROPERLY AND IN SUCH EVENT, LICENSEE SHALL ASSUME THE ENTIRE COST AND RISK OF ANY REPAIR, SERVICE, CORRECTION, OR ANY OTHER LIABILITIES OR DAMAGES CAUSED BY OR ASSOCIATED WITH THE SOFTWARE. IN NO EVENT SHALL LATTICE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS FILE OR ITS CONTENTS, EVEN IF LATTICE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. LATTICE 'S SOLE LIABILITY, AND LICENSEE' S SOLE REMEDY, IS SET FORTH ABOVE. LATTICE DOES NOT WARRANT OR REPRESENT THAT THIS FILE, ITS CONTENTS OR USE THEREOF DOES NOT INFRINGE ON THIRD PARTIES' INTELLECTUAL PROPERTY RIGHTS, INCLUDING ANY PATENT. IT IS THE USER' S RESPONSIBILITY TO VERIFY THE USER SOFTWARE DESIGN FOR CONSISTENCY AND FUNCTIONALITY THROUGH THE USE OF FORMAL SOFTWARE VALIDATION METHODS. ------------------------------------------------------------------ */ #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_ */