const TickType_t xDelay = 1000 / portTICK_PERIOD_MS;
const TickType_t xDelay2 = 800 / portTICK_PERIOD_MS;
int temp_LSB = 0;
int temp_MSB = 0;
int temp_celsius = 0;
char temp[8];
while(1)
{
vTaskDelay(xDelay);
if(one_wire_reset())
{
USART2->BRR = (SystemCoreClock /115200);
one_wire_write_byte(0xCC);
one_wire_write_byte(0x44);
vTaskDelay(xDelay2);
one_wire_reset();
USART2->BRR = (SystemCoreClock /115200);
one_wire_write_byte(0xCC);
one_wire_write_byte(0xBE);
temp_LSB = one_wire_read_byte();
temp_MSB = one_wire_read_byte();
one_wire_reset();
USART2->BRR = (SystemCoreClock /115200);
USART1_PutString(" ");
USART1_PutString(itoa(temp_LSB,temp,10));
USART1_PutString(itoa(temp_MSB,temp,10));
USART1_PutString(" ");
temp_celsius = ((temp_MSB * 256) + temp_LSB) / 16.0;
USART1_PutString(itoa(temp_celsius,temp,10));
}
}