Skip to main content

pamoja_ds18b20_build_scratchpad

Function pamoja_ds18b20_build_scratchpad 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn pamoja_ds18b20_build_scratchpad( celsius: f32, bits: u8, alarm_high: i8, alarm_low: i8, out_bytes: *mut u8, ) -> PamojaStatus
Expand description

Builds the nine bytes a DS18B20 in the given state puts on the bus, CRC last.

This is the inverse of pamoja_ds18b20_parse_scratchpad, so a node can be written and tested against what a thermometer sends without one attached.

§Returns

PamojaStatus::Ok on success, with the nine bytes written to out_bytes, or PamojaStatus::InvalidArgument if bits is not 9, 10, 11, or 12.

§Safety

out_bytes must point to at least nine writable bytes.