Align loader to 32-bit boundary
[fw/stlink] / src / stlink-usb.h
1 /*
2  * File:   stlink-usb.h
3  * Author: karl
4  *
5  * Created on October 1, 2011, 11:29 PM
6  */
7
8 #ifndef STLINK_USB_H
9 #define STLINK_USB_H
10
11 #include <stdbool.h>
12 #include <libusb.h>
13
14 #include "stlink-common.h"
15 #include "uglylogging.h"
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 #define STLINK_SG_SIZE 31
22 #define STLINK_CMD_SIZE 16
23
24     struct stlink_libusb {
25         libusb_context* libusb_ctx;
26         libusb_device_handle* usb_handle;
27         unsigned int ep_req;
28         unsigned int ep_rep;
29         int protocoll;
30         unsigned int sg_transfer_idx;
31         unsigned int cmd_len;
32     };
33
34     /**
35      * Open a stlink
36      * @param verbose Verbosity loglevel
37      * @param reset   Reset stlink programmer
38      * @param serial  Serial number to search for, when NULL the first stlink found is opened (binary format)
39      * @retval NULL   Error while opening the stlink
40      * @retval !NULL  Stlink found and ready to use
41      */
42     stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[16]);
43     size_t stlink_probe_usb(stlink_t **stdevs[]);
44     void stlink_probe_usb_free(stlink_t **stdevs[], size_t size);
45
46 #ifdef __cplusplus
47 }
48 #endif
49
50 #endif /* STLINK_USB_H */
51