Subversion Repositories HomeAutomation

Rev

Rev 1895 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. #ifndef _DHT11wire_h_
  2. #define _DHT11wire_h_
  3.  
  4. #include <inttypes.h>
  5. #include <drivers/mcu/gpio.h>
  6. #include <drivers/can/canprintf.h>
  7. #include "config.h"
  8. /*******************************************/
  9. /* Hardware connection                     */
  10. /*******************************************/
  11.  
  12. /* Define DHT11_ONE_BUS if only one 1-Wire-Bus is used
  13.    in the application -> shorter code.
  14.    If not defined make sure to call dht11_set_bus() before using
  15.    a bus. Runtime bus-select increases code size by around 300
  16.    bytes so use DHT11_ONE_BUS if possible */
  17. #define DHT11_ONE_BUS
  18.  
  19. #ifdef DHT11_ONE_BUS
  20.  
  21. #ifndef DHT11_PIN
  22.   #warning DHT11_PIN shall be defined in config.inc, useing DHT11_PIN=EXP_F...
  23.   #define DHT11_PIN  EXP_F
  24. #endif
  25.  
  26. #define DHT11_CONF_DELAYOFFSET 0
  27.  
  28. #else
  29. #error The lib does not support not defining DHT11_ONE_BUS
  30. #if F_CPU<1843200
  31.  #warning | experimental multi-bus-mode is not tested for
  32.  #warning | frequencies below 1,84MHz - use DHT11_ONE_WIRE or
  33.  #warning | faster clock-source (i.e. internal 2MHz R/C-Osc.)
  34. #endif
  35. #define DHT11_CONF_CYCLESPERACCESS 13
  36. #define DHT11_CONF_DELAYOFFSET ( (uint16_t)( ((DHT11_CONF_CYCLESPERACCESS)*1000000L) / F_CPU  ) )
  37. #endif
  38.  
  39. /*******************************************/
  40.  
  41. extern uint8_t dht11_start(void);
  42. extern uint8_t dht11_readData(uint8_t* data);
  43.  
  44.  
  45. #ifndef DHT11_ONE_BUS
  46. extern void dht11_set_bus(volatile uint8_t* in,
  47.     volatile uint8_t* out,
  48.     volatile uint8_t* ddr,
  49.     uint8_t pin);
  50. #endif
  51.  
  52. #endif
  53.  
  54.