OneWire + DS18X20 Library
Basic functions for OneWire operations + specific DS18x20 operations
 All Functions Groups Pages
/*****************************************************************************
OneWire (tm) library
Copyright (C) 2016 Falk Brunner
*****************************************************************************/
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <Falk.Brunner@gmx.de> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Falk Brunner
* ----------------------------------------------------------------------------
*/
#ifndef ONEWIRE_H_
#define ONEWIRE_H_
#include <avr/io.h>
#define ONEWIRE_BIT PA0
#define ONEWIRE_PIN PINA
#define ONEWIRE_PORT PORTA
#define ONEWIRE_DDR DDRA
#define ONEWIRE_STRONG_PU_ON ONEWIRE_PORT |= ONEWIRE_MASK; ONEWIRE_DDR |= ONEWIRE_MASK;
#define ONEWIRE_STRONG_PU_OFF ONEWIRE_DDR &= ~ONEWIRE_MASK;
#define ONEWIRE_MASK (1<<ONEWIRE_BIT)
#define ONEWIRE_MATCH_ROM 0x55
#define ONEWIRE_SEARCH_ROM 0xF0
#define ONEWIRE_SKIP_ROM 0xCC
#define ONEWIRE_READ_ROM 0x33
#define ONEWIRE_ALARM_SEARCH 0xEC
#define ONEWIRE_OK 0 // no error
#define ONEWIRE_NO_PRESENCE 1 // no presence pulse detected during onewire reset
#define ONEWIRE_CRC_ERROR 2 // crc error in data reception
#define ONEWIRE_SCAN_ERROR 3 // scan error during ROM scan
#define ONEWIRE_LAST_CODE 4 // last rom code scanned (no error, just info)
#define ONEWIRE_GND_SHORT 5 // bus short circuit to GND
uint8_t onewire_reset(void);
uint8_t onewire_read_byte(void);
void onewire_write_byte(uint8_t data);
void onewire_search_init(uint8_t buffer[8]);
uint8_t onewire_alarm_search(uint8_t buffer[8]);
uint8_t onewire_search_rom(uint8_t buffer[8]);
uint8_t onewire_match_rom(const uint8_t rom[8]);
uint8_t onewire_read_rom(uint8_t rom[8]);
uint8_t onewire_skip_rom(void);
uint8_t onewire_crc(const uint8_t *data, uint8_t cnt);
void onewire_write_bit(uint8_t data);
uint8_t onewire_read_bit(void);
uint8_t onewire_search(uint8_t buffer[8], uint8_t cmd);
#endif