onewire

package
v0.27.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2024 License: BSD-3-Clause Imports: 3 Imported by: 3

Documentation

Overview

Package wire implements the Dallas Semiconductor Corp.'s 1-wire bus system.

Wikipedia: https://en.wikipedia.org/wiki/1-Wire

Index

Constants

View Source
const (
	READ_ROM   uint8 = 0x33
	MATCH_ROM  uint8 = 0x55
	SKIP_ROM   uint8 = 0xCC
	SEARCH_ROM uint8 = 0xF0
)

OneWire ROM commands

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct{}

Config wraps a configuration to an 1-Wire devices.

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device wraps a connection to an 1-Wire devices.

func New

func New(p machine.Pin) Device

New creates a new GPIO 1-Wire connection. The pin must be pulled up to the VCC via a resistor greater than 500 ohms (default 4.7k).

func (*Device) Configure

func (d *Device) Configure(config Config)

Configure initializes the protocol.

func (Device) Read

func (d Device) Read() (data uint8)

Read receives a byte from 1-Wire bus. (LSB first)

func (Device) ReadAddress

func (d Device) ReadAddress() ([]uint8, error)

ReadAddress receives a 64-bit unique ROM ID from Device. (LSB first) Note: use this if there is only one slave device on the bus.

func (Device) ReadBit

func (d Device) ReadBit() (data uint8)

ReadBit receives a bit from 1-Wire bus.

func (Device) Reset

func (d Device) Reset() error

Reset pull DQ line low, then up.

func (Device) Search

func (d Device) Search(cmd uint8) ([][]uint8, error)

Search searches for all devices on the bus. Note: max 32 slave devices per bus

func (Device) Select

func (d Device) Select(romid []uint8) error

Select selects the address of the device for communication

func (Device) Write

func (d Device) Write(data uint8)

Write transmits a byte as bit array to 1-Wire bus. (LSB first)

func (Device) WriteBit

func (d Device) WriteBit(data uint8)

WriteBit transmits a bit to 1-Wire bus.

func (Device) Сrc8

func (d Device) Сrc8(buffer []uint8, size int) (crc uint8)

Crc8 compute a Dallas Semiconductor 8 bit CRC.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL