Standalone SWD programator
swd-api.h
Zobrazit dokumentaci tohoto souboru.
1 #ifndef SWD_API_H
2 #define SWD_API_H
3 #include <stdint.h>
4 
10 #define SWDBUFLEN 0x100
11 
12 enum CORE_REGS {
13  CORE_R0 = 0,
14  CORE_R1 = 1,
15  CORE_R2 = 2,
16  CORE_R3 = 3,
17  CORE_R4 = 4,
18  CORE_R5 = 5,
19  CORE_R6 = 6,
20  CORE_R7 = 7,
21  CORE_R8 = 8,
22  CORE_R9 = 9,
23  CORE_R10 = 10,
24  CORE_R11 = 11,
25  CORE_R12 = 12,
26  CORE_R13 = 13,
27  CORE_SP = 13,
28  CORE_R14 = 14,
29  CORE_R15 = 15,
30  CORE_PC = 15,
31  CORE_XPSR= 16
32 };
33 
34 // SWD status responses. SWD_ACK is good.
35 enum OR_STATUS_CODES {
36  OR_STATUS_ACK = 0b001,
37  OR_STATUS_WAIT = 0b010,
38  OR_STATUS_FAULT = 0b100,
39  OR_STATUS_PARITY = 0b1000,
40  OR_STATUS_NOTHING = 0b11111111
41 };
49 extern uint8_t ReadDP (uint8_t address, uint32_t *data);
57 extern uint8_t WriteDP (uint8_t address, uint32_t data);
64 extern uint8_t SetAPSelect (uint8_t address);
72 extern uint8_t ReadAP (uint8_t address, uint32_t *data);
80 extern uint8_t ReadAP2 (uint8_t address, uint32_t *data);
88 extern uint8_t WriteAP (uint8_t address, uint32_t data);
95 extern uint8_t Connect (uint32_t *CoreID);
103 extern uint8_t ReadMemory (uint32_t address, uint32_t *data);
112 extern uint8_t ReadMemoryArray (uint32_t address, uint32_t *data, uint32_t count);
120 extern uint8_t WriteMemory (uint32_t address, uint32_t data);
129 extern uint8_t WriteMemoryArray(uint32_t address, const uint32_t *data, uint32_t count);
132 extern uint8_t Attach (void);
135 extern uint8_t Run (void);
138 extern uint8_t Step (void);
141 extern uint8_t Stop (void);
143 extern uint8_t Reset (void);
146 extern uint8_t WaitHalt (void);
147 
155 extern uint8_t ReadCore (uint8_t regno, uint32_t *data);
163 extern uint8_t WriteCore (uint8_t regno, uint32_t data);
164 
165 #endif // SWD_API_H
uint8_t Step(void)
Definition: swd-api.c:204
uint8_t SetAPSelect(uint8_t address)
Nastavení AP.
Definition: swd-api.c:22
uint8_t Attach(void)
Definition: swd-api.c:103
uint8_t Connect(uint32_t *CoreID)
Připojení k cíli.
Definition: swd-api.c:64
uint8_t ReadAP2(uint8_t address, uint32_t *data)
Čtení AP dvakrát.
Definition: swd-api.c:45
uint8_t WriteAP(uint8_t address, uint32_t data)
Zápis AP.
Definition: swd-api.c:53
uint8_t ReadDP(uint8_t address, uint32_t *data)
Čtení DP.
Definition: swd-api.c:6
uint8_t ReadAP(uint8_t address, uint32_t *data)
Čtení AP.
Definition: swd-api.c:33
uint8_t WriteMemoryArray(uint32_t address, const uint32_t *data, uint32_t count)
Zápis bloku do paměti.
Definition: swd-api.c:174
uint8_t Stop(void)
Definition: swd-api.c:220
uint8_t Run(void)
Definition: swd-api.c:188
uint8_t WriteMemory(uint32_t address, uint32_t data)
Zápis slova do paměti.
Definition: swd-api.c:163
uint8_t ReadCore(uint8_t regno, uint32_t *data)
Čtení registru.
Definition: swd-api.c:256
uint8_t ReadMemoryArray(uint32_t address, uint32_t *data, uint32_t count)
Čtení bloku paměti.
Definition: swd-api.c:148
uint8_t WriteCore(uint8_t regno, uint32_t data)
Zápis do registru.
Definition: swd-api.c:265
uint8_t Reset(void)
Reset.
Definition: swd-api.c:236
uint8_t WaitHalt(void)
Definition: swd-api.c:274
uint8_t WriteDP(uint8_t address, uint32_t data)
Zápis DP.
Definition: swd-api.c:14
uint8_t ReadMemory(uint32_t address, uint32_t *data)
Čtení slova paměti.
Definition: swd-api.c:140