SAM4S-EK_FreeRTOS+FAT-SL  1.0
An example project to test the functionality of FreeRTOS+FAT-SL using SD card as data storage medium
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
SAM4S-EK C Ex.c File Reference
#include <stdarg.h>
#include "sam4.h"
#include "printf_stdarg.h"
#include "HSMCI.h"
#include "sd_mmc_protocol.h"
#include "FreeRTOS.h"
#include "task.h"
#include "fat_sl.h"
#include "api_mdriver.h"

Go to the source code of this file.

Macros

#define fsSD_BUFFER_SIZE   200
 The number of bytes read/written to the example files at a time. More...
 
#define fsMAX_FILE_NAME_LEN   13
 8.3 format, plus null terminator. More...
 
#define fsPUTC_FILE_SIZE   100
 The number of bytes written to the file that uses f_putc() and f_getc(). More...
 

Functions

void vCreateAndVerifySampleFiles (void)
 A function which uses FreeRTOS+FAT-SL APIs Creates and verifies different files on the volume, demonstrating the use of various different API functions. More...
 
void vApplicationMallocFailedHook (void)
 FreeRTOS hook (or callback) functions that are defined in this file. More...
 
void vApplicationIdleHook (void)
 
void vApplicationStackOverflowHook (xTaskHandle pxTask, signed char *pcTaskName)
 
void vApplicationTickHook (void)
 
void SD_Test (void *pvParameters)
 FreeRTOS tasks These are the method declarations for the tasks created and executed by FreeRTOS scheduler. More...
 
void Impulse (void *pvParameters)
 A function which creates an impulse This is a task used to generate a short impulse on an external LED. More...
 
void Config_UART0 (void)
 A function which initializes UART This is a method used to configure the UART0 interface of SAM4S. More...
 
void WaitSomeTime (void)
 A function which creates a delay This is a method used to generate a delay by executing a for loop for a certain number of iteration. More...
 
int main (void)
 Application entry point. More...
 

Macro Definition Documentation

#define fsMAX_FILE_NAME_LEN   13

8.3 format, plus null terminator.

Definition at line 26 of file SAM4S-EK C Ex.c.

#define fsPUTC_FILE_SIZE   100

The number of bytes written to the file that uses f_putc() and f_getc().

Definition at line 30 of file SAM4S-EK C Ex.c.

#define fsSD_BUFFER_SIZE   200

The number of bytes read/written to the example files at a time.

Definition at line 22 of file SAM4S-EK C Ex.c.

Function Documentation

void Config_UART0 ( void  )

A function which initializes UART This is a method used to configure the UART0 interface of SAM4S.

Set peripheral A on PA9.

Disable PIO controller for PA9.

Set peripheral A on PA10.

Disable PIO controller for PA10.

Enable peripheral clock for UART0.

Reset and disable receiver & transmitter.

Configure baud rate Asynchronous, no oversampling.

Configure mode.

Disable PDC channel.

Enable receiver and transmitter.

Configure UART in normal mode.

Definition at line 95 of file SAM4S-EK C Ex.c.

void Impulse ( void *  pvParameters)

A function which creates an impulse This is a task used to generate a short impulse on an external LED.

Enable output.

Output write enable.

Declare a variable for timekeeping.

Get tick counts of the task.

Set and reset output.

Insert a task delay.

Definition at line 182 of file SAM4S-EK C Ex.c.

int main ( void  )

Application entry point.

Returns
Unused (ANSI-C compatibility).

Initialize the SAM system.

Configure the UART0 interface.

Configure the HSMCI interface.

Initialize the SD card and format if needed.

Create tasks.

Start scheduler.

Definition at line 155 of file SAM4S-EK C Ex.c.

void SD_Test ( void *  pvParameters)

FreeRTOS tasks These are the method declarations for the tasks created and executed by FreeRTOS scheduler.

A function which tests SD card This is a task used to write a string to the SD card using the FreeRTOS FAT FS.

Generate a file name.

Obtain the current working directory and print out the file name and the directory into which the file is being written.

Open the file TestFile.txt for writing.

Write characters to the opened file.

All bytes were written to the file.

Close the file again.

Definition at line 207 of file SAM4S-EK C Ex.c.

void vApplicationIdleHook ( void  )

vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle task. It is essential that code added to this hook function never attempts to block in any way (for example, call xQueueReceive() with a block time specified, or call vTaskDelay()). If the application makes use of the vTaskDelete() API function (as this demo application does) then it is also important that vApplicationIdleHook() is permitted to return to its calling function, because it is the responsibility of the idle task to clean up memory allocated by the kernel to any task that has since been deleted.

Definition at line 509 of file SAM4S-EK C Ex.c.

void vApplicationMallocFailedHook ( void  )

FreeRTOS hook (or callback) functions that are defined in this file.


vApplicationMallocFailedHook() will only be called if configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook function that will get called if a call to pvPortMalloc() fails. pvPortMalloc() is called internally by the kernel whenever a task, queue, timer or semaphore is created. It is also called by various parts of the demo application. If heap_1.c or heap_2.c are used, then the size of the heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used to query the size of free heap space that remains (although it does not provide information on how the remaining heap might be fragmented).

Definition at line 490 of file SAM4S-EK C Ex.c.

void vApplicationStackOverflowHook ( xTaskHandle  pxTask,
signed char *  pcTaskName 
)

Run time stack overflow checking is performed if configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is called if a stack overflow is detected.

Definition at line 524 of file SAM4S-EK C Ex.c.

void vApplicationTickHook ( void  )

This function will be called by each tick interrupt if configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be added here, but the tick hook is called from an interrupt context, so code must not attempt to block, and only the interrupt safe FreeRTOS API functions can be used (those that end in FromISR()).

Definition at line 539 of file SAM4S-EK C Ex.c.

void vCreateAndVerifySampleFiles ( void  )

A function which uses FreeRTOS+FAT-SL APIs Creates and verifies different files on the volume, demonstrating the use of various different API functions.

/brief A function which uses FreeRTOS+FAT-SL APIs This is a method used to initialize the SD card. It formats the SD card using FreeRTOS_FAT FS.

First create the volume.

It is expected that the volume is not formatted.

Format the created volume with FAT32 FS.

Create a set of files using f_write().

Read back and verify the files that were created using f_write().

Create sub directories two deep then create a file using putc.

Read back and verify the file created by prvCreateDemoFileUsing_f_putc().

Definition at line 250 of file SAM4S-EK C Ex.c.

void WaitSomeTime ( void  )

A function which creates a delay This is a method used to generate a delay by executing a for loop for a certain number of iteration.

Definition at line 140 of file SAM4S-EK C Ex.c.