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@6:3873db4a0164, 2015-04-30 (annotated)
- Committer:
- ottaviano3
- Date:
- Thu Apr 30 17:01:46 2015 +0000
- Revision:
- 6:3873db4a0164
- Parent:
- 3:3c3707b0f5cd
- Child:
- 7:3cb67634fa4e
added function to clear buffer;
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 | 0:8c8a8244e590 | 13 | /** |
ottaviano3 | 0:8c8a8244e590 | 14 | * Initialize the xBee Module |
ottaviano3 | 0:8c8a8244e590 | 15 | */ |
ottaviano3 | 1:b97d46c5d7ce | 16 | xbee900hp(PinName pin_mosi,PinName pin_miso,PinName pin_sck,PinName pin_attn, PinName pin_rst); |
ottaviano3 | 0:8c8a8244e590 | 17 | |
ottaviano3 | 0:8c8a8244e590 | 18 | /** |
ottaviano3 | 0:8c8a8244e590 | 19 | * Destructor |
ottaviano3 | 0:8c8a8244e590 | 20 | */ |
ottaviano3 | 0:8c8a8244e590 | 21 | ~xbee900hp(); |
ottaviano3 | 0:8c8a8244e590 | 22 | |
ottaviano3 | 0:8c8a8244e590 | 23 | /** |
ottaviano3 | 0:8c8a8244e590 | 24 | * Subroutine to reset the xBee Module |
ottaviano3 | 0:8c8a8244e590 | 25 | */ |
ottaviano3 | 0:8c8a8244e590 | 26 | void reset(); |
ottaviano3 | 0:8c8a8244e590 | 27 | |
ottaviano3 | 0:8c8a8244e590 | 28 | /** |
ottaviano3 | 0:8c8a8244e590 | 29 | * Send packet over spi to xBee for TX |
ottaviano3 | 0:8c8a8244e590 | 30 | */ |
ottaviano3 | 0:8c8a8244e590 | 31 | void sendPacket(char* data, unsigned int length); |
ottaviano3 | 0:8c8a8244e590 | 32 | |
ottaviano3 | 1:b97d46c5d7ce | 33 | /** |
ottaviano3 | 1:b97d46c5d7ce | 34 | * Write a setting value to the module |
ottaviano3 | 1:b97d46c5d7ce | 35 | */ |
ottaviano3 | 1:b97d46c5d7ce | 36 | void writeSetting(char command[2], unsigned int value); |
ottaviano3 | 1:b97d46c5d7ce | 37 | |
ottaviano3 | 2:7f4ddf710a44 | 38 | /** |
ottaviano3 | 3:3c3707b0f5cd | 39 | * Get serial number of xbee module |
ottaviano3 | 3:3c3707b0f5cd | 40 | */ |
ottaviano3 | 3:3c3707b0f5cd | 41 | int getSerial(char* serialnumber); |
ottaviano3 | 3:3c3707b0f5cd | 42 | |
ottaviano3 | 3:3c3707b0f5cd | 43 | /** |
ottaviano3 | 2:7f4ddf710a44 | 44 | * Wait for and read incoming data packet |
ottaviano3 | 2:7f4ddf710a44 | 45 | */ |
ottaviano3 | 2:7f4ddf710a44 | 46 | int readPacket(char* data); |
ottaviano3 | 2:7f4ddf710a44 | 47 | |
ottaviano3 | 2:7f4ddf710a44 | 48 | /** |
ottaviano3 | 6:3873db4a0164 | 49 | * Clear output buffer |
ottaviano3 | 6:3873db4a0164 | 50 | */ |
ottaviano3 | 6:3873db4a0164 | 51 | void clearBuff(); |
ottaviano3 | 6:3873db4a0164 | 52 | |
ottaviano3 | 6:3873db4a0164 | 53 | /** |
ottaviano3 | 2:7f4ddf710a44 | 54 | * Check ATTN signal |
ottaviano3 | 2:7f4ddf710a44 | 55 | */ |
ottaviano3 | 2:7f4ddf710a44 | 56 | int attn(); |
ottaviano3 | 2:7f4ddf710a44 | 57 | |
ottaviano3 | 0:8c8a8244e590 | 58 | private: |
ottaviano3 | 0:8c8a8244e590 | 59 | // Setup pin input types. |
ottaviano3 | 0:8c8a8244e590 | 60 | |
ottaviano3 | 0:8c8a8244e590 | 61 | // Reset |
ottaviano3 | 0:8c8a8244e590 | 62 | DigitalOut _pin_rst; |
ottaviano3 | 1:b97d46c5d7ce | 63 | // Asert Pin Use Interrupts for Super Speed |
ottaviano3 | 2:7f4ddf710a44 | 64 | DigitalIn _pin_attn; |
ottaviano3 | 1:b97d46c5d7ce | 65 | |
ottaviano3 | 1:b97d46c5d7ce | 66 | void readDataISR(); |
ottaviano3 | 0:8c8a8244e590 | 67 | |
ottaviano3 | 0:8c8a8244e590 | 68 | // SPI |
ottaviano3 | 0:8c8a8244e590 | 69 | SPI _xbeespi; |
ottaviano3 | 0:8c8a8244e590 | 70 | |
ottaviano3 | 0:8c8a8244e590 | 71 | }; |
ottaviano3 | 0:8c8a8244e590 | 72 | |
ottaviano3 | 0:8c8a8244e590 | 73 | #endif |