28
28
#include "DAP_config.h"
29
29
#include "DAP.h"
30
30
#include "target_family.h"
31
+ #include "device.h"
31
32
32
33
// Default NVIC and Core debug base addresses
33
34
// TODO: Read these addresses from ROM.
45
46
#define MAX_SWD_RETRY 100//10
46
47
#define MAX_TIMEOUT 1000000 // Timeout for syscalls on target
47
48
48
- #define SCB_AIRCR_PRIGROUP_Pos 8 /*!< SCB AIRCR: PRIGROUP Position */
49
+ // Use the CMSIS-Core definition if available.
50
+ #if !defined(SCB_AIRCR_PRIGROUP_Pos )
51
+ #define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */
49
52
#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */
53
+ #endif
50
54
51
55
typedef struct {
52
56
uint32_t select ;
@@ -709,7 +713,7 @@ uint8_t swd_flash_syscall_exec(const program_syscall_t *sysCallParam, uint32_t e
709
713
if (!swd_read_core_register (0 , & state .r [0 ])) {
710
714
return 0 ;
711
715
}
712
-
716
+
713
717
//remove the C_MASKINTS
714
718
if (!swd_write_word (DBG_HCSR , DBGKEY | C_DEBUGEN | C_HALT )) {
715
719
return 0 ;
@@ -795,7 +799,7 @@ uint8_t swd_init_debug(void)
795
799
// init dap state with fake values
796
800
dap_state .select = 0xffffffff ;
797
801
dap_state .csw = 0xffffffff ;
798
-
802
+
799
803
int8_t retries = 4 ;
800
804
int8_t do_abort = 0 ;
801
805
do {
@@ -829,9 +833,9 @@ uint8_t swd_init_debug(void)
829
833
if (!swd_write_dp (DP_SELECT , 0 )) {
830
834
do_abort = 1 ;
831
835
continue ;
832
-
836
+
833
837
}
834
-
838
+
835
839
// Power up
836
840
if (!swd_write_dp (DP_CTRL_STAT , CSYSPWRUPREQ | CDBGPWRUPREQ )) {
837
841
do_abort = 1 ;
@@ -870,11 +874,11 @@ uint8_t swd_init_debug(void)
870
874
do_abort = 1 ;
871
875
continue ;
872
876
}
873
-
877
+
874
878
return 1 ;
875
-
879
+
876
880
} while (-- retries > 0 );
877
-
881
+
878
882
return 0 ;
879
883
}
880
884
@@ -904,10 +908,10 @@ uint8_t swd_set_target_state_hw(TARGET_RESET_STATE state)
904
908
if (!swd_init_debug ()) {
905
909
return 0 ;
906
910
}
907
-
911
+
908
912
if (reset_connect == CONNECT_UNDER_RESET ) {
909
913
// Assert reset
910
- swd_set_target_reset (1 );
914
+ swd_set_target_reset (1 );
911
915
osDelay (2 );
912
916
}
913
917
@@ -926,17 +930,17 @@ uint8_t swd_set_target_state_hw(TARGET_RESET_STATE state)
926
930
if (!swd_write_word (DBG_EMCR , VC_CORERESET )) {
927
931
return 0 ;
928
932
}
929
-
933
+
930
934
if (reset_connect == CONNECT_NORMAL ) {
931
935
// Assert reset
932
- swd_set_target_reset (1 );
936
+ swd_set_target_reset (1 );
933
937
osDelay (2 );
934
938
}
935
-
939
+
936
940
// Deassert reset
937
941
swd_set_target_reset (0 );
938
942
osDelay (2 );
939
-
943
+
940
944
do {
941
945
if (!swd_read_word (DBG_HCSR , & val )) {
942
946
return 0 ;
0 commit comments