unleashed-firmware/lib/toolbox/protocols/protocol.h
hedger ffa3996a5e
[FL-3867] Code formatting update (#3765)
* clang-format: AllowShortEnumsOnASingleLine: false
* clang-format: InsertNewlineAtEOF: true
* clang-format: Standard:        c++20
* clang-format: AlignConsecutiveBitFields
* clang-format: AlignConsecutiveMacros
* clang-format: RemoveParentheses: ReturnStatement
* clang-format: RemoveSemicolon: true
* Restored RemoveParentheses: Leave, retained general changes for it
* formatting: fixed logging TAGs
* Formatting update for dev

Co-authored-by: あく <alleteam@gmail.com>
2024-07-15 13:38:49 +09:00

47 lines
1.3 KiB
C

#pragma once
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <lib/toolbox/level_duration.h>
#include <furi.h>
typedef void* (*ProtocolAlloc)(void);
typedef void (*ProtocolFree)(void* protocol);
typedef uint8_t* (*ProtocolGetData)(void* protocol);
typedef void (*ProtocolDecoderStart)(void* protocol);
typedef bool (*ProtocolDecoderFeed)(void* protocol, bool level, uint32_t duration);
typedef bool (*ProtocolEncoderStart)(void* protocol);
typedef LevelDuration (*ProtocolEncoderYield)(void* protocol);
typedef void (*ProtocolRenderData)(void* protocol, FuriString* result);
typedef bool (*ProtocolWriteData)(void* protocol, void* data);
typedef struct {
ProtocolDecoderStart start;
ProtocolDecoderFeed feed;
} ProtocolDecoder;
typedef struct {
ProtocolEncoderStart start;
ProtocolEncoderYield yield;
} ProtocolEncoder;
typedef struct {
const size_t data_size;
const char* name;
const char* manufacturer;
const uint32_t features;
const uint8_t validate_count;
ProtocolAlloc alloc;
ProtocolFree free;
ProtocolGetData get_data;
ProtocolDecoder decoder;
ProtocolEncoder encoder;
ProtocolRenderData render_uid;
ProtocolRenderData render_data;
ProtocolRenderData render_brief_data;
ProtocolWriteData write_data;
} ProtocolBase;