File: main.c

package info (click to toggle)
stlink 1.7.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,464 kB
  • sloc: ansic: 12,183; asm: 219; makefile: 86; sh: 50
file content (28 lines) | stat: -rw-r--r-- 518 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <stdlib.h>
#include <stlink.h>

static stlink_t *stlink_open_first(void) {
    stlink_t* sl = NULL;
    sl = stlink_v1_open(0, 1);
    if (sl == NULL)
        sl = stlink_open_usb(0, 1, NULL);

    return sl;
}


int main() {
    stlink_t* sl = NULL;
    sl = stlink_open_first();

    if (sl == NULL) {
        fprintf(stderr, "Failed to open stlink device ;(\n");
        exit(1);
    }

    fprintf(stderr, "STlink device opened, that's cool!\n");
    stlink_close(sl);

    return 0;
}