Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CI/codespell/.codespellignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ nwe
ore
shiftin
socio-economic
clen
64 changes: 64 additions & 0 deletions boards.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ add_subdirectory(CMSIS_DSP)
add_subdirectory(EEPROM)
add_subdirectory(IWatchdog)
add_subdirectory(Keyboard)
add_subdirectory(Mouse)
add_subdirectory(Mouse_STM32)
add_subdirectory(RGB_LED_TLC59731)
add_subdirectory(SPI)
add_subdirectory(Servo)
Expand Down
30 changes: 0 additions & 30 deletions libraries/Mouse/CMakeLists.txt

This file was deleted.

30 changes: 30 additions & 0 deletions libraries/Mouse_STM32/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# v3.21 implemented semantic changes regarding $<TARGET_OBJECTS:...>
# See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects
cmake_minimum_required(VERSION 3.21)

add_library(Mouse_STM32 INTERFACE)
add_library(Mouse_STM32_usage INTERFACE)

target_include_directories(Mouse_STM32_usage INTERFACE
src
)


target_link_libraries(Mouse_STM32_usage INTERFACE
base_config
)

target_link_libraries(Mouse_STM32 INTERFACE Mouse_STM32_usage)



add_library(Mouse_STM32_bin OBJECT EXCLUDE_FROM_ALL
src/Mouse_STM32.cpp
)
target_link_libraries(Mouse_STM32_bin PUBLIC Mouse_STM32_usage)

target_link_libraries(Mouse_STM32 INTERFACE
Mouse_STM32_bin
$<TARGET_OBJECTS:Mouse_STM32_bin>
)

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
https://www.arduino.cc/en/Tutorial/BuiltInExamples/ButtonMouseControl
*/

#include "Mouse.h"
#include "Mouse_STM32.h"

// set pin numbers for the five buttons:
const int upButton = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Datatypes (KEYWORD1)
#######################################

Mouse KEYWORD1
Mouse_STM32 KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name=Mouse
name=Mouse_STM32
version=1.1.0
author=Arduino, stm32duino
maintainer=stm32duino
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "Mouse.h"
#include "Mouse_STM32.h"

#if defined(USBCON)
#include "usbd_hid_composite_if.h"
Expand Down
File renamed without changes.
62 changes: 62 additions & 0 deletions libraries/USBDevice/examples/PluggableUSB-JoystickMouse/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include <Arduino.h>
#include "Mouse.h"
#include "Joystick.h"

#define LED PC13
#define HIGHPIN A7
#define ADCPIN A6
#define LOWPIN A5

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
JOYSTICK_TYPE_JOYSTICK, 0, 0,
true, false, false, false, false, false,
false, false, false, false, false);

int analogvalue = 0;

void setup()
{
Joystick.setXAxisRange(0, 255);
Joystick.begin();
Mouse.begin();
USB_Begin();
pinMode(HIGHPIN, OUTPUT);
pinMode(ADCPIN, INPUT);
pinMode(LOWPIN, OUTPUT);
digitalWrite(HIGHPIN, HIGH);
digitalWrite(LOWPIN, LOW);
pinMode(LED, OUTPUT);
}

bool high = false;
int loops = 0;

void loop()
{
auto last = analogvalue;
auto val = analogRead(ADCPIN);
analogvalue <<= 1;
analogvalue += val;
analogvalue /= 3;
if (analogvalue >> 2 != last >> 2)
{
Joystick.setXAxis(analogvalue >> 2);
}
delay(1);
loops++;
if (loops >= 500)
{
// every 500ms
loops = 0;
high = !high;
digitalWrite(LED, high ? HIGH : LOW);
if (high)
{
Mouse.move(10, 0);
}
else
{
Mouse.move(-10, 0);
}
}
}
28 changes: 28 additions & 0 deletions libraries/USBDevice/examples/PluggableUSB-SerialUSB/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <Arduino.h>
#include "USBCDC.h"

USBCDC USBSerial;

void setup()
{
USBSerial.begin(115200);
USB_Begin();
while (!USB_Running())
{
// wait until usb connected
delay(5);
}
while (!USBSerial)
{
//(optional) wait until Serial port is connected
delay(5);
}
}

void loop()
{
if (USBSerial.available())
{
USBSerial.print((char)USBSerial.read());
}
}
124 changes: 124 additions & 0 deletions libraries/USBDevice/inc/PluggableUSB/HID.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
Copyright (c) 2015, Arduino LLC
Original code (pre-library): Copyright (c) 2011, Peter Barrett
* Modified by Levi Gillis @ 2022-2025
Changes can be found in the git repo https://github.com/Levi--G/USBLibrarySTM32

Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
*/

#ifndef HID_STM32_h
#define HID_STM32_h

#if defined(USBCON) && defined(PLUGGABLE_USB_ENABLED)

#include "PluggableUSB.h"
#include <Arduino.h>
#include <stdint.h>

#define _USING_HID

// HID 'Driver'
// ------------
#define HID_GET_REPORT 0x01
#define HID_GET_IDLE 0x02
#define HID_GET_PROTOCOL 0x03
#define HID_SET_REPORT 0x09
#define HID_SET_IDLE 0x0A
#define HID_SET_PROTOCOL 0x0B

#define HID_HID_DESCRIPTOR_TYPE 0x21
#define HID_REPORT_DESCRIPTOR_TYPE 0x22
#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23

// HID subclass HID1.11 Page 8 4.2 Subclass
#define HID_SUBCLASS_NONE 0
#define HID_SUBCLASS_BOOT_INTERFACE 1

// HID Keyboard/Mouse bios compatible protocols HID1.11 Page 9 4.3 Protocols
#define HID_PROTOCOL_NONE 0
#define HID_PROTOCOL_KEYBOARD 1
#define HID_PROTOCOL_MOUSE 2

// Normal or bios protocol (Keyboard/Mouse) HID1.11 Page 54 7.2.5 Get_Protocol Request
// "protocol" variable is used for this purpose.
#define HID_BOOT_PROTOCOL 0
#define HID_REPORT_PROTOCOL 1

// HID Request Type HID1.11 Page 51 7.2.1 Get_Report Request
#define HID_REPORT_TYPE_INPUT 1
#define HID_REPORT_TYPE_OUTPUT 2
#define HID_REPORT_TYPE_FEATURE 3

typedef struct {
uint8_t len; // 9
uint8_t dtype; // 0x21
uint8_t addr;
uint8_t versionL; // 0x101
uint8_t versionH; // 0x101
uint8_t country;
uint8_t desctype; // 0x22 report
uint8_t descLenL;
uint8_t descLenH;
} HIDDescDescriptor;

typedef struct {
InterfaceDescriptor hid;
HIDDescDescriptor desc;
EndpointDescriptor in;
} HIDDescriptor;

class HIDSubDescriptor {
public:
HIDSubDescriptor *next = NULL;
HIDSubDescriptor(const void *d, const uint16_t l) : data(d), length(l) {}

const void *data;
const uint16_t length;
};

class HID_ : public PluggableUSBModule {
public:
HID_(void);
int begin(void);
int SendReport(uint8_t id, const void *data, int len);
void AppendDescriptor(HIDSubDescriptor *node);

protected:
// Implementation of the PluggableUSBModule
int getInterface(uint8_t *interfaceCount);
int getDescriptor(USBSetup &setup);
bool setup(USBSetup &setup);
uint8_t getShortName(char *name);

private:
uint8_t epType[1];

HIDSubDescriptor *rootNode;
uint16_t descriptorSize;

uint8_t protocol;
uint8_t idle;
};

// Replacement for global singleton.
// This function prevents static-initialization-order-fiasco
// https://isocpp.org/wiki/faq/ctors#static-init-order-on-first-use
HID_ &HID();

#define D_HIDREPORT(length) {9, 0x21, 0x01, 0x01, 0, 1, 0x22, lowByte(length), highByte(length)}

#endif // USBCON PLUGGABLE_USB_ENABLED

#endif // HID_STM32_h
Loading
Loading