remove the keypress to exit the app
[fw/stlink] / src / test_usb.c
1 #include <stdio.h>
2 #include "stlink-common.h"
3
4
5 int main(int ac, char** av) {
6     stlink_t* sl;
7
8     sl = stlink_open_usb(NULL, 10);
9     if (sl != NULL) {
10         printf("-- version\n");
11         stlink_version(sl);
12
13         if (stlink_current_mode(sl) == STLINK_DEV_DFU_MODE) {
14             printf("-- exit_dfu_mode\n");
15             stlink_exit_dfu_mode(sl);
16         }
17
18         printf("-- enter_swd_mode\n");
19         stlink_enter_swd_mode(sl);
20
21         printf("-- current_mode\n");
22         stlink_current_mode(sl);
23
24         /*     printf("-- core_id\n"); */
25         /*     stlink_core_id(sl); */
26
27         printf("-- read_sram\n");
28         static const uint32_t sram_base = 0x8000000;
29         uint32_t off;
30         for (off = 0; off < 16; off += 4)
31             stlink_read_mem32(sl, sram_base + off, 4);
32
33         printf("-- read_mem, cpuid\n");
34         stlink_read_mem32(sl, 0xe000e008, 4);
35         /*     stlink_read_mem32(sl, 0xe000ed90, 4); */
36         /*     stlink_read_mem32(sl, 0xe000edf0, 4); */
37         /*     stlink_read_mem32(sl, 0x4001100c, 4); */
38
39         printf("-- status\n");
40         stlink_status(sl);
41
42         printf("-- reset\n");
43         stlink_reset(sl);
44
45         printf("-- status\n");
46         stlink_status(sl);
47
48         printf("-- step\n");
49         stlink_step(sl);
50
51         printf("-- run\n");
52         stlink_run(sl);
53
54         printf("-- exit_debug_mode\n");
55         stlink_exit_debug_mode(sl);
56
57         stlink_close(sl);
58     }
59
60     return 0;
61 }