Beispiel #1
0
int main(void)
{
	UART_Init();
	UART_SendStr("\nSTM32F103RET6 is online.\n");

	UART_SendStr("I2C init ... ");
	if (!LM75_Init(100000)) UART_SendStr("ready.\n"); else {
		UART_SendStr("fail.\n");
		UART_SendStr("MCU halted now.\n");
		while(1);
	}

	uint16_t value;

    value = LM75_ReadReg(0x00);
	UART_SendHex16(value); UART_SendChar('\n');
	value = LM75_ReadConf();
	UART_SendHex8(value); UART_SendChar('\n');
	value = LM75_ReadReg(0x02);
	UART_SendHex16(value); UART_SendChar('\n');
	value = LM75_ReadReg(0x03);
	UART_SendHex16(value); UART_SendChar('\n');

    LM75_Shutdown(DISABLE);

    int16_t temp = LM75_Temperature();
    UART_SendInt(temp / 10); UART_SendChar('.');
    temp %= 10;
    if (temp < 0) temp *= -1;
    UART_SendInt(temp % 10); UART_SendStr("C\n");

    while(1);
}
Beispiel #2
0
void LM75_RW(void)
{
    char str[50];
    uint16_t temp16;

    temp16 = LM75_Temperature();

    str[0] = LM75_ReadConf();
    LM75_WriteConf(str[0] & 0xFE);

//	adc_Y = LM75_ReadReg(LM75_REG_CONF);
//	adc_Z = LM75_ReadReg(LM75_REG_THYS);

    sprintf(str, "x= %d\n", temp16);
}