Skip to content
Snippets Groups Projects
Commit 2b2efce7 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Implemented the write command function.

parent 50e98dec
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,18 @@
// private functions
void action_write_cmd(TActionMModule *module,unsigned short int address,unsigned short int length,unsigned char *data)
{
ram_write_table(module->memory,address,length,data);
unsigned int ram_offset;
ram_offset=address-module->ram_base_address;
if(ram_in_range(module->ram_base_address+ACTION_MM_CONTROL_OFFSET,address,length))
{
if(data[ACTION_MM_CONTROL_OFFSET-ram_offset]&ACTION_MM_START)
action_start_page(module);
if(data[ACTION_MM_CONTROL_OFFSET-ram_offset]&ACTION_MM_STOP)
action_stop_page(module);
}
if(ram_in_range(module->ram_base_address+ACTION_MM_PAGE_OFFSET,address,length))// load the page identifier
action_load_page(module,data[ACTION_MM_PAGE_OFFSET-ram_offset]);
}
void action_read_cmd(TActionMModule *module,unsigned short int address,unsigned short int length,unsigned char *data)
......@@ -202,6 +213,7 @@ void action_finish(TActionMModule *action)
action->end=0x00;
// change the internal state
action->running=0x00;
action->memory->data[action->ram_base_address+ACTION_MM_CONTROL_OFFSET]&=(~ACTION_MM_RUNNING);
}
void action_set_period(void *module,unsigned short int period_ms)
......@@ -508,6 +520,7 @@ unsigned char action_load_page(TActionMModule *action,unsigned char page_id)
return 0x00;
if(!pages_check_checksum(&action->next_page))
return 0x00;
action->memory->data[action->ram_base_address+ACTION_MM_PAGE_OFFSET]=page_id;
return 0x01;
}
......@@ -524,6 +537,7 @@ void action_start_page(TActionMModule *action)
action->current_step_index=-1;
/* clear the interrupt flag */
action->running=0x01;
action->memory->data[action->ram_base_address+ACTION_MM_CONTROL_OFFSET]|=ACTION_MM_RUNNING;
}
void action_stop_page(TActionMModule *action)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment