ff1e2244301537611497a0f524703200f6542971
1 /*****************************************************************************
2 * i2c.h: Header file for NXP LPC11xx Family Microprocessors
4 * Copyright(C) 2006, NXP Semiconductor
5 * Parts of this code are (C) 2010, MyVoice CAD/CAM Services
9 * 2006.07.19 ver 1.00 Preliminary version, first Release
10 * 2010.07.19 ver 1.10 Rob Jansen - MyVoice CAD/CAM Services
11 * Updated to reflect new code
13 ******************************************************************************/
17 #include "projectconfig.h"
20 * These are states returned by the I2CEngine:
22 * IDLE - is never returned but only used internally
23 * PENDING - is never returned but only used internally in the I2C functions
24 * ACK - The transaction finished and the slave returned ACK (on all bytes)
25 * NACK - The transaction is aborted since the slave returned a NACK
26 * SLA_NACK - The transaction is aborted since the slave returned a NACK on the SLA
27 * this can be intentional (e.g. an 24LC08 EEPROM states it is busy)
28 * or the slave is not available/accessible at all.
29 * ARB_LOSS - Arbitration loss during any part of the transaction.
30 * This could only happen in a multi master system or could also
31 * identify a hardware problem in the system.
33 #define I2CSTATE_IDLE 0x000
34 #define I2CSTATE_PENDING 0x001
35 #define I2CSTATE_ACK 0x101
36 #define I2CSTATE_NACK 0x102
37 #define I2CSTATE_SLA_NACK 0x103
38 #define I2CSTATE_ARB_LOSS 0x104
40 #define FAST_MODE_PLUS 0
42 #define I2C_BUFSIZE 64
43 #define MAX_TIMEOUT 0x00FFFFFF
45 #define I2CMASTER 0x01
48 #define SLAVE_ADDR 0xA0
49 #define READ_WRITE 0x01
53 #define I2C_GENERALCALL 0x00 /* General Call Address (to 'ping' I2C bus for devices) */
55 #define I2CONSET_I2EN 0x00000040 /* I2C Control Set Register */
56 #define I2CONSET_AA 0x00000004
57 #define I2CONSET_SI 0x00000008
58 #define I2CONSET_STO 0x00000010
59 #define I2CONSET_STA 0x00000020
61 #define I2CONCLR_AAC 0x00000004 /* I2C Control clear Register */
62 #define I2CONCLR_SIC 0x00000008
63 #define I2CONCLR_STAC 0x00000020
64 #define I2CONCLR_I2ENC 0x00000040
66 #define I2DAT_I2C 0x00000000 /* I2C Data Reg */
67 #define I2ADR_I2C 0x00000000 /* I2C Slave Address Reg */
69 /* SCLH and SCLL = I2C PCLK High/Low cycles for I2C clock and
70 determine the data rate/duty cycle for I2C:
72 I2CBitFrequency = I2CPCLK / (I2CSCLH + I2CSCLL)
74 Standard Mode (100KHz) = CFG_CPU_CCLK / 200000
75 Fast Mode (400KHz) = CFG_CPU_CCLK / 800000
76 Fast- Mode Plus (1MHz) = CFG_CPU_CCLK / 2000000 */
78 #define I2SCLH_SCLH CFG_CPU_CCLK / 800000 /* Standard Mode I2C SCL Duty Cycle High (400KHz) */
79 #define I2SCLL_SCLL CFG_CPU_CCLK / 800000 /* Fast Mode I2C SCL Duty Cycle Low (400KHz) */
80 #define I2SCLH_HS_SCLH CFG_CPU_CCLK / 2000000 /* Fast Plus I2C SCL Duty Cycle High Reg */
81 #define I2SCLL_HS_SCLL CFG_CPU_CCLK / 2000000 /* Fast Plus I2C SCL Duty Cycle Low Reg */
83 extern volatile uint8_t I2CMasterBuffer
[I2C_BUFSIZE
];
84 extern volatile uint8_t I2CSlaveBuffer
[I2C_BUFSIZE
];
85 extern volatile uint32_t I2CReadLength
, I2CWriteLength
;
87 extern void I2C_IRQHandler( void );
88 extern uint32_t i2cInit( uint32_t I2cMode
);
89 extern uint32_t i2cEngine( void );
90 uint32_t i2cSendGeneralCall( void );
92 #endif /* end __I2C_H */
93 /****************************************************************************
95 *****************************************************************************/
This page took 0.049862 seconds and 3 git commands to generate.