/*! \brief Send a Reset signal and listen for Presence signal. (Polled * UART DRIVER) * * Generates the waveform for transmission of a Reset pulse on the * 1-Wire(R) bus and listens for presence signals. * * \return A bitmask of the buses where a presence signal was detected. */ unsigned char OWI_DetectPresence() { // Reset UART receiver to clear RXC register. OWI_UART_STATCTRL_REG_B &= ~(1 << OWI_RXEN); OWI_UART_STATCTRL_REG_B |= (1 << OWI_RXEN); // Set UART Baud Rate to 9600 for Reset/Presence signalling. OWI_UART_BAUD_RATE_REG_L = OWI_UBRR_9600; // Return 0 if the value received matches the value sent. // return 1 else. (Presence detected) return (OWI_TouchBit(OWI_UART_RESET) != OWI_UART_RESET); }
/*! \brief Read a bit from the bus(es). (Polled UART DRIVER) * * Generates the waveform for reception of a bit on the 1-Wire(R) bus(es). * * \return The value read from the bus (0 or 1). */ unsigned char OWI_ReadBit() { // Return 1 if the value received matches the value sent. // Return 0 else. (A slave held the bus low). return (OWI_TouchBit(OWI_UART_READ_BIT) == OWI_UART_READ_BIT); }
/*! \brief Write a '1' bit to the bus(es). (Polled UART DRIVER) * * Generates the waveform for transmission of a '1' bit on the 1-Wire * bus. */ void OWI_WriteBit1() { OWI_TouchBit(OWI_UART_WRITE1); }
/*! \brief Write a '0' to the bus(es). (Polled UART DRIVER) * * Generates the waveform for transmission of a '0' bit on the 1-Wire(R) * bus. */ void OWI_WriteBit0() { OWI_TouchBit(OWI_UART_WRITE0); }
/*! \brief Write a '0' to the bus(es). (Polled UART DRIVER) * * Generates the waveform for transmission of a '0' bit on the 1-Wire(R) * bus. */ void OWI_WriteBit0(unsigned char pins) { OWI_TouchBit(OWI_UART_WRITE0); }