Skip to content

USB reworked #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0c3f8e7
Create USBHIDComposite library by adding library properties
Jul 27, 2017
7600dec
Add descriptor to USB HID library
Jul 27, 2017
861aba3
Rework usb descriptor files to leave only common descriptors in varia…
Jul 27, 2017
0518fd2
Move USB HID class functions inside the library
Jul 27, 2017
1f92459
Add USB HID library API
Jul 27, 2017
74f57d8
Remove usb interface because no more required
Jul 27, 2017
dc146ec
Remove USB HID option in USB interface menu because we only need to s…
Jul 27, 2017
6c3e677
Update Keyword library: uses HID library
Jul 27, 2017
8546a63
Update Mouse library: uses HID library
Jul 27, 2017
2aca1c7
Remove some 'unused parameters' warnings
Jul 28, 2017
8f347b1
Fix: wrong array used in keyboard setup
Jul 28, 2017
c9d463e
Add syntax coloring map
Jul 28, 2017
58d357d
Add a readme file
Jul 28, 2017
e6fef78
Fist port USB CDC
fpistm Aug 18, 2017
45421cb
Merge branch 'test_usb' into rework_usb
Aug 23, 2017
64fdc24
Create USBSerial library
Aug 23, 2017
f7ec604
Move USB CDC definition inside library
Aug 23, 2017
d14aeba
Move usb serial class inside library
Aug 23, 2017
f7b91f7
Rename USB serial files to match with library name
Aug 23, 2017
5bec940
Remove old file path
Aug 23, 2017
83dc291
Add CDC descriptors
Aug 23, 2017
944e747
Move CDC file inside library
Aug 23, 2017
c96c4aa
Remove unused flag
Aug 23, 2017
4ba7c68
Adapt USBSerial class for the library
Aug 23, 2017
0996b43
Add an example
Aug 23, 2017
26254f7
Update all usb configuration files
Aug 23, 2017
f4bf79c
Remove some warnings in USBSerial library
Aug 23, 2017
ba26177
Improve USBSerial example
Aug 23, 2017
3219970
Move USB libraries source files to src/ repository
Sep 6, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 9 additions & 17 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -346,26 +346,18 @@ Disco.menu.Other_serial.enable_Serial2=Serial2 (if available)
Disco.menu.Other_serial.enable_Serial2.build.enable_Serialx=-DENABLE_SERIAL2

# USB connectivity
Nucleo_144.menu.USB_interface.enable_USB=None
Nucleo_144.menu.USB_interface.enable_HID=HID keyboard and mouse support (if available)
Nucleo_144.menu.USB_interface.enable_HID.build.enable_usb={build.usb_flags} -DUSBD_USE_HID_COMPOSITE
#Nucleo_144.menu.USB_interface.enable_CDC=CDC (if available)
#Nucleo_144.menu.USB_interface.enable_CDC.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC -DUSE_USB_FS
Nucleo_144.menu.USB_interface.enable_usb=None
Nucleo_144.menu.USB_interface.enable_usb_periph=Enable USB (if available)
Nucleo_144.menu.USB_interface.enable_usb_periph.build.enable_usb={build.usb_flags}

Nucleo_64.menu.USB_interface.enable_USB=None
Nucleo_64.menu.USB_interface.enable_HID=HID keyboard and mouse support (if available)
Nucleo_64.menu.USB_interface.enable_HID.build.enable_usb={build.usb_flags} -DUSBD_USE_HID_COMPOSITE
#Nucleo_64.menu.USB_interface.enable_CDC=CDC (if available)
#Nucleo_64.menu.USB_interface.enable_CDC.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC -DUSE_USB_FS
Nucleo_64.menu.USB_interface.enable_usb_periph=Enable USB (if available)
Nucleo_64.menu.USB_interface.enable_usb_periph.build.enable_usb={build.usb_flags}

Nucleo_32.menu.USB_interface.enable_USB=None
Nucleo_32.menu.USB_interface.enable_HID=HID keyboard and mouse support (if available)
Nucleo_32.menu.USB_interface.enable_HID.build.enable_usb={build.usb_flags} -DUSBD_USE_HID_COMPOSITE
#Nucleo_32.menu.USB_interface.enable_CDC=CDC (if available)
#Nucleo_32.menu.USB_interface.enable_CDC.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC -DUSE_USB_FS
Nucleo_32.menu.USB_interface.enable_usb_periph=Enable USB (if available)
Nucleo_32.menu.USB_interface.enable_usb_periph.build.enable_usb={build.usb_flags}

Disco.menu.USB_interface.enable_USB=None
Disco.menu.USB_interface.enable_HID=HID keyboard and mouse support (if available)
Disco.menu.USB_interface.enable_HID.build.enable_usb={build.usb_flags} -DUSBD_USE_HID_COMPOSITE
#Disco.menu.USB_interface.enable_CDC=CDC (if available)
#Disco.menu.USB_interface.enable_CDC.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC -DUSE_USB_FS
Disco.menu.USB_interface.enable_usb_periph=Enable USB (if available)
Disco.menu.USB_interface.enable_usb_periph.build.enable_usb={build.usb_flags}
3 changes: 0 additions & 3 deletions cores/arduino/chip.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
#include "timer.h"
#include "twi.h"
#include "stm32_eeprom.h"
#ifdef USBCON
#include "usb_interface.h"
#endif //USBCON

#include "ethernet.h"

Expand Down
4 changes: 0 additions & 4 deletions cores/arduino/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ int main( void )
{
initVariant();

#if defined(USBCON)
usbd_interface_init();
#endif

setup();

for (;;)
Expand Down
13 changes: 12 additions & 1 deletion cores/arduino/stm32/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@ uint32_t getTimerIrq(TIM_TypeDef* tim)
*/
void TimerHandleDeinit(stimer_t *obj)
{
HAL_TIM_Base_DeInit(&(obj->handle));
HAL_TIM_Base_Stop_IT(&(obj->handle));
HAL_TIM_Base_DeInit(&(obj->handle));
}

/**
Expand Down Expand Up @@ -1024,6 +1024,17 @@ void attachIntHandle(stimer_t *obj, void (*irqHandle)(stimer_t *))
obj->irqHandle = irqHandle;
}

/**
* @brief Attached an interrupt handler
* @param htim : TIM handle
* @param irqHandle : interrupt handler
* @retval none
*/
void timer_attach_interrupt_handle(TIM_HandleTypeDef *htim, void (*irqHandle)(stimer_t *))
{
stimer_t *obj = get_timer_obj(htim);
obj->irqHandle = irqHandle;
}

/******************************************************************************/
/* TIMx IRQ HANDLER */
Expand Down
1 change: 1 addition & 0 deletions cores/arduino/stm32/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ struct timer_s{

void timer_enable_clock(TIM_HandleTypeDef *htim);
void timer_disable_clock(TIM_HandleTypeDef *htim);
void timer_attach_interrupt_handle(TIM_HandleTypeDef *htim, void (*irqHandle)(stimer_t *));

void TimerHandleInit(stimer_t *obj, uint16_t period, uint16_t prescaler);
void TimerHandleDeinit(stimer_t *obj);
Expand Down
173 changes: 0 additions & 173 deletions cores/arduino/stm32/usb_interface.c

This file was deleted.

2 changes: 2 additions & 0 deletions cores/arduino/wiring.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#ifndef _WIRING_
#define _WIRING_

#include <clock.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand Down
6 changes: 4 additions & 2 deletions libraries/Keyboard/src/Keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

#include "Keyboard.h"
#include "usbd_hid_composite.h"
#include "USBHIDComposite.h"

#if defined(USBCON)

Expand All @@ -34,18 +34,20 @@ Keyboard_::Keyboard_(void)

void Keyboard_::begin(void)
{
HID.begin();
}

void Keyboard_::end(void)
{
HID.end();
}

void Keyboard_::sendReport(KeyReport* keys)
{
uint8_t buf[8] = {keys->modifiers, keys->reserved, keys->keys[0], keys->keys[1],
keys->keys[2], keys->keys[3], keys->keys[4], keys->keys[5]};

usbd_interface_keyboard_sendReport(buf, 8);
HID.keyboardSend(buf, 8);

//delay required to prevent persistent key when call print
delay(20);
Expand Down
4 changes: 2 additions & 2 deletions libraries/Keyboard/src/Keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

#include <Arduino.h>

#if !defined(USBCON) || !defined(USBD_USE_HID_COMPOSITE)
#if !defined(USBCON)

#error "USB HID not enabled! Select 'HID' in the 'Tools->USB interface' menu."
#error "USB not enabled! Select 'USB Enable' in the 'Tools->USB interface' menu."

#else

Expand Down
6 changes: 4 additions & 2 deletions libraries/Mouse/src/Mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

#include "Mouse.h"
#include "usbd_hid_composite.h"
#include "USBHIDComposite.h"

#if defined(USBCON)

Expand All @@ -34,10 +34,12 @@ Mouse_::Mouse_(void) : _buttons(0)

void Mouse_::begin(void)
{
HID.begin();
}

void Mouse_::end(void)
{
HID.end();
}

void Mouse_::click(uint8_t b)
Expand All @@ -56,7 +58,7 @@ void Mouse_::move(signed char x, signed char y, signed char wheel)
m[2] = y;
m[3] = wheel;

usbd_interface_mouse_sendReport(m, 4);
HID.mouseSend(m, 4);
}

void Mouse_::buttons(uint8_t b)
Expand Down
4 changes: 2 additions & 2 deletions libraries/Mouse/src/Mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

#include <Arduino.h>

#if !defined(USBCON) || !defined(USBD_USE_HID_COMPOSITE)
#if !defined(USBCON)

#error "USB HID not enabled! Select 'HID' in the 'Tools->USB interface' menu."
#error "USB not enabled! Select 'USB Enable' in the 'Tools->USB interface' menu."

#else

Expand Down
14 changes: 14 additions & 0 deletions libraries/USBHIDComposite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# USBHIDComposite

Arduino library to provide USB HID class with Mouse and Keyboard descriptors.

This library functions allow to configure the USB peripheral and to send mouse
and keyboard report descriptors.

* HID.begin()
* HID.end()
* HID.mouseSend()
* HID.keyboardSend()

For more information about this library please visit us at
https://github.com/stm32duino/Arduino_Core_STM32
22 changes: 22 additions & 0 deletions libraries/USBHIDComposite/keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#######################################
# Syntax Coloring Map For HID
#######################################

#######################################
# Datatypes (KEYWORD1)
#######################################

HID KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
#######################################

begin KEYWORD2
end KEYWORD2
mouseSend KEYWORD2
keyboardSend KEYWORD2

#######################################
# Constants (LITERAL1)
#######################################
Loading