/* ================================================================== >>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<< ------------------------------------------------------------------ Copyright (c) 2019-2020 by Lattice Semiconductor Corporation ALL RIGHTS RESERVED ------------------------------------------------------------------ IMPORTANT: THIS FILE IS USED BY OR GENERATED BY the LATTICE PROPELâ„¢ DEVELOPMENT SUITE, WHICH INCLUDES PROPEL BUILDER AND PROPEL SDK. Lattice grants permission to use this code pursuant to the terms of the Lattice Propel License Agreement. 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 I2C_MONITOR_H #define I2C_MONITOR_H struct i2c_mon_instance { unsigned int base_addr; unsigned char num_entry; // maximun is 20 unsigned char event_det_cnt; unsigned char int_en; unsigned int evt_entry_num; }; struct i2c_mon_entry { unsigned char check_data[12]; unsigned char op_sel_mask; unsigned char det_en_mask; union { struct { unsigned short check_mode:2; unsigned short rw_not_check:1; unsigned short rw_check:1; // 1 for read, 0 for write unsigned short i2c_addr:7; unsigned short addr_msb:3; unsigned short addr_10bits:1; unsigned short entry_en:1; } conf_bits; unsigned short conf_value; } entry_conf; }; struct i2c_mon_dev { unsigned int i2cbf_sr; // Status Register unsigned int i2cbf_intsetr; // Interrupt Set Register. unsigned int i2cbf_intenr; // Interrupt Enable Register. unsigned int i2cbf_cr; // Control Register }; #define I2C_MON_DEV_OFFSET 0x1F0 #define I2C_MON_MAX_ENTRY_CNT 20 #define I2CBF_DET_EN (1<<7) #define I2CBF_BUS_STOP (1<<6) #define I2CBF_BUS_DIS_EN (1<<5) #define I2CBF_ENT_NUM_MASK (0x1f) #define I2CBF_INT_EN (1<<5) #define I2CBF_ENT_DET (1<<5) /* ***************************************************************************** * * unsigned char i2c_mon_init(struct i2c_mon_instance *this_i2cmon, * unsigned int base_addr, * unsigned char num_entry, * unsigned char int_en) * * performs i2c monitor block initialization * * Note: This function initializes the i2c monitor block * * * Arguments: * struct i2c_mon_instance *this_i2cmon: i2c monitor instance * unsigned int base_addr : base address of the i2c monitor * unsigned char num_entry : number of monitor entry, max is 20 * unsigned char int_en : enable the interrupt or not * * * Return Value: * int: * * ***************************************************************************** */ unsigned char i2c_mon_init(struct i2c_mon_instance *this_i2cmon, unsigned int base_addr); unsigned char i2c_mon_conf(struct i2c_mon_instance *this_i2cmon, struct i2c_mon_entry *entry_data, unsigned int entry_num); unsigned char i2c_mon_enable(struct i2c_mon_instance *this_i2cmon, unsigned int mon_en); unsigned char i2c_mon_bus_stop(struct i2c_mon_instance *this_i2cmon, unsigned char bus_stop); unsigned char i2c_mon_event_get(struct i2c_mon_instance *this_i2cmon, unsigned char *event_cnt, unsigned int *dct_evt); void i2c_mon_isr(unsigned int intr_level, void *ctx); #endif