This is an experimental driver for the XBee 900 HP pro module's SPI connection. This driver is unfinished and stability is not guaranteed. Use with caution.
Dependents: Sentinel_BASE Sentinel_NODE
xbee900hp.h@7:3cb67634fa4e, 2016-04-07 (annotated)
- Committer:
- ottaviano3
- Date:
- Thu Apr 07 18:09:59 2016 +0000
- Revision:
- 7:3cb67634fa4e
- Parent:
- 6:3873db4a0164
- Child:
- 9:d4542525b218
Mostly bug fixes.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ottaviano3 | 0:8c8a8244e590 | 1 | #ifndef XBEE900HP_H |
ottaviano3 | 0:8c8a8244e590 | 2 | #define XBEE900HP_H |
ottaviano3 | 0:8c8a8244e590 | 3 | |
ottaviano3 | 0:8c8a8244e590 | 4 | #include "mbed.h" |
ottaviano3 | 0:8c8a8244e590 | 5 | |
ottaviano3 | 0:8c8a8244e590 | 6 | /** |
ottaviano3 | 0:8c8a8244e590 | 7 | * Wrapper for the xBee 900 HP Module |
ottaviano3 | 0:8c8a8244e590 | 8 | */ |
ottaviano3 | 0:8c8a8244e590 | 9 | class xbee900hp |
ottaviano3 | 0:8c8a8244e590 | 10 | { |
ottaviano3 | 0:8c8a8244e590 | 11 | public: |
ottaviano3 | 0:8c8a8244e590 | 12 | |
ottaviano3 | 7:3cb67634fa4e | 13 | /** |
ottaviano3 | 0:8c8a8244e590 | 14 | * Initialize the xBee Module |
ottaviano3 | 7:3cb67634fa4e | 15 | */ |
ottaviano3 | 7:3cb67634fa4e | 16 | xbee900hp(PinName pin_mosi,PinName pin_miso,PinName pin_sck,PinName pin_attn, PinName pin_rst, unsigned int freq); |
ottaviano3 | 7:3cb67634fa4e | 17 | |
ottaviano3 | 0:8c8a8244e590 | 18 | /** |
ottaviano3 | 0:8c8a8244e590 | 19 | * Destructor |
ottaviano3 | 0:8c8a8244e590 | 20 | */ |
ottaviano3 | 0:8c8a8244e590 | 21 | ~xbee900hp(); |
ottaviano3 | 7:3cb67634fa4e | 22 | |
ottaviano3 | 7:3cb67634fa4e | 23 | /** |
ottaviano3 | 0:8c8a8244e590 | 24 | * Subroutine to reset the xBee Module |
ottaviano3 | 7:3cb67634fa4e | 25 | */ |
ottaviano3 | 0:8c8a8244e590 | 26 | void reset(); |
ottaviano3 | 0:8c8a8244e590 | 27 | |
ottaviano3 | 7:3cb67634fa4e | 28 | /** |
ottaviano3 | 0:8c8a8244e590 | 29 | * Send packet over spi to xBee for TX |
ottaviano3 | 7:3cb67634fa4e | 30 | */ |
ottaviano3 | 7:3cb67634fa4e | 31 | int sendPacket(char* data, unsigned int length, bool enMesh); |
ottaviano3 | 7:3cb67634fa4e | 32 | |
ottaviano3 | 1:b97d46c5d7ce | 33 | /** |
ottaviano3 | 7:3cb67634fa4e | 34 | * Get signal strength of last recieved packet |
ottaviano3 | 1:b97d46c5d7ce | 35 | */ |
ottaviano3 | 7:3cb67634fa4e | 36 | unsigned int getRSSI(); |
ottaviano3 | 7:3cb67634fa4e | 37 | |
ottaviano3 | 7:3cb67634fa4e | 38 | /** |
ottaviano3 | 7:3cb67634fa4e | 39 | * Set the transmission power level |
ottaviano3 | 7:3cb67634fa4e | 40 | */ |
ottaviano3 | 7:3cb67634fa4e | 41 | int setPower(int value); |
ottaviano3 | 7:3cb67634fa4e | 42 | |
ottaviano3 | 2:7f4ddf710a44 | 43 | /** |
ottaviano3 | 3:3c3707b0f5cd | 44 | * Get serial number of xbee module |
ottaviano3 | 3:3c3707b0f5cd | 45 | */ |
ottaviano3 | 7:3cb67634fa4e | 46 | unsigned long long getSerial(); |
ottaviano3 | 7:3cb67634fa4e | 47 | |
ottaviano3 | 3:3c3707b0f5cd | 48 | /** |
ottaviano3 | 2:7f4ddf710a44 | 49 | * Wait for and read incoming data packet |
ottaviano3 | 7:3cb67634fa4e | 50 | * Returns the source address if successful, or 0 if it failed. |
ottaviano3 | 2:7f4ddf710a44 | 51 | */ |
ottaviano3 | 7:3cb67634fa4e | 52 | unsigned long long readPacket(char* data); |
ottaviano3 | 7:3cb67634fa4e | 53 | |
ottaviano3 | 2:7f4ddf710a44 | 54 | /** |
ottaviano3 | 6:3873db4a0164 | 55 | * Clear output buffer |
ottaviano3 | 6:3873db4a0164 | 56 | */ |
ottaviano3 | 6:3873db4a0164 | 57 | void clearBuff(); |
ottaviano3 | 7:3cb67634fa4e | 58 | |
ottaviano3 | 6:3873db4a0164 | 59 | /** |
ottaviano3 | 2:7f4ddf710a44 | 60 | * Check ATTN signal |
ottaviano3 | 2:7f4ddf710a44 | 61 | */ |
ottaviano3 | 2:7f4ddf710a44 | 62 | int attn(); |
ottaviano3 | 7:3cb67634fa4e | 63 | |
ottaviano3 | 7:3cb67634fa4e | 64 | /** |
ottaviano3 | 7:3cb67634fa4e | 65 | * Read raw data in from module |
ottaviano3 | 7:3cb67634fa4e | 66 | */ |
ottaviano3 | 7:3cb67634fa4e | 67 | char debug(); |
ottaviano3 | 7:3cb67634fa4e | 68 | |
ottaviano3 | 7:3cb67634fa4e | 69 | private: |
ottaviano3 | 0:8c8a8244e590 | 70 | // Setup pin input types. |
ottaviano3 | 7:3cb67634fa4e | 71 | |
ottaviano3 | 0:8c8a8244e590 | 72 | // Reset |
ottaviano3 | 0:8c8a8244e590 | 73 | DigitalOut _pin_rst; |
ottaviano3 | 1:b97d46c5d7ce | 74 | // Asert Pin Use Interrupts for Super Speed |
ottaviano3 | 2:7f4ddf710a44 | 75 | DigitalIn _pin_attn; |
ottaviano3 | 7:3cb67634fa4e | 76 | |
ottaviano3 | 1:b97d46c5d7ce | 77 | void readDataISR(); |
ottaviano3 | 7:3cb67634fa4e | 78 | |
ottaviano3 | 0:8c8a8244e590 | 79 | // SPI |
ottaviano3 | 0:8c8a8244e590 | 80 | SPI _xbeespi; |
ottaviano3 | 0:8c8a8244e590 | 81 | |
ottaviano3 | 0:8c8a8244e590 | 82 | }; |
ottaviano3 | 0:8c8a8244e590 | 83 | |
ottaviano3 | 7:3cb67634fa4e | 84 | #endif |