status_code_t nvm_init(mem_type_t mem) { switch (mem) { case INT_FLASH: #if SAM4S case INT_USERPAGE: #endif break; #if defined(USE_EXTMEM) && defined(CONF_BOARD_AT45DBX) case AT45DBX: /* Initialize dataflash */ at45dbx_init(); /* Perform memory check */ if (!at45dbx_mem_check()) { return ERR_NO_MEMORY; } break; #endif default: return ERR_INVALID_ARG; } return STATUS_OK; }
Ctrl_status at45dbx_test_unit_ready(void) { if (b_at45dbx_unloaded) { return CTRL_NO_PRESENT; } return (at45dbx_mem_check() == true) ? CTRL_GOOD : CTRL_NO_PRESENT; }
/** * \brief Performs a memory check on all DataFlash memories * * This function will simply test the output of the function * \ref at45dbx_mem_check and returns an error in case of failure. * * \param test Current test case. */ static void run_memory_check_test(const struct test_case *test) { bool status; status = at45dbx_mem_check(); test_assert_true(test, status == true, "Error memory check failed"); }
void memories_initialization(void) { #ifdef CONF_BOARD_AT45DBX at45dbx_init(); if (at45dbx_mem_check() != true) { while (1) { } } #endif }
/*! \brief Performs a memory check on all DFs. */ static void at45dbx_example_check_mem(void) { if (at45dbx_mem_check()) { print_dbg("\tSize:\t"); print_dbg_ulong(AT45DBX_MEM_CNT << (AT45DBX_MEM_SIZE - 20)); print_dbg(" MB\t" TEST_SUCCESS); } else { print_dbg(TEST_FAIL); } }
void memories_initialization(void) { #ifdef CONF_BOARD_SMC_PSRAM psram_init(); #endif #ifdef CONF_BOARD_SRAM sram_init(); #endif #ifdef CONF_BOARD_SDRAMC /* Enable SMC peripheral clock */ pmc_enable_periph_clk(ID_SMC); /* Complete SDRAM configuration */ sdramc_init((sdramc_memory_dev_t *)&SDRAM_MICRON_MT48LC16M16A2, sysclk_get_cpu_hz()); #endif #ifdef CONF_BOARD_AT45DBX at45dbx_init(); if (at45dbx_mem_check() != true) { while (1) { } } #endif #ifdef CONF_BOARD_SD_MMC_HSMCI uint8_t slot = 0; sd_mmc_err_t err; sd_mmc_init(); if (slot == sd_mmc_nb_slot()) { slot = 0; } // Wait for a card and ready do { err = sd_mmc_check(slot); if ((SD_MMC_ERR_NO_CARD != err) && (SD_MMC_INIT_ONGOING != err) && (SD_MMC_OK != err)) { while (SD_MMC_ERR_NO_CARD != sd_mmc_check(slot)) { } } } while (SD_MMC_OK != err); #endif }
/*! \brief Main function. */ int main(void) { uint16_t i; // Initialize the system - clock and board. system_init(); at45dbx_init(); if(at45dbx_mem_check()==true) { port_pin_set_output_level(DATA_FLASH_LED_EXAMPLE_0, false); } else { test_ko(); } // Prepare half a data flash sector to 0xAA for(i=0;i<AT45DBX_SECTOR_SIZE/2;i++) { ram_buf[i]=0xAA; } // And the remaining half to 0x55 for(;i<AT45DBX_SECTOR_SIZE;i++) { ram_buf[i]=0x55; } at45dbx_write_sector_open(TARGET_SECTOR); at45dbx_write_sector_from_ram(ram_buf); at45dbx_write_close(); // Read back this sector and compare to expected values at45dbx_read_sector_open(TARGET_SECTOR); at45dbx_read_sector_to_ram(ram_buf); at45dbx_read_close(); for(i=0;i<AT45DBX_SECTOR_SIZE/2;i++) { if (ram_buf[i]!=0xAA) { test_ko(); } } for(;i<AT45DBX_SECTOR_SIZE;i++) { if (ram_buf[i]!=0x55) { test_ko(); } } // Write one data flash sector to 0x00, 0x01 .... for(i=0;i<AT45DBX_SECTOR_SIZE;i++) { ram_buf[i]=i; } at45dbx_write_sector_open(TARGET_SECTOR); at45dbx_write_sector_from_ram(ram_buf); at45dbx_write_close(); // Read one data flash sector to ram at45dbx_read_sector_open(TARGET_SECTOR); at45dbx_read_sector_to_ram(ram_buf); at45dbx_read_close(); for(i=0;i<AT45DBX_SECTOR_SIZE;i++) { if ( ram_buf[i]!=(i%0x100) ) { test_ko(); } } while (1); }
/*! \brief Main function. */ int main(void) { uint16_t i; sysclk_init(); // Initialize the board. // The board-specific conf_board.h file contains the configuration of the board // initialization. board_init(); at45dbx_init(); if(at45dbx_mem_check()==true) { gpio_set_pin_low(DATA_FLASH_LED_EXAMPLE_0); } else { test_ko(); } // Prepare half a data flash sector to 0xAA for(i=0;i<AT45DBX_SECTOR_SIZE/2;i++) { ram_buf[i]=0xAA; } // And the remaining half to 0x55 for(;i<AT45DBX_SECTOR_SIZE;i++) { ram_buf[i]=0x55; } at45dbx_write_sector_open(TARGET_SECTOR); at45dbx_write_sector_from_ram(ram_buf); at45dbx_write_close(); // Read back this sector and compare to expected values at45dbx_read_sector_open(TARGET_SECTOR); at45dbx_read_sector_to_ram(ram_buf); at45dbx_read_close(); for(i=0;i<AT45DBX_SECTOR_SIZE/2;i++) { if (ram_buf[i]!=0xAA) { test_ko(); } } for(;i<AT45DBX_SECTOR_SIZE;i++) { if (ram_buf[i]!=0x55) { test_ko(); } } // Write one data flash sector to 0x00, 0x01 .... for(i=0;i<AT45DBX_SECTOR_SIZE;i++) { ram_buf[i]=i; } at45dbx_write_sector_open(TARGET_SECTOR); at45dbx_write_sector_from_ram(ram_buf); at45dbx_write_close(); // Read one data flash sector to ram at45dbx_read_sector_open(TARGET_SECTOR); at45dbx_read_sector_to_ram(ram_buf); at45dbx_read_close(); for(i=0;i<AT45DBX_SECTOR_SIZE;i++) { if ( ram_buf[i]!=(i%0x100) ) { test_ko(); } } gpio_set_pin_low(DATA_FLASH_LED_EXAMPLE_1); while (1); }