#ifndef FWU_H #define FWU_H #include /** * @file fwu.h * @brief API for the Firmware Update (FWU) library. * * This library provides the core logic for handling the over-the-air firmware * update process via Modbus. It manages the data buffer, processes commands, * and calculates CRC checksums for data verification. */ /** * @brief Initializes the firmware update module. * * This function currently does nothing but is a placeholder for future * initialization logic. */ void fwu_init(void); /** * @brief Handles incoming Modbus register writes related to firmware updates. * * This function is the main entry point for the FWU process. It parses the * address and value from a Modbus write operation and takes appropriate action, * such as storing metadata (offset, size) or data chunks, and processing * commands (verify, finalize). * * @param addr The Modbus register address being written to. * @param reg The 16-bit value being written to the register. */ void fwu_handler(uint16_t addr, uint16_t reg); /** * @brief Gets the CRC16-CCITT of the last received firmware chunk. * * After a data chunk is fully received into the buffer, this function can be * called to retrieve the calculated CRC checksum. The master can then compare * this with its own calculated CRC to verify data integrity. * * @return The 16-bit CRC of the last chunk. */ uint16_t fwu_get_last_chunk_crc(void); #endif // FWU_H