summaryrefslogtreecommitdiff
path: root/doc/dev/app-example/main.c
blob: b8e64b25954ba4ab89b37ea60045307138958cb6 (plain)
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;
}