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

Committer:
ottaviano3
Date:
2016-04-07
Revision:
7:3cb67634fa4e
Parent:
6:3873db4a0164
Child:
9:d4542525b218

File content as of revision 7:3cb67634fa4e:

#ifndef XBEE900HP_H
#define XBEE900HP_H

#include "mbed.h"

/**
 * Wrapper for the xBee 900 HP Module
 */
class xbee900hp
{
public:

    /**
    * Initialize the xBee Module
    */
    xbee900hp(PinName pin_mosi,PinName pin_miso,PinName pin_sck,PinName pin_attn, PinName pin_rst, unsigned int freq);

    /**
    * Destructor
    */
    ~xbee900hp();

    /**
    * Subroutine to reset the xBee Module
    */
    void reset();

    /**
    * Send packet over spi to xBee for TX
    */
    int sendPacket(char* data, unsigned int length, bool enMesh);

    /**
    * Get signal strength of last recieved packet
    */
    unsigned int getRSSI();

    /**
    * Set the transmission power level
    */
    int setPower(int value);

    /**
    * Get serial number of xbee module
    */
    unsigned long long getSerial();

    /**
    * Wait for and read incoming data packet
    * Returns the source address if successful, or 0 if it failed.
    */
    unsigned long long readPacket(char* data);

    /**
    * Clear output buffer
    */
    void clearBuff();

    /**
    * Check ATTN signal
    */
    int attn();

    /**
    * Read raw data in from module
    */
    char debug();

private:
    // Setup pin input types.

    // Reset
    DigitalOut _pin_rst;
    // Asert Pin Use Interrupts for Super Speed
    DigitalIn _pin_attn;

    void readDataISR();

    // SPI
    SPI _xbeespi;

};

#endif