From 64545e5ebd243ced5072383c59748d4956648ade Mon Sep 17 00:00:00 2001
From: Kilian Bracher <k.bracher@fasttube.de>
Date: Thu, 27 Jun 2024 16:09:55 +0200
Subject: [PATCH] minor refactor

---
 DS2482_HAL.c | 28 ++++++++++++++++++++++++++++
 DS2482_HAL.h | 30 ------------------------------
 2 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/DS2482_HAL.c b/DS2482_HAL.c
index fd2849e..dbad2aa 100644
--- a/DS2482_HAL.c
+++ b/DS2482_HAL.c
@@ -1,6 +1,34 @@
 #include "DS2482_HAL.h"
 #include <stdint.h>
 
+#define DS2482_CMD_RESET         0xF0
+#define DS2482_CMD_SET_READ_PTR  0xE1
+#define DS2482_CMD_WRITE_CONFIG  0xD2
+#define DS2482_CMD_1W_RESET      0xB4
+#define DS2482_CMD_1W_SINGLE_BIT 0x87
+#define DS2482_CMD_1W_WRITE_BYTE 0xA5
+#define DS2482_CMD_1W_READ_BYTE  0x96
+#define DS2482_CMD_1W_TRIPLET    0x78
+
+#define DS2482_STATUS 0xF0
+#define DS2482_READ_DATA 0xE1
+#define DS2482_CONFIG 0xC3
+
+#define DS2482_CONFIG_APU 1 << 0
+#define DS2482_CONFIG_SPU 1 << 2
+#define DS2482_CONFIG_1WS 1 << 3
+
+typedef struct {
+    uint8_t BUSY : 1;
+    uint8_t PPD : 1;
+    uint8_t SHORT : 1;
+    uint8_t LL : 1;
+    uint8_t RST : 1;
+    uint8_t SBR : 1;
+    uint8_t TSB : 1;
+    uint8_t DIR : 1;
+} DS2482_Status;
+
 static I2C_HandleTypeDef* hi2c;
 
 HAL_StatusTypeDef ds2482_init(I2C_HandleTypeDef* handle) {
diff --git a/DS2482_HAL.h b/DS2482_HAL.h
index 84df806..355b3e3 100644
--- a/DS2482_HAL.h
+++ b/DS2482_HAL.h
@@ -13,40 +13,10 @@
     #error "No target defined"
 #endif
 
-
 #define DS2482_I2C_ADDR 0x30 // TODO: change to actual address
-
-#define DS2482_CMD_RESET         0xF0
-#define DS2482_CMD_SET_READ_PTR  0xE1
-#define DS2482_CMD_WRITE_CONFIG  0xD2
-#define DS2482_CMD_1W_RESET      0xB4
-#define DS2482_CMD_1W_SINGLE_BIT 0x87
-#define DS2482_CMD_1W_WRITE_BYTE 0xA5
-#define DS2482_CMD_1W_READ_BYTE  0x96
-#define DS2482_CMD_1W_TRIPLET    0x78
-
-#define DS2482_STATUS 0xF0
-#define DS2482_READ_DATA 0xE1
-#define DS2482_CONFIG 0xC3
-
-#define DS2482_CONFIG_APU 1 << 0
-#define DS2482_CONFIG_SPU 1 << 2
-#define DS2482_CONFIG_1WS 1 << 3
-
 #define DS2482_TIMEOUT_1W 100
 #define DS2482_TIMEOUT_I2C 100
 
-typedef struct {
-    uint8_t BUSY : 1;
-    uint8_t PPD : 1;
-    uint8_t SHORT : 1;
-    uint8_t LL : 1;
-    uint8_t RST : 1;
-    uint8_t SBR : 1;
-    uint8_t TSB : 1;
-    uint8_t DIR : 1;
-} DS2482_Status;
-
 HAL_StatusTypeDef ds2482_init(I2C_HandleTypeDef* handle);
 HAL_StatusTypeDef ds2482_reset();
 HAL_StatusTypeDef ds2482_write_config(uint8_t config);