This is a part of the Kinetiszer project.

Dependencies:   inc

Dependents:   kinetisizer

Committer:
Clemo
Date:
Tue Oct 28 20:09:12 2014 +0000
Revision:
1:8ae4ab73ca6a
Parent:
0:cb80470434eb
First publication (untested)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Clemo 0:cb80470434eb 1 #include "atmegatron.h"
Clemo 0:cb80470434eb 2 //#include "libeeprom.h"
Clemo 0:cb80470434eb 3
Clemo 0:cb80470434eb 4 // The top 64 bytes of the EEPROM memory are reserved and cannot be written to.
Clemo 0:cb80470434eb 5 #define EEPROM_ADDRESS_OFFSET (0x40)
Clemo 0:cb80470434eb 6
Clemo 0:cb80470434eb 7
Clemo 0:cb80470434eb 8 void eeprom_write(uint32_t address, uint8_t value);
Clemo 0:cb80470434eb 9 uint8_t eeprom_read(uint32_t address);
Clemo 0:cb80470434eb 10
Clemo 0:cb80470434eb 11
Clemo 0:cb80470434eb 12 eeprom_t EEPROM =
Clemo 0:cb80470434eb 13 {
Clemo 0:cb80470434eb 14 eeprom_write,
Clemo 0:cb80470434eb 15 eeprom_read,
Clemo 0:cb80470434eb 16 };
Clemo 0:cb80470434eb 17
Clemo 0:cb80470434eb 18
Clemo 0:cb80470434eb 19 /*void eeprom_execute(EELIB_Command pCommand, EELIB_Result pOutput)
Clemo 0:cb80470434eb 20 {
Clemo 0:cb80470434eb 21 // Use libeeprom instead of the IAP driver.
Clemo 0:cb80470434eb 22 // Now you don't have to disable interrupts anymore.
Clemo 0:cb80470434eb 23 //__disable_irq();
Clemo 0:cb80470434eb 24 EELIB_entry(pCommand,pOutput);
Clemo 0:cb80470434eb 25 //__enable_irq();
Clemo 0:cb80470434eb 26 }*/
Clemo 0:cb80470434eb 27
Clemo 0:cb80470434eb 28
Clemo 0:cb80470434eb 29 void eeprom_write(uint32_t address, uint8_t value)
Clemo 0:cb80470434eb 30 {
Clemo 0:cb80470434eb 31 /*EEPROM_WRITE_COMMAND_T command;
Clemo 0:cb80470434eb 32 EEPROM_WRITE_OUTPUT_T result;
Clemo 0:cb80470434eb 33
Clemo 0:cb80470434eb 34 command.cmd = EELIB_IAP_COMMAND_EEPROM_WRITE;
Clemo 0:cb80470434eb 35 command.eepromAddr = address + EEPROM_ADDRESS_OFFSET;
Clemo 0:cb80470434eb 36 command.ramAddr = (uint32_t) &value;
Clemo 0:cb80470434eb 37 command.byteNum = sizeof(value);
Clemo 0:cb80470434eb 38 command.cclk = Chip_Clock_GetSystemClockRate() / 1000;
Clemo 0:cb80470434eb 39 EELIB_entry((uint32_t*)&command,(uint32_t*)&result);
Clemo 0:cb80470434eb 40 if (result.status!=EELIB_IAP_STATUS_CMD_SUCCESS)
Clemo 0:cb80470434eb 41 {
Clemo 0:cb80470434eb 42 // Do something on error?
Clemo 0:cb80470434eb 43 }*/
Clemo 0:cb80470434eb 44 }
Clemo 0:cb80470434eb 45
Clemo 0:cb80470434eb 46
Clemo 0:cb80470434eb 47 uint8_t eeprom_read(uint32_t address)
Clemo 0:cb80470434eb 48 {
Clemo 0:cb80470434eb 49 /*uint8_t buffer;
Clemo 0:cb80470434eb 50 EEPROM_READ_COMMAND_T command;
Clemo 0:cb80470434eb 51 EEPROM_READ_OUTPUT_T result;
Clemo 0:cb80470434eb 52
Clemo 0:cb80470434eb 53 command.cmd = EELIB_IAP_COMMAND_EEPROM_READ;
Clemo 0:cb80470434eb 54 command.eepromAddr = address + EEPROM_ADDRESS_OFFSET;
Clemo 0:cb80470434eb 55 command.ramAddr = (uint32_t) &buffer;
Clemo 0:cb80470434eb 56 command.byteNum = sizeof(buffer);
Clemo 0:cb80470434eb 57 command.cclk = Chip_Clock_GetSystemClockRate() / 1000;
Clemo 0:cb80470434eb 58 EELIB_entry((uint32_t*)&command,(uint32_t*)&result);
Clemo 0:cb80470434eb 59 if (result.status!=EELIB_IAP_STATUS_CMD_SUCCESS)
Clemo 0:cb80470434eb 60 {
Clemo 0:cb80470434eb 61 buffer = 0;
Clemo 0:cb80470434eb 62 }
Clemo 0:cb80470434eb 63 return buffer;*/
Clemo 0:cb80470434eb 64 return 0;
Clemo 0:cb80470434eb 65 }