1use num_enum::{IntoPrimitive, TryFromPrimitive};
2
3#[cfg_attr(feature = "defmt", derive(defmt::Format))]
4#[derive(Copy, Clone)]
5pub enum DapVersion {
6 V1,
7 V2,
8}
9
10#[cfg_attr(feature = "defmt", derive(defmt::Format))]
11#[derive(Copy, Clone, TryFromPrimitive, PartialEq)]
12#[allow(non_camel_case_types)]
13#[repr(u8)]
14pub enum Command {
15 DAP_Info = 0x00,
17 DAP_HostStatus = 0x01,
18 DAP_Connect = 0x02,
19 DAP_Disconnect = 0x03,
20 DAP_WriteABORT = 0x08,
21 DAP_Delay = 0x09,
22 DAP_ResetTarget = 0x0A,
23
24 DAP_SWJ_Pins = 0x10,
26 DAP_SWJ_Clock = 0x11,
27 DAP_SWJ_Sequence = 0x12,
28
29 DAP_SWD_Configure = 0x13,
31 DAP_SWD_Sequence = 0x1D,
32
33 DAP_SWO_Transport = 0x17,
35 DAP_SWO_Mode = 0x18,
36 DAP_SWO_Baudrate = 0x19,
37 DAP_SWO_Control = 0x1A,
38 DAP_SWO_Status = 0x1B,
39 DAP_SWO_ExtendedStatus = 0x1E,
40 DAP_SWO_Data = 0x1C,
41
42 DAP_JTAG_Sequence = 0x14,
44 DAP_JTAG_Configure = 0x15,
45 DAP_JTAG_IDCODE = 0x16,
46
47 DAP_TransferConfigure = 0x04,
49 DAP_Transfer = 0x05,
50 DAP_TransferBlock = 0x06,
51 DAP_TransferAbort = 0x07,
52
53 DAP_ExecuteCommands = 0x7F,
55 DAP_QueueCommands = 0x7E,
56
57 Unimplemented = 0xFF,
59}
60
61#[cfg_attr(feature = "defmt", derive(defmt::Format))]
62#[derive(Copy, Clone, IntoPrimitive)]
63#[repr(u8)]
64pub enum ResponseStatus {
65 DapOk = 0x00,
66 DapError = 0xFF,
67}
68
69#[cfg_attr(feature = "defmt", derive(defmt::Format))]
70#[derive(Copy, Clone, TryFromPrimitive)]
71#[allow(non_camel_case_types)]
72#[repr(u8)]
73pub enum DapInfoID {
74 VendorID = 0x01,
75 ProductID = 0x02,
76 SerialNumber = 0x03,
77 FirmwareVersion = 0x04,
78 TargetVendor = 0x05,
79 TargetName = 0x06,
80 Capabilities = 0xF0,
81 TestDomainTimer = 0xF1,
82 SWOTraceBufferSize = 0xFD,
83 MaxPacketCount = 0xFE,
84 MaxPacketSize = 0xFF,
85}
86
87#[cfg_attr(feature = "defmt", derive(defmt::Format))]
88#[derive(Copy, Clone, TryFromPrimitive)]
89#[repr(u8)]
90pub enum HostStatusType {
91 Connect = 0,
92 Running = 1,
93}
94
95#[cfg_attr(feature = "defmt", derive(defmt::Format))]
96pub enum HostStatus {
97 Connected(bool),
98 Running(bool),
99}
100
101#[cfg_attr(feature = "defmt", derive(defmt::Format))]
102#[derive(Copy, Clone, TryFromPrimitive)]
103#[repr(u8)]
104pub enum ConnectPort {
105 Default = 0,
106 SWD = 1,
107 JTAG = 2,
108}
109
110#[cfg_attr(feature = "defmt", derive(defmt::Format))]
111#[repr(u8)]
112pub enum ConnectPortResponse {
113 Failed = 0,
114 SWD = 1,
115 JTAG = 2,
116}
117
118#[cfg_attr(feature = "defmt", derive(defmt::Format))]
119pub enum DapMode {
120 SWD,
121 JTAG,
122}