Skip to content

Commit b0c7240

Browse files
committed
adapted FW v.2.0
1 parent 51201e2 commit b0c7240

8 files changed

+53
-197
lines changed

SeeeduinoDapLink.code-workspace

-8
This file was deleted.

src/DAP.c src/DAP.cpp

+26-16
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#endif
3434
#include "DAP_config.h"
3535
#include "DAP.h"
36-
#include "dap_strings.h"
3736

3837
#if (DAP_PACKET_SIZE < 64U)
3938
#error "Minimum Packet Size is 64!"
@@ -62,14 +61,22 @@
6261
volatile uint8_t DAP_TransferAbort; // Transfer Abort Flag
6362

6463

65-
// static const char DAP_FW_Ver [] = DAP_FW_VER;
64+
#ifdef DAP_VENDOR
65+
const char DAP_Vendor [] = DAP_VENDOR;
66+
#endif
67+
#ifdef DAP_PRODUCT
68+
const char DAP_Product[] = DAP_PRODUCT;
69+
#endif
70+
#ifdef DAP_SER_NUM
71+
const char DAP_SerNum [] = DAP_SER_NUM;
72+
#endif
73+
const char DAP_FW_Ver [] = DAP_FW_VER;
6674

6775
#if TARGET_DEVICE_FIXED
68-
static const char TargetDeviceVendor [] = TARGET_DEVICE_VENDOR;
69-
static const char TargetDeviceName [] = TARGET_DEVICE_NAME;
76+
const char TargetDeviceVendor [] = TARGET_DEVICE_VENDOR;
77+
const char TargetDeviceName [] = TARGET_DEVICE_NAME;
7078
#endif
7179

72-
7380
// Get DAP Information
7481
// id: info identifier
7582
// info: pointer to info data
@@ -79,23 +86,26 @@ static uint8_t DAP_Info(uint8_t id, uint8_t *info) {
7986

8087
switch (id) {
8188
case DAP_ID_VENDOR:
82-
length = DAP_GetVendorString((char *)info);
89+
#ifdef DAP_VENDOR
90+
memcpy(info, DAP_Vendor, sizeof(DAP_Vendor));
91+
length = (uint8_t)sizeof(DAP_Vendor);
92+
#endif
8393
break;
8494
case DAP_ID_PRODUCT:
85-
length = DAP_GetProductString((char *)info);
95+
#ifdef DAP_PRODUCT
96+
memcpy(info, DAP_Product, sizeof(DAP_Product));
97+
length = (uint8_t)sizeof(DAP_Product);
98+
#endif
8699
break;
87100
case DAP_ID_SER_NUM:
88-
length = DAP_GetSerNumString((char *)info);
101+
#ifdef DAP_SER_NUM
102+
length = USBDevice.getSerialDescriptor((uint16_t*) info);
103+
#endif
89104
break;
90-
case DAP_ID_FW_VER: {
91-
// --- begin DAPLink change ---
92-
length = DAP_GetFirmwareVersionString((char *)info);
93-
// Original:
94-
// memcpy(info, DAP_FW_Ver, sizeof(DAP_FW_Ver));
95-
// length = (uint8_t)sizeof(DAP_FW_Ver);
96-
// --- end DAPLink change ---
105+
case DAP_ID_FW_VER:
106+
memcpy(info, DAP_FW_Ver, sizeof(DAP_FW_Ver));
107+
length = (uint8_t)sizeof(DAP_FW_Ver);
97108
break;
98-
}
99109
case DAP_ID_DEVICE_VENDOR:
100110
#if TARGET_DEVICE_FIXED
101111
length = (uint8_t)sizeof(TargetDeviceVendor);

src/DAP.h

+1
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,4 @@ __STATIC_FORCEINLINE void PIN_DELAY_FAST (void) {
330330

331331

332332
#endif /* __DAP_H__ */
333+

src/DAP_config.h

+26-19
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
// #include "HID-Project.h"
2626
// #endif
2727

28+
2829
#ifndef __DAP_CONFIG_H__
2930
#define __DAP_CONFIG_H__
3031

@@ -123,7 +124,7 @@ Provides definitions about:
123124
#define SWO_STREAM 0 ///< SWO Streaming Trace: 1 = available, 0 = not available.
124125

125126
/// Clock frequency of the Test Domain Timer. Timer value is returned with \ref TIMESTAMP_GET.
126-
#define TIMESTAMP_CLOCK 100000000U ///< Timestamp clock in Hz (0 = timestamps not supported).
127+
#define TIMESTAMP_CLOCK 48000000U ///< Timestamp clock in Hz (0 = timestamps not supported).
127128
/// Debug Unit is connected to fixed Target Device.
128129
/// The Debug Unit may be part of an evaluation board and always connected to a fixed
129130
/// known device. In this case a Device Vendor and Device Name string is stored which
@@ -202,7 +203,7 @@ Provides definitions about:
202203
//**************************************************************************************************
203204
//**
204205
//Faster Port Manipulation
205-
inline void digitalWrite_fast(int pin, bool val)
206+
inline void digitalWrite_fast_(int pin, bool val)
206207
{
207208
if (val)
208209
PORT->Group[g_APinDescription[pin].ulPort].OUTSET.reg = (1ul << g_APinDescription[pin].ulPin);
@@ -211,7 +212,7 @@ inline void digitalWrite_fast(int pin, bool val)
211212
}
212213

213214

214-
inline int digitalRead_fast(int pin)
215+
inline int digitalRead_fast_(int pin)
215216
{
216217
return !!(PORT->Group[g_APinDescription[pin].ulPort].IN.reg & (1ul << g_APinDescription[pin].ulPin));
217218
}
@@ -308,7 +309,7 @@ Set the SWCLK/TCK DAP hardware I/O pin to high level.
308309
*/
309310
static __forceinline void PIN_SWCLK_TCK_SET (void) {
310311
if(Fast){
311-
digitalWrite_fast(PIN_SWCLK, HIGH);}
312+
digitalWrite_fast_(PIN_SWCLK, HIGH);}
312313
else{
313314
digitalWrite(PIN_SWCLK, HIGH); }
314315
}
@@ -318,7 +319,7 @@ Set the SWCLK/TCK DAP hardware I/O pin to low level.
318319
*/
319320
static __forceinline void PIN_SWCLK_TCK_CLR (void) {
320321
if(Fast){
321-
digitalWrite_fast(PIN_SWCLK, LOW);}
322+
digitalWrite_fast_(PIN_SWCLK, LOW);}
322323
else {
323324
digitalWrite(PIN_SWCLK, HIGH);}
324325
}
@@ -331,7 +332,7 @@ static __forceinline void PIN_SWCLK_TCK_CLR (void) {
331332
*/
332333
static __forceinline uint32_t PIN_SWDIO_TMS_IN (void) {
333334
if(Fast){
334-
return (digitalRead_fast(PIN_SWDIO) == HIGH) ? 1 : 0;}
335+
return (digitalRead_fast_(PIN_SWDIO) == HIGH) ? 1 : 0;}
335336
else {
336337
return (digitalRead(PIN_SWDIO) == HIGH) ? 1 : 0;}
337338

@@ -342,7 +343,7 @@ Set the SWDIO/TMS DAP hardware I/O pin to high level.
342343
*/
343344
static __forceinline void PIN_SWDIO_TMS_SET (void) {
344345
if(Fast){
345-
digitalWrite_fast(PIN_SWDIO, HIGH);}
346+
digitalWrite_fast_(PIN_SWDIO, HIGH);}
346347
else {
347348
digitalWrite(PIN_SWDIO, HIGH);}
348349

@@ -353,7 +354,7 @@ Set the SWDIO/TMS DAP hardware I/O pin to low level.
353354
*/
354355
static __forceinline void PIN_SWDIO_TMS_CLR (void) {
355356
if(Fast){
356-
digitalWrite_fast(PIN_SWDIO, LOW);}
357+
digitalWrite_fast_(PIN_SWDIO, LOW);}
357358
else {
358359
digitalWrite(PIN_SWDIO, LOW);}
359360
}
@@ -363,7 +364,7 @@ static __forceinline void PIN_SWDIO_TMS_CLR (void) {
363364
*/
364365
static __forceinline uint32_t PIN_SWDIO_IN (void) {
365366
if(Fast){
366-
return (digitalRead_fast(PIN_SWDIO) == HIGH) ? 1 : 0;}
367+
return (digitalRead_fast_(PIN_SWDIO) == HIGH) ? 1 : 0;}
367368
else {
368369
return (digitalRead(PIN_SWDIO) == HIGH) ? 1 : 0;}
369370
}
@@ -373,7 +374,7 @@ static __forceinline uint32_t PIN_SWDIO_IN (void) {
373374
*/
374375
static __forceinline void PIN_SWDIO_OUT (uint32_t bit) {
375376
if(Fast){
376-
digitalWrite_fast(PIN_SWDIO, (bit & 1) ? HIGH : LOW);}
377+
digitalWrite_fast_(PIN_SWDIO, (bit & 1) ? HIGH : LOW);}
377378
else {
378379
digitalWrite(PIN_SWDIO, (bit & 1) ? HIGH : LOW);}
379380
}
@@ -402,7 +403,7 @@ static __forceinline void PIN_SWDIO_OUT_DISABLE (void) {
402403
*/
403404
static __forceinline uint32_t PIN_TDI_IN (void) {
404405
if(Fast){
405-
return (digitalRead_fast(PIN_TDI) == HIGH) ? 1 : 0;}
406+
return (digitalRead_fast_(PIN_TDI) == HIGH) ? 1 : 0;}
406407
else{
407408
return (digitalRead(PIN_TDI) == HIGH) ? 1 : 0;}
408409
}
@@ -412,7 +413,7 @@ else{
412413
*/
413414
static __forceinline void PIN_TDI_OUT (uint32_t bit) {
414415
if(Fast){
415-
digitalWrite_fast(PIN_TDI, (bit & 1) ? HIGH : LOW);}
416+
digitalWrite_fast_(PIN_TDI, (bit & 1) ? HIGH : LOW);}
416417
else{
417418
digitalWrite(PIN_TDI, (bit & 1) ? HIGH : LOW);}
418419
}
@@ -425,7 +426,7 @@ else{
425426
*/
426427
static __forceinline uint32_t PIN_TDO_IN (void) {
427428
if(Fast){
428-
return (digitalRead_fast(PIN_TDO) == HIGH) ? 1 : 0;}
429+
return (digitalRead_fast_(PIN_TDO) == HIGH) ? 1 : 0;}
429430
else{
430431
return (digitalRead(PIN_TDO) == HIGH) ? 1 : 0;}
431432
}
@@ -456,7 +457,7 @@ static __forceinline void PIN_nTRST_OUT (uint32_t bit) {
456457
*/
457458
static __forceinline uint32_t PIN_nRESET_IN (void) {
458459
if(Fast){
459-
return (digitalRead_fast(PIN_nRESET) == HIGH) ? 1 : 0;}
460+
return (digitalRead_fast_(PIN_nRESET) == HIGH) ? 1 : 0;}
460461
else{
461462
return (digitalRead(PIN_nRESET) == HIGH) ? 1 : 0;}
462463
}
@@ -468,7 +469,7 @@ else{
468469
*/
469470
static __forceinline void PIN_nRESET_OUT (uint32_t bit) {
470471
if(Fast){
471-
digitalWrite_fast(PIN_nRESET, (bit & 1) ? HIGH : LOW);}
472+
digitalWrite_fast_(PIN_nRESET, (bit & 1) ? HIGH : LOW);}
472473
else{
473474
digitalWrite(PIN_nRESET, (bit & 1) ? HIGH : LOW);}
474475
}
@@ -496,7 +497,7 @@ It is recommended to provide the following LEDs for status indication:
496497
*/
497498
static __inline void LED_CONNECTED_OUT (uint32_t bit) {
498499
if(Fast){
499-
digitalWrite_fast(PIN_LED_CONNECTED, bit ? HIGH : LOW);}
500+
digitalWrite_fast_(PIN_LED_CONNECTED, bit ? HIGH : LOW);}
500501
else{
501502
digitalWrite(PIN_LED_CONNECTED, bit ? HIGH : LOW);}
502503
}
@@ -508,7 +509,7 @@ else{
508509
*/
509510
static __inline void LED_RUNNING_OUT (uint32_t bit) {
510511
if(Fast){
511-
digitalWrite_fast(PIN_LED_RUNNING, bit ? HIGH : LOW);}
512+
digitalWrite_fast_(PIN_LED_RUNNING, bit ? HIGH : LOW);}
512513
else{
513514
digitalWrite(PIN_LED_RUNNING, bit ? HIGH : LOW);}
514515
}
@@ -531,7 +532,14 @@ default, the DWT timer is used. The frequency of this timer is configured with
531532
\return Current timestamp value.
532533
*/
533534
__STATIC_INLINE uint32_t TIMESTAMP_GET (void) {
534-
return (DWT->CYCCNT) / (CPU_CLOCK / TIMESTAMP_CLOCK);
535+
uint32_t ticks = SysTick->VAL;
536+
// Configure SysTick to trigger every millisecond using the CPU Clock
537+
SysTick->CTRL = 0; // Disable SysTick
538+
SysTick->LOAD = 0xFFFFFF; // Set reload register for MAX Value
539+
SysTick->VAL = 0; // Reset the SysTick counter value
540+
SysTick->CTRL = 0x00000005; // Enable SysTick,No Interrupt, Use CPU Clock
541+
return(ticks);
542+
//return (DWT->CYCCNT) / (CPU_CLOCK / TIMESTAMP_CLOCK);
535543
}
536544

537545
///@}
@@ -580,4 +588,3 @@ static __inline uint32_t RESET_TARGET (void) {
580588

581589

582590
#endif /* __DAP_CONFIG_H__ */
583-

src/JTAG_DP.c src/JTAG_DP.cpp

File renamed without changes.

src/SW_DP.c src/SW_DP.cpp

File renamed without changes.

src/dap_strings.h

-62
This file was deleted.

0 commit comments

Comments
 (0)