Dallas 1-Wire(R) Master Polled driver File Documentation

advertisement
Dallas 1-Wire(R) Master Polled driver File
Documentation
main.c File Reference
Detailed Description
Atmel Corporation



File: main.c
Compiler: IAR EWAAVR 3.20a
Support mail: avr@atmel.com

Supported devices: All AVRs.

Application Note: AVR318 - Dallas 1-Wire(R) master.

Description: Example on how to use the 1-Wire(R) interface master.
Revision
1.7
Date
Thursday, August 19, 2004 14:27:18 UTC
Functions

signed int DS1820_ReadTemperature (unsigned char bus, unsigned char *id)
Read the temperature from a DS1820 temperature sensor.

void DS2890_SetWiperPosition (unsigned char position, unsigned char bus, unsigned char *id)
Set the wiper position of a DS2890.

OWI_device * FindFamily (unsigned char familyID, OWI_device *devices, unsigned char size)
Find the first device of a family based on the family id.

void main (void)
Example application for the polled drivers.

unsigned char SearchBuses (OWI_device *devices, unsigned char len, unsigned char buses)
1
Perform a 1-Wire search.
Function Documentation
signed int DS1820_ReadTemperature (unsigned char bus, unsigned char * id)
This function will start a conversion and read back the temperature from a DS1820 temperature sensor.
Parameters:
bus A bitmask of the bus where the DS1820 is located.
id The 64 bit identifier of the DS1820.
Returns:
The 16 bit signed temperature read from the DS1820.
void DS2890_SetWiperPosition (unsigned char position, unsigned char bus, unsigned
char * id)
This function initializes the DS2890 by enabling the charge pump. It then changes the wiper position.
Parameters:
position The new wiper position.
bus The bus where the DS2890 is connected.
id The 64 bit identifier of the DS2890.
OWI_device * FindFamily (unsigned char familyID, OWI_device * devices, unsigned char
size)
This function returns a pointer to a device in the device array that matches the specified family.
Parameters:
familyID The 8 bit family ID to search for.
devices An array of devices to search through.
size The size of the array 'devices'
Returns:
A pointer to a device of the family.
Return values:
NULL if no device of the family was found.
2
void main (void)
Example application for the software only and polled UART driver. This example application will find
all devices (upper bounded by MAX_DEVICES) on the buses defined by BUSES. It then tries to find
either a DS1820 or DS2890 device on a bus, and communicate with them to read temperature
(DS1820) or set wiper position (DS2890). This example is not written in a very optimal way. It is
merely intended to show how the polled 1-Wire(R) driver can be used.
unsigned char SearchBuses (OWI_device * devices, unsigned char len, unsigned char
buses)
This function shows how the OWI_SearchRom function can be used to discover all slaves on the bus.
It will also CRC check the 64 bit identifiers.
Parameters:
devices Pointer to an array of type OWI_device. The discovered devices will be placed from the
beginning of this array.
len The length of the device array. (Max. number of elements).
buses Bitmask of the buses to perform search on.
Return values:
SEARCH_SUCCESSFUL Search completed successfully.
SEARCH_CRC_ERROR A CRC error occured. Probably because of noise during transmission.
3
OWIBitFunctions.h File Reference
Detailed Description
Atmel Corporation



File: OWIBitFunctions.h
Compiler: IAR EWAAVR 3.20a
Support mail: avr@atmel.com

Supported devices: All AVRs.

Application Note: AVR318 - Dallas 1-Wire(R) master.

Description: Header file for OWIBitFunctions.c
Revision
1.7
Date
Thursday, August 19, 2004 14:27:18 UTC
Functions

unsigned char OWI_DetectPresence ()
Send a Reset signal and listen for Presence signal. (Polled UART DRIVER).

unsigned char OWI_DetectPresence (unsigned char pins)
Send a Reset signal and listen for Presence signal. (software only driver).

void OWI_Init ()
Initialization of the one wire bus. (Polled UART driver).

void OWI_Init (unsigned char pins)
Initialization of the one wire bus(es). (Software only driver).

unsigned char OWI_ReadBit ()
Read a bit from the bus(es). (Polled UART DRIVER).

unsigned char OWI_ReadBit (unsigned char pins)
Read a bit from the bus(es). (Software only driver).
4

unsigned char OWI_TouchBit (unsigned char outValue)
Write and read one bit to/from the 1-Wire bus. (Polled UART driver).

void OWI_WriteBit0 ()
Write a '0' to the bus(es). (Polled UART DRIVER).

void OWI_WriteBit0 (unsigned char pins)
Write a '0' to the bus(es). (Software only driver).

void OWI_WriteBit1 ()
Write a '1' bit to the bus(es). (Polled UART DRIVER).

void OWI_WriteBit1 (unsigned char pins)
Write a '1' bit to the bus(es). (Software only driver).
Function Documentation
unsigned char OWI_DetectPresence ()
Generates the waveform for transmission of a Reset pulse on the 1-Wire(R) bus and listens for
presence signals.
Returns:
A bitmask of the buses where a presence signal was detected.
unsigned char OWI_DetectPresence (unsigned char pins)
Generates the waveform for transmission of a Reset pulse on the 1-Wire(R) bus and listens for
presence signals.
Parameters:
pins A bitmask of the buses to send the Reset signal on.
Returns:
A bitmask of the buses where a presence signal was detected.
void OWI_Init ()
This function initializes the 1-Wire bus by configuring the UART.
5
void OWI_Init (unsigned char pins)
This function initializes the 1-Wire bus(es) by releasing it and waiting until any presence sinals are
finished.
Parameters:
pins A bitmask of the buses to initialize.
unsigned char OWI_ReadBit ()
Generates the waveform for reception of a bit on the 1-Wire(R) bus(es).
Returns:
The value read from the bus (0 or 1).
unsigned char OWI_ReadBit (unsigned char pins)
Generates the waveform for reception of a bit on the 1-Wire(R) bus(es).
Parameters:
pins A bitmask of the bus(es) to read from.
Returns:
A bitmask of the buses where a '1' was read.
unsigned char OWI_TouchBit (unsigned char outValue)
Writes one bit to the bus and returns the value read from the bus.
Parameters:
outValue The value to transmit on the bus.
Returns:
The value received by the UART from the bus.
void OWI_WriteBit0 ()
Generates the waveform for transmission of a '0' bit on the 1-Wire(R) bus.
6
void OWI_WriteBit0 (unsigned char pins)
Generates the waveform for transmission of a '0' bit on the 1-Wire(R) bus.
Parameters:
pins A bitmask of the buses to write to.
void OWI_WriteBit1 ()
Generates the waveform for transmission of a '1' bit on the 1-Wire bus.
void OWI_WriteBit1 (unsigned char pins)
Generates the waveform for transmission of a '1' bit on the 1-Wire bus.
Parameters:
pins A bitmask of the buses to write to.
7
OWIHighLevelFunctions.c File Reference
Detailed Description
Atmel Corporation



File: OWIHighLevelFunctions.c
Compiler: IAR EWAAVR 3.20a
Support mail: avr@atmel.com

Supported devices: All AVRs.

Application Note: AVR318 - Dallas 1-Wire(R) master.

Description: High level functions for transmission of full bytes on the 1-Wire(R) bus and
implementations of ROM commands.
Revision
1.7
Date
Thursday, August 19, 2004 14:27:18 UTC
Functions

void OWI_MatchRom (unsigned char *romValue, unsigned char pins)
Sends the MATCH ROM command and the ROM id to match against.

void OWI_ReadRom (unsigned char *romValue, unsigned char pin)
Sends the READ ROM command and reads back the ROM id.

unsigned char OWI_ReceiveByte (unsigned char pin)
Receives one byte of data from the 1-Wire(R) bus.

unsigned char OWI_SearchRom (unsigned char *bitPattern, unsigned char lastDeviation, unsigned
char pin)
Sends the SEARCH ROM command and returns 1 id found on the 1-Wire(R) bus.

void OWI_SendByte (unsigned char data, unsigned char pins)
Sends one byte of data on the 1-Wire(R) bus(es).
8

void OWI_SkipRom (unsigned char pins)
Sends the SKIP ROM command to the 1-Wire bus(es).
Function Documentation
void OWI_MatchRom (unsigned char * romValue, unsigned char pins)
Parameters:
romValue A pointer to the ID to match against.
pins A bitmask of the buses to perform the MATCH ROM command on.
void OWI_ReadRom (unsigned char * romValue, unsigned char pin)
Parameters:
romValue A pointer where the id will be placed.
pin A bitmask of the bus to read from.
unsigned char OWI_ReceiveByte (unsigned char pin)
This function automates the task of receiving a complete byte of data from the 1-Wire bus.
Parameters:
pin A bitmask of the bus to read from.
Returns:
The byte read from the bus.
unsigned char OWI_SearchRom (unsigned char * bitPattern, unsigned char lastDeviation,
unsigned char pin)
Parameters:
bitPattern A pointer to an 8 byte char array where the discovered identifier will be placed. When
searching for several slaves, a copy of the last found identifier should be supplied in the array, or
the search will fail.
lastDeviation The bit position where the algorithm made a choice the last time it was run. This
argument should be 0 when a search is initiated. Supplying the return argument of this function
when calling repeatedly will go through the complete slave search.
pin A bit-mask of the bus to perform a ROM search on.
9
Returns:
The last bit position where there was a discrepancy between slave addresses the last time this
function was run. Returns OWI_ROM_SEARCH_FAILED if an error was detected (e.g. a device
was connected to the bus during the search), or OWI_ROM_SEARCH_FINISHED when there are
no more devices to be discovered.
Note:
See main.c for an example of how to utilize this function.
void OWI_SendByte (unsigned char data, unsigned char pins)
This function automates the task of sending a complete byte of data on the 1-Wire bus(es).
Parameters:
data The data to send on the bus(es).
pins A bitmask of the buses to send the data to.
void OWI_SkipRom (unsigned char pins)
Parameters:
pins A bitmask of the buses to send the SKIP ROM command to.
10
OWIHighLevelFunctions.h File Reference
Detailed Description
Atmel Corporation



File: OWIHighLevelFunctions.h
Compiler: IAR EWAAVR 3.20a
Support mail: avr@atmel.com

Supported devices: All AVRs.

Application Note: AVR318 - Dallas 1-Wire(R) master.

Description: Header file for OWIHighLevelFunctions.c
Revision
1.7
Date
Thursday, August 19, 2004 14:27:18 UTC
Functions

void OWI_MatchRom (unsigned char *romValue, unsigned char pins)
Sends the MATCH ROM command and the ROM id to match against.

void OWI_ReadRom (unsigned char *romValue, unsigned char pins)
Sends the READ ROM command and reads back the ROM id.

unsigned char OWI_ReceiveByte (unsigned char pin)
Receives one byte of data from the 1-Wire(R) bus.

unsigned char OWI_SearchRom (unsigned char *bitPattern, unsigned char lastDeviation, unsigned
char pins)
Sends the SEARCH ROM command and returns 1 id found on the 1-Wire(R) bus.

void OWI_SendByte (unsigned char data, unsigned char pins)
Sends one byte of data on the 1-Wire(R) bus(es).

void OWI_SkipRom (unsigned char pins)
11
Sends the SKIP ROM command to the 1-Wire bus(es).
Function Documentation
void OWI_MatchRom (unsigned char * romValue, unsigned char pins)
Parameters:
romValue A pointer to the ID to match against.
pins A bitmask of the buses to perform the MATCH ROM command on.
void OWI_ReadRom (unsigned char * romValue, unsigned char pin)
Parameters:
romValue A pointer where the id will be placed.
pin A bitmask of the bus to read from.
unsigned char OWI_ReceiveByte (unsigned char pin)
This function automates the task of receiving a complete byte of data from the 1-Wire bus.
Parameters:
pin A bitmask of the bus to read from.
Returns:
The byte read from the bus.
unsigned char OWI_SearchRom (unsigned char * bitPattern, unsigned char lastDeviation,
unsigned char pin)
Parameters:
bitPattern A pointer to an 8 byte char array where the discovered identifier will be placed. When
searching for several slaves, a copy of the last found identifier should be supplied in the array, or
the search will fail.
lastDeviation The bit position where the algorithm made a choice the last time it was run. This
argument should be 0 when a search is initiated. Supplying the return argument of this function
when calling repeatedly will go through the complete slave search.
pin A bit-mask of the bus to perform a ROM search on.
12
Returns:
The last bit position where there was a discrepancy between slave addresses the last time this
function was run. Returns OWI_ROM_SEARCH_FAILED if an error was detected (e.g. a device
was connected to the bus during the search), or OWI_ROM_SEARCH_FINISHED when there are
no more devices to be discovered.
Note:
See main.c for an example of how to utilize this function.
void OWI_SendByte (unsigned char data, unsigned char pins)
This function automates the task of sending a complete byte of data on the 1-Wire bus(es).
Parameters:
data The data to send on the bus(es).
pins A bitmask of the buses to send the data to.
void OWI_SkipRom (unsigned char pins)
Parameters:
pins A bitmask of the buses to send the SKIP ROM command to.
13
OWIPolled.h File Reference
Detailed Description
Atmel Corporation



File: OWIPolled.h
Compiler: IAR EWAAVR 3.20a
Support mail: avr@atmel.com

Supported devices: All AVRs.

Application Note: AVR318 - Dallas 1-Wire(R) master.

Description: Defines used in the polled 1-Wire(R) driver.
Revision
1.7
Date
Thursday, August 19, 2004 14:27:18 UTC
14
OWISWBitFunctions.c File Reference
Detailed Description
Atmel Corporation



File: OWISWBitFunctions.c
Compiler: IAR EWAAVR 3.20a
Support mail: avr@atmel.com

Supported devices: All AVRs.

Application Note: AVR318 - Dallas 1-Wire(R) master.

Description: Polled software only implementation of the basic bit-level signalling in the 1Wire(R) protocol.
Revision
1.7
Date
Thursday, August 19, 2004 14:27:18 UTC
Functions

unsigned char OWI_DetectPresence (unsigned char pins)
Send a Reset signal and listen for Presence signal. (software only driver).

void OWI_Init (unsigned char pins)
Initialization of the one wire bus(es). (Software only driver).

unsigned char OWI_ReadBit (unsigned char pins)
Read a bit from the bus(es). (Software only driver).

void OWI_WriteBit0 (unsigned char pins)
Write a '0' to the bus(es). (Software only driver).

void OWI_WriteBit1 (unsigned char pins)
Write a '1' bit to the bus(es). (Software only driver).
15
Function Documentation
unsigned char OWI_DetectPresence (unsigned char pins)
Generates the waveform for transmission of a Reset pulse on the 1-Wire(R) bus and listens for
presence signals.
Parameters:
pins A bitmask of the buses to send the Reset signal on.
Returns:
A bitmask of the buses where a presence signal was detected.
void OWI_Init (unsigned char pins)
This function initializes the 1-Wire bus(es) by releasing it and waiting until any presence sinals are
finished.
Parameters:
pins A bitmask of the buses to initialize.
unsigned char OWI_ReadBit (unsigned char pins)
Generates the waveform for reception of a bit on the 1-Wire(R) bus(es).
Parameters:
pins A bitmask of the bus(es) to read from.
Returns:
A bitmask of the buses where a '1' was read.
void OWI_WriteBit0 (unsigned char pins)
Generates the waveform for transmission of a '0' bit on the 1-Wire(R) bus.
Parameters:
pins A bitmask of the buses to write to.
16
void OWI_WriteBit1 (unsigned char pins)
Generates the waveform for transmission of a '1' bit on the 1-Wire bus.
Parameters:
pins A bitmask of the buses to write to.
17
OWIUARTBitFunctions.c File Reference
Detailed Description
Atmel Corporation



File: OWIUARTFunctions.c
Compiler: IAR EWAAVR 3.20a
Support mail: avr@atmel.com

Supported devices: All AVRs.

Application Note: AVR318 - Dallas 1-Wire(R) master.

Description: Polled UART implementation of the basic bit-level signalling in the 1-Wire(R)
protocol.
Revision
1.7
Date
Thursday, August 19, 2004 14:27:18 UTC
Functions

unsigned char OWI_DetectPresence ()
Send a Reset signal and listen for Presence signal. (Polled UART DRIVER).

void OWI_Init ()
Initialization of the one wire bus. (Polled UART driver).

unsigned char OWI_ReadBit ()
Read a bit from the bus(es). (Polled UART DRIVER).

unsigned char OWI_TouchBit (unsigned char outValue)
Write and read one bit to/from the 1-Wire bus. (Polled UART driver).

void OWI_WriteBit0 ()
Write a '0' to the bus(es). (Polled UART DRIVER).

void OWI_WriteBit1 ()
18
Write a '1' bit to the bus(es). (Polled UART DRIVER).
Function Documentation
unsigned char OWI_DetectPresence ()
Generates the waveform for transmission of a Reset pulse on the 1-Wire(R) bus and listens for
presence signals.
Returns:
A bitmask of the buses where a presence signal was detected.
void OWI_Init ()
This function initializes the 1-Wire bus by configuring the UART.
unsigned char OWI_ReadBit ()
Generates the waveform for reception of a bit on the 1-Wire(R) bus(es).
Returns:
The value read from the bus (0 or 1).
unsigned char OWI_TouchBit (unsigned char outValue)
Writes one bit to the bus and returns the value read from the bus.
Parameters:
outValue The value to transmit on the bus.
Returns:
The value received by the UART from the bus.
void OWI_WriteBit0 ()
Generates the waveform for transmission of a '0' bit on the 1-Wire(R) bus.
19
void OWI_WriteBit1 ()
Generates the waveform for transmission of a '1' bit on the 1-Wire bus.
20
Download