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