32 lines
977 B
C
32 lines
977 B
C
#pragma once
|
|
|
|
#ifndef DS2482_HAL_H
|
|
#define DS2482_HAL_H
|
|
|
|
#ifdef STM32F3
|
|
#include "stm32f3xx_hal.h"
|
|
#elifdef STM32F4
|
|
#include "stm32f4xx_hal.h"
|
|
#elifdef STM32H7
|
|
#include "stm32h7xx_hal.h"
|
|
#else
|
|
#error "No target defined"
|
|
#endif
|
|
|
|
#define DS2482_I2C_ADDR 0x30 // TODO: change to actual address
|
|
#define DS2482_TIMEOUT_1W 100
|
|
#define DS2482_TIMEOUT_I2C 100
|
|
|
|
HAL_StatusTypeDef ds2482_init(I2C_HandleTypeDef* handle);
|
|
HAL_StatusTypeDef ds2482_reset();
|
|
HAL_StatusTypeDef ds2482_write_config(uint8_t config);
|
|
HAL_StatusTypeDef ds2482_set_read_ptr(uint8_t read_ptr);
|
|
HAL_StatusTypeDef ds2482_1w_reset(bool* presence);
|
|
HAL_StatusTypeDef ds2482_1w_write_byte(uint8_t byte);
|
|
HAL_StatusTypeDef ds2482_1w_read_byte(uint8_t* byte);
|
|
HAL_StatusTypeDef ds2482_1w_triplet(uint8_t dir);
|
|
|
|
HAL_StatusTypeDef ds2482_1w_search(uint16_t max_devices, uint64_t devices[static max_devices]);
|
|
HAL_StatusTypeDef ds2482_1w_verify_device(uint64_t device, bool* present);
|
|
|
|
#endif // DS2482_HAL_H
|