Karl Zweimüller / Mbed 2 deprecated eth_comfort_test

Dependencies:   TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers eth_comfort.h Source File

eth_comfort.h

Go to the documentation of this file.
00001 #ifndef ETH_COMFORT_H
00002 #define ETH_COMFORT_H
00003 
00004 /*!
00005  * \file       eth_comfort.h
00006  * \brief      Read the messages from the ETH-Radio-Shutter
00007  * \author     Karl Zweimüller 
00008  */
00009 
00010 
00011 #include "mbed.h"
00012 
00013 #include "rfm12b.h"
00014 
00015 // a message from the eth-Device
00016 struct eth_message {
00017     uint8_t    cnt;                //message-counter
00018     uint8_t    len;                //message-length
00019     uint32_t   adr;                // unique address of device
00020     uint8_t    cmd;                // the command
00021     uint8_t    data;               // optional data
00022     uint8_t    xdata;              // optional extra data
00023     uint16_t   crc;                // crc fro the message
00024 };
00025 
00026 /**
00027   * Class for the ETH-Window shutter by ELV(R)
00028   * Uses the rfm12B to receive the signals sent by the radio-shutter
00029   *
00030  */
00031 class eth_comfort {
00032 
00033 public:
00034 
00035     /**
00036      * Constructor.
00037     *
00038     * @param mosi SPI-Interface. One of the 2 PSI-Interfaces of mbed. Pin p5 or p11
00039     * @param miso SPI-Interface. One of the 2 PSI-Interfaces of mbed. Pin p6 or p12
00040     * @param sclk SPI-Interface. One of the 2 PSI-Interfaces of mbed. Pin p7 or p13
00041     * @param nsel Chip-Select.   A Digial Output of mbed
00042     * @param rxdata  Data-Pin for received data. A DigitalIn of mbed
00043     * @param rxled   LED1 - LED4 for showing received bytes
00044     */
00045     eth_comfort(PinName mosi, PinName miso, PinName sclk, PinName nsel, PinName rxdata, PinName rxled);
00046 
00047 
00048 // initialize eth_comfort-receiver
00049     void init();
00050 
00051 // is a new message readable - non blocking
00052     bool readable();
00053 
00054 // read a eth-messsage - non blocking, shows the old message if no new is available
00055     eth_message getMessage();
00056 
00057 
00058 
00059 private:
00060 
00061 // Interrupt Routine
00062     void ISR();
00063 
00064 // the last received message
00065     eth_message last_message;
00066 
00067 // new meeesage
00068     eth_message new_message;
00069 
00070 // is a new message in the buffer?
00071     bool message_received;
00072 
00073 // calcualte the crc for eth
00074     uint16_t calcCRC16r( uint16_t c,uint16_t crc, uint16_t mask);
00075 
00076     volatile uint8_t bit_cnt;
00077     volatile uint16_t buffer_cnt;
00078 
00079     volatile uint8_t rbyte;
00080 
00081     volatile uint8_t buf[1024];
00082     volatile uint8_t pack_ok,startbit;
00083     volatile uint8_t decode,bcnt,lastbit;
00084     volatile uint8_t state;
00085     volatile uint16_t b;
00086     volatile uint8_t blocklength;
00087     int i,j,k;
00088     bool  crc_ok;
00089     uint16_t crc, swapped;
00090 
00091     rfm12b *rfm12b_spi;
00092 
00093     DigitalOut *rxLED;
00094 
00095 };
00096 
00097 #endif
00098