Subversion Repositories idreammicro-avr

Rev

Blame | Last modification | View Log | Download | RSS feed

/**************************************************************************//**
 * \brief EEPROM 24C01/24C02 library.
 * \author Copyright (C) 2012  Julien Le Sech - www.idreammicro.com
 * \version 1.0
 * \date 20121102
 *
 * This file is part of the iDreamMicro library.
 *
 * This library is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/
 ******************************************************************************/


/**************************************************************************//**
 * \headerfile eeprom_24c01_24c02.h
 ******************************************************************************/


#ifndef H__IDREAMMICRO__EEPROM_24C01_24C02__H
#define H__IDREAMMICRO__EEPROM_24C01_24C02__H

#ifdef _cplusplus
extern "C"{
#endif

/******************************************************************************
 * Header file inclusion.
 ******************************************************************************/


#include <stdint.h>

/******************************************************************************
 * Public macro definitions.
 ******************************************************************************/


/**************************************************************************//**
 * \def     EEPROM_24C01_24C02__CLOCK_RATE
 * \brief   24C01/24C02 frequency in Hertz.
 * On ATmega, can be 100 kHz or 400 Khz.
 ******************************************************************************/

#define EEPROM_24C01_24C02__CLOCK_RATE   100000

/******************************************************************************
 * Public function prototypes.
 ******************************************************************************/


/**************************************************************************//**
 * \fn void eeprom_24c01_24c02__initialize(uint8_t hardware_address)
 *
 * \brief Initialize EEPROM 24C01/24C02.
 *
 * \param hardware_address Hardware address. Pins A0 to A2.
 ******************************************************************************/

void
eeprom_24c01_24c02__initialize
(
    uint8_t hardware_address
);

/**************************************************************************//**
 * \fn void eeprom_24c01_24c02__write_byte(uint8_t address, uint8_t data)
 *
 * \brief Write a byte into memory.
 *
 * \param   address Address in memory.
 * \param   data    Byte to write.
 ******************************************************************************/

void
eeprom_24c01_24c02__write_byte
(
    uint8_t address,
    uint8_t data
);

/**************************************************************************//**
 * \fn void eeprom_24c01_24c02__write_bytes(
 * uint8_t  address,
 * uint8_t  length,
 * uint8_t* p_data)
 *
 * \brief Write bytes into memory.
 *
 * \param       address Start address.
 * \param       length  Number of bytes to write.
 * \param[in]   p_data  Bytes to write.
 ******************************************************************************/

void
eeprom_24c01_24c02__write_bytes
(
    uint8_t     address,
    uint8_t     length,
    uint8_t*    p_data
);

/**************************************************************************//**
 * \fn uint8_t eeprom_24c01_24c02__read_byte(uint8_t address)
 *
 * \brief Read a byte in memory.
 *
 * \param address   Address to read.
 *
 * \return Read byte.
 ******************************************************************************/

uint8_t
eeprom_24c01_24c02__read_byte
(
    uint8_t address
);

/**************************************************************************//**
 * \fn void eeprom_24c01_24c02__read_bytes(
 * uint8_t  address,
 * uint8_t  length,
 * uint8_t* p_data)
 *
 * \brief Read bytes in memory.
 *
 * \param       address Start address of data to read.
 * \param       length  Number of bytes to read.
 * \param[in]   p_data  Buffer to fill with read bytes.
 ******************************************************************************/

void
eeprom_24c01_24c02__read_bytes
(
    uint8_t     address,
    uint8_t     length,
    uint8_t*    p_data
);

#ifdef _cplusplus
}
#endif

#endif /* H__IDREAMMICRO__EEPROM_24C01_24C02__H */