dap-test.c (1533B)
1 // Copyright 2014 Brian Swetland <swetland@frotz.net> 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #include <stdio.h> 16 #include <stdlib.h> 17 #include <string.h> 18 19 #include "dap.h" 20 21 u32 DATA[1024*1024]; 22 23 int dap_probe(DAP *dap); 24 25 int main(int argc, char **argv) { 26 JTAG *jtag; 27 DAP *dap; 28 unsigned n; 29 u32 x; 30 31 if (jtag_mpsse_open(&jtag)) return -1; 32 33 dap = dap_init(jtag, 0x4ba00477); 34 if (dap_attach(dap)) 35 return -1; 36 37 // dap_dp_rd(dap, DPACC_CSW, &x); 38 // printf("DPCSW=%08x\n", x); 39 40 dap_probe(dap); 41 42 #if 1 43 for (n = 0; n < 8; n++) { 44 x = 0xefefefef; 45 dap_mem_rd32(dap, 0, 0x00000000 + n*4, &x); 46 printf("%08x: %08x\n", n*4, x); 47 } 48 #endif 49 50 #if 0 51 for (n = 0; n < 1024*1024; n++) DATA[n] = n; 52 for (n = 0; n < 10; n++) 53 dap_mem_write(dap, 0, 0, DATA, 192*1024); 54 #endif 55 56 #if 0 57 if (dap_mem_read(dap, 0, 0, DATA, 4096) == 0) { 58 for (n = 0; n < 16; n++) printf("%08x ",DATA[n]); 59 printf("\n"); 60 } 61 //dap_mem_wr32(dap, 0, 0x10, 0x805038a1); 62 dap_dp_rd(dap, DPACC_CSW, &x); 63 printf("DPCSW=%08x\n", x); 64 #endif 65 return 0; 66 }