2026-07-15 02:49:37 +08:00
|
|
|
#ifndef DEVICE_SPI_COMMAND_HANDLER_H
|
2026-06-23 01:49:33 +08:00
|
|
|
#define DEVICE_SPI_COMMAND_HANDLER_H
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
|
|
class AppSpiCommand;
|
|
|
|
|
|
|
|
|
|
struct SpiCommandContext {
|
|
|
|
|
uint8_t frame_type;
|
|
|
|
|
const uint8_t *payload;
|
|
|
|
|
uint16_t payload_len;
|
|
|
|
|
uint8_t *tx_buf;
|
|
|
|
|
uint16_t tx_buf_size;
|
|
|
|
|
uint16_t *tx_len;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ISpiCommandHandler {
|
|
|
|
|
public:
|
|
|
|
|
virtual bool canHandle(uint8_t frame_type) const = 0;
|
|
|
|
|
virtual void handle(AppSpiCommand &bus, const SpiCommandContext &ctx) = 0;
|
2026-07-15 02:49:37 +08:00
|
|
|
protected:
|
|
|
|
|
~ISpiCommandHandler() = default; /* 接口基类,不允许通过基类指针 delete;裸机不退出。 */
|
2026-06-23 01:49:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif /* DEVICE_SPI_COMMAND_HANDLER_H */
|