This commit is contained in:
Олег Бородин
2024-08-27 11:29:20 +02:00
parent 4f3d8cfda4
commit f38727054d
2 changed files with 8 additions and 7 deletions

View File

@@ -548,7 +548,7 @@ void contr_main(void) {
contr_tx_handle();
counter++;
_delay_ms(1);
if ((counter % 10) == 1) buzzer_onoff();
//if ((counter % 10) == 1) buzzer_onoff();
}
}

13
temp.c
View File

@@ -12,11 +12,12 @@ uint8_t ds18b20_reset() {
uint8_t error;
REG_SETDOWN_BIT(DS18B20_PORT, DS18B20_PB);
REG_SETUP_BIT(DS18B20_DDR, DS18B20_PB);
_delay_us(340);
_delay_us(480);
REG_SETDOWN_BIT(DS18B20_DDR, DS18B20_PB);
_delay_us(64);
_delay_us(60);
error = REG_BIT_VALUE(DS18B20_PIN, DS18B20_PB);
_delay_us(320);
_delay_us(420);
return error;
}
@@ -27,7 +28,7 @@ void ds18b20_write_bit(uint8_t bit) {
if (bit) {
REG_SETDOWN_BIT(DS18B20_DDR, DS18B20_PB);
}
_delay_us(40);
_delay_us(60);
REG_SETDOWN_BIT(DS18B20_DDR, DS18B20_PB);
}
@@ -62,7 +63,7 @@ uint8_t ds18b20_read_byte(void) {
return byte;
}
#define TEMP_MEASURE_SCALE 63
#define TEMP_SCALE 63
uint16_t ds18b20_get_temp() {
uint8_t ltemp;
uint8_t htemp;
@@ -81,6 +82,6 @@ uint16_t ds18b20_get_temp() {
ltemp = ds18b20_read_byte();
htemp = ds18b20_read_byte();
temp = (((htemp << 8) | ltemp) * TEMP_MEASURE_SCALE) / 10;
temp = ((htemp << 8) | ltemp) * TEMP_SCALE / 10;
return temp;
}