Eep C Reference

Defines

BUFSIZE_BLKS
BUFSIZE_BYTES

Functions

void fram_write_enable(void)

Enable writes to FRAM. Should be defined in the processor-specific cuplTag project.

void fram_write_disable(void)

Disable writes to FRAM. Should be defined in the processor-specific cuplTag project.

static inline int inbounds(int byteindex)

Checks if a byte index is within the bounds the buffer array.

This can be used to prevent the program from accessing memory that is out of bounds.

Parameters

byteindex – Index of a buffer byte that is to be read or written.

Returns

0 if the index is less than the size of the buffer and can be accessed safely. Otherwise 1.

int eep_write(const int eepblk, const unsigned int bufblk)

Write a 16-byte block from the buffer to EEPROM.

Parameters
  • eepblk – Block of the EEPROM to write to.

  • bufblk – Block of the buffer to write from.

Returns

1 if the block to be written greater than the buffer size. 0 on success and -1 on write error.

void eep_waitwritedone()

Block until the EEPROM block write has finished.

Writes of Flash memory take some milliseconds to complete.

int eep_read(const int eepblk, const unsigned int bufblk)

Read a 16-byte block from EEPROM to the buffer.

Parameters
  • eepblk – EEPROM block to read.

  • bufblk – Block of the buffer to copy the EEPROM contents to.

int eep_swap(const unsigned int srcblk, const unsigned int destblk)

Swap two buffer blocks.

Parameters
  • srcblk – The buffer block to read from.

  • destblk – The buffer block to write to.

int eep_cp(int *indexptr, const char *dataptr, const int lenbytes)

Copy data from a pointer into the buffer.

Parameters
  • indexptr – Data are copied into the buffer starting from this index. An integer from 0 to N-1, where N is the size of the buffer. indexptr is overwritten by the index one greater than the last data to be written.

  • dataptr – Data are copied from this pointer.

  • lenbytes – The number of bytes to copy into the buffer from dataptr.

Returns

0 if the data to be copied will fit entirely in the buffer. Otherwise 1.

int eep_cpbyte(int *indexptr, const char bytedata)

Copy one byte into the buffer.

Parameters
  • indexptr – The byte is copied into this index of the buffer. An integer from 0 to N-1, where N is the size of the buffer. indexptr is overwritten by indexptr+1.

  • bytedata – Byte to be copied into the buffer.

Returns

0 if indexptr is an index that will not overflow the buffer. Otherwise 1.

Variables

char _blkbuffer[BUFSIZE_BLKS * BLKSIZE] = {0}