Setup
Revision 0:17b249a76ce6, committed 2019-02-28
- Comitter:
- jmateo09
- Date:
- Thu Feb 28 15:54:52 2019 +0000
- Commit message:
- Setup;
Changed in this revision
| Setup.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Setup.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Setup.cpp Thu Feb 28 15:54:52 2019 +0000
@@ -0,0 +1,83 @@
+#include "Setup.h"
+#include "mbed.h"
+#include "XBee.h"
+#include "MODSERIAL.h"
+#include "sstream"
+
+Communication::Communication() : pc(USBTX, USBRX, 256,256), XBee(p13, p14,256,256)
+{
+
+}
+
+void Communication::DoComConfig(char *swversion)
+{
+
+ DigitalOut rst1(p11); //Digital reset for the XBee, 200ns for reset
+ DigitalOut Sleep(p12); //0 is awake. 1 is Sleep.
+
+
+ Sleep = 0; // sleep mode off
+ wait_ms(2);
+ rst1 = 0; //Set reset pin to 0
+ wait_ms(1);//Wait at least one millisecond
+ rst1 = 1;//Set reset pin to 1
+ wait_ms(1);//Wait another millisecond
+
+ XBee.baud(9600);
+ wait_ms(1100); // no commands within 1sec guard-time
+ XBee.printf("+++"); // special command to enter command-mode
+ wait_ms(1100); // no commands within 1sec guard-time
+
+ // Change settings:
+ //XBee.printf("ATCH\r"); // Read channel
+ XBee.printf("ATCHC\r"); // Set channel 12 (=0xC =default)
+ wait_ms(100);
+ XBee.printf("ATID1337\r"); // PAN-ID (once chosen to be 1337)
+ wait_ms(100);
+ //XBee.printf("ATDH13A200\r"); // DH
+ XBee.printf("ATDH0\r"); // DH
+ wait_ms(100);
+ //XBee.printf("ATDL40BFEF31\r"); // DL
+ XBee.printf("ATDLFFFF\r"); // DL
+ wait_ms(100);
+ XBee.printf("ATBD7\r"); // Baudrate nr.7 = 115200
+ wait_ms(100);
+
+ // Save and exit:
+ XBee.printf("ATWR\r"); // Write settings
+ wait_ms(3000);
+ XBee.printf("ATCN\r"); // Exit AT mode
+ wait_ms(100);
+ XBee.baud(115200); // set mbed-comport
+ pc.baud (115200);
+
+ pc.printf("Maggie starting\r\n");
+ pc.printf(swversion);
+
+ XBee.printf("Maggie starting \r");
+ XBee.printf(swversion);
+
+ wait_ms(1);
+
+}
+
+IO::IO() : myled1(LED1),myled2(LED2),myled3(LED3),myled4(LED4),LCDRed(p22),LCDGreen(p23),LCDBlue(p24),FB1(p29),FB2(p30),FB3(p26),Speed(p21),CW(p16),CCW(p17),SW1(p18),SW2(p19)
+{
+
+}
+void IO::DoIOConfig()
+{
+ //Defining Mbed Pin Functions.
+ //Buttons:
+ FB1.mode(PullUp); // Black pushbutton, Wire color: Orange & black. (Up)
+ FB2.mode(PullUp); // Black pushbutton, Wire color: Orange & black. (Down)
+ FB3.mode(PullUp); // Green pushbutton, Wire color: Orange & black. (Select/start)
+
+ //Selector Switch:
+ SW1.mode(PullUp);
+ SW2.mode(PullUp);
+
+
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Setup.h Thu Feb 28 15:54:52 2019 +0000
@@ -0,0 +1,55 @@
+#include "mbed.h"
+#include "XBee.h"
+#include "MODSERIAL.h"
+#include "sstream"
+
+class Communication
+{
+public:
+ Communication();
+ MODSERIAL pc;
+ MODSERIAL XBee;
+ void DoComConfig(char *swversion);
+
+private:
+
+};
+
+class IO
+{
+public:
+ IO();
+ // Mapping IO-pins
+ // Onboard Leds on the Mbed.
+ DigitalOut myled1;
+ DigitalOut myled2;
+ DigitalOut myled3;
+ DigitalOut myled4;
+
+ // RGB LED background.
+ PwmOut LCDRed;
+ PwmOut LCDGreen;
+ PwmOut LCDBlue;
+
+
+
+ //PushButtons & Selector switch, they all need the 'Pull-up' function.
+ //FB means 'Function Button'.
+ DigitalIn FB1; // Black pushbutton, Wire color: Orange & black.
+ DigitalIn FB2; // Black pushbutton, Wire color: Orange & black.
+ DigitalIn FB3; // Green pushbutton, Wire color: Orange & black.
+
+ //Motor Pins
+ PwmOut Speed;
+ DigitalOut CW;
+ DigitalOut CCW;
+
+ //SW means 'Selector Switch'.
+ //(Pins to be determent(P18,P19).)
+ DigitalIn SW1;
+ DigitalIn SW2;
+
+ void DoIOConfig();
+private:
+
+};
\ No newline at end of file