5
5
6
6
#include <stm32f1xx.h>
7
7
8
+ #include "platform/stm32f1/dbg.h"
8
9
#include "platform/stm32f1/flash.h"
10
+ #include "platform/stm32f1/gpio.h"
9
11
#include "platform/stm32f1/rcc.h"
10
12
#include "platform/stm32f1/systick.h"
13
+ #include "platform/stm32f1/usb.h"
14
+
15
+ #include "util/data.h"
16
+ #include "util/types.h"
17
+
18
+ #define CFG_TUSB_CONFIG_FILE "targets/stm32f1-generic/tusb_config.h"
19
+ #include "tusb.h"
20
+
21
+ #define OI_MOUSE_REPORT_ID 0x01
22
+
23
+ struct output_report {
24
+ u8 id ;
25
+ s8 x ;
26
+ s8 y ;
27
+ s8 wheel ;
28
+ u8 button1 : 1 ;
29
+ u8 button2 : 1 ;
30
+ u8 button3 : 1 ;
31
+ } __attribute__((__packed__ ));
11
32
12
33
int main ()
13
34
{
@@ -16,4 +37,24 @@ int main()
16
37
rcc_init (EXTERNAL_CLOCK_VALUE );
17
38
18
39
systick_init ();
40
+
41
+ struct gpio_config_t gpio_config ;
42
+ struct gpio_pin_t usb_dm_io = {.port = GPIO_PORT_A , .pin = 11 };
43
+ struct gpio_pin_t usb_dp_io = {.port = GPIO_PORT_A , .pin = 12 };
44
+ struct gpio_pin_t usb_dp_pu_io = USB_DP_PU_IO ;
45
+
46
+ gpio_init_config (& gpio_config );
47
+
48
+ gpio_setup_pin (& gpio_config , usb_dm_io , GPIO_MODE_INPUT | GPIO_CNF_INPUT_FLOATING , 0 ); /* USB DM */
49
+ gpio_setup_pin (& gpio_config , usb_dp_io , GPIO_MODE_INPUT | GPIO_CNF_INPUT_FLOATING , 0 ); /* USB DP */
50
+ gpio_setup_pin (
51
+ & gpio_config , usb_dp_pu_io , GPIO_MODE_OUTPUT_50MHZ | GPIO_CNF_OUTPUT_GENERAL_PUSH_PULL , 0 ); /* USB DP PU */
52
+
53
+ gpio_apply_config (gpio_config );
54
+
55
+ usb_init ();
56
+
57
+ for (;;) {
58
+ tud_task ();
59
+ }
19
60
}
0 commit comments