Microchip® Advanced Software Framework

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

Low-level driver for the AT24MACXX Series EEPROM controller.

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

Macros

#define at24mac_build_word_address(p_u8, addr)
 

Functions

static void at24macxx_acknowledge_polling (twihs_package_t *twihs_package)
 Poll the acknowledge from AT24MACXX. More...
 
uint32_t at24macxx_fill_pattern (uint32_t u32_start_address, uint32_t u32_end_address, uint8_t u8_pattern)
 Fill the specified pattern to AT24MACXX. More...
 
uint32_t at24macxx_read_byte (uint32_t u32_address, uint8_t *p_rd_byte)
 Read single byte from AT24MACXX. More...
 
uint32_t at24macxx_read_continuous (uint32_t u32_start_address, uint16_t u16_length, uint8_t *p_rd_buffer)
 Read multiple bytes continuously from AT24MACXX. More...
 
uint32_t at24macxx_read_page (uint32_t u32_page_address, uint32_t u32_page_size, uint8_t *p_rd_buffer)
 Read data from the specified page in AT24MACXX. More...
 
void at24macxx_reset (void)
 Reset AT24MACXX. More...
 
uint32_t at24macxx_write_byte (uint32_t u32_address, uint8_t u8_value)
 Write single byte to AT24MACXX. More...
 
uint32_t at24macxx_write_continuous (uint32_t u32_start_address, uint16_t u16_length, uint8_t const *p_wr_buffer)
 Write multiple bytes continuously to AT24MACXX. More...
 
uint32_t at24macxx_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 AT24MACXX. More...
 

#define at24mac_build_word_address (   p_u8,
  addr 
)
Value:
do {\
p_u8[0] = (uint8_t)(addr >> 0);\
} while (0)

Referenced by at24macxx_read_byte(), at24macxx_read_continuous(), at24macxx_read_page(), at24macxx_write_byte(), and at24macxx_write_page().

static void at24macxx_acknowledge_polling ( twihs_package_t twihs_package)
static

Poll the acknowledge from AT24MACXX.

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

References twihs_packet::addr, twihs_packet::addr_length, BOARD_AT24MAC_TWIHS_INSTANCE, twihs_packet::buffer, twihs_packet::length, twihs_master_write(), and TWIHS_SUCCESS.

Referenced by at24macxx_write_byte(), and at24macxx_write_page().

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

Fill the specified pattern to AT24MACXX.

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

References AT24MAC_WRITE_FAIL, AT24MAC_WRITE_SUCCESS, and at24macxx_write_byte().

Referenced by main().

uint32_t at24macxx_read_byte ( uint32_t  u32_address,
uint8_t *  p_rd_byte 
)

Read single byte from AT24MACXX.

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

References twihs_packet::addr, twihs_packet::addr_length, at24mac_build_word_address, AT24MAC_MEM_ADDR_LEN, AT24MAC_READ_FAIL, AT24MAC_READ_SUCCESS, BOARD_AT24MAC_ADDRESS, BOARD_AT24MAC_TWIHS_INSTANCE, twihs_packet::buffer, twihs_packet::chip, twihs_packet::length, twihs_master_read(), and TWIHS_SUCCESS.

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

Read multiple bytes continuously from AT24MACXX.

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
AT24MAC_READ_SUCCESS if one byte was read, AT24MAC_READ_FAIL otherwise.

References twihs_packet::addr, twihs_packet::addr_length, at24mac_build_word_address, AT24MAC_MEM_ADDR_LEN, AT24MAC_READ_FAIL, AT24MAC_READ_SUCCESS, BOARD_AT24MAC_ADDRESS, BOARD_AT24MAC_TWIHS_INSTANCE, twihs_packet::buffer, twihs_packet::chip, twihs_packet::length, twihs_master_read(), and TWIHS_SUCCESS.

Referenced by main().

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

Read data from the specified page in AT24MACXX.

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
AT24MAC_READ_SUCCESS if the page was read, AT24MAC_READ_FAIL otherwise.

References twihs_packet::addr, twihs_packet::addr_length, at24mac_build_word_address, AT24MAC_MEM_ADDR_LEN, AT24MAC_READ_FAIL, AT24MAC_READ_SUCCESS, BOARD_AT24MAC_ADDRESS, BOARD_AT24MAC_TWIHS_INSTANCE, twihs_packet::buffer, twihs_packet::chip, twihs_packet::length, twihs_master_read(), and TWIHS_SUCCESS.

Referenced by main().

void at24macxx_reset ( void  )

Reset AT24MACXX.

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_TWIHS_EEPROM, BOARD_CLK_TWIHS_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().

Referenced by main().

uint32_t at24macxx_write_byte ( uint32_t  u32_address,
uint8_t  u8_value 
)

Write single byte to AT24MACXX.

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

References twihs_packet::addr, twihs_packet::addr_length, at24mac_build_word_address, AT24MAC_MEM_ADDR_LEN, AT24MAC_WRITE_FAIL, AT24MAC_WRITE_SUCCESS, at24macxx_acknowledge_polling(), BOARD_AT24MAC_ADDRESS, BOARD_AT24MAC_TWIHS_INSTANCE, twihs_packet::buffer, twihs_packet::chip, twihs_packet::length, twihs_master_write(), and TWIHS_SUCCESS.

Referenced by at24macxx_fill_pattern(), and at24macxx_write_continuous().

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

Write multiple bytes continuously to AT24MACXX.

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
AT24MAC_WRITE_SUCCESS if single byte was written, AT24MAC_WRITE_FAIL otherwise.

References AT24MAC_WRITE_FAIL, AT24MAC_WRITE_SUCCESS, and at24macxx_write_byte().

Referenced by main().

uint32_t at24macxx_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 AT24MACXX.

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
AT24MAC_WRITE_SUCCESS if the page was written, AT24MAC_WRITE_FAIL otherwise.

References twihs_packet::addr, twihs_packet::addr_length, at24mac_build_word_address, AT24MAC_MEM_ADDR_LEN, AT24MAC_WRITE_FAIL, AT24MAC_WRITE_SUCCESS, at24macxx_acknowledge_polling(), BOARD_AT24MAC_ADDRESS, BOARD_AT24MAC_TWIHS_INSTANCE, twihs_packet::buffer, twihs_packet::chip, twihs_packet::length, twihs_master_write(), and TWIHS_SUCCESS.

Referenced by main().