2012-12-12 18:01:40 -04:00
|
|
|
#include <AP_HAL.h>
|
|
|
|
#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2)
|
2012-08-30 21:18:20 -03:00
|
|
|
|
|
|
|
#include <avr/io.h>
|
|
|
|
#include <avr/eeprom.h>
|
|
|
|
#include "Storage.h"
|
|
|
|
using namespace AP_HAL_AVR;
|
|
|
|
|
2012-11-12 15:05:20 -04:00
|
|
|
uint8_t AVREEPROMStorage::read_byte(uint16_t loc) {
|
|
|
|
return eeprom_read_byte((uint8_t*)loc);
|
2012-08-30 21:18:20 -03:00
|
|
|
}
|
|
|
|
|
2012-11-12 15:05:20 -04:00
|
|
|
uint16_t AVREEPROMStorage::read_word(uint16_t loc) {
|
|
|
|
return eeprom_read_word((uint16_t*)loc);
|
2012-08-30 21:18:20 -03:00
|
|
|
}
|
|
|
|
|
2012-11-12 15:05:20 -04:00
|
|
|
uint32_t AVREEPROMStorage::read_dword(uint16_t loc) {
|
|
|
|
return eeprom_read_dword((uint32_t*)loc);
|
2012-08-30 21:18:20 -03:00
|
|
|
}
|
|
|
|
|
2012-11-12 15:05:20 -04:00
|
|
|
void AVREEPROMStorage::read_block(void *dst, uint16_t src, size_t n) {
|
|
|
|
eeprom_read_block(dst,(const void*)src,n);
|
2012-08-30 21:18:20 -03:00
|
|
|
}
|
|
|
|
|
2012-11-12 15:05:20 -04:00
|
|
|
void AVREEPROMStorage::write_byte(uint16_t loc, uint8_t value) {
|
|
|
|
eeprom_write_byte((uint8_t*)loc,value);
|
2012-08-30 21:18:20 -03:00
|
|
|
}
|
|
|
|
|
2012-11-12 15:05:20 -04:00
|
|
|
void AVREEPROMStorage::write_word(uint16_t loc, uint16_t value) {
|
|
|
|
eeprom_write_word((uint16_t*)loc,value);
|
2012-08-30 21:18:20 -03:00
|
|
|
}
|
|
|
|
|
2012-11-12 15:05:20 -04:00
|
|
|
void AVREEPROMStorage::write_dword(uint16_t loc, uint32_t value) {
|
|
|
|
eeprom_write_dword((uint32_t*)loc,value);
|
2012-08-30 21:18:20 -03:00
|
|
|
}
|
|
|
|
|
2012-11-12 15:05:20 -04:00
|
|
|
void AVREEPROMStorage::write_block(uint16_t dst, void *src, size_t n) {
|
|
|
|
eeprom_write_block(src,(void*)dst,n);
|
2012-08-30 21:18:20 -03:00
|
|
|
}
|
|
|
|
|
2012-12-12 18:01:40 -04:00
|
|
|
#endif
|