a

Dependencies:   LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI

Committer:
matis755
Date:
Wed May 20 15:42:07 2020 +0000
Revision:
2:8788d711db7e
Parent:
1:42a82d41947f
Child:
3:6fc7976cc5bf
Initial version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
matis755 0:e65dff476cf0 1 #include "mbed.h"
matis755 2:8788d711db7e 2 #include "string.h"
matis755 0:e65dff476cf0 3
matis755 2:8788d711db7e 4 #define BUFFER_SIZE 100
matis755 2:8788d711db7e 5
matis755 2:8788d711db7e 6 Serial MySerial(USBTX, USBRX);
matis755 0:e65dff476cf0 7 DigitalOut led_green(LED1);
matis755 0:e65dff476cf0 8 DigitalOut led_red(LED2);
matis755 0:e65dff476cf0 9
matis755 2:8788d711db7e 10 char gets(char *pStr, unsigned char ucSize){
matis755 2:8788d711db7e 11 unsigned char ucStrPtr = 0;
matis755 2:8788d711db7e 12 while(ucStrPtr < ucSize) {
matis755 2:8788d711db7e 13 pStr[ucStrPtr] = MySerial.getc();
matis755 2:8788d711db7e 14 if(pStr[ucStrPtr] == '\r') {
matis755 2:8788d711db7e 15 pStr[ucStrPtr] = NULL;
matis755 2:8788d711db7e 16 return 0;
matis755 2:8788d711db7e 17 }
matis755 2:8788d711db7e 18 ucStrPtr ++;
matis755 2:8788d711db7e 19 }
matis755 2:8788d711db7e 20 return 1;
matis755 2:8788d711db7e 21 }
matis755 1:42a82d41947f 22
matis755 2:8788d711db7e 23 char puts(char *pStr, unsigned char ucSize){
matis755 2:8788d711db7e 24 unsigned char ucNullPtr;
matis755 2:8788d711db7e 25 for(ucNullPtr = 0; ucNullPtr <= ucSize; ucNullPtr++){
matis755 2:8788d711db7e 26 if(pStr[ucNullPtr] == NULL) {
matis755 2:8788d711db7e 27 break;
matis755 2:8788d711db7e 28 }
matis755 2:8788d711db7e 29 else {}
matis755 2:8788d711db7e 30 }
matis755 2:8788d711db7e 31 if (ucNullPtr == ucSize) {
matis755 2:8788d711db7e 32 return 1;
matis755 2:8788d711db7e 33 }
matis755 0:e65dff476cf0 34
matis755 2:8788d711db7e 35 for(unsigned char ucIdx = 0; ucIdx < ucNullPtr; ucIdx ++) {
matis755 2:8788d711db7e 36 MySerial.putc(pStr[ucIdx]);
matis755 2:8788d711db7e 37 }
matis755 2:8788d711db7e 38 MySerial.putc('\r');
matis755 2:8788d711db7e 39 return 0;
matis755 2:8788d711db7e 40 }
matis755 2:8788d711db7e 41
matis755 2:8788d711db7e 42
matis755 2:8788d711db7e 43 int main() {
matis755 2:8788d711db7e 44 char cTablica[BUFFER_SIZE];
matis755 2:8788d711db7e 45 extern struct Token asToken[];
matis755 2:8788d711db7e 46 extern unsigned char ucTokenCnt;
matis755 2:8788d711db7e 47
matis755 2:8788d711db7e 48 while(1){
matis755 2:8788d711db7e 49 if(!gets(cTablica, BUFFER_SIZE)){
matis755 2:8788d711db7e 50 DecodeMsg(cTablica);
matis755 2:8788d711db7e 51 if ((asToken[0].eType == KEYWORD) & (ucTokenCnt != 0)){
matis755 2:8788d711db7e 52 switch (asToken[0].uValue.eKeyword){
matis755 2:8788d711db7e 53 case (CLB):
matis755 2:8788d711db7e 54 led_green = !led_green;
matis755 2:8788d711db7e 55 break;
matis755 2:8788d711db7e 56 case (GT):
matis755 2:8788d711db7e 57 led_red = !led_red;
matis755 2:8788d711db7e 58 break;
matis755 2:8788d711db7e 59 default:
matis755 2:8788d711db7e 60 break;
matis755 2:8788d711db7e 61 }
matis755 2:8788d711db7e 62 }
matis755 0:e65dff476cf0 63 }
matis755 0:e65dff476cf0 64 }
matis755 0:e65dff476cf0 65 }