1.2 KiB
1.2 KiB
STM32-DS2482-HAL
A DS2482-100 HAL for the STM32F3/F4/H7 series
Usage
Define the target chip, and set the compiler to C23+:
gcc [...] --std=gnu2x -DSTM32[F3/F4/H7]
or
# (in STM32-for-VSCode.config.yaml)
# Compiler definitions. The -D prefix for the compiler will be automatically added.
cDefinitions:
- STM32[F3/F4/H7]
- USE_HAL_DRIVER
# ...
# Compiler flags
cFlags:
- --std=gnu2x
Then, configure the HAL:
// (in DS2482_HAL.h)
#define MULTIPLE_DEVICES false //set to true if multiple DS2482 devices are connected
#if !MULTIPLE_DEVICES
#define DS2482_I2C_ADDR 0x00 //set to I2C address of the DS2482 device (if in single device mode)
#endif
#define DS2482_TIMEOUT_1W 100 //timeout in ms for 1-wire operations
#define DS2482_TIMEOUT_I2C 100 //timeout in ms for I2C operations
For multiple DS2482 devices on one chip:
- Set
MULTIPLE_DEVICES
totrue
- Call
ds2482_create()
with the I2C handle and address - Call
ds2482_init()
with the handle - The HAL is ready
For just one DS2482:
- Set
DS2482_I2C_ADDR
to the I2C address - Call
ds2482_init()
with the I2C handle - The HAL is ready
Be sure to check the return values for error handling.