Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:43

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  * @ingroup i2c
0006  */
0007 
0008 /*
0009  * COPYRIGHT (c) 2007 Cobham Gaisler AB
0010  * with parts from the RTEMS MPC83xx I2C driver (c) 2007 Embedded Brains GmbH.
0011  *
0012  * Redistribution and use in source and binary forms, with or without
0013  * modification, are permitted provided that the following conditions
0014  * are met:
0015  * 1. Redistributions of source code must retain the above copyright
0016  *    notice, this list of conditions and the following disclaimer.
0017  * 2. Redistributions in binary form must reproduce the above copyright
0018  *    notice, this list of conditions and the following disclaimer in the
0019  *    documentation and/or other materials provided with the distribution.
0020  *
0021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0022  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0024  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0025  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0026  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0027  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0028  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0029  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0030  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0031  * POSSIBILITY OF SUCH DAMAGE.
0032  */
0033 
0034 #ifndef _I2CMST_H
0035 #define _I2CMST_H
0036 
0037 /**
0038  * @defgroup i2c I2C-master
0039  *
0040  * @ingroup RTEMSBSPsSharedGRLIB
0041  *
0042  * @brief Driver for GRLIB port of OpenCores I2C-master
0043  *
0044  * @{
0045  */
0046 
0047 #include <rtems/libi2c.h>
0048 #include "ambapp.h"
0049 
0050 #ifdef __cplusplus
0051 extern "C" {
0052 #endif
0053 
0054 /* I2C-master operational registers */
0055 
0056 typedef struct gr_i2cmst_regs {
0057   volatile unsigned int prescl; /* Prescale register */
0058   volatile unsigned int ctrl;   /* Control register */
0059   volatile unsigned int tdrd;   /* Transmit and Receive registers */
0060   volatile unsigned int cmdsts; /* Command and Status registers */
0061 } gr_i2cmst_regs_t;
0062 
0063 /* Control (CTRL) register */
0064 #define GRI2C_CTRL_EN         0x00000080 /* Enable core */
0065 #define GRI2C_CTRL_IEN        0x00000040 /* Interrupt enable */
0066 
0067 /* Command (CMD) register */
0068 #define GRI2C_CMD_STA         0x00000080 /* Generate START condition */
0069 #define GRI2C_CMD_STO         0x00000040 /* Generate STOP condition */
0070 #define GRI2C_CMD_RD          0x00000020 /* Read from slave */
0071 #define GRI2C_CMD_WR          0x00000010 /* Write to slave */
0072 #define GRI2C_CMD_ACK         0x00000008 /* Acknowledge */
0073 #define GRI2C_CMD_IACK        0x00000001 /* Interrupt acknowledge */
0074 
0075 /* Status (STS) register */
0076 #define GRI2C_STS_RXACK       0x00000080 /* Receive acknowledge */
0077 #define GRI2C_STS_BUSY        0x00000040 /* I2C-bus busy */
0078 #define GRI2C_STS_AL          0x00000020 /* Arbitration lost */
0079 #define GRI2C_STS_TIP         0x00000002 /* Transfer in progress */
0080 #define GRI2C_STS_IF          0x00000001 /* Interrupt flag */
0081 
0082 #define GRI2C_STATUS_IDLE     0x00000000
0083 
0084 /* Register I2CMST driver to Driver Manager */
0085 void i2cmst_register_drv (void);
0086 
0087 #ifdef __cplusplus
0088 }
0089 #endif
0090 
0091 /** @} */
0092 
0093 #endif /*  _I2CMST_H */