#include "DS18B20.h" #include "tim.h" #include "gpio.h" #include "main.h" /*T1 auf A4 */ #define SENSOR_T1_LOW HAL_GPIO_WritePin(TEMPERATURE_T1_GPIO_Port,TEMPERATURE_T1_Pin,OFF) #define SENSOR_T1_HIGH HAL_GPIO_WritePin(TEMPERATURE_T1_GPIO_Port,TEMPERATURE_T1_Pin,ON) void set_sensor_data_as_input(void) { GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitStruct.Pin = TEMPERATURE_T1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); } void set_sensor_data_as_output(void) { GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitStruct.Pin = TEMPERATURE_T1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); } uint8_t sensor_init(void) { set_sensor_data_as_output(); SENSOR_T1_LOW; delay_us(480); set_sensor_data_as_input(); delay_us(80); if(!(HAL_GPIO_ReadPin(TEMPERATURE_T1_GPIO_Port, TEMPERATURE_T1_Pin))) { delay_us(400); eturn 0; } else { delay_us(400); return 1; } } void sensor_write(uint8_t data) { set_sensor_data_as_output(); for (int i=0; i<8; i++) { /* BIT HIGH, SCHREIBE 1*/ if ((data & (1<