00001 /* 00002 * $Id: I2C.h,v 1 2004/11/23 12:52:00 BorisK Exp $ 00003 * 00004 * Copyright (C) 2004 ONTRACK s.r.o. 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00019 * 02111-1307, USA. 00020 * 00021 * [1] AD7414/AD7415 0.5deg.Accurate, 10-Bit Digital Temperature Sensors in SOT-23, AnalogDevices, AD7414_15_c.pdf 00022 * [2] AD5382 32-Channel,3V/5V SingleSupply, 14-Bit,Voltage-OutputDAC, AnalogDevices,43102112594034AD5382_prd.pdf 00023 * [3] MAXIM 2.7V to 5.5V,Low-Power,4-/12-Channel 2-Wire Serial 8-Bit ADCs 19-244; Rev1;10/02 00024 * 00025 * Written by Boris Kralik <kralikbo@yahoo.com>, 2004 00026 * 00027 */ 00028 #ifndef I2C_H 00029 #define I2C_H 00030 00031 #include "./include/types.h" 00032 #include "uart.h" 00033 //--- LPC21XX I2C flags -------------------- 00034 #define I2C_DBG 0 00035 #define I2C_IRQ 0 00036 #define TEMPERATURE 0 00037 00038 #define I2C_FLAG_AA (1<<2) 00039 #define I2C_FLAG_SI (1<<3) 00040 #define I2C_FLAG_STO (1<<4) 00041 #define I2C_FLAG_STA (1<<5) 00042 #define I2C_FLAG_I2EN (1<<6) 00043 00044 #define I2C_FLAG_STAC (1<<5) //STA 00045 #define I2C_FLAG_SIC (1<<3) //SI 00046 00047 #define STA 0x20 00048 #define SIC 0x08 00049 #define SI 0x08 00050 #define STO 0x10 00051 #define STAC 0x20 00052 #define AA 0x04 00053 00054 void __attribute__ ((interrupt("IRQ"))) I2C_interrupt(void); 00055 void __attribute__ ((interrupt("IRQ"))) EINT1_interrupt(void); 00056 00057 00058 // modules Addresses 00059 short I2C_Initialize(void); 00060 void I2C_off(void); 00061 void I2C_SetSTA(); 00062 void I2C_SetSlaveAdr(uint32_t); 00063 void I2C_SetDataRegister(uint32_t); 00064 void I2C_SendStartBit(void); 00065 boolean I2C_Status(void); 00066 unsigned char WriteOnI2C(unsigned char); 00067 unsigned char ReadOnI2C(void); 00068 void I2C_SetSTO(void); 00069 short SendSlaveAdress(uint32_t Addr_S); //Return 0 - OK 00070 boolean Status_I2C; 00071 uint32_t I2CAddress; 00072 uint32_t I2CData; 00073 00074 #endif
1.4.7