[FL-2393][FL-2381] iButton, OneWire: move to plain C (#1068)
* iButton: getting started on the worker concept * Hal delay: added global instructions_per_us variable * iButton: one wire slave * iButton: ibutton key setter * iButton: one wire host, use ibutton_hal * iButton\RFID: common pulse decoder concept * iButton: cyfral decoder * iButton: worker thread concept * iButton: metakom decoder * iButton: write key through worker * iButton: worker mode holder * iButton: worker improvements * iButton: Cyfral encoder * iButton: Metakom encoder * lib: pulse protocol helpers * iButton: Metakom decoder * iButton: Cyfral decoder * iButton worker: separate modes * iButton: libs documentation * HAL: iButton gpio modes * iButton worker: rename modes file * iButton worker, hal: move to LL * iButton CLI: worker for reading and emulation commands * iButton HAL: correct init and emulation sequence * iButton cli: moved to plain C * iButton: move to worker, small step to plain C * Libs, one wire: move to plain C * Libs: added forgotten files to compilation * iButton writer: get rid of manual disable/enable irq
This commit is contained in:
122
lib/one_wire/pulse_protocols/pulse_protocol.h
Normal file
122
lib/one_wire/pulse_protocols/pulse_protocol.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* @file pulse_protocol.h
|
||||
*
|
||||
* Generic pulse protocol decoder library, protocol interface
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Anonymous PulseProtocol struct
|
||||
*/
|
||||
typedef struct PulseProtocol PulseProtocol;
|
||||
|
||||
/**
|
||||
* Process pulse callback
|
||||
*/
|
||||
typedef void (*PulseProtocolPulseCallback)(void* context, bool polarity, uint32_t length);
|
||||
|
||||
/**
|
||||
* Reset protocol callback
|
||||
*/
|
||||
typedef void (*PulseProtocolResetCallback)(void* context);
|
||||
|
||||
/**
|
||||
* Get decoded data callback
|
||||
*/
|
||||
typedef void (*PulseProtocolGetDataCallback)(void* context, uint8_t* data, size_t length);
|
||||
|
||||
/**
|
||||
* Is protocol decoded callback
|
||||
*/
|
||||
typedef bool (*PulseProtocolDecodedCallback)(void* context);
|
||||
|
||||
/**
|
||||
* Allocate protocol
|
||||
* @return PulseProtocol*
|
||||
*/
|
||||
PulseProtocol* pulse_protocol_alloc();
|
||||
|
||||
/**
|
||||
* Deallocate protocol
|
||||
* @param protocol
|
||||
*/
|
||||
void pulse_protocol_free(PulseProtocol* protocol);
|
||||
|
||||
/**
|
||||
* Set context for callbacks
|
||||
* @param protocol
|
||||
* @param context
|
||||
*/
|
||||
void pulse_protocol_set_context(PulseProtocol* protocol, void* context);
|
||||
|
||||
/**
|
||||
* Set "Process pulse" callback. Called from the decoder when a new pulse is received.
|
||||
* @param protocol
|
||||
* @param callback
|
||||
*/
|
||||
void pulse_protocol_set_pulse_cb(PulseProtocol* protocol, PulseProtocolPulseCallback callback);
|
||||
|
||||
/**
|
||||
* Set "Reset protocol" callback. Called from the decoder when the decoder is reset.
|
||||
* @param protocol
|
||||
* @param callback
|
||||
*/
|
||||
void pulse_protocol_set_reset_cb(PulseProtocol* protocol, PulseProtocolResetCallback callback);
|
||||
|
||||
/**
|
||||
* Set "Get decoded data" callback. Called from the decoder when the decoder wants to get decoded data.
|
||||
* @param protocol
|
||||
* @param callback
|
||||
*/
|
||||
void pulse_protocol_set_get_data_cb(PulseProtocol* protocol, PulseProtocolGetDataCallback callback);
|
||||
|
||||
/**
|
||||
* Set "Is protocol decoded" callback. Called from the decoder when the decoder wants to know if a protocol has been decoded.
|
||||
* @param protocol
|
||||
* @param callback
|
||||
*/
|
||||
void pulse_protocol_set_decoded_cb(PulseProtocol* protocol, PulseProtocolDecodedCallback callback);
|
||||
|
||||
/**
|
||||
* Part of decoder interface.
|
||||
* @param protocol
|
||||
* @param polarity
|
||||
* @param length
|
||||
*/
|
||||
void pulse_protocol_process_pulse(PulseProtocol* protocol, bool polarity, uint32_t length);
|
||||
|
||||
/**
|
||||
* Part of decoder interface.
|
||||
* @param protocol
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool pulse_protocol_decoded(PulseProtocol* protocol);
|
||||
|
||||
/**
|
||||
* Part of decoder interface.
|
||||
* @param protocol
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
void pulse_protocol_get_data(PulseProtocol* protocol, uint8_t* data, size_t length);
|
||||
|
||||
/**
|
||||
* Part of decoder interface.
|
||||
* @param protocol
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
void pulse_protocol_reset(PulseProtocol* protocol);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user