- u8 trans_mode;
- u8 trans_rw;
- u8 ack;
-} swjdp_common_t;
-
-/* Internal functions used in the module, partial transactions, use with caution */
-extern int dap_dp_write_reg(swjdp_common_t *swjdp, u32 value, u8 reg_addr);
-/* extern int swjdp_write_apacc(swjdp_common_t *swjdp, u32 value, u8 reg_addr); */
-extern int dap_dp_read_reg(swjdp_common_t *swjdp, u32 *value, u8 reg_addr);
-/* extern int swjdp_read_apacc(swjdp_common_t *swjdp, u32 *value, u8 reg_addr); */
-extern int dap_setup_accessport(swjdp_common_t *swjdp, u32 csw, u32 tar);
-extern int dap_ap_select(swjdp_common_t *swjdp,u8 apsel);
-
-extern int dap_ap_write_reg(swjdp_common_t *swjdp, u32 reg_addr, u8* out_value_buf);
-extern int dap_ap_write_reg_u32(swjdp_common_t *swjdp, u32 reg_addr, u32 value);
-extern int dap_ap_read_reg(swjdp_common_t *swjdp, u32 reg_addr, u8 *in_value_buf);
-extern int dap_ap_read_reg_u32(swjdp_common_t *swjdp, u32 reg_addr, u32 *value);
-
-/* External interface, partial operations must be completed with swjdp_transaction_endcheck() */
-extern int swjdp_transaction_endcheck(swjdp_common_t *swjdp);
-
-/* MEM-AP memory mapped bus single u32 register transfers, without endcheck */
-extern int mem_ap_read_u32(swjdp_common_t *swjdp, u32 address, u32 *value);
-extern int mem_ap_write_u32(swjdp_common_t *swjdp, u32 address, u32 value);
-
-/* MEM-AP memory mapped bus transfers, single registers, complete transactions */
-extern int mem_ap_read_atomic_u32(swjdp_common_t *swjdp, u32 address, u32 *value);
-extern int mem_ap_write_atomic_u32(swjdp_common_t *swjdp, u32 address, u32 value);
+ uint8_t ack;
+
+ /**
+ * Configures how many extra tck clocks are added after starting a
+ * MEM-AP access before we try to read its status (and/or result).
+ */
+ uint32_t memaccess_tck;
+ /* Size of TAR autoincrement block, ARM ADI Specification requires at least 10 bits */
+ uint32_t tar_autoincr_block;
+
+};
+
+/** Accessor for currently selected DAP-AP number (0..255) */
+static inline uint8_t dap_ap_get_select(struct swjdp_common *swjdp)
+{
+ return (uint8_t)(swjdp ->apsel >> 24);
+}
+
+/* AP selection applies to future AP transactions */
+void dap_ap_select(struct swjdp_common *dap,uint8_t apsel);
+
+/* Queued AP transactions */
+int dap_setup_accessport(struct swjdp_common *swjdp,
+ uint32_t csw, uint32_t tar);
+int dap_ap_write_reg_u32(struct swjdp_common *swjdp,
+ uint32_t addr, uint32_t value);
+int dap_ap_read_reg_u32(struct swjdp_common *swjdp,
+ uint32_t addr, uint32_t *value);
+
+/* Queued JTAG ops must be completed with jtagdp_transaction_endcheck() */
+int jtagdp_transaction_endcheck(struct swjdp_common *swjdp);
+
+/* Queued MEM-AP memory mapped single word transfers */
+int mem_ap_read_u32(struct swjdp_common *swjdp, uint32_t address, uint32_t *value);
+int mem_ap_write_u32(struct swjdp_common *swjdp, uint32_t address, uint32_t value);
+
+/* Synchronous MEM-AP memory mapped single word transfers */
+int mem_ap_read_atomic_u32(struct swjdp_common *swjdp,
+ uint32_t address, uint32_t *value);
+int mem_ap_write_atomic_u32(struct swjdp_common *swjdp,
+ uint32_t address, uint32_t value);