Example #1
0
uintptr_t where_write_dict(size_t num_bite){
	uintptr_t result, fn;
	if (flash_have_memory_dict(num_bite))
		return flash_dict_now;
	else{
		flash_write32(END_OF_PAGE, flash_dict_now);
		flash_dict_now +=1*4;
		fn =flash_dict_now;
		flash_write32(flash_dict_now = result = flash_alloc_dict(), fn);
		return result;
	}
}
Example #2
0
uintptr_t where_write_code(size_t num_bite){
	uintptr_t  fn;
	if (flash_have_memory_code(num_bite))
		return flash_code_now;
	else{
		flash_write32(END_OF_PAGE, flash_code_now);
		flash_code_now +=1*4;
		fn =flash_code_now;
		flash_write32(flash_code_now = flash_alloc_code(), fn);
		return flash_code_now;
	}
}
Example #3
0
void flash_write(uint32_t *num, size_t leng_int, uintptr_t ptr){
	if ((ptr & 0b11) != 0)
			fault("invalid ptr");

	for (size_t i = 0; i<leng_int; ++i)
		flash_write32(num[i], ptr + i * 4);
}
Example #4
0
void main(void)
{
  MCU_init();   // inicializa o microcontrolador      
  flash_init(); // inicializa a FSL
  while (1)
  {
    if (save_status)    // se há requisição de salvamento na flash
    {
      save_status = 0;  // limpa a requisição
      flash_erase();    // apaga a flash
      // se o led está ligado, salva 0 no endereço 0xFC00
      // se o led está desligado, o endereço 0xFC00 permanece com 0xFF
      if (!LED_RPB) flash_write32(0,0xFC00);
    }
  }
}