--- a/MC9target/plc_MC9_main_retain.c Sat Mar 14 18:32:06 2015 +0100
+++ b/MC9target/plc_MC9_main_retain.c Sat Mar 14 20:19:18 2015 +0100
@@ -99,7 +99,6 @@
static void SPI_init(void)
@@ -190,6 +189,19 @@
printf("> (GET) DMA threshold : %d bytes \n", uint);
+ /* Prepare for future write commands */ /* Set Sequencial access mode */
@@ -201,21 +213,15 @@
printf("Failed to change mode. ERR : %d\n", status);
/* Read the whole NVRAM at start */
SPI_Read(&priv.buf, NVRAM_SIZE);
- /* Prepare for future write commands */
void RETAIN_task_proc(void *arg)
while (!rt_event_wait(&RETAIN_Event, 1, &msk, EV_ANY, TM_INFINITE)) {
if(rt_mutex_acquire(&RETAIN_Mutex, TM_INFINITE)) return;
SPI_Write(&priv, CMDSIZE + actual_size + IDLEN);
@@ -224,9 +230,8 @@
+void InitRetain(void) /* TODO return error and care */
if(rt_event_create (&RETAIN_Event, "RETAIN_Event", 0, 0))
@@ -237,8 +242,19 @@
SPI_init(); /*TODO if error */
if(rt_task_start(&RETAIN_task, &RETAIN_task_proc, NULL))
+ while(!NVRAM_Done && count--){ + printf("NVRAM init timeout\n"); @@ -295,7 +311,6 @@
void Retain(unsigned int offset, unsigned int count, void *p)
- rt_printf("retain %d %d\n", offset, count);
if(!retain_busy && offset + count < RETAIN_BUFFER_SIZE){
/* write in RETAIN buffer at offset*/
actual_size = offset + count;
@@ -305,7 +320,6 @@
void Remind(unsigned int offset, unsigned int count, void *p)
- rt_printf("remind %d %d\n", offset, count);
if(!retain_busy && offset + count < RETAIN_BUFFER_SIZE)
/* read at offset in RETAIN buffer */
memcpy(p, &priv.buf.vars[offset], count);