WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

oneWireBus.h

Adds support for a Dallas One Wire bus.
The one wire bus allows many devices to be connected to the same signal line.
If you are using Project Designer then you don't need to worry about the details of this bus because it will generate all the necessary code for you.
An example device is the DS18B20 thermometer. See Maxim/DS18B20.h

 

Function

 


ONE_WIRE_BUS MAKE_ONE_WIRE_BUS(const IOPin* signal, ONE_WIRE_DEVICE_LIST* devices)

Creates a one wire bus.
The 'signal' parameter specifies which I/O pin to use for the bus signal and the 'devices' parameter specifies the list of known devices on the bus.
For example: assume we want to use 'C0' as the signal line and we want to use a DS18B20 thermometer:
// Create the thermometer
DS18B20 thermometer = MAKE_DS18B20(DS18B20_RESOLUTION_9_BIT);
 
// Create the list of devices in PROGMEM
// Each device should have '._wire1_' at the end
ONE_WIRE_DEVICE_LIST PROGMEM devices = { &thermometer._wire1_ };
 
// Create the bus
ONE_WIRE_BUS bus = MAKE_ONE_WIRE_BUS( C0, &devices );

oneWireInit(ONE_WIRE_BUS* bus)

Initialise the one wire bus.
This should be called from appInitHardware and will attempt to locate all the plugged in devices and discover their unique ROM ID.

uint16_t oneWireListDevices(ONE_WIRE_BUS* bus)

Displays the ROM ID of each device that is plugged in to the bus.
Note that this will report on ALL of the devices that are found - not just the ones you are using. It is therefore a useful function to check that the bus and the devices are working correctly.
The return value is the total number of devices found.

boolean oneWireReadBit(const ONE_WIRE_BUS* bus)

Reads a single bit from the bus.
Returns TRUE for a 1 or FALSE for a 0.

oneWireWriteBit(const ONE_WIRE_BUS* bus, boolean bit)

Writes a single bit to the bus.
The value should be TRUE for a 1, or FALSE for a 0.

uint8_t oneWireReadByte(const ONE_WIRE_BUS* bus)

Read a byte from the bus.

oneWireWriteByte(const ONE_WIRE_BUS* bus, uint8_t data)

Write a byte to the bus.

oneWireSetSpeed(ONE_WIRE_BUS* bus, boolean standard)

Set the speed of the bus.
The final parameter should be TRUE for standard speed or FALSE for overdrive speed.

boolean boolean oneWireReset(const ONE_WIRE_BUS* bus)

Performs a RESET and returns the 'presence' bit.

boolean oneWireFirst(ONE_WIRE_BUS* bus)

Searches for the first device on the bus.
Returns TRUE if a device has been found in which case you can use the oneWireDumpROM command to list out the matching ROM ID number.

boolean oneWireNext(ONE_WIRE_BUS* bus)

Finds the next device on the bus.
Returns TRUE whilst there are more devices or FALSE if there are no more.
You can use the oneWireDumpROM function to list out the ROM ID number.

boolean oneWireVerify(const ONE_WIRE_DEVICE* device)

Returns TRUE if the specified device is present on the bus or FALSE if cannot be found.

oneWireMatchROM(const ONE_WIRE_DEVICE* device)

Issues the match rom command for the specified device.

oneWireDeviceDumpROM(FILE* f,const ONE_WIRE_DEVICE* device)

Dumps out the ROM ID of the specified device.

oneWireApplyPower(ONE_WIRE_BUS* bus)

Applies power to the bus so that parasitic devices continue to be powered.
Only use this if you know what you are doing - otherwise you could create a short circuit on the bus signal line.

Valid XHTML 1.0 Transitional