4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2010 Develer S.r.l. (http://www.develer.com/)
33 * \author Andrea Righi <arighi@develer.com>
35 * \brief BeRTOS Virtual USB Mouse.
37 * This project implements a HID USB device using the Olimex STM32-P103
38 * evaluation board. The virtual mouse can be connected to the USB port of a
41 * The WAKE_UP button on the board can be pressed to send to the host the mouse
42 * movement to draw a rectangle shape (taking the left button pressed).
44 * Example (mouse detection on Linux):
47 * [25361.710435] usb 1-8.1.3: new full speed USB device using ehci_hcd and address 33
48 * [25361.943901] usb 1-8.1.3: configuration #1 chosen from 1 choice
49 * [25362.004002] input: BeRTOS USB Mouse as /devices/pci0000:00/0000:00:1d.7/usb1/1-8/1-8.1/1-8.1.3/1-8.1.3:1.0/input/input19
50 * [25362.004738] generic-usb 0003:FFFF:0000.0008: input,hidraw3: USB HID v1.10 Mouse [BeRTOS USB Mouse] on usb-0000:00:1d.7-8.1.3/input0
54 #include "hw/hw_led.h"
56 #include <cfg/debug.h>
61 #include <drv/timer.h>
62 #include <drv/usbmouse.h>
64 static void init(void)
66 /* Enable all the interrupts */
69 /* Initialize debugging module (allow kprintf(), etc.) */
71 /* Initialize system timer */
73 /* Initialize LED driver */
75 /* Enable the WAKE_UP button */
77 /* Initialize the USB mouse device */
85 /* Hardware initialization */
88 /* Put your code here... */
89 kprintf("USB HID Mouse configured\n");
90 kbd_setRepeatMask(K_WAKEUP);
93 /* Wait until WAKE_UP is pressed */
96 /* Left button pressed down */
97 usbmouse_sendEvent(0, 0, BV(0));
101 for (i = 0; i < 25; i++)
103 usbmouse_sendEvent(-2, 0, BV(0));
107 for (i = 0; i < 25; i++)
109 usbmouse_sendEvent(0, 2, BV(0));
113 for (i = 0; i < 25; i++)
115 usbmouse_sendEvent(2, 0, BV(0));
119 for (i = 0; i < 25; i++)
121 usbmouse_sendEvent(0, -2, BV(0));
124 /* Left button released */
125 usbmouse_sendEvent(0, 0, 0);