Defines | |
| #define | DEBUG_VERBOSE_LEVEL 1 |
| #define | DEBUG_MSG MIOS32_MIDI_SendDebugMessage |
| #define | PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x000)) |
| #define | PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1))) |
| #define | PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + PAGE_SIZE)) |
| #define | PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1))) |
| #define | PAGE0 ((uint16_t)0x0000) |
| #define | PAGE1 ((uint16_t)0x0001) |
| #define | NO_VALID_PAGE ((uint16_t)0x00AB) |
| #define | ERASED ((uint16_t)0xFFFF) |
| #define | RECEIVE_DATA ((uint16_t)0xEEEE) |
| #define | VALID_PAGE ((uint16_t)0x0000) |
| #define | READ_FROM_VALID_PAGE ((uint8_t)0x00) |
| #define | WRITE_IN_VALID_PAGE ((uint8_t)0x01) |
| #define | PAGE_FULL ((uint8_t)0x80) |
Functions | |
| s32 | EEPROM_Init (u32 mode) |
| Restore the pages to a known good state in case of page's status corruption after a power loss. | |
| s32 | EEPROM_Read (u16 VirtAddress) |
| Returns the last stored variable data, if found, which correspond to the passed virtual address. | |
| s32 | EEPROM_Write (u16 VirtAddress, u16 Data) |
| Writes/upadtes variable data in EEPROM. | |
| s32 | EEPROM_SendDebugMessage (u32 mode) |
The 24LC64 allows to store up to 8192 bytes.
Since this driver works halfword-wise to keep it compatible to the STM32 variant, this means that EEPROM_EMULATED_SIZE can be up to 4096
Optionally an external EEPROM can be connected to one of the two IIC ports of the MBHP_CORE_LPC17 by setting following defines in mios32_config.h
set this either to 0 (for first IIC port) or 2 (for second IIC port) IIC1 selects the on-board EEPROM define EEPROM_IIC_DEVICE 1 Set a device number if the 3 address pins are not tied to ground define EEPROM_IIC_CS 0
Usage:
Configuration: optionally EEPROM_EMULATED_SIZE can be overruled in mios32_config.h to change the number of virtual addresses.
By default, 128 addresses are available:
#define EEPROM_EMULATED_SIZE 128 // -> 128 half words = 256 bytes
Example application:
$MIOS32_PATH/apps/tutorials/025_sysex_and_eeprom (see patch.c)
| #define DEBUG_MSG MIOS32_MIDI_SendDebugMessage |
| #define DEBUG_VERBOSE_LEVEL 1 |
| #define ERASED ((uint16_t)0xFFFF) |
| #define NO_VALID_PAGE ((uint16_t)0x00AB) |
| #define PAGE0 ((uint16_t)0x0000) |
| #define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x000)) |
| #define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1))) |
| #define PAGE1 ((uint16_t)0x0001) |
| #define PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + PAGE_SIZE)) |
| #define PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1))) |
| #define PAGE_FULL ((uint8_t)0x80) |
| #define READ_FROM_VALID_PAGE ((uint8_t)0x00) |
| #define RECEIVE_DATA ((uint16_t)0xEEEE) |
| #define VALID_PAGE ((uint16_t)0x0000) |
| #define WRITE_IN_VALID_PAGE ((uint8_t)0x01) |
Restore the pages to a known good state in case of page's status corruption after a power loss.
Connects to the (on-board) EEPROM
| [in] | mode | not used yet, only mode 0 is supported! |
Returns the last stored variable data, if found, which correspond to the passed virtual address.
Returns the 16bit word on the given halfword address
| [in] | address | the address which should be read |
-1 if EEPROM not available
Sends the EEPROM content and optionally the whole flash page content to the MIOS Terminal
| [in] | mode | following modes are provided:
|
Writes/upadtes variable data in EEPROM.
Writes into EEPROM at given halfword address
| [in] | address | the address which should be written |
| [in] | value | the 16bit value which should be written |
1.4.7