minor refactor
This commit is contained in:
parent
a41cc7e9de
commit
64545e5ebd
28
DS2482_HAL.c
28
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) {
|
||||
|
30
DS2482_HAL.h
30
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user