Vincent Belanger
/
Reset-Xbee
Program to Reset the Xbee module.
Revision 0:baa33f698412, committed 2016-02-08
- Comitter:
- vinbel93
- Date:
- Mon Feb 08 19:50:26 2016 +0000
- Commit message:
- Initial commit
Changed in this revision
diff -r 000000000000 -r baa33f698412 Xbee.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Xbee.cpp Mon Feb 08 19:50:26 2016 +0000 @@ -0,0 +1,24 @@ +#include "mbed.h" +#include "Xbee.h" + +void resetXbee(Serial* xbee) +{ + const int frameLength = 16; + char frame[frameLength]; + frame[0] = 0x7E; // Start delimiter + frame[1] = 0x00; // Length (MSB) + frame[2] = 0x04; // Length (LSB) + frame[3] = 0x08; // AT Command + frame[4] = 0x00; // Frame ID + frame[5] = 'R'; + frame[6] = 'E'; + frame[7] = 0x60; + + if (xbee->writeable()) + { + for (int i = 0; i < frameLength; i++) + { + xbee->putc(frame[i]); + } + } +}
diff -r 000000000000 -r baa33f698412 Xbee.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Xbee.h Mon Feb 08 19:50:26 2016 +0000 @@ -0,0 +1,3 @@ +#pragma once + +void resetXbee(Serial* xbee);
diff -r 000000000000 -r baa33f698412 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Feb 08 19:50:26 2016 +0000 @@ -0,0 +1,27 @@ +#include "mbed.h" +#include "Xbee.h" + +DigitalOut reset(p8); +Serial xbee(p13, p14); +Serial pc(USBTX, USBRX); + +int main() +{ + reset = 0; + wait(0.4); + reset = 1; + wait(1); + + while (xbee.readable()) + { + char dump = xbee.getc(); + } + + resetXbee(&xbee); + wait(1); + pc.printf("Reset done\r\n"); + while (true) + { + + } +}
diff -r 000000000000 -r baa33f698412 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Feb 08 19:50:26 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6f327212ef96 \ No newline at end of file