# HardwareRadio.h

Go to the documentation of this file.

    00001
    00006 #ifndef HardwareRadio_h
    00007 #define HardwareRadio_h
    00008
    00013 #include <string.h>
    00014 #include "radio.h"
    00015 #include "board.h"
    00016
    00017 typedef struct radio_buffer
    00018 {
    00019     struct radio_buffer *next;
    00020     uint8_t len;
    00021     uint8_t frm[127];
    00022     uint8_t idx;
    00023 }
    00024 radio_buffer_t;
    00025
    00026 #define DATA_INT (0x81)
    00027 #define DATA_DOUBLE (0x82)
    00028 #define DATA_BLOCK (0x83)
    00029
    00030 # ifdef __cplusplus || defined(DOXYGEN)
    00031
    00035     class HardwareRadio
    00036     {
    00037         private:
    00038             uint8_t txseq;
    00039             void txbuffer_init(radio_buffer_t *pbuf);
    00040
    00041         public:
    00042             /* user reads from this buffer */
    00043             radio_buffer_t *prdbuf;
    00044             /* user writes to this buffer */
    00045             radio_buffer_t *pwrbuf;
    00046             /* buffer which is currently transmited */
    00047             radio_buffer_t *txbuf;
    00048             /* buffer which is currently used for reception */
    00049             radio_buffer_t *rxbuf;
    00050
    00051             volatile uint8_t tx_in_progress;
    00052
    00053
    00054             node_config_t nc;
    00055
    00056             /* constructors */
    00057             HardwareRadio(void);
    00058
    00059
    00060             /* methods */
    00061
    00063             void begin(void);
    00064
    00066             void begin(uint8_t channel, uint8_t idlestate);
    00067
    00069             void write(uint8_t byte);
    00071             void write(char * str);
    00072
    00074             void put(int16_t value);
    00075
    00077             void flush(void);
    00078
    00080             int available(void);
    00081
    00083             int read(void);
    00084
    00086             void get_int(int16_t& value);
    00087
    00089             radio_buffer_t * alloc_buffer(void);
    00091             void free_buffer(radio_buffer_t * pbuf);
    00092
    00093    };
    00094 #  ifndef HARDWARERADIO_CPP
    00095     extern HardwareRadio Radio;
    00096 #  endif
    00097 # endif
    00098
    00099 #endif /*#ifndef HardwareRadio_h*/