2.1.2 Polled UART Implementation
In this implementation, all the timing details are taken care of by the UART module. To send a bit, the UART baud rate is set to the appropriate value, and the UART data register is loaded with a value that will generate the desired waveform as described in the “Generating the signals with a UART” section.
Initialization
To initialize the 1-Wire interface for the polled UART driver, the UART module has to be initialized with the right parameters. Enable transmission and reception, set data format to eight bits, no parity, one stop bit and set the baud rate to 115.2 kBaud.
This will cause the TXD pin to enter a UART idle state, which is a logic high. Slave devices will interpret this rising edge as the end of a RESET signal, and answer with a presence signal.
Bit-level functions
All bit-level functions in the Polled UART driver are implemented through one common function called OWI_TouchBit. This function outputs the first input argument to the UART module, waits until the UART reception is complete, and then returns the AVR318112579A-AVR-09/04 received value. Each of the bit-level functions calls OWI_TouchBit with the value that will generate the correct waveform on the bus.
The interface to these functions is the same as for the software only implementation. The pins argument is, however, not necessary in the polled UART driver. A set of macros makes it possible to call these functions with or without the pins argument. If the pins argument is included, it will be removed by the macros.