ButterflyMP3

eeprom169.h

Go to the documentation of this file.
00001 
00018 #ifndef _eeprom168_h_
00019 #define _eeprom168_h_
00020 
00021 #include <inttypes.h>
00022 #include <avr/interrupt.h>
00023 
00024 static inline uint8_t eeprom_read_byte_169(const uint16_t *addr)
00025 {
00026         // cli();
00027         /* Wait for completion of previous write */
00028         while(EECR & (1<<EEWE)) asm volatile ("nop"::);
00029         /* Set up address register */
00030         EEAR = *addr;
00031         /* Start eeprom read by writing EERE */
00032         EECR |= (1<<EERE);
00033         /* Return data from Data Register */
00034         // sei();
00035         return EEDR;
00036 }
00037 
00038 static inline void eeprom_write_byte_169(uint16_t *addr, uint8_t val) 
00039 {
00040         cli();
00041         /* Wait for completion of previous write */
00042         while(EECR & (1<<EEWE)) asm volatile ("nop"::);
00043         /* Set up address and Data Registers */
00044         EEAR = *addr;
00045         EEDR = val;
00046         /* Write logical one to EEMWE */
00047         EECR |= (1<<EEMWE);
00048         /* Start eeprom write by setting EEWE */
00049         EECR |= (1<<EEWE);
00050         while(EECR & (1<<EEWE)) asm volatile ("nop"::);
00051         sei();
00052 }
00053 
00054 #endif
 All Files Functions Variables Typedefs Enumerations Enumerator Defines