Patrick McNamara / Mbed 2 deprecated ADC_SDcard_serial

Dependencies:   BufferedSerial SDFileSystem mbed

Fork of SDFileSystem_HelloWorld by mbed official

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "SDFileSystem.h"
00003 #include "globals.h"
00004 #include <string>
00005 #include <cstring>
00006 #include "ReadADC.h"
00007 #include "serial_transfer.h"
00008 #include "sd_card.h"
00009 
00010 
00011 /*========================================================================================
00012                                            NOTES
00013   ========================================================================================
00014 
00015 
00016 6/14/2016 - Everything is working!  115200 baud with array sizes of 32 bytes seems to be
00017             what is working reliably.
00018           - Keeping array sizes at 32 seems easy to send and receive over serial.  Trying
00019             to figure out why serial receive hangs with more than 32 bytes of data
00020             
00021 
00022 6/1/2016 - test to see if the recieve interrupt is handling the serial transfer and the
00023            read_line() does not need to be called
00024          - set up receive buffer to be stored into an array
00025            ... this will depend on where serial data is being received
00026 
00027 
00028 Board:  STM Nucleo f303re
00029 Serial communciation: 
00030     uart2 is connected to uart1 = 
00031     PC_10 to D2, PC_11 to D8
00032 SPI communication to SD card:
00033     MOSI, MISO, SCK, CS
00034 ******************************************************************************************/
00035 
00036 
00037 
00038 
00039 
00040  
00041 
00042 
00043 /*========================================================================================
00044                                               MAIN
00045   ========================================================================================*/
00046 
00047 
00048 /************************************************************************
00049 * main handles:
00050 *       setting up serial ports, interrupts 
00051 *       reading ADC data into char array c
00052 *       then store it to an SD card, 
00053 *       then send it over serial
00054 *
00055 ************************************************************************/
00056 int main() 
00057 {
00058     pc.baud(128000);
00059 // 6/1/2016 sped up baud rate and need to compare with output to see if still the same
00060 // 6/14/2016 any baud rate over 115200 hangs up the serial recieve interrupt :/
00061     uart1.baud(115200);
00062     uart2.baud(115200); 
00063     uart1.attach(&Tx_interrupt, Serial::TxIrq);                                         // Setup a serial interrupt function to transmit data
00064     uart2.attach(&Rx_interrupt, Serial::RxIrq);                                         // Setup a serial interrupt function to receive data
00065     
00066     
00067     for (int j = 0; j < 10; j++)
00068     {
00069         pc.printf("\r\nStarting SD card and serial test.\r\n\r\n");   
00070   
00071         readADC();  
00072     
00073         writeToSdCard();
00074         readFromSdCard();
00075 
00076         sendSdCardDataOverSerial();
00077         receiveSdCardDataOverSerial();                                                    // Rx interrupt interferes with this since it reads from 2 places
00078     
00079 
00080     //debug code
00081         for(int i = 0; i < arrayCount; i++)
00082         {
00083             pc.printf("     %f  -   %f   \r\n", squibCLT_array[i], squibCLT_array2[i]);   //, squib_test);
00084         }
00085                 
00086             pc.printf("%s", squibCLT_array3);
00087             pc.printf("\r\n\r\n");
00088         
00089     
00090         pc.printf("%d     %d\r\n", rxInterruptCount, sendCount);
00091     
00092         pc.printf("\r\nEND\r\n");
00093         cleanBuffers();
00094     }
00095 }
00096 
00097 
00098