summaryrefslogtreecommitdiff
path: root/avr/1wire.h
blob: 36160b79d997d4caa082c03bdd6ccf2935e4c8d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef _1wire_h_
#define _1wire_h_
#define MATCH_ROM	0x55
#define SKIP_ROM	0xCC
#define	SEARCH_ROM	0xF0

#define CONVERT_T	0x44		// DS1820 commands
#define READ		0xBE
#define WRITE		0x4E
#define EE_WRITE	0x48
#define EE_RECALL	0xB8

#define	SEARCH_FIRST	0xFF		// start new search
#define	PRESENCE_ERR	0xFF
#define	DATA_ERR	0xFE
#define LAST_DEVICE	0x00		// last device found
//			0x01 ... 0x40: continue searching

uint8_t w1_reset(void);

uint8_t w1_byte_wr( uint8_t b );
uint8_t w1_byte_rd( void );

uint8_t w1_rom_search( uint8_t diff, uint8_t*id );

void w1_command( uint8_t command, uint8_t *id );

void ds1992_read(uint16_t addr, uint8_t* buf, uint8_t len);
void ds1992_scratch_write(uint16_t addr, const uint8_t* buf, uint8_t len);
uint8_t ds1992_scratch_verify(uint16_t addr, const uint8_t* buf, uint8_t len, uint8_t* es_reg_ptr);
void ds1992_scratch_copy(uint16_t addr, uint8_t es_reg);

#endif