feat: onewire and ds18b20 driver

This commit is contained in:
2024-11-28 02:35:59 +08:00
parent 31482c9a70
commit 8edaf36a1a
9 changed files with 141 additions and 105 deletions

View File

@@ -1,7 +1,8 @@
#include <8052.h>
#include "serial_command.h"
#include "temp.h"
#include "onewire.h"
#include "ds18b20.h"
typedef unsigned int u16;
typedef unsigned char u8;
@@ -199,7 +200,8 @@ void ProcessTempCmd(void) {
#endif
if (tempCmdCode == CTRL_CODE_TEMP_Enable) {
EA = 0;
temp = Ds18b20ReadTemp();
DS18B20_startConvert();
temp = DS18B20_readTemperature();
EA = 1;
tc = MCU_CMD_TEMP << 12;
td = (u16) temp & 0xFFF;
@@ -222,6 +224,8 @@ int ProcessGasCmd(void) {
void main(void) {
int gasFlag, bodyFlag;
DS18B20_startConvert();
delay(100);
UsartInit();
while (1) {
ProcessCommand();