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@3:3c3707b0f5cd, 2015-04-29 (annotated)
- Committer:
- ottaviano3
- Date:
- Wed Apr 29 23:25:43 2015 +0000
- Revision:
- 3:3c3707b0f5cd
- Parent:
- 2:7f4ddf710a44
- Child:
- 6:3873db4a0164
added getserial
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 | 2:7f4ddf710a44 | 49 | * Check ATTN signal |
ottaviano3 | 2:7f4ddf710a44 | 50 | */ |
ottaviano3 | 2:7f4ddf710a44 | 51 | int attn(); |
ottaviano3 | 2:7f4ddf710a44 | 52 | |
ottaviano3 | 0:8c8a8244e590 | 53 | private: |
ottaviano3 | 0:8c8a8244e590 | 54 | // Setup pin input types. |
ottaviano3 | 0:8c8a8244e590 | 55 | |
ottaviano3 | 0:8c8a8244e590 | 56 | // Reset |
ottaviano3 | 0:8c8a8244e590 | 57 | DigitalOut _pin_rst; |
ottaviano3 | 1:b97d46c5d7ce | 58 | // Asert Pin Use Interrupts for Super Speed |
ottaviano3 | 2:7f4ddf710a44 | 59 | DigitalIn _pin_attn; |
ottaviano3 | 1:b97d46c5d7ce | 60 | |
ottaviano3 | 1:b97d46c5d7ce | 61 | void readDataISR(); |
ottaviano3 | 0:8c8a8244e590 | 62 | |
ottaviano3 | 0:8c8a8244e590 | 63 | // SPI |
ottaviano3 | 0:8c8a8244e590 | 64 | SPI _xbeespi; |
ottaviano3 | 0:8c8a8244e590 | 65 | |
ottaviano3 | 0:8c8a8244e590 | 66 | }; |
ottaviano3 | 0:8c8a8244e590 | 67 | |
ottaviano3 | 0:8c8a8244e590 | 68 | #endif |