00001 /* 00002 * "Copyright (c) 2008 Robert B. Reese, Bryan A. Jones, J. W. Bruce ("AUTHORS")" 00003 * All rights reserved. 00004 * (R. Reese, reese_AT_ece.msstate.edu, Mississippi State University) 00005 * (B. A. Jones, bjones_AT_ece.msstate.edu, Mississippi State University) 00006 * (J. W. Bruce, jwbruce_AT_ece.msstate.edu, Mississippi State University) 00007 * 00008 * Permission to use, copy, modify, and distribute this software and its 00009 * documentation for any purpose, without fee, and without written agreement is 00010 * hereby granted, provided that the above copyright notice, the following 00011 * two paragraphs and the authors appear in all copies of this software. 00012 * 00013 * IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR 00014 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT 00015 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS" 00016 * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00017 * 00018 * THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES, 00019 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00020 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 00021 * ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO 00022 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." 00023 * 00024 * Please maintain this header in its entirety when copying/modifying 00025 * these files. 00026 * 00027 * 00028 */ 00029 00030 #ifndef _PIC24_I2C1_H_ 00031 #define _PIC24_I2C1_H_ 00032 00033 // Only include if this I2C Module exists. 00034 #if (NUM_I2C_MODS >= 1) 00035 00036 // Documentation for this file. If the \file tag is not present, 00037 // this file will not be documented. 00038 // Note: place this comment below the #if NUM_I2C_MODS so Doxygen 00039 // will only see it once. 00053 #ifndef I2C_ACK 00054 #define I2C_ACK 0 00055 #endif 00056 #ifndef I2C_NAK 00057 #define I2C_NAK 1 00058 #endif 00059 00060 #define I2C_WADDR(x) (x & 0xFE) //clear R/W bit of I2C addr 00061 #define I2C_RADDR(x) (x | 0x01) //set R/W bit of I2C addr 00062 00063 00064 //I2C Operations 00065 void configI2C1(uint16 u16_FkHZ); 00066 void startI2C1(void); 00067 void rstartI2C1(void); 00068 void stopI2C1(void); 00069 void putI2C1(uint8 u8_val); 00070 uint8 putNoAckCheckI2C1(uint8 u8_val); 00071 uint8 getI2C1(uint8 u8_ack2Send); 00072 00073 //I2C Transactions 00074 void write1I2C1(uint8 u8_addr,uint8 u8_d1); 00075 void write2I2C1(uint8 u8_addr,uint8 u8_d1, uint8 u8_d2); 00076 void writeNI2C1(uint8 u8_addr,uint8* pu8_data, uint16 u16_cnt); 00077 void read1I2C1 (uint8 u8_addr,uint8* pu8_d1); 00078 void read2I2C1 (uint8 u8_addr,uint8* pu8_d1, uint8* pu8_d2); 00079 void readNI2C1 (uint8 u8_addr,uint8* pu8_data, uint16 u16_cnt); 00080 00081 #endif // #if (NUM_I2C_MODS >= 1) 00082 #endif // #ifndef _PIC24_I2C1_H_ 00083 00084 00085 00086 00087 00088 /* 00089 * "Copyright (c) 2008 Robert B. Reese, Bryan A. Jones, J. W. Bruce ("AUTHORS")" 00090 * All rights reserved. 00091 * (R. Reese, reese_AT_ece.msstate.edu, Mississippi State University) 00092 * (B. A. Jones, bjones_AT_ece.msstate.edu, Mississippi State University) 00093 * (J. W. Bruce, jwbruce_AT_ece.msstate.edu, Mississippi State University) 00094 * 00095 * Permission to use, copy, modify, and distribute this software and its 00096 * documentation for any purpose, without fee, and without written agreement is 00097 * hereby granted, provided that the above copyright notice, the following 00098 * two paragraphs and the authors appear in all copies of this software. 00099 * 00100 * IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR 00101 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT 00102 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS" 00103 * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00104 * 00105 * THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES, 00106 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00107 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 00108 * ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO 00109 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." 00110 * 00111 * Please maintain this header in its entirety when copying/modifying 00112 * these files. 00113 * 00114 * 00115 */ 00116 00117 #ifndef _PIC24_I2C2_H_ 00118 #define _PIC24_I2C2_H_ 00119 00120 // Only include if this I2C Module exists. 00121 #if (NUM_I2C_MODS >= 2) 00122 00123 // Documentation for this file. If the \file tag is not present, 00124 // this file will not be documented. 00125 // Note: place this comment below the #if NUM_I2C_MODS so Doxygen 00126 // will only see it once. 00140 #ifndef I2C_ACK 00141 #define I2C_ACK 0 00142 #endif 00143 #ifndef I2C_NAK 00144 #define I2C_NAK 1 00145 #endif 00146 00147 #define I2C_WADDR(x) (x & 0xFE) //clear R/W bit of I2C addr 00148 #define I2C_RADDR(x) (x | 0x01) //set R/W bit of I2C addr 00149 00150 00151 //I2C Operations 00152 void configI2C2(uint16 u16_FkHZ); 00153 void startI2C2(void); 00154 void rstartI2C2(void); 00155 void stopI2C2(void); 00156 void putI2C2(uint8 u8_val); 00157 uint8 putNoAckCheckI2C2(uint8 u8_val); 00158 uint8 getI2C2(uint8 u8_ack2Send); 00159 00160 //I2C Transactions 00161 void write1I2C2(uint8 u8_addr,uint8 u8_d1); 00162 void write2I2C2(uint8 u8_addr,uint8 u8_d1, uint8 u8_d2); 00163 void writeNI2C2(uint8 u8_addr,uint8* pu8_data, uint16 u16_cnt); 00164 void read1I2C2 (uint8 u8_addr,uint8* pu8_d1); 00165 void read2I2C2 (uint8 u8_addr,uint8* pu8_d1, uint8* pu8_d2); 00166 void readNI2C2 (uint8 u8_addr,uint8* pu8_data, uint16 u16_cnt); 00167 00168 #endif // #if (NUM_I2C_MODS >= 2) 00169 #endif // #ifndef _PIC24_I2C2_H_ 00170 00171 00172 00173 00174