This file gives an example of using the SD/MMC card driver. If a SD or a MMC card is detected, a message is sent to user after that it copies data from SD/MMC to RAM.
Definition in file sd_mmc_mci_example.c.
#include <avr32/io.h>
#include "pm.h"
#include "gpio.h"
#include "intc.h"
#include "print_funcs.h"
#include "sd_mmc_mci.h"
#include "sd_mmc_mci_mem.h"
#include "cycle_counter.h"
#include "conf_sd_mmc_mci.h"
Go to the source code of this file.
Defines | |
#define | ALLOCATED_SECTORS 16 |
#define | APPLI_CPU_SPEED 48000000 |
Configuration file for the example. | |
#define | APPLI_PBA_SPEED 48000000 |
#define | BENCH_START_SECTOR 0x15000 |
#define | BENCH_TIME_MS 3000 |
#define | EXAMPLE_SD_SLOT SD_SLOT_4BITS |
#define | PBB_HZ pm_freq_param.pba_f |
Functions | |
static void | display_perf_bps (U32 bandwidth) |
Display results in bps. | |
static void | init_hmatrix (void) |
Initializes the HSB bus matrix. | |
int | main (void) |
Main function. Execution starts here. | |
static void | sd_mmc_mci_resources_init (void) |
Initializes SD/MMC resources: GPIO, MCI and SD/MMC. | |
static Bool | test_sd_mmc_write (U8 pattern_id) |
Variables | |
U8 | buffer_in [SD_MMC_SECTOR_SIZE *ALLOCATED_SECTORS] |
U8 | buffer_saved [SD_MMC_SECTOR_SIZE] |
pm_freq_param_t | pm_freq_param |
#define ALLOCATED_SECTORS 16 |
#define APPLI_CPU_SPEED 48000000 |
Configuration file for the example.
PBB clock frequency (Hz)
Definition at line 109 of file sd_mmc_mci_example.c.
#define APPLI_PBA_SPEED 48000000 |
Definition at line 110 of file sd_mmc_mci_example.c.
#define BENCH_START_SECTOR 0x15000 |
#define BENCH_TIME_MS 3000 |
#define EXAMPLE_SD_SLOT SD_SLOT_4BITS |
Definition at line 114 of file sd_mmc_mci_example.c.
Referenced by main(), sd_mmc_mci_resources_init(), and test_sd_mmc_write().
#define PBB_HZ pm_freq_param.pba_f |
static void display_perf_bps | ( | U32 | bandwidth | ) | [static] |
Display results in bps.
Definition at line 201 of file sd_mmc_mci_example.c.
Referenced by main().
00202 { 00203 if( bandwidth<10000 ) 00204 { 00205 print_dbg("Bandwidth: "); 00206 print_dbg(CL_GREEN); 00207 print_dbg_ulong( bandwidth ); 00208 print_dbg(CL_BLACK); 00209 print_dbg(" Bps\n"); 00210 } 00211 /* 00212 else if( bandwidth<10000000 ) 00213 { 00214 print_dbg("Bandwidth: "); 00215 print_dbg(CL_GREEN); 00216 print_dbg_ulong( bandwidth/1000 ); 00217 print_dbg(CL_BLACK); 00218 print_dbg(" KBps\n"); 00219 }*/ 00220 else 00221 { 00222 print_dbg("Bandwidth: "); 00223 print_dbg(CL_GREEN); 00224 //print_dbg_ulong( bandwidth/1000000 ); 00225 print_dbg_ulong( bandwidth/1000 ); 00226 print_dbg(CL_BLACK); 00227 print_dbg(" KBps\n"); 00228 //print_dbg(" MBps\n"); 00229 } 00230 }
static void init_hmatrix | ( | void | ) | [static] |
Initializes the HSB bus matrix.
Definition at line 141 of file sd_mmc_mci_example.c.
Referenced by main().
00142 { 00143 // Set flashc master type to last default to save one cycle for 00144 // each branch. 00145 avr32_hmatrix_scfg_t scfg = AVR32_HMATRIX.SCFG[AVR32_HMATRIX_SLAVE_FLASH]; 00146 scfg.defmstr_type = AVR32_HMATRIX_DEFMSTR_TYPE_LAST_DEFAULT; 00147 AVR32_HMATRIX.SCFG[AVR32_HMATRIX_SLAVE_FLASH] = scfg; 00148 }
int main | ( | void | ) |
Main function. Execution starts here.
Definition at line 364 of file sd_mmc_mci_example.c.
References ALLOCATED_SECTORS, BENCH_START_SECTOR, BENCH_TIME_MS, display_perf_bps(), EXAMPLE_SD_SLOT, init_hmatrix(), sd_mmc_mci_dma_mem_2_ram(), sd_mmc_mci_dma_multiple_mem_2_ram(), sd_mmc_mci_dma_multiple_ram_2_mem(), sd_mmc_mci_dma_ram_2_mem(), sd_mmc_mci_mem_2_ram(), sd_mmc_mci_mem_check(), sd_mmc_mci_multiple_mem_2_ram(), sd_mmc_mci_multiple_ram_2_mem(), sd_mmc_mci_ram_2_mem(), sd_mmc_mci_read_capacity(), sd_mmc_mci_resources_init(), and test_sd_mmc_write().
00365 { 00366 U32 n_sector = 0; 00367 U32 card_size; // Unit is in sector. 00368 U32 bench_start_sector; 00369 U16 i = 0; 00370 U16 j = 0; 00371 t_cpu_time timer; 00372 Ctrl_status status; 00373 00374 // Set CPU and PBA clock 00375 if( PM_FREQ_STATUS_FAIL==pm_configure_clocks(&pm_freq_param) ) 00376 return 42; 00377 00378 // Initialize HMatrix 00379 init_hmatrix(); 00380 00381 // Initialize debug RS232 with PBA clock 00382 init_dbg_rs232(pm_freq_param.pba_f); 00383 00384 // Start test 00385 print_dbg("\nInitialize SD/MMC driver"); 00386 00387 // Initialize SD/MMC driver resources: GPIO, SDIO and SD/MMC. 00388 sd_mmc_mci_resources_init(); 00389 00390 // Wait for a card to be inserted 00391 #if (BOARD == EVK1104) 00392 #if EXAMPLE_SD_SLOT == SD_SLOT_8BITS 00393 print_dbg("\nInsert a MMC/SD card into the SD/MMC 8bits slot..."); 00394 #elif EXAMPLE_SD_SLOT == SD_SLOT_4BITS 00395 print_dbg("\nInsert a MMC/SD card into the SD/MMC 4bits slot..."); 00396 #else 00397 # error SD_SLOT not supported 00398 #endif 00399 while ( sd_mmc_mci_mem_check(EXAMPLE_SD_SLOT) != OK ); 00400 #else 00401 # error Board not supported 00402 #endif 00403 00404 print_dbg("Card detected!\n"); 00405 00406 // Read Card capacity 00407 sd_mmc_mci_read_capacity(EXAMPLE_SD_SLOT, &card_size); 00408 print_dbg("\nCapacity = "); 00409 print_dbg_ulong(card_size*512); 00410 print_dbg(" Bytes\n"); 00411 00412 00413 00414 // Read the first sector number 0 of the card 00415 status = sd_mmc_mci_mem_2_ram(EXAMPLE_SD_SLOT, 0, buffer_in); 00416 if( status!=CTRL_GOOD ) 00417 { 00418 print_dbg("\nERROR: can not read device.\r\n"); 00419 return -1; 00420 } 00421 00422 // Display the ram_buffer content 00423 print_dbg("\nFirst sector of the card:\n"); 00424 for (i=0;i<(512);i++) 00425 { 00426 print_dbg_char_hex(buffer_in[i]); 00427 j++; 00428 if (j%32==0) 00429 print_dbg("\n"), j=0; 00430 else if (j%4==0) 00431 print_dbg(" "); 00432 } 00433 00434 00435 00436 // Write some patterns in the first sector number 0 of the card 00437 print_dbg("Testing write.\r\n"); 00438 if( !test_sd_mmc_write(0) ) return -1; 00439 if( !test_sd_mmc_write(1) ) return -1; 00440 if( !test_sd_mmc_write(2) ) return -1; 00441 if( !test_sd_mmc_write(3) ) return -1; 00442 00443 00444 // Bench single-block read operations without DMA 00445 // 00446 print_dbg("Benching single-block read (without DMA). Please wait..."); 00447 n_sector = 00448 bench_start_sector = (card_size<BENCH_START_SECTOR) ? 0 : BENCH_START_SECTOR; 00449 00450 cpu_set_timeout( cpu_ms_2_cy(BENCH_TIME_MS, pm_freq_param.cpu_f), &timer); 00451 while( !cpu_is_timeout(&timer) ) 00452 { 00453 status = sd_mmc_mci_mem_2_ram(EXAMPLE_SD_SLOT, n_sector, buffer_in); 00454 if( status!=CTRL_GOOD ) 00455 { 00456 print_dbg("\nERROR: can not read device.\r\n"); 00457 return -1; 00458 } 00459 n_sector+=1; 00460 } 00461 display_perf_bps((((U64)n_sector-bench_start_sector)*512)/(BENCH_TIME_MS/1000)); 00462 00463 00464 00465 // Bench single-block read operations with DMA 00466 // 00467 print_dbg("Benching single-block read (with DMA). Please wait..."); 00468 n_sector = 00469 bench_start_sector = (card_size<BENCH_START_SECTOR) ? 0 : BENCH_START_SECTOR; 00470 00471 cpu_set_timeout( cpu_ms_2_cy(BENCH_TIME_MS, pm_freq_param.cpu_f), &timer); 00472 while( !cpu_is_timeout(&timer) ) 00473 { 00474 status = sd_mmc_mci_dma_mem_2_ram(EXAMPLE_SD_SLOT, n_sector, buffer_in); 00475 if( status!=CTRL_GOOD ) 00476 { 00477 print_dbg("\nERROR: can not read device.\r\n"); 00478 return -1; 00479 } 00480 n_sector+=1; 00481 } 00482 display_perf_bps((((U64)n_sector-bench_start_sector)*512)/(BENCH_TIME_MS/1000)); 00483 00484 00485 00486 // Bench multi-block read operations without DMA 00487 // 00488 print_dbg("Benching multi-block read (without DMA). Please wait..."); 00489 n_sector = 00490 bench_start_sector = (card_size<BENCH_START_SECTOR) ? 0 : BENCH_START_SECTOR; 00491 00492 cpu_set_timeout( cpu_ms_2_cy(BENCH_TIME_MS, pm_freq_param.cpu_f), &timer); 00493 while( !cpu_is_timeout(&timer) ) 00494 { 00495 status = sd_mmc_mci_multiple_mem_2_ram(EXAMPLE_SD_SLOT, n_sector, buffer_in, ALLOCATED_SECTORS); 00496 if( status!=CTRL_GOOD ) 00497 { 00498 print_dbg("\nERROR: can not read device.\r\n"); 00499 return -1; 00500 } 00501 n_sector+=ALLOCATED_SECTORS; 00502 } 00503 display_perf_bps((((U64)n_sector-bench_start_sector)*512)/(BENCH_TIME_MS/1000)); 00504 00505 00506 00507 // Bench multi-block read operations with DMA 00508 // 00509 print_dbg("Benching multi-block read (with DMA). Please wait..."); 00510 n_sector = 00511 bench_start_sector = (card_size<BENCH_START_SECTOR) ? 0 : BENCH_START_SECTOR; 00512 00513 cpu_set_timeout( cpu_ms_2_cy(BENCH_TIME_MS, pm_freq_param.cpu_f), &timer); 00514 while( !cpu_is_timeout(&timer) ) 00515 { 00516 status = sd_mmc_mci_dma_multiple_mem_2_ram(EXAMPLE_SD_SLOT, n_sector, buffer_in, ALLOCATED_SECTORS); 00517 if( status!=CTRL_GOOD ) 00518 { 00519 print_dbg("\nERROR: can not read device.\r\n"); 00520 return -1; 00521 } 00522 n_sector+=ALLOCATED_SECTORS; 00523 } 00524 display_perf_bps((((U64)n_sector-bench_start_sector)*512)/(BENCH_TIME_MS/1000)); 00525 00526 00527 00528 // Bench single-block write operations without DMA 00529 // 00530 print_dbg("Benching single-block write (without DMA). Please wait..."); 00531 status = sd_mmc_mci_mem_2_ram(EXAMPLE_SD_SLOT, 0, buffer_in); // Backup the first sector number 0 of the card 00532 if( status!=CTRL_GOOD ) 00533 { 00534 print_dbg("\nERROR: can not read device.\r\n"); 00535 return -1; 00536 } 00537 00538 n_sector = 00539 bench_start_sector = (card_size<BENCH_START_SECTOR) ? 0 : BENCH_START_SECTOR; 00540 cpu_set_timeout( cpu_ms_2_cy(BENCH_TIME_MS, pm_freq_param.cpu_f), &timer); 00541 while( !cpu_is_timeout(&timer) ) 00542 { 00543 status = sd_mmc_mci_ram_2_mem(EXAMPLE_SD_SLOT, n_sector, buffer_in); 00544 if( status!=CTRL_GOOD ) 00545 { 00546 print_dbg("\nERROR: can not write device.\r\n"); 00547 return -1; 00548 } 00549 n_sector+=1; 00550 } 00551 display_perf_bps((((U64)n_sector-bench_start_sector)*512)/(BENCH_TIME_MS/1000)); 00552 00553 00554 00555 // Bench single-block write operations with DMA 00556 // 00557 print_dbg("Benching single-block write (with DMA). Please wait..."); 00558 status = sd_mmc_mci_mem_2_ram(EXAMPLE_SD_SLOT, 0, buffer_in); // Backup the first sector number 0 of the card 00559 if( status!=CTRL_GOOD ) 00560 { 00561 print_dbg("\nERROR: can not read device.\r\n"); 00562 return -1; 00563 } 00564 00565 n_sector = 00566 bench_start_sector = (card_size<BENCH_START_SECTOR) ? 0 : BENCH_START_SECTOR; 00567 cpu_set_timeout( cpu_ms_2_cy(BENCH_TIME_MS, pm_freq_param.cpu_f), &timer); 00568 while( !cpu_is_timeout(&timer) ) 00569 { 00570 status = sd_mmc_mci_dma_ram_2_mem(EXAMPLE_SD_SLOT, n_sector, buffer_in); 00571 if( status!=CTRL_GOOD ) 00572 { 00573 print_dbg("\nERROR: can not write device.\r\n"); 00574 return -1; 00575 } 00576 n_sector+=1; 00577 } 00578 display_perf_bps((((U64)n_sector-bench_start_sector)*512)/(BENCH_TIME_MS/1000)); 00579 00580 00581 00582 // Bench multi-block write operations without DMA 00583 // 00584 print_dbg("Benching multi-block write (without DMA). Please wait..."); 00585 status = sd_mmc_mci_mem_2_ram(EXAMPLE_SD_SLOT, 0, buffer_in); // Backup the first sector number 0 of the card 00586 if( status!=CTRL_GOOD ) 00587 { 00588 print_dbg("\nERROR: can not read device.\r\n"); 00589 return -1; 00590 } 00591 00592 n_sector = 00593 bench_start_sector = (card_size<BENCH_START_SECTOR) ? 0 : BENCH_START_SECTOR; 00594 cpu_set_timeout( cpu_ms_2_cy(BENCH_TIME_MS, pm_freq_param.cpu_f), &timer); 00595 while( !cpu_is_timeout(&timer) ) 00596 { 00597 status = sd_mmc_mci_multiple_ram_2_mem(EXAMPLE_SD_SLOT, n_sector, buffer_in, ALLOCATED_SECTORS); 00598 if( status!=CTRL_GOOD ) 00599 { 00600 print_dbg("\nERROR: can not write device.\r\n"); 00601 return -1; 00602 } 00603 n_sector+=ALLOCATED_SECTORS; 00604 } 00605 display_perf_bps((((U64)n_sector-bench_start_sector)*512)/(BENCH_TIME_MS/1000)); 00606 00607 00608 00609 // Bench multi-block write operations with DMA 00610 // 00611 print_dbg("Benching multi-block write (with DMA). Please wait..."); 00612 status = sd_mmc_mci_mem_2_ram(EXAMPLE_SD_SLOT, 0, buffer_in); // Backup the first sector number 0 of the card 00613 if( status!=CTRL_GOOD ) 00614 { 00615 print_dbg("\nERROR: can not read device.\r\n"); 00616 return -1; 00617 } 00618 00619 n_sector = 00620 bench_start_sector = (card_size<BENCH_START_SECTOR) ? 0 : BENCH_START_SECTOR; 00621 cpu_set_timeout( cpu_ms_2_cy(BENCH_TIME_MS, pm_freq_param.cpu_f), &timer); 00622 while( !cpu_is_timeout(&timer) ) 00623 { 00624 status = sd_mmc_mci_dma_multiple_ram_2_mem(EXAMPLE_SD_SLOT, n_sector, buffer_in, ALLOCATED_SECTORS); 00625 if( status!=CTRL_GOOD ) 00626 { 00627 print_dbg("\nERROR: can not write device.\r\n"); 00628 return -1; 00629 } 00630 n_sector+=ALLOCATED_SECTORS; 00631 } 00632 display_perf_bps((((U64)n_sector-bench_start_sector)*512)/(BENCH_TIME_MS/1000)); 00633 00634 return 0; 00635 }
static void sd_mmc_mci_resources_init | ( | void | ) | [static] |
Initializes SD/MMC resources: GPIO, MCI and SD/MMC.
Definition at line 153 of file sd_mmc_mci_example.c.
References EXAMPLE_SD_SLOT, PBB_HZ, and sd_mmc_mci_init().
Referenced by main().
00154 { 00155 // GPIO pins used for SD/MMC interface 00156 #if EXAMPLE_SD_SLOT == SD_SLOT_8BITS 00157 static const gpio_map_t SD_MMC_MCI_GPIO_MAP = 00158 { 00159 {SD_SLOT_8BITS_CMD_PIN, SD_SLOT_8BITS_CMD_FUNCTION }, // CMD Pin. 00160 {SD_SLOT_8BITS_CLK_PIN, SD_SLOT_8BITS_CLK_FUNCTION}, // CLOCK Pin. 00161 {SD_SLOT_8BITS_DATA0_PIN, SD_SLOT_8BITS_DATA0_FUNCTION}, // DATA Pin. 00162 {SD_SLOT_8BITS_DATA1_PIN, SD_SLOT_8BITS_DATA1_FUNCTION}, // DATA Pin. 00163 {SD_SLOT_8BITS_DATA2_PIN, SD_SLOT_8BITS_DATA2_FUNCTION}, // DATA Pin. 00164 {SD_SLOT_8BITS_DATA3_PIN, SD_SLOT_8BITS_DATA3_FUNCTION}, // DATA Pin. 00165 {SD_SLOT_8BITS_DATA4_PIN, SD_SLOT_8BITS_DATA4_FUNCTION}, // DATA Pin. 00166 {SD_SLOT_8BITS_DATA5_PIN, SD_SLOT_8BITS_DATA5_FUNCTION}, // DATA Pin. 00167 {SD_SLOT_8BITS_DATA6_PIN, SD_SLOT_8BITS_DATA6_FUNCTION}, // DATA Pin. 00168 {SD_SLOT_8BITS_DATA7_PIN, SD_SLOT_8BITS_DATA7_FUNCTION} // DATA Pin. 00169 }; 00170 #elif EXAMPLE_SD_SLOT == SD_SLOT_4BITS 00171 static const gpio_map_t SD_MMC_MCI_GPIO_MAP = 00172 { 00173 {SD_SLOT_4BITS_CMD_PIN, SD_SLOT_4BITS_CMD_FUNCTION }, // CMD Pin. 00174 {SD_SLOT_4BITS_CLK_PIN, SD_SLOT_4BITS_CLK_FUNCTION}, // CLOCK Pin. 00175 {SD_SLOT_4BITS_DATA0_PIN, SD_SLOT_4BITS_DATA0_FUNCTION}, // DATA Pin. 00176 {SD_SLOT_4BITS_DATA1_PIN, SD_SLOT_4BITS_DATA1_FUNCTION}, // DATA Pin. 00177 {SD_SLOT_4BITS_DATA2_PIN, SD_SLOT_4BITS_DATA2_FUNCTION}, // DATA Pin. 00178 {SD_SLOT_4BITS_DATA3_PIN, SD_SLOT_4BITS_DATA3_FUNCTION} // DATA Pin. 00179 }; 00180 #else 00181 # error SD_SLOT not supported 00182 #endif 00183 00184 // MCI options. 00185 static const mci_options_t MCI_OPTIONS = 00186 { 00187 .card_speed = 400000, 00188 .card_slot = EXAMPLE_SD_SLOT, 00189 }; 00190 00191 // Assign I/Os to SPI. 00192 gpio_enable_module(SD_MMC_MCI_GPIO_MAP, 00193 sizeof(SD_MMC_MCI_GPIO_MAP) / sizeof(SD_MMC_MCI_GPIO_MAP[0])); 00194 00195 // Initialize SD/MMC driver with MCI clock (PBB). 00196 sd_mmc_mci_init(&MCI_OPTIONS, PBB_HZ, pm_freq_param.cpu_f); 00197 }
static Bool test_sd_mmc_write | ( | U8 | pattern_id | ) | [static] |
Definition at line 232 of file sd_mmc_mci_example.c.
References EXAMPLE_SD_SLOT, sd_mmc_mci_mem_2_ram(), sd_mmc_mci_ram_2_mem(), and SD_MMC_SECTOR_SIZE.
Referenced by main().
00233 { 00234 U16 i = 0; 00235 U16 j = 0; 00236 Bool b_error; 00237 Ctrl_status status; 00238 00239 print_dbg("Testing pattern "); 00240 print_dbg_char_hex( pattern_id ); 00241 // Backup sector 0. 00242 status = sd_mmc_mci_mem_2_ram(EXAMPLE_SD_SLOT, 0, buffer_saved); 00243 if( status!=CTRL_GOOD ) 00244 { 00245 print_dbg("\nERROR 001: can not read device.\r\n"); 00246 return FALSE; 00247 } 00248 00249 // Initialize pattern. 00250 for( i=0 ; i<SD_MMC_SECTOR_SIZE ; i++ ) 00251 { 00252 switch( pattern_id ) 00253 { 00254 case 0: 00255 buffer_in[i] = i; 00256 break; 00257 00258 case 1: 00259 buffer_in[i] = 0xAA; 00260 break; 00261 00262 case 2: 00263 buffer_in[i] = 0x55; 00264 break; 00265 00266 default: 00267 buffer_in[i] = (256-(U8)i); 00268 break; 00269 } 00270 } 00271 00272 // Write the pattern into the sector. 00273 status = sd_mmc_mci_ram_2_mem(EXAMPLE_SD_SLOT, 0, buffer_in); 00274 if( status!=CTRL_GOOD ) 00275 { 00276 print_dbg("\nERROR: can not write device.\r\n"); 00277 return FALSE; 00278 } 00279 00280 // Clear buffer before comparing. 00281 for( i=0 ; i<SD_MMC_SECTOR_SIZE ; i++ ) 00282 buffer_in[i] = 0; 00283 00284 // Read back the sector. 00285 status = sd_mmc_mci_mem_2_ram(EXAMPLE_SD_SLOT, 0, buffer_in); 00286 if( status!=CTRL_GOOD ) 00287 { 00288 print_dbg("\nERROR 002: can not read device.\r\n"); 00289 return FALSE; 00290 } 00291 00292 // Check the sector content. 00293 b_error = FALSE; 00294 for( i=0 ; i<SD_MMC_SECTOR_SIZE ; i++ ) 00295 { 00296 switch( pattern_id ) 00297 { 00298 case 0: 00299 if( buffer_in[i]!=(i%256) ) 00300 b_error = TRUE; 00301 break; 00302 00303 case 1: 00304 if( buffer_in[i]!=0xAA ) 00305 b_error = TRUE; 00306 break; 00307 00308 case 2: 00309 if( buffer_in[i]!=0x55 ) 00310 b_error = TRUE; 00311 break; 00312 00313 default: 00314 if( buffer_in[i]!=((256-(U8)i)%256) ) 00315 b_error = TRUE; 00316 break; 00317 } 00318 00319 if( b_error ) 00320 { 00321 print_dbg("\nERROR: pattern comparaison failed.\r\n"); 00322 for( i=0 ; i<SD_MMC_SECTOR_SIZE ; i++ ) 00323 { 00324 print_dbg_char_hex(buffer_in[i]); 00325 j++; 00326 if (j%32==0) 00327 print_dbg("\n"), j=0; 00328 else if (j%4==0) 00329 print_dbg(" "); 00330 } 00331 return FALSE; 00332 } 00333 } 00334 00335 // Restore back the old sector content. 00336 status = sd_mmc_mci_ram_2_mem(EXAMPLE_SD_SLOT, 0, buffer_saved); 00337 if( status!=CTRL_GOOD ) 00338 { 00339 print_dbg("\nERROR: can not write device.\r\n"); 00340 return FALSE; 00341 } 00342 00343 // Check that the sector restore is succesful. 00344 status = sd_mmc_mci_mem_2_ram(EXAMPLE_SD_SLOT, 0, buffer_in); 00345 if( status!=CTRL_GOOD ) 00346 { 00347 print_dbg("\nERROR 003: can not read device.\r\n"); 00348 return FALSE; 00349 } 00350 for (i=0;i<(512);i++) 00351 { 00352 if( buffer_in[i]!=buffer_saved[i] ) 00353 { 00354 print_dbg("\nERROR: old sector is not correctly restored.\r\n"); 00355 return FALSE; 00356 } 00357 } 00358 print_dbg(" [PASS].\r\n"); 00359 return TRUE; 00360 }
U8 buffer_in[SD_MMC_SECTOR_SIZE *ALLOCATED_SECTORS] |
Definition at line 122 of file sd_mmc_mci_example.c.
U8 buffer_saved[SD_MMC_SECTOR_SIZE] |
Definition at line 129 of file sd_mmc_mci_example.c.
pm_freq_param_t pm_freq_param |
Initial value:
{ .cpu_f = APPLI_CPU_SPEED , .pba_f = APPLI_PBA_SPEED , .osc0_f = FOSC0 , .osc0_startup = OSC0_STARTUP }
Definition at line 131 of file sd_mmc_mci_example.c.