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