| 1234567891011121314151617181920212223242526272829 |
- #include "src/peripherals/temp/tmp1075.h"
- #include "src/interfaces/i2c_controller.h"
- #include <stdio.h>
- /**
- * Read Temperature
- * of a former initalized TMP1075 sensor
- */
- uint16_t read_temperature(uint8_t slot) {
- controllerRxPackage.len = 3;
- controllerRxPackage.count = 0;
- controllerRxPackage.complete = false;
- i2c_hal.read(TMP1075_BASE_ADDRESS + slot);
- while(!controllerRxPackage.complete);
- uint16_t byte1 = controllerRxPackage.packet[0];
- uint8_t byte2 = controllerRxPackage.packet[1];
-
- uint16_t temp = ((byte1 << 4) | (byte2 >> 4)) * 62.5;
- #ifdef DEBUG_TEMPERATURE
- printf("Temperatur von slot %d: 0x%02X 0x%02X -> %d \n", slot, byte1, byte2, temp);
- #endif
- return temp;
- }
|