This software is designed to write to an SD card on the mbed adapter module which is part of the RS-EDP system.

Dependencies:   mbed SDFileSystem

Files at this revision

API Documentation at this revision

Comitter:
DavidGilesHitex
Date:
Fri Nov 19 09:57:10 2010 +0000
Commit message:

Changed in this revision

FATFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
HeaderFiles/defines.h Show annotated file Show diff for this revision Revisions of this file
HeaderFiles/mbed_Port_Structure.h Show annotated file Show diff for this revision Revisions of this file
HeaderFiles/misra_types.h Show annotated file Show diff for this revision Revisions of this file
SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
SourceFiles/main.cpp Show annotated file Show diff for this revision Revisions of this file
SourceFiles/mbed_Port_Structure.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FATFileSystem.lib	Fri Nov 19 09:57:10 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_unsupported/code/fatfilesystem/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HeaderFiles/defines.h	Fri Nov 19 09:57:10 2010 +0000
@@ -0,0 +1,11 @@
+/* Defines */
+/* ******* */
+
+
+/* Software Revision Number */
+#define FIRMWARE_VERSION 3
+
+
+/* LED On/OFF Defines */
+#define LED_ON 1
+#define LED_OFF 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HeaderFiles/mbed_Port_Structure.h	Fri Nov 19 09:57:10 2010 +0000
@@ -0,0 +1,17 @@
+/* Header Files for Port Structure */
+/* ******************************* */
+
+
+extern void setup_mbed_ports(void);
+
+
+/* Configure the I/O Port Structure */
+extern DigitalOut User_Led1;
+extern DigitalOut User_Led2;
+extern DigitalOut User_Led3;
+extern DigitalOut User_Led4;
+
+
+/* Serial interface via USB  */
+extern Serial pc;
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HeaderFiles/misra_types.h	Fri Nov 19 09:57:10 2010 +0000
@@ -0,0 +1,32 @@
+/* Hitex Standard Header File */
+/* Types As Recommended By MISRA */
+
+
+
+/* Bytes (8bit length) */
+typedef unsigned char uint8_t;
+typedef char sint8_t;
+
+/* Half Words (16bit lengths) */
+typedef unsigned short uint16_t;
+typedef short sint16_t;
+
+/* Words (32bit lengths) */
+/* Also int */
+typedef unsigned int uint32_t;
+typedef long sint32_t;
+
+/* Double Words */
+typedef unsigned long long uint64_t;
+typedef long long sint64_t;
+
+
+/*
+ Constants should use the following suffixes also 
+
+u - Unsigned
+f - floating
+L - Long double (64bit)
+
+*/
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Fri Nov 19 09:57:10 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/SDFileSystem/#b1ddfc9a9b25
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SourceFiles/main.cpp	Fri Nov 19 09:57:10 2010 +0000
@@ -0,0 +1,84 @@
+/* SD-Card Utility Program for RS-EDP and RS-EDP mbed adapter module */
+/* ***************************************************************** */
+
+/* This application will create a file and write a few bytes to the SD Card on the mbed adapter board */
+
+
+#include "mbed.h"
+
+#include "defines.h"
+#include "misra_types.h"
+#include "mbed_Port_Structure.h"
+
+#include "SDFileSystem.h"
+
+
+
+
+/* Main Loop Here */
+int main(void) 
+    {
+        FILE *MyNewFile;
+        char file_name_with_root_and_path[30];
+        char input_file_name[30];
+        char *pointer1;
+        char *pointer2;
+        char n = 0;
+
+
+        for (n = 0; n < 30; n++)                                                       /* initialise arrays to zero */
+            {
+                file_name_with_root_and_path[n] = 0;    
+                input_file_name[n] = 0;
+            }
+            
+        setup_mbed_ports();                                                            /* Setup the I/O Structure of the mbed module */
+
+        pc.printf("\n\n\n\n\n\n\n\rWelcome the the RS-EDP platform\n\r");
+        pc.printf("This software is for the MBED - LPC1768 Module\n\r");
+        pc.printf("This software exercises the on board SD-CARD card via an SPI interface\n\r");
+        pc.printf("The SD card slot is present on the reverse side of the MBED adapter board\n\r");        
+        pc.printf("\nSoftware Revision Number: %03d\n\r\n", FIRMWARE_VERSION);
+        
+        pc.printf("This application writes a few bytes to a txt file on the SD-CARD\n\r"); 
+        pc.printf("Make sure the LOCAL ECHO on your terminal emulator is turned ON\n\r"); 
+          
+        User_Led1 = LED_OFF;
+        User_Led2 = LED_OFF;
+        User_Led3 = LED_OFF;
+        User_Led4 = LED_OFF;    
+        
+        while(1)
+            {            
+
+                pointer1 = file_name_with_root_and_path;                                  /* set pointer1 to point at the complete name and path array */
+                strcpy(pointer1, "/sd/");                                                 /* Start to build the root, directory and file name of the file we want to create */
+       
+                pointer2 = input_file_name;                                               /* set pointer2 to point at an empty string array to take the user input file name */
+                pc.printf("Enter the file name you wish to create\n\r\n");
+
+                scanf("%s", pointer2);                                                    /* Get the file name into an array called 'input_file_name', pointed to by a pointer called pointer2 */
+                strcat(pointer1, pointer2);                                               /* Add on the entered file name to the root direcotry, and store in pointer1 */
+
+
+                pc.printf("Creating the file: %s\n\r", file_name_with_root_and_path);     /* Print the name including the root and path of the file */
+
+                MyNewFile = fopen(file_name_with_root_and_path, "w");                     /* attempt to open/create the file */
+
+
+                if (MyNewFile == 0 ) 
+                    {
+                        /* Problems - can not create the file whos name we just inputed */
+                        pc.printf("Unable to create the file '%s'\n\r", file_name_with_root_and_path);
+                        pc.printf("Please try again\n\n\r");                    
+                    }
+                else{
+                        /* ok file is now open - lets print the header file */
+                        pc.printf("Writing to the file...\n\r");                    
+                        fprintf(MyNewFile, "This text string has just been written to your file");
+                        pc.printf("Finished writing to the file...\n\n\r");                    
+                        fclose(MyNewFile);                                                  /* Close the file */
+                    }
+            }
+      }
+  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SourceFiles/mbed_Port_Structure.cpp	Fri Nov 19 09:57:10 2010 +0000
@@ -0,0 +1,47 @@
+/* Configure the I/O Port Structure */
+/* ******************************** */
+
+
+/* includes files */
+#include "mbed.h"                                /* Header file for mbed module */
+#include "defines.h"                            /* User defines */
+#include "misra_types.h"                         /* MISRA Types */
+#include "SDFileSystem.h"                        /* File System for SD Card */
+
+
+
+/* Digital I/O */
+DigitalOut User_Led1(LED1);
+DigitalOut User_Led2(LED2);
+DigitalOut User_Led3(LED3);
+DigitalOut User_Led4(LED4);
+
+
+/* SPI Interface to RS-EDP CNTRL_SPI and the SD Card on Adapter board */
+SDFileSystem sd(p11, p12, p13, p14, "sd");
+
+
+/* Configure the USB as a virtual communications port */
+Serial pc(USBTX, USBRX);
+
+
+
+
+/* Function Prototypes */
+void setup_mbed_ports(void);
+
+
+
+/* Configure the I/O Ports */
+void setup_mbed_ports(void)
+    {
+        pc.baud(115000);                        /* Baud rate should be 115k baud */
+        pc.format(8, Serial::None, 1);          /* format is 8 data bits, no stop bit, no parity */
+
+        User_Led1 = LED_ON;
+        User_Led2 = LED_OFF;
+        User_Led3 = LED_ON;
+        User_Led4 = LED_OFF;
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Nov 19 09:57:10 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/3944f1e2fa4f