Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 24:f8fea5e5bf73
- Parent:
- 23:0b6901c9302c
- Child:
- 25:57de395d89aa
diff -r 0b6901c9302c -r f8fea5e5bf73 main.cpp
--- a/main.cpp Mon Jul 22 17:53:24 2013 +0000
+++ b/main.cpp Tue Jul 23 04:33:02 2013 +0000
@@ -21,7 +21,7 @@
#include "menu.h"
#include "parameters.h"
#include "handlers.h"
-//#define DEBUG
+#define DEBUG
Serial pc(USBTX, USBRX); // serial io
SPI spi(PTD2, PTD3, PTD1); // mosi, miso, sclk
@@ -75,6 +75,86 @@
mode_idle_handler(&state, recv); //Change state based on recv input
break;
+ case MODE_SPI_RAW: //Input the SPI raw bits
+ pc.printf("%s", cmd5);
+ line_buf[3] = 255;
+ line_buf[2] = 255;
+ line_buf[1] = 255;
+ line_buf[0] = 255;
+ line_pt = 0;
+ line_length = 0;
+ while(1)
+ {
+ recv = pc.getc();
+ if(recv == 13) //enter is pressed
+ {
+ #ifdef DEBUG
+ pc.printf("decimal output : %d %d %d %d", line_buf[3], line_buf[2], line_buf[1], line_buf[0]);
+ pc.printf("char output: %c %c %c %c", line_buf[3], line_buf[2], line_buf[1], line_buf[0]);
+ pc.printf("length = %d\n", line_length);
+ #endif
+ break;
+ }
+ else if(recv == 8 || recv == 127)
+ {
+ if(line_length > 0) //Delete one char on screen
+ {
+ pc.putc(8);
+ pc.putc(32);
+ pc.putc(8);
+ }
+ if(line_length <= 4 && line_length>=1)
+ {
+ line_pt --;
+ line_buf[line_pt] = 255;
+ }
+ if(line_length > 0)
+ line_length --;
+ }
+ else if( (recv >= '0' && recv <= '9')||(recv >= 'a' && recv <= 'f')||(recv >= 'A' && recv <= 'F') )
+ {
+ pc.putc(recv);
+ line_length ++;
+
+ if(line_length <= 4)
+ {
+ line_buf[line_pt] = recv;
+ line_pt ++;
+ }
+
+ }
+
+ }
+ ret = parse_spi_raw(line_buf, line_length, &cha1_pha, &cha2_pha, &cha1_amp, &cha2_amp);
+
+ if(ret == PARSE_LONG) //Input string too long
+ {
+ pc.printf("%s", msg_strlong);
+ pc.getc();
+ }
+ else if(ret == PARSE_EMPTY)
+ {
+ pc.printf("%s", msg_empty);
+ pc.printf("%s", msg_ret);
+ pc.getc();
+ }
+ else if(ret == PARSE_SHORT) //Input string has error
+ {
+ pc.printf("%s", msg_strshort);
+ pc.getc();
+ }
+ else //Input is good
+ {
+ pc.printf("%s", msg_ok);
+ #ifdef DEBUG
+ pc.printf("%d %d %d %d \n", cha2_amp, cha2_pha, cha1_amp, cha1_pha);
+ #endif
+ pc.printf("%s", msg_ret);
+ pc.getc();
+ }
+ state = MODE_IDLE;
+ break;
+
case MODE_CHA1PHA:
case MODE_CHA1AMP:
@@ -240,9 +320,9 @@
case MODE_DISPLAY:
pc.printf("\n\n ******** Current Parameters ********\n\n");
pc.printf("Phase shift for RF out1 is %d degrees\n", cha1_pha*-7);
- pc.printf("Attenuation for RF out1 is %.1f dB\n", cha1_amp*5.0/10.0);
+ pc.printf("Attenuation for RF out1 is %.1f dB\n", cha1_amp*5.0/10.0);
pc.printf("Phase shift for RF out2 is %d degrees\n", cha2_pha*-7);
- pc.printf("Attenuation for RF out2 is %.1f dB\n", cha2_amp*5.0/10.0);
+ pc.printf("Attenuation for RF out2 is %.1f dB\n", cha2_amp*5.0/10.0);
pc.printf("%s", msg_ret);
pc.getc();
state = MODE_IDLE;
@@ -271,9 +351,9 @@
//Start printint...
pc.printf("******** Now sending parameters ********\n\n");
pc.printf("Phase shift for RF out1 is %d degrees\n", cha1_pha*-7);
- pc.printf("Attenuation for RF out1 is %.1f dB\n", cha1_amp*5.0/10.0);
+ pc.printf("Attenuation for RF out1 is %.1f dB\n", cha1_amp*5.0/10.0);
pc.printf("Phase shift for RF out2 is %d degrees\n", cha2_pha*-7);
- pc.printf("Attenuation for RF out2 is %.1f dB\n", cha2_amp*5.0/10.0);
+ pc.printf("Attenuation for RF out2 is %.1f dB\n", cha2_amp*5.0/10.0);
pc.printf("\nSPI bit stream sent:\n");
pc.printf("%s", bit_index);