2014 Freescale / Hack A Day Make It Challenge FRDM-K64 Internet of "Thing"
Embed:
(wiki syntax)
Show/hide line numbers
Main.cpp
00001 /* 00002 00003 -------------------------------------------- 00004 | | 00005 | .... | 00006 | 7OO$?I78. | 00007 | .?8++++7+II?D. | 00008 | .?O++=I++II+?= | 00009 | .IO++?7==I??$. | 00010 | .8++=$===?+I$ | 00011 | ?+++===+===+ | 00012 | ???=+I++==+? | 00013 | .??++====+==++ | 00014 | ?+++==========~ | 00015 | $+++==========+= | 00016 | =?+===+==+I======== | 00017 | ..++======~~~~========? | 00018 | .$?I??+=~~===~~~===~===++. | 00019 | .+==.+=~~~=~==~~~~==~~=~==+? | 00020 | ?===I+====~~=~~~=~~=====~~~=?. | 00021 | .=~~~+==~==..~~~~~~= ~~~~=7= | 00022 | +=~~?+~~=. ==~~~~=. ~~~~=?. | 00023 | =~~~=~~~ ?===~~+. ~~~~+ | 00024 | +~~:+~~= =~~==. =~~+. | 00025 | ~:~ =~~= =~~~= ~=== | 00026 | I=~~ ,=~~= ,. | 00027 | ~~. ,==== | 00028 | ==== | 00029 | =~~. | 00030 | | 00031 |------------------------------------------| 00032 | Internet Of Thing | 00033 | Eli Hughes | 00034 | Freescale / Hack-a-day Make-It-Challenge | 00035 | FTF 2014 - Dallas, Tx | 00036 |------------------------------------------| 00037 00038 */ 00039 #include "mbed.h" 00040 #include "Queue.h" 00041 #include "Terminal.h" 00042 #include "System.h" 00043 00044 00045 //Note -- Seems that there is a bug with the new K64 firmware. When I enable 2 serial port objects there seems to be some cross mojination going on. We use a 00046 //macro to select wifi or com port for debug 00047 00048 #define USE_WIFI 00049 00050 #define DATA_BUFFER_MAX_SIZE 128 00051 00052 DigitalOut SPIN_CCW (PTA2); 00053 DigitalOut SPIN_CW (PTC2); 00054 DigitalOut GO_FORWARD (PTC3); 00055 DigitalOut GO_REVERSE (PTB23); 00056 00057 #ifdef USE_USB 00058 Serial PC(USBTX, USBRX); // tx, rx 00059 #endif 00060 00061 #ifdef USE_WIFI 00062 Serial WIFI(PTC17,PTC16); 00063 #endif 00064 00065 uint8_t DataBuffer[DATA_BUFFER_MAX_SIZE]; 00066 00067 int main (void) 00068 { 00069 uint32_t i; 00070 uint8_t DataOut; 00071 uint32_t BytesToSend; 00072 00073 #ifdef USE_WIFI 00074 00075 WIFI.baud(115200); 00076 00077 #endif 00078 00079 #ifdef USE_USB 00080 00081 PC.baud(115200); 00082 00083 #endif 00084 00085 00086 TFC_InitTerminal(); 00087 00088 while(1) 00089 { 00090 00091 //Shuffle Datafrom the terminal Queue to the USB port or TCP Port 00092 //Inefficient but workable 00093 BytesToSend = BytesInQueue(&TERMINAL_OUTPUT_QUEUE); 00094 00095 if(BytesToSend >0) 00096 { 00097 //Limit to maximum chunk size 00098 00099 if(BytesToSend > DATA_BUFFER_MAX_SIZE) 00100 BytesToSend = DATA_BUFFER_MAX_SIZE; 00101 00102 for(i=0 ; i< BytesToSend; i++) 00103 { 00104 ByteDequeue(&TERMINAL_OUTPUT_QUEUE,&DataOut); 00105 00106 #ifdef USE_USB 00107 PC.putc(DataOut); 00108 #endif 00109 00110 #ifdef USE_WIFI 00111 WIFI.putc(DataOut); 00112 #endif 00113 } 00114 } 00115 00116 00117 00118 00119 #ifdef USE_USB 00120 if(PC.readable()) 00121 { 00122 00123 ByteEnqueue(&TERMINAL_INPUT_QUEUE,PC.getc()); 00124 } 00125 #endif 00126 00127 #ifdef USE_WIFI 00128 00129 if(WIFI.readable()) 00130 { 00131 DataOut = WIFI.getc(); 00132 ByteEnqueue(&TERMINAL_INPUT_QUEUE,DataOut); 00133 00134 } 00135 #endif 00136 00137 TFC_ProcessTerminal(); 00138 00139 } 00140 00141 } 00142 00143
Generated on Tue Jul 19 2022 00:46:05 by
1.7.2
Eli Hughes