mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-05 20:38:27 +02:00
Shelly dimmer: Use unique_ptr to handle the lifetime of stm32_t (#3400)
Co-authored-by: Martin <25747549+martgras@users.noreply.github.com> Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#ifdef USE_SHD_FIRMWARE_DATA
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include "esphome/components/uart/uart.h"
|
||||
|
||||
namespace esphome {
|
||||
@@ -108,19 +109,20 @@ struct VarlenCmd {
|
||||
uint8_t length;
|
||||
};
|
||||
|
||||
stm32_t *stm32_init(uart::UARTDevice *stream, uint8_t flags, char init);
|
||||
void stm32_close(stm32_t *stm);
|
||||
stm32_err_t stm32_read_memory(const stm32_t *stm, uint32_t address, uint8_t *data, unsigned int len);
|
||||
stm32_err_t stm32_write_memory(const stm32_t *stm, uint32_t address, const uint8_t *data, unsigned int len);
|
||||
stm32_err_t stm32_wunprot_memory(const stm32_t *stm);
|
||||
stm32_err_t stm32_wprot_memory(const stm32_t *stm);
|
||||
stm32_err_t stm32_erase_memory(const stm32_t *stm, uint32_t spage, uint32_t pages);
|
||||
stm32_err_t stm32_go(const stm32_t *stm, uint32_t address);
|
||||
stm32_err_t stm32_reset_device(const stm32_t *stm);
|
||||
stm32_err_t stm32_readprot_memory(const stm32_t *stm);
|
||||
stm32_err_t stm32_runprot_memory(const stm32_t *stm);
|
||||
stm32_err_t stm32_crc_memory(const stm32_t *stm, uint32_t address, uint32_t length, uint32_t *crc);
|
||||
stm32_err_t stm32_crc_wrapper(const stm32_t *stm, uint32_t address, uint32_t length, uint32_t *crc);
|
||||
using stm32_unique_ptr = std::unique_ptr<stm32_t, void (*)(stm32_t *)>;
|
||||
|
||||
stm32_unique_ptr stm32_init(uart::UARTDevice *stream, uint8_t flags, char init);
|
||||
stm32_err_t stm32_read_memory(const stm32_unique_ptr &stm, uint32_t address, uint8_t *data, unsigned int len);
|
||||
stm32_err_t stm32_write_memory(const stm32_unique_ptr &stm, uint32_t address, const uint8_t *data, unsigned int len);
|
||||
stm32_err_t stm32_wunprot_memory(const stm32_unique_ptr &stm);
|
||||
stm32_err_t stm32_wprot_memory(const stm32_unique_ptr &stm);
|
||||
stm32_err_t stm32_erase_memory(const stm32_unique_ptr &stm, uint32_t spage, uint32_t pages);
|
||||
stm32_err_t stm32_go(const stm32_unique_ptr &stm, uint32_t address);
|
||||
stm32_err_t stm32_reset_device(const stm32_unique_ptr &stm);
|
||||
stm32_err_t stm32_readprot_memory(const stm32_unique_ptr &stm);
|
||||
stm32_err_t stm32_runprot_memory(const stm32_unique_ptr &stm);
|
||||
stm32_err_t stm32_crc_memory(const stm32_unique_ptr &stm, uint32_t address, uint32_t length, uint32_t *crc);
|
||||
stm32_err_t stm32_crc_wrapper(const stm32_unique_ptr &stm, uint32_t address, uint32_t length, uint32_t *crc);
|
||||
uint32_t stm32_sw_crc(uint32_t crc, uint8_t *buf, unsigned int len);
|
||||
|
||||
} // namespace shelly_dimmer
|
||||
|
||||
Reference in New Issue
Block a user