Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
EEPROM AT24Cxx Series

Low-level driver for the AT24CXX Series EEPROM controller.

This driver provides access to the main features of the AT24CXX Series EEPROM.

Macros

#define at24c_build_word_address(p_u8, addr)
 

Functions

static void at24cxx_acknowledge_polling (twi_package_t *twi_package)
 Poll the acknowledge from AT24CXX. More...
 
uint32_t at24cxx_fill_pattern (uint32_t u32_start_address, uint32_t u32_end_address, uint8_t u8_pattern)
 Fill the specified pattern to AT24CXX. More...
 
uint32_t at24cxx_read_byte (uint32_t u32_address, uint8_t *p_rd_byte)
 Read single byte from AT24CXX. More...
 
uint32_t at24cxx_read_continuous (uint32_t u32_start_address, uint16_t u16_length, uint8_t *p_rd_buffer)
 Read multiple bytes continuously from AT24CXX. More...
 
uint32_t at24cxx_read_page (uint32_t u32_page_address, uint32_t u32_page_size, uint8_t *p_rd_buffer)
 Read data from the specified page in AT24CXX. More...
 
void at24cxx_reset (void)
 Reset AT24CXX. More...
 
uint32_t at24cxx_write_byte (uint32_t u32_address, uint8_t u8_value)
 Write single byte to AT24CXX. More...
 
uint32_t at24cxx_write_continuous (uint32_t u32_start_address, uint16_t u16_length, uint8_t const *p_wr_buffer)
 Write multiple bytes continuously to AT24CXX. More...
 
uint32_t at24cxx_write_page (uint32_t u32_page_address, uint32_t u32_page_size, uint8_t const *p_wr_buffer)
 Write data to the specified page in AT24CXX. More...
 

#define at24c_build_word_address (   p_u8,
  addr 
)
Value:
do {\
p_u8[0] = (uint8_t)(addr >> 8);\
p_u8[1] = (uint8_t)(addr >> 0);\
} while (0)
struct sockaddr_in addr
Definition: common/components/wifi/winc3400/simple_roaming_udp_client_example/main.c:153

Referenced by at24cxx_read_byte(), at24cxx_read_continuous(), at24cxx_read_page(), at24cxx_write_byte(), at24cxx_write_continuous(), and at24cxx_write_page().

static void at24cxx_acknowledge_polling ( twi_package_t twi_package)
static

Poll the acknowledge from AT24CXX.

Parameters
twi_packagePointer to TWI data package. Only the slave address is used in the acknowledge polling.

References twi_packet::addr, addr, twi_packet::addr_length, BOARD_AT24C_TWI_INSTANCE, buffer, twi_packet::buffer, data, twi_packet::length, twi_master_write(), and TWI_SUCCESS.

Referenced by at24cxx_write_byte(), at24cxx_write_continuous(), and at24cxx_write_page().

uint32_t at24cxx_fill_pattern ( uint32_t  u32_start_address,
uint32_t  u32_end_address,
uint8_t  u8_pattern 
)

Fill the specified pattern to AT24CXX.

Parameters
u32_start_addressThe first address to be filled.
u32_end_addressThe last address to be filled.
u8_patternThe pattern to be filled.
Returns
AT24C_WRITE_SUCCESS if the pattern was filled, AT24C_WRITE_FAIL otherwise.

References addr, AT24C_WRITE_FAIL, AT24C_WRITE_SUCCESS, and at24cxx_write_byte().

uint32_t at24cxx_read_byte ( uint32_t  u32_address,
uint8_t *  p_rd_byte 
)

Read single byte from AT24CXX.

Parameters
u32_addressAddress of the byte to read.
p_rd_bytePointer to memory where the read byte will be stored.
Returns
AT24C_READ_SUCCESS if one byte was read, AT24C_READ_FAIL otherwise.

References twi_packet::addr, twi_packet::addr_length, at24c_build_word_address, AT24C_MEM_ADDR_LEN, AT24C_READ_FAIL, AT24C_READ_SUCCESS, BOARD_AT24C_ADDRESS, BOARD_AT24C_TWI_INSTANCE, twi_packet::buffer, twi_packet::chip, twi_packet::length, twi_master_read(), and TWI_SUCCESS.

uint32_t at24cxx_read_continuous ( uint32_t  u32_start_address,
uint16_t  u16_length,
uint8_t *  p_rd_buffer 
)

Read multiple bytes continuously from AT24CXX.

Parameters
u32_start_addressAddress of the first byte to read.
u16_lengthNumber of bytes to read.
p_rd_bufferPointer to memory where the read bytes will be stored.
Returns
AT24C_READ_SUCCESS if one byte was read, AT24C_READ_FAIL otherwise.

References twi_packet::addr, twi_packet::addr_length, at24c_build_word_address, AT24C_MEM_ADDR_LEN, AT24C_READ_FAIL, AT24C_READ_SUCCESS, BOARD_AT24C_ADDRESS, BOARD_AT24C_TWI_INSTANCE, twi_packet::buffer, twi_packet::chip, twi_packet::length, twi_master_read(), and TWI_SUCCESS.

uint32_t at24cxx_read_page ( uint32_t  u32_page_address,
uint32_t  u32_page_size,
uint8_t *  p_rd_buffer 
)

Read data from the specified page in AT24CXX.

Parameters
u32_page_addressThe page number.
u32_page_sizeThe size of the page (which varies with the chips).
p_rd_bufferPointer to array where the bytes read are to be stored.
Returns
AT24C_READ_SUCCESS if the page was read, AT24C_READ_FAIL otherwise.

References twi_packet::addr, twi_packet::addr_length, at24c_build_word_address, AT24C_MEM_ADDR_LEN, AT24C_READ_FAIL, AT24C_READ_SUCCESS, BOARD_AT24C_ADDRESS, BOARD_AT24C_TWI_INSTANCE, twi_packet::buffer, twi_packet::chip, twi_packet::length, twi_master_read(), and TWI_SUCCESS.

void at24cxx_reset ( void  )

Reset AT24CXX.

Send 9 clock cycles to reset memory state.

Note
IO mode is used in this function, so it can be used even if TWI is not enabled.

References BOARD_CLK_TWI_EEPROM, BOARD_CLK_TWI_MUX_EEPROM, delay_us, IOPORT_DIR_OUTPUT, ioport_disable_pin(), ioport_enable_pin(), ioport_set_pin_dir(), ioport_set_pin_level(), and ioport_set_pin_mode().

uint32_t at24cxx_write_byte ( uint32_t  u32_address,
uint8_t  u8_value 
)

Write single byte to AT24CXX.

Parameters
u32_addressAddress of the byte to write.
u8_valueValue that will be written to the specified address.
Returns
AT24C_WRITE_SUCCESS if single byte was written, AT24C_WRITE_FAIL otherwise.

References twi_packet::addr, twi_packet::addr_length, at24c_build_word_address, AT24C_MEM_ADDR_LEN, AT24C_WRITE_FAIL, AT24C_WRITE_SUCCESS, at24cxx_acknowledge_polling(), BOARD_AT24C_ADDRESS, BOARD_AT24C_TWI_INSTANCE, twi_packet::buffer, twi_packet::chip, twi_packet::length, twi_master_write(), and TWI_SUCCESS.

Referenced by at24cxx_fill_pattern().

uint32_t at24cxx_write_continuous ( uint32_t  u32_start_address,
uint16_t  u16_length,
uint8_t const *  p_wr_buffer 
)

Write multiple bytes continuously to AT24CXX.

Parameters
u32_start_addressAddress of the first byte in transaction.
u16_lengthNumber of bytes to write.
p_wr_bufferPointer to array where the bytes to be written are stored.
Returns
AT24C_WRITE_SUCCESS if single byte was written, AT24C_WRITE_FAIL otherwise.

References twi_packet::addr, twi_packet::addr_length, at24c_build_word_address, AT24C_MEM_ADDR_LEN, AT24C_WRITE_FAIL, AT24C_WRITE_SUCCESS, at24cxx_acknowledge_polling(), BOARD_AT24C_ADDRESS, BOARD_AT24C_TWI_INSTANCE, twi_packet::buffer, twi_packet::chip, twi_packet::length, twi_master_write(), and TWI_SUCCESS.

uint32_t at24cxx_write_page ( uint32_t  u32_page_address,
uint32_t  u32_page_size,
uint8_t const *  p_wr_buffer 
)

Write data to the specified page in AT24CXX.

Parameters
u32_page_addressThe page number.
u32_page_sizeThe size of the page (which varies with the chips).
p_wr_bufferPointer to array where the bytes to be written are stored.
Returns
AT24C_WRITE_SUCCESS if the page was written, AT24C_WRITE_FAIL otherwise.

References twi_packet::addr, twi_packet::addr_length, at24c_build_word_address, AT24C_MEM_ADDR_LEN, AT24C_WRITE_FAIL, AT24C_WRITE_SUCCESS, at24cxx_acknowledge_polling(), BOARD_AT24C_ADDRESS, BOARD_AT24C_TWI_INSTANCE, twi_packet::buffer, twi_packet::chip, twi_packet::length, twi_master_write(), and TWI_SUCCESS.