?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 6

Line No. Rev Author Line
1 6 kaklik /*! \file i2ceeprom.c \brief Interface for standard I2C EEPROM memories. */
2 //*****************************************************************************
3 //
4 // File Name : 'i2ceeprom.c'
5 // Title : Interface for standard I2C EEPROM memories
6 // Author : Pascal Stang - Copyright (C) 2003
7 // Created : 2003.04.23
8 // Revised : 2003.04.23
9 // Version : 0.1
10 // Target MCU : Atmel AVR series
11 // Editor Tabs : 4
12 //
13 // This code is distributed under the GNU Public License
14 // which can be found at http://www.gnu.org/licenses/gpl.txt
15 //
16 //*****************************************************************************
17  
18 #include <avr/io.h>
19 #include <avr/interrupt.h>
20  
21 #include "i2c.h"
22 #include "i2ceeprom.h"
23  
24 // Standard I2C bit rates are:
25 // 100KHz for slow speed
26 // 400KHz for high speed
27  
28 // functions
29 void i2ceepromInit(void)
30 {
31 // although there is no code here
32 // don't forget to initialize the I2C interface itself
33 }
34  
35 u08 i2ceepromReadByte(u08 i2cAddr, u32 memAddr)
36 {
37 u08 packet[2];
38 // prepare address
39 packet[0] = (memAddr>>8);
40 packet[1] = (memAddr&0x00FF);
41 // send memory address we wish to access to the memory chip
42 i2cMasterSendNI(i2cAddr, 2, packet);
43 // retrieve the data at this memory address
44 i2cMasterReceiveNI(i2cAddr, 1, packet);
45 // return data
46 return packet[0];
47 }
48  
49 void i2ceepromWriteByte(u08 i2cAddr, u32 memAddr, u08 data)
50 {
51 u08 packet[3];
52 // prepare address + data
53 packet[0] = (memAddr>>8);
54 packet[1] = (memAddr&0x00FF);
55 packet[2] = data;
56 // send memory address we wish to access to the memory chip
57 // along with the data we wish to write
58 i2cMasterSendNI(i2cAddr, 3, packet);
59 }
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3