2022-03-29 13:01:56 +00:00
|
|
|
/**
|
|
|
|
* @file ibutton_worker_i.h
|
|
|
|
*
|
|
|
|
* iButton worker, internal definitions
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2023-03-02 13:23:33 +00:00
|
|
|
|
|
|
|
#include <core/thread.h>
|
|
|
|
#include <core/message_queue.h>
|
|
|
|
|
2022-03-29 13:01:56 +00:00
|
|
|
#include "ibutton_worker.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
const uint32_t quant;
|
2022-06-26 12:00:03 +00:00
|
|
|
void (*const start)(iButtonWorker* worker);
|
|
|
|
void (*const tick)(iButtonWorker* worker);
|
|
|
|
void (*const stop)(iButtonWorker* worker);
|
2022-03-29 13:01:56 +00:00
|
|
|
} iButtonWorkerModeType;
|
|
|
|
|
|
|
|
typedef enum {
|
2023-03-02 13:23:33 +00:00
|
|
|
iButtonWorkerModeIdle,
|
|
|
|
iButtonWorkerModeRead,
|
|
|
|
iButtonWorkerModeWriteBlank,
|
|
|
|
iButtonWorkerModeWriteCopy,
|
|
|
|
iButtonWorkerModeEmulate,
|
2022-03-29 13:01:56 +00:00
|
|
|
} iButtonWorkerMode;
|
|
|
|
|
|
|
|
struct iButtonWorker {
|
2023-03-02 13:23:33 +00:00
|
|
|
iButtonKey* key;
|
|
|
|
iButtonProtocols* protocols;
|
2022-03-29 13:01:56 +00:00
|
|
|
iButtonWorkerMode mode_index;
|
2022-07-20 10:56:33 +00:00
|
|
|
FuriMessageQueue* messages;
|
2022-03-29 13:01:56 +00:00
|
|
|
FuriThread* thread;
|
|
|
|
|
|
|
|
iButtonWorkerReadCallback read_cb;
|
|
|
|
iButtonWorkerWriteCallback write_cb;
|
|
|
|
iButtonWorkerEmulateCallback emulate_cb;
|
|
|
|
|
2023-03-02 13:23:33 +00:00
|
|
|
void* cb_ctx;
|
2022-03-29 13:01:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const iButtonWorkerModeType ibutton_worker_modes[];
|
|
|
|
|
|
|
|
void ibutton_worker_switch_mode(iButtonWorker* worker, iButtonWorkerMode mode);
|
2022-05-11 15:47:01 +00:00
|
|
|
void ibutton_worker_notify_emulate(iButtonWorker* worker);
|
2022-03-29 13:01:56 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2022-05-06 13:37:10 +00:00
|
|
|
#endif
|