onewire_master.h
Go to the documentation of this file.
/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#define ONEWIRE_MASTER_PORT C
#define ONEWIRE_MASTER_PIN 9
void onewire_master_setup(void);
void onewire_master_release(void);
bool onewire_master_reset(void);
uint8_t onewire_master_crc(uint8_t* data, uint32_t length);
uint64_t onewire_master_rom_read(void);
bool onewire_master_rom_search(uint64_t* code, bool alarm);
bool onewire_master_rom_skip(void);
bool onewire_master_rom_match(uint64_t code);
bool onewire_master_read_byte(uint8_t* data);
bool onewire_master_write_byte(uint8_t data);
bool onewire_master_function_read(uint8_t function, uint8_t* data, uint32_t bits);
bool onewire_master_function_write(uint8_t function, uint8_t* data, uint32_t bits);
struct onewire_family_code_t {
uint8_t code;
const char* device;
};
static const struct onewire_family_code_t onewire_family_codes[] = {
{
.code = 0x01,
.device = "DS1990R/DS2401/DS2411/DS2490A",
},
{
.code = 0x02,
.device = "DS1991/DS1425",
},
{
.code = 0x04,
.device = "DS1994/DS2404",
},
{
.code = 0x05,
.device = "DS2405",
},
{
.code = 0x06,
.device = "DS1993",
},
{
.code = 0x08,
.device = "DS1992",
},
{
.code = 0x09,
.device = "DS1982/DS2502/DS2703/DS2704",
},
{
.code = 0x0a,
.device = "DS1995",
},
{
.code = 0x0b,
.device = "DS1985/DS2505",
},
{
.code = 0x0c,
.device = "DS1996",
},
{
.code = 0x0f,
.device = "DS1986/DS2506",
},
{
.code = 0x10,
.device = "DS1920/DS18S20",
},
{
.code = 0x12,
.device = "DS2406/DS2407",
},
{
.code = 0x14,
.device = "DS1971/DS2430A",
},
{
.code = 0x16,
.device = "DS1954/DS1957",
},
{
.code = 0x18,
.device = "DS1963S/DS1962",
},
{
.code = 0x1a,
.device = "DS1963L",
},
{
.code = 0x1b,
.device = "DS2436",
},
{
.code = 0x1c,
.device = "DS28E04-100",
},
{
.code = 0x1d,
.device = "DS2423",
},
{
.code = 0x1e,
.device = "DS2437",
},
{
.code = 0x1f,
.device = "DS2409",
},
{
.code = 0x20,
.device = "DS2450",
},
{
.code = 0x21,
.device = "DS1921",
},
{
.code = 0x22,
.device = "DS1922",
},
{
.code = 0x23,
.device = "DS1973/DS2433",
},
{
.code = 0x24,
.device = "DS1904/DS2415",
},
{
.code = 0x26,
.device = "DS2438",
},
{
.code = 0x27,
.device = "DS2417",
},
{
.code = 0x28,
.device = "DS18B20",
},
{
.code = 0x29,
.device = "DS2408",
},
{
.code = 0x2c,
.device = "DS2890",
},
{
.code = 0x2d,
.device = "DS1972/DS2431",
},
{
.code = 0x2e,
.device = "DS2770",
},
{
.code = 0x2f,
.device = "DS28E01-100",
},
{
.code = 0x30,
.device = "DS2760/DS2761/DS2762",
},
{
.code = 0x31,
.device = "DS2720",
},
{
.code = 0x32,
.device = "DS2780",
},
{
.code = 0x33,
.device = "DS1961S/DS2432",
},
{
.code = 0x34,
.device = "DS2703",
},
{
.code = 0x35,
.device = "DS2755",
},
{
.code = 0x36,
.device = "DS2740",
},
{
.code = 0x37,
.device = "DS1977",
},
{
.code = 0x3a,
.device = "DS2413",
},
{
.code = 0x3b,
.device = "DS1825/MAX31826/MAX31850",
},
{
.code = 0x3d,
.device = "DS2781",
},
{
.code = 0x41,
.device = "DS1922/DS1923/DS2422",
},
{
.code = 0x42,
.device = "DS28EA00",
},
{
.code = 0x43,
.device = "DS28EC20",
},
{
.code = 0x44,
.device = "DS28E10",
},
{
.code = 0x51,
.device = "DS2751",
},
{
.code = 0x7e,
.device = "EDS00xx",
},
{
.code = 0x81,
.device = "DS1420/DS2490R/DS2490B",
},
{
.code = 0x82,
.device = "DS1425",
},
{
.code = 0x84,
.device = "DS2404S",
},
{
.code = 0x89,
.device = "DS1982U/DS2502",
},
{
.code = 0x8b,
.device = "DS1985U/DS2505",
},
{
.code = 0x8f,
.device = "DS1986U/DS2506",
},
{
.code = 0xa0,
.device = "mRS001",
},
{
.code = 0xa1,
.device = "mVM001",
},
{
.code = 0xa2,
.device = "mCM001",
},
{
.code = 0xa6,
.device = "mTS017",
},
{
.code = 0xb1,
.device = "mTC001",
},
{
.code = 0xb2,
.device = "mAM001",
},
{
.code = 0xb3,
.device = "DS2432/mTC002",
},
{
.code = 0xfc,
.device = "BAE0910/BAE0911",
},
{
.code = 0xff,
.device = "Swart LCD",
}
};
onewire_master_write_byte
bool onewire_master_write_byte(uint8_t data)
write data byte
Definition: onewire_master.c:353
onewire_master_rom_read
uint64_t onewire_master_rom_read(void)
send READ ROM command and read ROM code response
Definition: onewire_master.c:407
onewire_master_reset
bool onewire_master_reset(void)
send reset pulse
Definition: onewire_master.c:227
onewire_family_codes
static const struct onewire_family_code_t onewire_family_codes[]
list of possible devices corresponding to the family code sources:
Definition: onewire_master.h:118
onewire_master_rom_search
bool onewire_master_rom_search(uint64_t *code, bool alarm)
send SEARCH ROM command
Definition: onewire_master.c:426
onewire_master_function_read
bool onewire_master_function_read(uint8_t function, uint8_t *data, uint32_t bits)
issue function and read data
Definition: onewire_master.c:364
onewire_master_read_byte
bool onewire_master_read_byte(uint8_t *data)
read data byte
Definition: onewire_master.c:338
onewire_master_rom_skip
bool onewire_master_rom_skip(void)
send SKIP ROM command (all slaves on the bus will be selected)
Definition: onewire_master.c:494
onewire_master_release
void onewire_master_release(void)
release 1-wire peripheral
Definition: onewire_master.c:206
onewire_family_code_t::device
const char * device
device name(s)
Definition: onewire_master.h:107
onewire_family_code_t
device corresponding to a family code
Definition: onewire_master.h:105
onewire_master_crc
uint8_t onewire_master_crc(uint8_t *data, uint32_t length)
compute CRC for 1-Wire
Definition: onewire_master.c:318
onewire_master_rom_match
bool onewire_master_rom_match(uint64_t code)
send MATCH ROM command to select a specific slave
Definition: onewire_master.c:502
onewire_family_code_t::code
uint8_t code
ROM ID code.
Definition: onewire_master.h:106
onewire_master_function_write
bool onewire_master_function_write(uint8_t function, uint8_t *data, uint32_t bits)
issue function and write data
Definition: onewire_master.c:385