22 #define fsSD_BUFFER_SIZE 200
26 #define fsMAX_FILE_NAME_LEN 13
30 #define fsPUTC_FILE_SIZE 100
37 static const char *pcRoot =
"/", *pcDirectory1 =
"SUB1", *pcDirectory2 =
"SUB2", *pcFullPath =
"/SUB1/SUB2";
51 static void prvCreateDemoFilesUsing_f_write(
void );
58 static void prvVerifyDemoFileUsing_f_read(
void );
64 static void prvCreateDemoFileUsing_f_putc(
void );
71 static void prvVerifyDemoFileUsing_f_getc(
void );
87 void SD_Test (
void* pvParameters );
88 void Impulse (
void* pvParameters );
98 PIOA->PIO_ABCDSR[0] = ~PIO_ABCDSR_P9;
99 PIOA->PIO_ABCDSR[1] = ~PIO_ABCDSR_P9;
102 PIOA->PIO_PDR = PIO_PDR_P9;
105 PIOA->PIO_ABCDSR[0] = ~PIO_ABCDSR_P10;
106 PIOA->PIO_ABCDSR[1] = ~PIO_ABCDSR_P10;
109 PIOA->PIO_PDR = PIO_PDR_P10;
112 PMC->PMC_PCER0 = PMC_PCER0_PID8;
115 UART0->UART_CR = UART_CR_RSTRX | UART_CR_RSTTX | UART_CR_RXDIS | UART_CR_TXDIS;
119 UART0->UART_BRGR = 65;
122 UART0->UART_MR = UART_MR_PAR_NO;
125 UART0->UART_PTCR = UART_PTCR_RXTDIS | UART_PTCR_TXTDIS;
128 UART0->UART_CR = UART_CR_RXEN | UART_CR_TXEN;
131 UART0->UART_MR = UART_MR_CHMODE_NORMAL;
142 volatile uint32_t i = 0;
185 REG_PIOA_OER = 0x100000;
187 REG_PIOA_OWER = 0x100000;
195 REG_PIOA_ODSR ^= 0x100000;
209 REG_PIOA_OER = 0x80000;
210 REG_PIOA_OWER = 0x80000;
214 char *pcString =
"This is a test string generated to calculate and evaluate the time required to write data on a SD card using the HSMCI interface of SAM4S";
216 sprintf( cFileName,
"TestFile.txt");
221 REG_PIOA_ODSR ^= 0x80000;
226 pxFile =
f_open( cFileName,
"w" );
230 if(
f_write( pcString, 1, 137, pxFile ) == 137)
252 unsigned char ucStatus;
253 printf(
"Please insert an SD card in slot\n\r");
255 printf(
"Card inserted\n\r");
280 printf(
"SD card initialized\n\r");
290 static void prvCreateDemoFilesUsing_f_write(
void )
300 for( xFileNumber = 1; xFileNumber <= xMaxFiles; xFileNumber++ )
303 sprintf( cFileName,
"TestF%03d.txt", (
int ) xFileNumber );
309 pxFile =
f_open( cFileName,
"w" );
319 for( xWriteNumber = 0; xWriteNumber < xFileNumber; xWriteNumber++ )
335 static void prvVerifyDemoFileUsing_f_read(
void )
340 long lItemsRead, lChar;
344 for( xFileNumber = 1; xFileNumber <= xMaxFiles; xFileNumber++ )
347 sprintf( cFileName,
"root%03d.txt", (
int ) xFileNumber );
354 pxFile =
f_open( cFileName,
"r" );
359 for( xReadNumber = 0; xReadNumber < xFileNumber; xReadNumber++ )
372 configASSERT( cSDBuffer[ lChar ] == (
'0' + (
char ) xFileNumber ) );
387 static void prvCreateDemoFileUsing_f_putc(
void )
389 unsigned char ucReturn;
390 int iByte, iReturned;
398 ucReturn =
f_mkdir( pcDirectory1 );
402 ucReturn =
f_chdir( pcDirectory1 );
409 ucReturn =
f_mkdir( pcDirectory2 );
413 ucReturn =
f_chdir( pcDirectory2 );
421 sprintf( cFileName,
"%s.txt", pcDirectory2 );
424 pxFile =
f_open( cFileName,
"w" );
429 iReturned =
f_putc( ( (
int )
'0' + iByte ), pxFile );
450 static void prvVerifyDemoFileUsing_f_getc(
void )
452 unsigned char ucReturn;
453 int iByte, iReturned;
458 ucReturn =
f_chdir( pcFullPath );
466 sprintf( cFileName,
"%s.txt", pcDirectory2 );
469 pxFile =
f_open( cFileName,
"r" );
474 iReturned =
f_getc( pxFile );
#define f_getcwd(buffer, maxlen)
void vApplicationTickHook(void)
#define fsPUTC_FILE_SIZE
The number of bytes written to the file that uses f_putc() and f_getc().
int sprintf(char *out, const char *format,...)
F_DRIVER * sd_init(unsigned long driver_param)
SD/MMC protocol definitions.
#define taskEXIT_CRITICAL()
int printf(const char *format,...)
void SystemInit(void)
Setup the microcontroller system.
void SD_Test(void *pvParameters)
FreeRTOS tasks These are the method declarations for the tasks created and executed by FreeRTOS sched...
void vApplicationStackOverflowHook(xTaskHandle pxTask, signed char *pcTaskName)
void vApplicationIdleHook(void)
void Impulse(void *pvParameters)
A function which creates an impulse This is a task used to generate a short impulse on an external LE...
uint32_t hsmci_init(void)
Initializes the low level driver.
void vTaskStartScheduler(void) PRIVILEGED_FUNCTION
#define f_putc(ch, filehandle)
TickType_t xTaskGetTickCount(void) PRIVILEGED_FUNCTION
#define fsSD_BUFFER_SIZE
The number of bytes read/written to the example files at a time.
void vTaskDelayUntil(TickType_t *const pxPreviousWakeTime, const TickType_t xTimeIncrement) PRIVILEGED_FUNCTION
#define f_write(buf, size, _size_t, filehandle)
void Config_UART0(void)
A function which initializes UART This is a method used to configure the UART0 interface of SAM4S...
void vApplicationMallocFailedHook(void)
FreeRTOS hook (or callback) functions that are defined in this file.
#define f_read(buf, size, _size_t, filehandle)
#define f_open(filename, mode)
void vCreateAndVerifySampleFiles(void)
A function which uses FreeRTOS+FAT-SL APIs Creates and verifies different files on the volume...
#define taskENTER_CRITICAL()
#define f_getc(filehandle)
#define f_format(fattype)
int main(void)
Application entry point.
void WaitSomeTime(void)
A function which creates a delay This is a method used to generate a delay by executing a for loop fo...
#define taskDISABLE_INTERRUPTS()
#define xTaskCreate(pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask)
#define f_close(filehandle)
#define fsMAX_FILE_NAME_LEN
8.3 format, plus null terminator.