/*! \brief Tests single-sector access functions. */ static void at45dbx_example_test_RAM_mem(void) { static U8 PatternTable[AT45DBX_SECTOR_SIZE]; static U8 ReceiveTable[AT45DBX_SECTOR_SIZE]; U8 Pattern = 0x55; memset(PatternTable, Pattern, AT45DBX_SECTOR_SIZE); memset(ReceiveTable, 0xA5, AT45DBX_SECTOR_SIZE); print_dbg("\tUsing Pattern 0x55"); // Perform write access. if (at45dbx_write_open(Pattern)) { at45dbx_write_sector_from_ram(PatternTable); at45dbx_write_close(); } // Perform read access. if (at45dbx_read_open(Pattern)) { at45dbx_read_sector_2_ram(ReceiveTable); at45dbx_read_close(); } // Check read and write operations. if (!memcmp(ReceiveTable, PatternTable, AT45DBX_SECTOR_SIZE)) { print_dbg(TEST_SUCCESS); } else { print_dbg(TEST_FAIL); } // Change the pattern used. Pattern = 0xAA; memset(PatternTable, Pattern, AT45DBX_SECTOR_SIZE); memset(ReceiveTable, 0xA5, AT45DBX_SECTOR_SIZE); print_dbg("\tUsing Pattern 0xAA"); // Perform write access. if (at45dbx_write_open(Pattern)) { at45dbx_write_sector_from_ram(PatternTable); at45dbx_write_close(); } // Perform read access. if (at45dbx_read_open(Pattern)) { at45dbx_read_sector_2_ram(ReceiveTable); at45dbx_read_close(); } // Check read and write operations. if (!memcmp(ReceiveTable, PatternTable, AT45DBX_SECTOR_SIZE)) { print_dbg(TEST_SUCCESS); } else { print_dbg(TEST_FAIL); } }
/*! \brief Tests single-byte access functions. */ static void at45dbx_example_test_byte_mem(void) { U8 Pattern = 0x55; U8 j = 0xA5; print_dbg("\tUsing Pattern 0x55"); // Perform write access. if (at45dbx_write_open(Pattern)) { at45dbx_write_byte(Pattern); at45dbx_write_close(); } // Perform read access. if (at45dbx_read_open(Pattern)) { j = at45dbx_read_byte(); at45dbx_read_close(); } // Check read and write operations. if (j == Pattern) { print_dbg(TEST_SUCCESS); } else { print_dbg(TEST_FAIL); } // Change the pattern used. Pattern = 0xAA; j = 0xA5; print_dbg("\tUsing Pattern 0xAA"); // Perform write access. if (at45dbx_write_open(Pattern)) { at45dbx_write_byte(Pattern); at45dbx_write_close(); } // Perform read access. if (at45dbx_read_open(Pattern)) { j = at45dbx_read_byte(); at45dbx_read_close(); } // Check read and write operations. if (j == Pattern) { print_dbg(TEST_SUCCESS); } else { print_dbg(TEST_FAIL); } }
status_code_t nvm_read_char(mem_type_t mem, uint32_t address, uint8_t *data) { switch (mem) { case INT_FLASH: case INT_USERPAGE: *data = *((uint8_t *)(address)); break; #if defined(USE_EXTMEM) && defined(CONF_BOARD_AT45DBX) case AT45DBX: if (!at45dbx_read_byte_open(address)) { return ERR_BAD_ADDRESS; } *data = at45dbx_read_byte(); at45dbx_read_close(); break; #endif default: return ERR_INVALID_ARG; } return STATUS_OK; }
/** * \brief Test the read and write byte operations on the DataFlash * * This function will test the read and write functionalities of the DataFlash * using byte access. It will first write a known pattern on the 2 first * consecutive sectors and read it back by testing each value read.\n * In addition to test the data integrity and the byte read / write * functions, this will also test the continuity of the sectors as well as the * auto-incrementation of the DataFlash address. * * \param test Current test case. */ static void run_byte_access_test(const struct test_case *test) { uint32_t i; bool status; uint8_t byte; /* Write bytes one by one to the 2 first continuous sectors */ status = at45dbx_write_byte_open(0); test_assert_true(test, status == true, "Cannot open the DataFlash memory for write access"); for (i=0; i<AT45DBX_SECTOR_SIZE * 2; i++) { status = at45dbx_write_byte(BYTE_PATTERN1(i)); test_assert_true(test, status == true, "Write byte operation error @ 0x%08x", i); } at45dbx_write_close(); /* Read back the 2 first sectors of the DataFlash and check the values */ status = at45dbx_read_byte_open(0); test_assert_true(test, status == true, "Cannot open the DataFlash memory for read access"); for (i=0; i<AT45DBX_SECTOR_SIZE * 2; i++) { byte = at45dbx_read_byte(); test_assert_true(test, byte == BYTE_PATTERN1(i), "Read byte operation error @ 0x%08x" " (read: 0x%02x, expected: 0x%02x)", i, byte, BYTE_PATTERN1(i)); } at45dbx_read_close(); }
status_code_t nvm_read(mem_type_t mem, uint32_t address, void *buffer, uint32_t len) { switch (mem) { case INT_FLASH: case INT_USERPAGE: memcpy(buffer, (const void *)address, len); break; #if defined(USE_EXTMEM) && defined(CONF_BOARD_AT45DBX) case AT45DBX: { uint32_t sector = address / AT45DBX_SECTOR_SIZE; if (!at45dbx_read_sector_open(sector)) { return ERR_BAD_ADDRESS; } at45dbx_read_sector_to_ram(buffer); at45dbx_read_close(); } break; #endif default: return ERR_INVALID_ARG; } return STATUS_OK; }
status_code_t nvm_read_char(mem_type_t mem, uint32_t address, uint8_t *data) { switch (mem) { case INT_FLASH: *data = nvm_flash_read_byte((flash_addr_t)address); break; case INT_USERPAGE: nvm_user_sig_read_buffer((flash_addr_t)address, (void *)data, 1); break; case INT_EEPROM: *data = nvm_eeprom_read_byte((eeprom_addr_t)address); break; #if defined(USE_EXTMEM) && defined(CONF_BOARD_AT45DBX) case AT45DBX: if (!at45dbx_read_byte_open(address)) { return ERR_BAD_ADDRESS; } *data = at45dbx_read_byte(); at45dbx_read_close(); break; #endif default: return ERR_INVALID_ARG; } return STATUS_OK; }
/*! \brief Tests multiple-sector access functions. */ static void at45dbx_example_test_multiple_sector(void) { U32 position = 252; U32 nb_sector = 4; // Initialize counters. at45dbx_example_error_cnt = 0; // Write sectors. print_dbg("\tWriting sectors\r\n"); at45dbx_write_open(position); at45dbx_write_multiple_sector(nb_sector); at45dbx_write_close(); // Read written sectors. print_dbg("\tReading sectors\t"); at45dbx_read_open(position); at45dbx_read_multiple_sector(nb_sector); at45dbx_read_close(); if (!at45dbx_example_error_cnt) { print_dbg(TEST_SUCCESS); } else { print_dbg(TEST_FAIL "\t"); print_dbg_ulong(at45dbx_example_error_cnt); print_dbg(" errors\r\n"); } }
Ctrl_status at45dbx_df_2_ram(U32 addr, void *ram) { if (addr + 1 > AT45DBX_MEM_CNT << (AT45DBX_MEM_SIZE - AT45DBX_SECTOR_BITS)) return CTRL_FAIL; at45dbx_read_open(addr); at45dbx_read_sector_2_ram(ram); at45dbx_read_close(); return CTRL_GOOD; }
Ctrl_status at45dbx_usb_read_10(U32 addr, U16 nb_sector) { if (addr + nb_sector > AT45DBX_MEM_CNT << (AT45DBX_MEM_SIZE - AT45DBX_SECTOR_BITS)) return CTRL_FAIL; at45dbx_read_open(addr); at45dbx_read_multiple_sector(nb_sector); at45dbx_read_close(); return CTRL_GOOD; }
/** * \brief Test the read and write multiple sector operations on the DataFlash * * This function will test the read and write functionalities of the DataFlash * using multiple sector access. It will first fill the 10 first DataFlash * sectors with a known pattern and read it back to test each value.\n * * \param test Current test case. */ static void run_multiple_sector_access_test(const struct test_case *test) { bool status; uint32_t i; uint8_t value, cur_sector; uint8_t expected; /* Write the ram sector to the DataFlash */ status = at45dbx_write_sector_open(0); test_assert_true(test, status == true, "Cannot open the DataFlash memory for write access"); cur_sector = 0; while (cur_sector++ < 10) { /* Fills a ram sector with a known pattern */ for (i=0; i<AT45DBX_SECTOR_SIZE; i++) { value = BYTE_PATTERN3(cur_sector * AT45DBX_SECTOR_SIZE + i); ((uint8_t *) sector_buf)[i] = value; } /* Write sector on DataFlash */ status = at45dbx_write_sector_from_ram(sector_buf); test_assert_true(test, status == true, "Error while writing sector # %i", cur_sector); } at45dbx_write_close(); /* Read back the sector of the DataFlash */ status = at45dbx_read_sector_open(0); test_assert_true(test, status == true, "Cannot open the DataFlash memory for read access"); cur_sector = 0; while (cur_sector++ < 10) { // Read the next sector. status = at45dbx_read_sector_to_ram(sector_buf); test_assert_true(test, status == true, "Error while reading sector # %i", cur_sector); /* Test each values of the current sector */ for (i=0; i<AT45DBX_SECTOR_SIZE; i++) { expected = BYTE_PATTERN3(cur_sector * AT45DBX_SECTOR_SIZE + i); test_assert_true(test, ((uint8_t *) sector_buf)[i] == expected, "Value not expected @ 0x%08x in sector # %i" " (read: 0x%02x, expected: 0x%02x)", i, cur_sector, ((uint8_t *) sector_buf)[i], expected); } } at45dbx_read_close(); }
Ctrl_status at45dbx_usb_read_10(U32 addr, U16 nb_sector) { if (addr + nb_sector > AT45DBX_MEM_CNT << (AT45DBX_MEM_SIZE - AT45DBX_SECTOR_BITS)){ return CTRL_FAIL; } at45dbx_read_sector_open(addr); while (nb_sector--) { // Read the next sector. at45dbx_read_sector_to_ram(sector_buf); udi_msc_trans_block( true, sector_buf, AT45DBX_SECTOR_SIZE, NULL); } at45dbx_read_close(); return CTRL_GOOD; }
status_code_t nvm_read(mem_type_t mem, uint32_t address, void *buffer, uint32_t len) { switch (mem) { case INT_FLASH: memcpy(buffer, (const void *)address, len); break; #if SAM4S case INT_USERPAGE: { /*! This function creates a buffer of IFLASH_PAGE_SIZE to * read the data from starting of user signature */ uint32_t temp_buff[IFLASH_PAGE_SIZE], *buff = buffer; /* Read from the starting of user signature */ if (flash_read_user_signature(temp_buff, len)) { return ERR_INVALID_ARG; } /* Calculate offset and copy required number of bytes */ for (uint16_t i = 0; i < len; i++) { *buff = temp_buff[address - IFLASH_ADDR + i]; buff++; } break; } #endif #if defined(USE_EXTMEM) && defined(CONF_BOARD_AT45DBX) case AT45DBX: { uint32_t sector = address / AT45DBX_SECTOR_SIZE; if (!at45dbx_read_sector_open(sector)) { return ERR_BAD_ADDRESS; } at45dbx_read_sector_to_ram(buffer); at45dbx_read_close(); } break; #endif default: return ERR_INVALID_ARG; } return STATUS_OK; }
status_code_t nvm_write_char(mem_type_t mem, uint32_t address, uint8_t data) { switch (mem) { case INT_FLASH: #if SAM4S /*! This erases 8 pages of flash before writing */ if (flash_erase_page(address, IFLASH_ERASE_PAGES_8)) { return ERR_INVALID_ARG; } else if (flash_write(address, (const void *)&data, 1, false)) { return ERR_INVALID_ARG; } #else if (flash_write(address, (const void *)&data, 1, true)) { return ERR_INVALID_ARG; } #endif break; #if SAM4S case INT_USERPAGE: if (flash_write_user_signature((const void *)&data, 1)) { return ERR_INVALID_ARG; } break; #endif #if defined(USE_EXTMEM) && defined(CONF_BOARD_AT45DBX) case AT45DBX: if (!at45dbx_write_byte_open() address) { return ERR_BAD_ADDRESS; } at45dbx_write_byte(data); at45dbx_write_close(); at45dbx_read_byte_open(address); read = at45dbx_read_byte(); at45dbx_read_close(); break; #endif default: return ERR_INVALID_ARG; } return STATUS_OK; }
/** * \brief Test the read and write sector operations on the DataFlash * * This function will test the read and write functionalities of the DataFlash * using sector access. It will first fill a sector with a known pattern and * read it back by testing each value read.\n * * \param test Current test case. */ static void run_sector_access_test(const struct test_case *test) { uint32_t i; bool status; /* Fills a ram sector with a known pattern */ for (i=0; i<AT45DBX_SECTOR_SIZE; i++) { sector_buf[i] = BYTE_PATTERN2(i); } /* Write the ram sector to the DataFlash */ status = at45dbx_write_sector_open(0); test_assert_true(test, status == true, "Cannot open the DataFlash memory for write access"); status = at45dbx_write_sector_from_ram(sector_buf); test_assert_true(test, status == true, "Write sector operation error"); at45dbx_write_close(); /* Clear the ram sector buffer */ for (i=0; i<AT45DBX_SECTOR_SIZE; i++) { sector_buf[i] = 0; } /* Read back the sector of the DataFlash */ status = at45dbx_read_sector_open(0); test_assert_true(test, status == true, "Cannot open the DataFlash memory for read access"); status = at45dbx_read_sector_to_ram(sector_buf); test_assert_true(test, status == true, "Read sector operation error"); at45dbx_read_close(); /* Compare the values read from the DataFlash with the expected values */ for (i=0; i<AT45DBX_SECTOR_SIZE; i++) { test_assert_true(test, sector_buf[i] == BYTE_PATTERN2(i), "Value not expected @ 0x%08x (read: 0x%02x," " expected: 0x%02x)", i, sector_buf[i], BYTE_PATTERN2(i)); } }
status_code_t nvm_read_char(mem_type_t mem, uint32_t address, uint8_t *data) { switch (mem) { case INT_FLASH: *data = *((uint8_t *)(address)); break; #if SAM4S case INT_USERPAGE: { /*! This function creates a buffer of IFLASH_PAGE_SIZE to * read the data from starting of user signature */ uint32_t buffer[IFLASH_PAGE_SIZE]; uint32_t offset = address - IFLASH_ADDR; if (offset < 0) { return ERR_INVALID_ARG; } flash_read_user_signature(buffer, offset); *data = buffer[offset]; break; } #endif #if defined(USE_EXTMEM) && defined(CONF_BOARD_AT45DBX) case AT45DBX: if (!at45dbx_read_byte_open(address)) { return ERR_BAD_ADDRESS; } *data = at45dbx_read_byte(); at45dbx_read_close(); break; #endif default: return ERR_INVALID_ARG; } return STATUS_OK; }
void network_application() { draw_background(); gfx_draw_filled_rect(5, 26, 310, 182, GFX_COLOR(20, 20, 20)); if(!wifi_ready && wifi_error) { gfx_draw_string_aligned(SYMFONT_WIFI, gfx_get_width() / 2, 120, &symbol_sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_RED, TEXT_POS_CENTER_X, TEXT_ALIGN_CENTER); gfx_draw_string_aligned("Not Connected", gfx_get_width() / 2, 155, &sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_RED, TEXT_POS_CENTER_X, TEXT_ALIGN_CENTER); } else { gfx_draw_string_aligned(SYMFONT_WIFI, gfx_get_width() / 2, 120, &symbol_sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_GREEN, TEXT_POS_CENTER_X, TEXT_ALIGN_CENTER); gfx_draw_string_aligned("Connected", gfx_get_width() / 2, 155, &sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_GREEN, TEXT_POS_CENTER_X, TEXT_ALIGN_CENTER); } uint8_t ram_buf[AT45DBX_SECTOR_SIZE]; at45dbx_read_sector_open(0x0007); at45dbx_read_sector_to_ram(ram_buf); at45dbx_read_close(); char mac_string[128]; snprintf(mac_string, sizeof(mac_string), "MAC: %s", ram_buf); gfx_draw_string_aligned(mac_string, 11, 27, &small_sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_WHITE, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); if (wifi_error) { gfx_draw_string_aligned(esp_error, 11, 47, &small_sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_WHITE, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); } struct keyboard_event input; while(mma8451_orientation() != 6) { esp8266_check_buffer(); keyboard_get_key_state(&input); if (input.type == KEYBOARD_RELEASE) { if (input.keycode == KEYBOARD_B) { break; } } if(mma8451_clear_interrupt() && is_low_power()) { exit_low_power(); } } }
status_code_t nvm_read(mem_type_t mem, uint32_t address, void *buffer, uint32_t len) { switch (mem) { case INT_FLASH: nvm_flash_read_buffer((flash_addr_t)address, buffer, (uint16_t)len); break; case INT_USERPAGE: nvm_user_sig_read_buffer((flash_addr_t)address, buffer, (uint16_t)len); break; case INT_EEPROM: nvm_eeprom_read_buffer((eeprom_addr_t)address, buffer, (uint16_t)len); break; #if defined(USE_EXTMEM) && defined(CONF_BOARD_AT45DBX) case AT45DBX: { uint32_t sector = address / AT45DBX_SECTOR_SIZE; if (!at45dbx_read_sector_open(sector)) { return ERR_BAD_ADDRESS; } at45dbx_read_sector_to_ram(buffer); at45dbx_read_close(); } break; #endif default: return ERR_INVALID_ARG; } return STATUS_OK; }
/*! \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); }
void draw_event() { draw_background(); draw_time(); gfx_draw_filled_rect(5, 26, 310, 182, GFX_COLOR(8, 8, 8)); draw_button_hints(); switch(event_track) { case 0: gfx_draw_string_aligned("Schedule - KEYNOTES", 11, 2, &sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_YELLOW, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); break; case 1: gfx_draw_string_aligned("Schedule - TRACK 1", 11, 2, &sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_YELLOW, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); break; case 2: gfx_draw_string_aligned("Schedule - TRACK 2", 11, 2, &sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_YELLOW, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); break; case 3: gfx_draw_string_aligned("Schedule - TRACK 3", 11, 2, &sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_YELLOW, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); break; case 4: gfx_draw_string_aligned("Schedule - TRACK 4", 11, 2, &sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_YELLOW, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); break; case 5: gfx_draw_string_aligned("Schedule - TRACK 5", 11, 2, &sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_YELLOW, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); break; } uint16_t keynote = 0x0100; uint16_t track1 = 0x0200; uint16_t track2 = 0x0300; uint16_t track3 = 0x0400; uint16_t track4 = 0x0500; uint16_t track5 = 0x0600; uint16_t addresses[] = {keynote, track1, track2, track3, track4, track5}; //uint16_t max_event[] = {5, 22, 22, 15, 23}; uint8_t ram_buf[AT45DBX_SECTOR_SIZE]; at45dbx_read_sector_open(addresses[event_track] + event_index); at45dbx_read_sector_to_ram(ram_buf); at45dbx_read_close(); char *array[6]; uint8_t i = 0; array[i] = strtok(ram_buf,";"); while(array[i] != NULL) { array[++i] = strtok(NULL, ";"); } char *title[256]; uint8_t a = word_wrap(&title, array[0], 30); gfx_draw_string_aligned(title, 11, 27, &sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_WHITE, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); char event_time[36]; snprintf(event_time, sizeof(event_time),"%s - %s", array[1], array[2]); char *names[256]; uint8_t n = word_wrap(&names, array[3], 33); gfx_draw_string_aligned(names, 11, 60+(a*20), &small_sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_RED, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); gfx_draw_string_aligned(array[4], 11, 85+(a*20)+(n*20), &tiny_sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_YELLOW, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); gfx_draw_string_aligned(event_time, 11, 100+(a*20)+(n*20), &tiny_sysfont, GFX_COLOR_TRANSPARENT, GFX_COLOR_WHITE, TEXT_POS_LEFT, TEXT_ALIGN_LEFT); // } }
/*! \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); }