Plymouth ELEC351 Group T
/
ELEC351_Group_T
FINAL PROJECT isn't it
Fork of ELEC351 by
main.cpp
- Committer:
- thomasmorris
- Date:
- 2018-01-08
- Revision:
- 47:6d128e500875
- Parent:
- 46:bd9e7e40b3f9
- Child:
- 48:244d6d81bb52
File content as of revision 47:6d128e500875:
/* ELEC 351 Group T Team Members : Christopher Hills, Thomas Morris Current Verision 19 Overiew: Working Tasks 1,2,3,5,6,7,8,9,10,11,12,13,14,15 Last Revision: Added Mail Box to serial Todo: Add functionality to SD card import chris's work on delete serial commnads Commnet code Check for race conditions Move code around Other fixes */ #include "SETUP.hpp" #include "NETWORK.hpp" #include "FIFO.hpp" #include "SD_CARD.hpp" #include "SERIAL_COMMANDS.hpp" #include "SAMPLE.hpp" #include "THREADS.hpp" void SD_Card()//Writes data to the SD card { while(1) { Thread::wait(Sample_Rate*1000); //Waits until a new is taken before checking again SD_Card_Write(); } } void Network() { while(1) { Thread::wait(NetworkWait);//Waits Network Wait amount of time Networking(); } } void LCD_Output() { while(1) { Thread::wait(10);//Small wait LCD_Print_Output(); } } void Serial_Commands() { while(1) { Serial_Commands_Output(); } } void Sample() { Sample_Event(); } int main() { set_time(1515352584); //Set RTC time to December 10 2017 pc.baud(9600); //Sets the Serial Comms Baud Rate LCD.Initialise(); LCD.DDRAM_Address(0x00); post(); //Power on Self Test //Initialise the SD card (this needs to move) if ( sd.init() != 0) { printf("SD Init failed \n"); LCD.Display_Clear(); LCD.Write_String("CANNOT INIT SD"); //Change me errorCode(FATAL); } //Create a filing system for SD Card FATFileSystem fs("sd", &sd); //Open to WRITE FILE* fp = fopen("/sd/test.csv","a");//test.csv is created in the SD Card if (fp == NULL) { error("Could not open file for write\n"); LCD.Display_Clear(); LCD.Write_String("CANNOT OPEN FILE"); errorCode(FATAL); } //Close File fclose(fp); int network_temp; network_temp = Network_Init(); if(network_temp == 1)//Sets up the network and checks if the network cable is not pluged in { error("Could not access network"); LCD.Display_Clear(); LCD.Write_String("Could not access network"); errorCode(NETWORK_FATAL); } //Last message before sampling begins LCD.Display_Clear(); LCD.Write_String("READY PLAYER"); LCD.DDRAM_Address(0x40); LCD.Write_String(" One "); LCD.DDRAM_Address(0x00); Sample_Rate = TimerInterval; //Run interrupt Sampling_Timer.attach(&Sampling_ISR,Sample_Rate); t1.start(Sample); t2.start(SD_Card); t3.start(LCD_Output); t4.start(Network); t5.start(Serial_Commands); //Main thread ID idMain = osThreadGetId(); //CMSIS RTOS call //Thread ID id1 = t1.gettid(); id2 = t2.gettid(); id3 = t3.gettid(); id4 = t4.gettid(); id5 = t5.gettid(); while(true) { if(onBoardSwitch == 1) { fclose(fp);//Close File sd.deinit();//Close down LCD.Display_Clear(); LCD.DDRAM_Address(0x00); LCD.Write_String("SD Card"); LCD.DDRAM_Address(0x40); LCD.Write_String("Unmounted"); LCD.DDRAM_Address(0x00); pc.printf("SD Card Unmounted\n"); Green_led.switchOn(); } } }