Skip to content

Commit 51201e2

Browse files
committed
Revised code to V2.0 + Fast Port Manipulation
1 parent 5b09536 commit 51201e2

File tree

5 files changed

+281
-86
lines changed

5 files changed

+281
-86
lines changed

src/DAP.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* CMSIS-DAP Interface Firmware
1+
/*
22
* Copyright (c) 2013-2017 ARM Limited. All rights reserved.
3+
* Copyright 2019, Cypress Semiconductor Corporation
4+
* or a subsidiary of Cypress Semiconductor Corporation.
35
*
46
* SPDX-License-Identifier: Apache-2.0
57
*
@@ -31,9 +33,7 @@
3133
#endif
3234
#include "DAP_config.h"
3335
#include "DAP.h"
34-
/* #include "info.h"
35-
#include "dap_strings.h" */
36-
36+
#include "dap_strings.h"
3737

3838
#if (DAP_PACKET_SIZE < 64U)
3939
#error "Minimum Packet Size is 64!"

src/DAP.h

+36-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* CMSIS-DAP Interface Firmware
2-
* Copyright (c) 2013-2017 ARM Limited. All rights reserved.
1+
/*
2+
* Copyright (c) 2013-2019 ARM Limited. All rights reserved.
3+
* Copyright 2019, Cypress Semiconductor Corporation
4+
* or a subsidiary of Cypress Semiconductor Corporation.
35
*
46
* SPDX-License-Identifier: Apache-2.0
57
*
@@ -17,7 +19,7 @@
1719
*
1820
* ----------------------------------------------------------------------
1921
*
20-
* $Date: 1. December 2017
22+
* $Date: 26. November 2019
2123
* $Revision: V2.0.0
2224
*
2325
* Project: CMSIS-DAP Include
@@ -101,6 +103,11 @@
101103
#define ID_DAP_Vendor30 0x9EU
102104
#define ID_DAP_Vendor31 0x9FU
103105

106+
// DAP Extended range of Vendor Command IDs
107+
108+
#define ID_DAP_VendorExFirst 0xA0U
109+
#define ID_DAP_VendorExLast 0xFEU
110+
104111
#define ID_DAP_Invalid 0xFFU
105112

106113
// DAP Status Code
@@ -194,7 +201,7 @@
194201

195202
#include <stddef.h>
196203
#include <stdint.h>
197-
//#include "cmsis_compiler.h"
204+
#include "cmsis_compiler.h"
198205

199206
// DAP Data structure
200207
typedef struct {
@@ -233,6 +240,11 @@ extern DAP_Data_t DAP_Data; // DAP Data
233240
extern volatile uint8_t DAP_TransferAbort; // Transfer Abort Flag
234241

235242

243+
#ifdef __cplusplus
244+
extern "C"
245+
{
246+
#endif
247+
236248
// Functions
237249
extern void SWJ_Sequence (uint32_t count, const uint8_t *data);
238250
extern void SWD_Sequence (uint32_t info, const uint8_t *swdo, uint8_t *swdi);
@@ -279,28 +291,42 @@ extern void DAP_Setup (void);
279291
#ifndef DELAY_SLOW_CYCLES
280292
#define DELAY_SLOW_CYCLES 3U // Number of cycles for one iteration
281293
#endif
294+
#if defined(__CC_ARM)
282295
__STATIC_FORCEINLINE void PIN_DELAY_SLOW (uint32_t delay) {
283-
uint32_t count;
284-
285-
count = delay;
296+
uint32_t count = delay;
286297
while (--count);
287298
}
299+
#else
300+
__STATIC_FORCEINLINE void PIN_DELAY_SLOW (uint32_t delay) {
301+
__ASM volatile (
302+
".syntax unified\n"
303+
"0:\n\t"
304+
"subs %0,%0,#1\n\t"
305+
"bne 0b\n"
306+
: "+l" (delay) : : "cc"
307+
);
308+
}
309+
#endif
288310

289311
// Fixed delay for fast clock generation
290312
#ifndef DELAY_FAST_CYCLES
291313
#define DELAY_FAST_CYCLES 0U // Number of cycles: 0..3
292314
#endif
293315
__STATIC_FORCEINLINE void PIN_DELAY_FAST (void) {
294316
#if (DELAY_FAST_CYCLES >= 1U)
295-
__nop();
317+
__NOP();
296318
#endif
297319
#if (DELAY_FAST_CYCLES >= 2U)
298-
__nop();
320+
__NOP();
299321
#endif
300322
#if (DELAY_FAST_CYCLES >= 3U)
301-
__nop();
323+
__NOP();
302324
#endif
303325
}
304326

327+
#ifdef __cplusplus
328+
}
329+
#endif
330+
305331

306332
#endif /* __DAP_H__ */

0 commit comments

Comments
 (0)