-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathccid_logic.h
More file actions
57 lines (52 loc) · 1.69 KB
/
Copy pathccid_logic.h
File metadata and controls
57 lines (52 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
typedef enum {
SeaderCcidDecodedCommandStatusProcessed = 0,
SeaderCcidDecodedCommandStatusFailed = 1,
SeaderCcidDecodedCommandStatusTimeExtension = 2,
} SeaderCcidDecodedCommandStatus;
typedef struct {
uint8_t icc_status;
SeaderCcidDecodedCommandStatus command_status;
} SeaderCcidStatus;
typedef enum {
SeaderCcidDataRouteSamT0 = 0,
SeaderCcidDataRouteSamT1 = 1,
SeaderCcidDataRouteAtrRecognition = 2,
SeaderCcidDataRouteWrongSlotError = 3,
} SeaderCcidDataRoute;
uint8_t seader_ccid_sequence_advance(uint8_t* sequence);
bool seader_ccid_payload_fits_frame(size_t payload_len, size_t uart_buf_size, size_t header_len);
bool seader_ccid_data_in_scratchpad(
const uint8_t* tx_buf,
size_t tx_buf_size,
size_t header_len,
const uint8_t* data,
size_t payload_len);
SeaderCcidStatus seader_ccid_decode_status(uint8_t status);
uint32_t seader_ccid_decode_le32(const uint8_t bytes[4]);
bool seader_ccid_response_matches_pending(bool pending, uint8_t expected_seq, uint8_t response_seq);
size_t seader_ccid_find_frame_start(
const uint8_t* data,
size_t len,
uint8_t sync,
uint8_t ctrl,
uint8_t nak);
bool seader_ccid_pending_timed_out(
bool pending,
uint32_t pending_since_tick,
uint32_t now_tick,
uint32_t timeout_ticks);
SeaderCcidDataRoute seader_ccid_route_data_block(
bool has_sam,
uint8_t sam_slot,
uint8_t message_slot,
uint8_t protocol_t);
bool seader_ccid_payload_matches_exact(
const uint8_t* payload,
size_t payload_len,
const uint8_t* expected,
size_t expected_len);
size_t seader_ccid_control_frame_size(size_t payload_len);