static void write_byte(uint8_t byte)
{
    uint8_t bit;

    for (bit = 0; bit < 8; ++bit)
    {
        if (byte & 1)
            write_1();
        else
            write_0();
        byte >>= 1;
    }
}
Exemple #2
0
/*****************************************************************************
 * Method:		write_byte
 * Description:	This method writes one byte to the oneWire device.
 *
 * Parameters:	data - the data to write to the device
 ****************************************************************************/
void oneWire::write_byte (uint8_t data)
{
	for (uint8_t i = 0; i < 8; i++)
	{
		if (data & 0x01)
		{
			write_1();
		}
		else
		{
			write_0();
		}
		data >>= 1;
	}
}
void write_cmd(unsigned int cmd){
	unsigned int i;
	unsigned int len = 8;
	unsigned int bit = 0;

	for(i = 0; i < len; i++){
		bit = cmd & 0x1;
		if(bit == 0){
			write_0();
		}
		if(bit == 1){
			write_1();
		}
		cmd = cmd >> 1;
	}
}