AN2681 Freescale Semiconductor / Motorola, AN2681 Datasheet - Page 11

no-image

AN2681

Manufacturer Part Number
AN2681
Description
1-Wire Interface on the i.MX21 Application Processor
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
}
uint16_t receive(void) {
}
float volts_decode(uint16_t volts) {
MOTOROLA
(addr & 0x02) ? write1() : write0();
(addr & 0x04) ? write1() : write0();
(addr & 0x08) ? write1() : write0();
(addr & 0x10) ? write1() : write0();
(addr & 0x20) ? write1() : write0();
(addr & 0x40) ? write1() : write0();
(addr & 0x80) ? write1() : write0();
int i;
uint16_t in_bit;
uint16_t x = 0;
// read the 16 bit value, 1 bit at a time
i = 0;
while (i < 16) {
}
return x;
int coded_volts;
float decoded_volts;
coded_volts = volts >> 5;
// check sign bit, front fill with 1's if negative
if (volts & 0x8000)
// units are 4.88 mV -> convert to volts
decoded_volts = coded_volts * 4.88 / 1000;
return decoded_volts;
// Read timing is same as Write 1
write1();
in_bit = *(p_uint16_t)OWIRE_CTRL & 0x0008;
// MSB
if (i < 8)
// LSB
else if (i > 7 && i < 12)
else
x |= in_bit;
i++;
coded_volts |= 0xFFFFF800;
in_bit = in_bit << (5+i);
in_bit = in_bit >> (i-12);
in_bit = in_bit << (i-11);
Freescale Semiconductor, Inc.
For More Information On This Product,
MC9328MX21 Application Note
Go to: www.freescale.com
Program Source Code
11

Related parts for AN2681