First SPI/SDcard & UART tests

Dependencies:   SDFileSystem mbed-rtos mbed cmsis_rtos_demo_thread

Fork of cmsis_rtos_demo_thread by Ye Cheng

Files at this revision

API Documentation at this revision

Comitter:
moxondesign
Date:
Fri Oct 03 18:20:52 2014 +0000
Parent:
2:23757aa762a7
Child:
4:2a43568b9705
Commit message:
Basic Working Version;

Changed in this revision

LogUtil.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed_rtos_test.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LogUtil.lib	Fri Oct 03 18:20:52 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/sam_grove/code/LogUtil/#ef45bd2cd9bb
--- a/main.cpp	Mon Sep 29 23:00:24 2014 +0000
+++ b/main.cpp	Fri Oct 03 18:20:52 2014 +0000
@@ -1,17 +1,37 @@
 #include "mbed.h"
+#include "rtos.h"
 #include "cmsis_os.h"
 #include "SDFileSystem.h"
 
 DigitalOut led1(D7);
-DigitalOut led2(PD_2);
-Serial uart1(D8, D2);                        /* UART1: Modbus           */
-Serial uart2(D1, D0);                        /* UART2: pc(USBTX, USBRX) */
-                                             /* (i.e.) pc(D1, D0)       */
-SDFileSystem sd(D11, D12, D13, D10, "sd");   /* MOSI, MISO, SCK, CS     */
+DigitalOut led2(D9);
+Serial uart1(D8, D2);                        /* UART1: Modbus               */
+Serial uart2(D1, D0);                        /* UART2: pc(USBTX, USBRX)     */
+                                             /* (i.e.) pc(D1, D0)           */
+I2C i2c(I2C_SDA, I2C_SCL);                   /* I2C1:                       */
+                                             
+SDFileSystem sd(D11, D12, D13, D10, "sd");   /* SPI1: MOSI, MISO, SCK, CS   */
 FILE *fp;
 
+AnalogIn ain_0(A0);
+AnalogIn ain_1(A1);
+AnalogIn ain_2(A2);
+AnalogIn ain_3(A3);
+
+InterruptIn user_sw_1(USER_BUTTON);
+
+/* N.B. - add to the FRU... */
+//const char key[] = "your_api_key";    // Replace with your API key
+//const char feed[] = "your_feed_id";   // Replace with your Feed ID
+//const char stream[] = "your_stream_name"; // Replace with your stream name  
+//char name[] = "your_device_location_name"; // Name of current location of datasource
+//double latitude = 30.3748076;
+//double longitude = -97.7386896; // You can also read those values from a GPS
+//double elevation = 400.00;
+
 void led2_thread(void const *args){
     while (true) {
+        led1 = led2;
         led2 = !led2;
         osDelay(1000);
     }
@@ -35,11 +55,16 @@
 osThreadDef(led2_thread, osPriorityNormal, DEFAULT_STACK_SIZE);
 
 int main() {
+    
+    /* Set RTC time to 16 December 2013 10:05:23 UTC */
+    set_time(1387188323);
+    /* Time as seconds since January 1, 1970 */
+    time_t seconds = time(NULL); /*  */
+    
     osThreadCreate(osThread(led2_thread), NULL);
     osThreadCreate(osThread(uart1_thread), NULL);
-
+    wait(1);
     
-    wait(1);
     uart2.printf("\r\n");
     wait(1);
     uart2.printf("Initializing...\r\n");
@@ -61,7 +86,8 @@
     }
     
     osThreadCreate(osThread(uart2_thread), NULL);
-        
+    
+    Thread::wait(osWaitForever);    /* this is better than an infinite loop... */
     /* spin and spin */    
-    while(true);
+    // while(true);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_rtos_test.lib	Fri Oct 03 18:20:52 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/cnhzcy14/code/cmsis_rtos_demo_thread/#23757aa762a7