projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'preload-maps'
[fw/altos]
/
src
/
ao_ee.c
diff --git
a/src/ao_ee.c
b/src/ao_ee.c
index 7de05b7be3b8cddb09a6a39941dd5e9e564e9d0b..83863af562af58bb6f9ff337fda21af8aec0ff4c 100644
(file)
--- a/
src/ao_ee.c
+++ b/
src/ao_ee.c
@@
-19,19
+19,20
@@
#include "25lc1024.h"
#define EE_BLOCK_SIZE ((uint16_t) (256))
#include "25lc1024.h"
#define EE_BLOCK_SIZE ((uint16_t) (256))
+#define EE_BLOCK_SHIFT 8
#define EE_DEVICE_SIZE ((uint32_t) 128 * (uint32_t) 1024)
/* Total bytes of available storage */
#define EE_DEVICE_SIZE ((uint32_t) 128 * (uint32_t) 1024)
/* Total bytes of available storage */
-__
x
data uint32_t ao_storage_total;
+__
p
data uint32_t ao_storage_total;
/* Block size - device is erased in these units. At least 256 bytes */
/* Block size - device is erased in these units. At least 256 bytes */
-__
x
data uint32_t ao_storage_block;
+__
p
data uint32_t ao_storage_block;
/* Byte offset of config block. Will be ao_storage_block bytes long */
/* Byte offset of config block. Will be ao_storage_block bytes long */
-__
x
data uint32_t ao_storage_config;
+__
p
data uint32_t ao_storage_config;
/* Storage unit size - device reads and writes must be within blocks of this size. Usually 256 bytes. */
/* Storage unit size - device reads and writes must be within blocks of this size. Usually 256 bytes. */
-__
x
data uint16_t ao_storage_unit;
+__
p
data uint16_t ao_storage_unit;
/*
* Using SPI on USART 0, with P1_2 as the chip select
/*
* Using SPI on USART 0, with P1_2 as the chip select
@@
-166,7
+167,7
@@
ao_ee_fill(uint16_t block)
uint8_t
ao_storage_device_write(uint32_t pos, __xdata void *buf, uint16_t len) __reentrant
{
uint8_t
ao_storage_device_write(uint32_t pos, __xdata void *buf, uint16_t len) __reentrant
{
- uint16_t block = (uint16_t) (pos >>
8
);
+ uint16_t block = (uint16_t) (pos >>
EE_BLOCK_SHIFT
);
/* Transfer the data */
ao_mutex_get(&ao_ee_mutex); {
/* Transfer the data */
ao_mutex_get(&ao_ee_mutex); {
@@
-185,7
+186,7
@@
ao_storage_device_write(uint32_t pos, __xdata void *buf, uint16_t len) __reentra
uint8_t
ao_storage_device_read(uint32_t pos, __xdata void *buf, uint16_t len) __reentrant
{
uint8_t
ao_storage_device_read(uint32_t pos, __xdata void *buf, uint16_t len) __reentrant
{
- uint16_t block = (uint16_t) (pos >>
8
);
+ uint16_t block = (uint16_t) (pos >>
EE_BLOCK_SHIFT
);
/* Transfer the data */
ao_mutex_get(&ao_ee_mutex); {
/* Transfer the data */
ao_mutex_get(&ao_ee_mutex); {
@@
-207,8
+208,8
@@
uint8_t
ao_storage_erase(uint32_t pos) __reentrant
{
ao_mutex_get(&ao_ee_mutex); {
ao_storage_erase(uint32_t pos) __reentrant
{
ao_mutex_get(&ao_ee_mutex); {
-
uint16_t block = (uint16_t) (pos >> 8
);
- ao_ee_
fill(block
);
+
ao_ee_flush_internal(
);
+ ao_ee_
block = (uint16_t) (pos >> EE_BLOCK_SHIFT
);
memset(ao_ee_data, 0xff, EE_BLOCK_SIZE);
ao_ee_block_dirty = 1;
} ao_mutex_put(&ao_ee_mutex);
memset(ao_ee_data, 0xff, EE_BLOCK_SIZE);
ao_ee_block_dirty = 1;
} ao_mutex_put(&ao_ee_mutex);