Subversion Repositories HomeAutomation

Rev

Rev 1148 | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. #ifndef _1wire_h_
  2. #define _1wire_h_
  3.  
  4. #include <inttypes.h>
  5. #include <drivers/mcu/gpio.h>
  6. #include "config.h"
  7. /*******************************************/
  8. /* Hardware connection                     */
  9. /*******************************************/
  10.  
  11. /* Define OW_ONE_BUS if only one 1-Wire-Bus is used
  12.    in the application -> shorter code.
  13.    If not defined make sure to call ow_set_bus() before using
  14.    a bus. Runtime bus-select increases code size by around 300
  15.    bytes so use OW_ONE_BUS if possible */
  16. #define OW_ONE_BUS
  17.  
  18. #ifdef OW_ONE_BUS
  19.  
  20. #ifndef OW_PIN
  21.   #warning OW_PIN shall be defined in config.inc, using OW_PIN=EXP_F...
  22.   #define OW_PIN  EXP_F
  23. #endif
  24.  
  25. #define OW_CONF_DELAYOFFSET 0
  26.  
  27. #else
  28. #error The lib does not support not defining OW_ONE_BUS
  29. #if F_CPU<1843200
  30.  #warning | experimental multi-bus-mode is not tested for
  31.  #warning | frequencies below 1,84MHz - use OW_ONE_WIRE or
  32.  #warning | faster clock-source (i.e. internal 2MHz R/C-Osc.)
  33. #endif
  34. #define OW_CONF_CYCLESPERACCESS 13
  35. #define OW_CONF_DELAYOFFSET ( (uint16_t)( ((OW_CONF_CYCLESPERACCESS)*1000000L) / F_CPU  ) )
  36. #endif
  37.  
  38. /*******************************************/
  39.  
  40. // #define OW_SHORT_CIRCUIT  0x01
  41.  
  42. #define OW_MATCH_ROM    0x55
  43. #define OW_SKIP_ROM     0xCC
  44. #define OW_SEARCH_ROM   0xF0
  45.  
  46. #define OW_SEARCH_FIRST 0xFF        // start new search
  47. #define OW_PRESENCE_ERR 0xFF
  48. #define OW_DATA_ERR     0xFE
  49. #define OW_LAST_DEVICE  0x00        // last device found
  50. //          0x01 ... 0x40: continue searching
  51.  
  52. // rom-code size including CRC
  53. #define OW_ROMCODE_SIZE 8
  54.  
  55. extern uint8_t ow_reset(void);
  56.  
  57. extern uint8_t ow_bit_io( uint8_t b );
  58. extern uint8_t ow_byte_wr( uint8_t b );
  59. extern uint8_t ow_byte_rd( void );
  60.  
  61. extern uint8_t ow_rom_search( uint8_t diff, uint8_t *id );
  62.  
  63. extern void ow_command( uint8_t command, uint8_t *id );
  64.  
  65. extern void ow_parasite_enable(void);
  66. extern void ow_parasite_disable(void);
  67. extern uint8_t ow_input_pin_state(void);
  68.  
  69. #ifndef OW_ONE_BUS
  70. extern void ow_set_bus(volatile uint8_t* in,
  71.     volatile uint8_t* out,
  72.     volatile uint8_t* ddr,
  73.     uint8_t pin);
  74. #endif
  75.  
  76. #endif
  77.  
  78.