├── .cproject
├── .gitignore
├── .mxproject
├── .project
├── Arduino_libs
├── Arduino.h
├── Print.cpp
├── Print.h
├── Printable.h
├── README.md
├── SerialClass.cpp
├── SerialClass.h
├── Stream.cpp
├── Stream.h
├── WString.cpp
├── WString.h
├── avr
│ ├── dtostrf.c
│ ├── dtostrf.h
│ └── pgmspace.h
├── itoa.c
├── itoa.h
└── newlib.c
├── CMakeLists.txt
├── CMakeLists_template.txt
├── Core
├── Inc
│ ├── FreeRTOSConfig.h
│ ├── main.h
│ ├── stm32f4xx_hal_conf.h
│ ├── stm32f4xx_it.h
│ └── ux_manager.h
├── Src
│ ├── freertos.c
│ ├── main.c
│ ├── main.cpp
│ ├── ssd1306_display.cpp
│ ├── stm32f4xx_hal_msp.c
│ ├── stm32f4xx_hal_timebase_tim.c
│ ├── stm32f4xx_it.c
│ ├── syscalls.c
│ ├── sysmem.c
│ └── system_stm32f4xx.c
└── Startup
│ └── startup_stm32f446retx.s
├── Debug
└── xbox_usb.elf
├── Drivers
├── CMSIS
│ ├── Device
│ │ └── ST
│ │ │ └── STM32F4xx
│ │ │ └── Include
│ │ │ ├── stm32f446xx.h
│ │ │ ├── stm32f4xx.h
│ │ │ └── system_stm32f4xx.h
│ └── Include
│ │ ├── cmsis_armcc.h
│ │ ├── cmsis_armclang.h
│ │ ├── cmsis_compiler.h
│ │ ├── cmsis_gcc.h
│ │ ├── cmsis_iccarm.h
│ │ ├── cmsis_version.h
│ │ ├── core_armv8mbl.h
│ │ ├── core_armv8mml.h
│ │ ├── core_cm0.h
│ │ ├── core_cm0plus.h
│ │ ├── core_cm1.h
│ │ ├── core_cm23.h
│ │ ├── core_cm3.h
│ │ ├── core_cm33.h
│ │ ├── core_cm4.h
│ │ ├── core_cm7.h
│ │ ├── core_sc000.h
│ │ ├── core_sc300.h
│ │ ├── mpu_armv7.h
│ │ ├── mpu_armv8.h
│ │ └── tz_context.h
├── SSD1306
│ ├── ssd1306.c
│ ├── ssd1306.h
│ ├── ssd1306_conf.h
│ ├── ssd1306_conf_template.h
│ ├── ssd1306_fonts.c
│ ├── ssd1306_fonts.h
│ ├── ssd1306_tests.c
│ └── ssd1306_tests.h
└── STM32F4xx_HAL_Driver
│ ├── Inc
│ ├── Legacy
│ │ └── stm32_hal_legacy.h
│ ├── stm32f4xx_hal.h
│ ├── stm32f4xx_hal_cortex.h
│ ├── stm32f4xx_hal_def.h
│ ├── stm32f4xx_hal_dma.h
│ ├── stm32f4xx_hal_dma_ex.h
│ ├── stm32f4xx_hal_exti.h
│ ├── stm32f4xx_hal_flash.h
│ ├── stm32f4xx_hal_flash_ex.h
│ ├── stm32f4xx_hal_flash_ramfunc.h
│ ├── stm32f4xx_hal_gpio.h
│ ├── stm32f4xx_hal_gpio_ex.h
│ ├── stm32f4xx_hal_i2c.h
│ ├── stm32f4xx_hal_i2c_ex.h
│ ├── stm32f4xx_hal_pcd.h
│ ├── stm32f4xx_hal_pcd_ex.h
│ ├── stm32f4xx_hal_pwr.h
│ ├── stm32f4xx_hal_pwr_ex.h
│ ├── stm32f4xx_hal_rcc.h
│ ├── stm32f4xx_hal_rcc_ex.h
│ ├── stm32f4xx_hal_spi.h
│ ├── stm32f4xx_hal_tim.h
│ ├── stm32f4xx_hal_tim_ex.h
│ ├── stm32f4xx_hal_uart.h
│ └── stm32f4xx_ll_usb.h
│ └── Src
│ ├── stm32f4xx_hal.c
│ ├── stm32f4xx_hal_cortex.c
│ ├── stm32f4xx_hal_dma.c
│ ├── stm32f4xx_hal_dma_ex.c
│ ├── stm32f4xx_hal_exti.c
│ ├── stm32f4xx_hal_flash.c
│ ├── stm32f4xx_hal_flash_ex.c
│ ├── stm32f4xx_hal_flash_ramfunc.c
│ ├── stm32f4xx_hal_gpio.c
│ ├── stm32f4xx_hal_i2c.c
│ ├── stm32f4xx_hal_i2c_ex.c
│ ├── stm32f4xx_hal_pcd.c
│ ├── stm32f4xx_hal_pcd_ex.c
│ ├── stm32f4xx_hal_pwr.c
│ ├── stm32f4xx_hal_pwr_ex.c
│ ├── stm32f4xx_hal_rcc.c
│ ├── stm32f4xx_hal_rcc_ex.c
│ ├── stm32f4xx_hal_spi.c
│ ├── stm32f4xx_hal_tim.c
│ ├── stm32f4xx_hal_tim_ex.c
│ ├── stm32f4xx_hal_uart.c
│ └── stm32f4xx_ll_usb.c
├── IMG_20210315_002914.jpg
├── Middlewares
├── ST
│ └── STM32_USB_Device_Library
│ │ ├── Class
│ │ └── HID
│ │ │ ├── Inc
│ │ │ └── usbd_hid.h
│ │ │ └── Src
│ │ │ └── usbd_hid.c
│ │ └── Core
│ │ ├── Inc
│ │ ├── usbd_core.h
│ │ ├── usbd_ctlreq.h
│ │ ├── usbd_def.h
│ │ └── usbd_ioreq.h
│ │ └── Src
│ │ ├── usbd_core.c
│ │ ├── usbd_ctlreq.c
│ │ └── usbd_ioreq.c
└── Third_Party
│ └── FreeRTOS
│ └── Source
│ ├── CMSIS_RTOS_V2
│ ├── cmsis_os.h
│ ├── cmsis_os2.c
│ ├── cmsis_os2.h
│ ├── freertos_mpool.h
│ └── freertos_os2.h
│ ├── croutine.c
│ ├── event_groups.c
│ ├── include
│ ├── FreeRTOS.h
│ ├── StackMacros.h
│ ├── atomic.h
│ ├── croutine.h
│ ├── deprecated_definitions.h
│ ├── event_groups.h
│ ├── list.h
│ ├── message_buffer.h
│ ├── mpu_prototypes.h
│ ├── mpu_wrappers.h
│ ├── portable.h
│ ├── projdefs.h
│ ├── queue.h
│ ├── semphr.h
│ ├── stack_macros.h
│ ├── stream_buffer.h
│ ├── task.h
│ └── timers.h
│ ├── list.c
│ ├── portable
│ ├── GCC
│ │ └── ARM_CM4F
│ │ │ ├── port.c
│ │ │ └── portmacro.h
│ └── MemMang
│ │ └── heap_4.c
│ ├── queue.c
│ ├── stream_buffer.c
│ ├── tasks.c
│ └── timers.c
├── README.md
├── STM32F446RETX_FLASH.ld
├── STM32F446RETX_RAM.ld
├── USB_DEVICE
├── App
│ ├── usb_device.c
│ ├── usb_device.h
│ ├── usbd_desc.c
│ └── usbd_desc.h
└── Target
│ ├── usbd_conf.c
│ └── usbd_conf.h
├── USB_Host_Shield_2_0
├── .gitattributes
├── .github
│ └── workflows
│ │ └── main.yml
├── .gitignore
├── .gitmodules
├── BTD.cpp
├── BTD.h
├── BTHID.cpp
├── BTHID.h
├── MiniDSP.cpp
├── MiniDSP.h
├── PS3BT.cpp
├── PS3BT.h
├── PS3Enums.h
├── PS3USB.cpp
├── PS3USB.h
├── PS4BT.h
├── PS4Parser.cpp
├── PS4Parser.h
├── PS4USB.h
├── PS5BT.h
├── PS5Parser.cpp
├── PS5Parser.h
├── PS5Trigger.cpp
├── PS5Trigger.h
├── PS5USB.h
├── PSBuzz.cpp
├── PSBuzz.h
├── README.md
├── SPP.cpp
├── SPP.h
├── UHS2_gpio.cpp
├── UHS2_gpio.h
├── Usb.cpp
├── Usb.h
├── UsbCore.h
├── Wii.cpp
├── Wii.h
├── WiiCameraReadme.md
├── XBOXOLD.cpp
├── XBOXOLD.h
├── XBOXONE.cpp
├── XBOXONE.h
├── XBOXONESBT.h
├── XBOXONESParser.cpp
├── XBOXONESParser.h
├── XBOXRECV.cpp
├── XBOXRECV.h
├── XBOXUSB.cpp
├── XBOXUSB.h
├── address.h
├── adk.cpp
├── adk.h
├── avrpins.h
├── cdc_XR21B1411.cpp
├── cdc_XR21B1411.h
├── cdcacm.cpp
├── cdcacm.h
├── cdcftdi.cpp
├── cdcftdi.h
├── cdcprolific.cpp
├── cdcprolific.h
├── confdescparser.h
├── controllerEnums.h
├── doc
│ ├── Doxyfile
│ ├── README.md
│ └── imageStyle.css
├── examples
│ ├── Bluetooth
│ │ ├── BTHID
│ │ │ ├── BTHID.ino
│ │ │ ├── KeyboardParser.h
│ │ │ └── MouseParser.h
│ │ ├── PS3BT
│ │ │ └── PS3BT.ino
│ │ ├── PS3Multi
│ │ │ └── PS3Multi.ino
│ │ ├── PS3SPP
│ │ │ └── PS3SPP.ino
│ │ ├── PS4BT
│ │ │ └── PS4BT.ino
│ │ ├── PS5BT
│ │ │ └── PS5BT.ino
│ │ ├── SPP
│ │ │ └── SPP.ino
│ │ ├── SPPMulti
│ │ │ └── SPPMulti.ino
│ │ ├── Wii
│ │ │ └── Wii.ino
│ │ ├── WiiBalanceBoard
│ │ │ └── WiiBalanceBoard.ino
│ │ ├── WiiIRCamera
│ │ │ └── WiiIRCamera.ino
│ │ ├── WiiMulti
│ │ │ └── WiiMulti.ino
│ │ └── WiiUProController
│ │ │ └── WiiUProController.ino
│ ├── GPIO
│ │ ├── Blink
│ │ │ └── Blink.ino
│ │ ├── Blink_LowLevel
│ │ │ └── Blink_LowLevel.ino
│ │ └── Input
│ │ │ └── Input.ino
│ ├── HID
│ │ ├── SRWS1
│ │ │ ├── SRWS1.cpp
│ │ │ ├── SRWS1.h
│ │ │ └── SRWS1.ino
│ │ ├── USBHIDBootKbd
│ │ │ └── USBHIDBootKbd.ino
│ │ ├── USBHIDBootKbdAndMouse
│ │ │ └── USBHIDBootKbdAndMouse.ino
│ │ ├── USBHIDBootMouse
│ │ │ └── USBHIDBootMouse.ino
│ │ ├── USBHIDJoystick
│ │ │ ├── USBHIDJoystick.ino
│ │ │ ├── hidjoystickrptparser.cpp
│ │ │ └── hidjoystickrptparser.h
│ │ ├── USBHIDMultimediaKbd
│ │ │ └── USBHIDMultimediaKbd.ino
│ │ ├── USBHID_desc
│ │ │ ├── USBHID_desc.ino
│ │ │ └── pgmstrings.h
│ │ ├── le3dp
│ │ │ ├── le3dp.ino
│ │ │ ├── le3dp_rptparser.cpp
│ │ │ └── le3dp_rptparser.h
│ │ ├── scale
│ │ │ ├── scale.ino
│ │ │ ├── scale_rptparser.cpp
│ │ │ └── scale_rptparser.h
│ │ └── t16km
│ │ │ └── t16km.ino
│ ├── MiniDSP
│ │ └── MiniDSP.ino
│ ├── PS3USB
│ │ └── PS3USB.ino
│ ├── PS4USB
│ │ └── PS4USB.ino
│ ├── PS5USB
│ │ └── PS5USB.ino
│ ├── PSBuzz
│ │ └── PSBuzz.ino
│ ├── USBH_MIDI
│ │ ├── USBH_MIDI_dump
│ │ │ └── USBH_MIDI_dump.ino
│ │ ├── USB_MIDI_converter
│ │ │ └── USB_MIDI_converter.ino
│ │ ├── USB_MIDI_converter_multi
│ │ │ └── USB_MIDI_converter_multi.ino
│ │ ├── bidirectional_converter
│ │ │ └── bidirectional_converter.ino
│ │ └── eVY1_sample
│ │ │ └── eVY1_sample.ino
│ ├── USB_desc
│ │ ├── USB_desc.ino
│ │ └── pgmstrings.h
│ ├── Xbox
│ │ ├── XBOXOLD
│ │ │ └── XBOXOLD.ino
│ │ ├── XBOXONE
│ │ │ └── XBOXONE.ino
│ │ ├── XBOXONESBT
│ │ │ └── XBOXONESBT.ino
│ │ ├── XBOXRECV
│ │ │ └── XBOXRECV.ino
│ │ └── XBOXUSB
│ │ │ └── XBOXUSB.ino
│ ├── acm
│ │ └── acm_terminal
│ │ │ ├── acm_terminal.ino
│ │ │ └── pgmstrings.h
│ ├── adk
│ │ ├── ArduinoBlinkLED
│ │ │ └── ArduinoBlinkLED.ino
│ │ ├── adk_barcode
│ │ │ └── adk_barcode.ino
│ │ ├── demokit_20
│ │ │ └── demokit_20.ino
│ │ ├── term_test
│ │ │ └── term_test.ino
│ │ └── term_time
│ │ │ └── term_time.ino
│ ├── board_qc
│ │ └── board_qc.ino
│ ├── cdc_XR21B1411
│ │ └── XR_terminal
│ │ │ └── XR_terminal.ino
│ ├── ftdi
│ │ └── USBFTDILoopback
│ │ │ ├── USBFTDILoopback.ino
│ │ │ └── pgmstrings.h
│ ├── hub_demo
│ │ ├── hub_demo.ino
│ │ └── pgmstrings.h
│ ├── max_LCD
│ │ └── max_LCD.ino
│ ├── pl2303
│ │ ├── pl2303_gprs_terminal
│ │ │ └── pl2303_gprs_terminal.ino
│ │ ├── pl2303_gps
│ │ │ └── pl2303_gps.ino
│ │ ├── pl2303_tinygps
│ │ │ └── pl2303_tinygps.ino
│ │ └── pl2303_xbee_terminal
│ │ │ └── pl2303_xbee_terminal.ino
│ └── testusbhostFAT
│ │ ├── Makefile
│ │ ├── README.md
│ │ └── testusbhostFAT.ino
├── gpl2.txt
├── hexdump.h
├── hidboot.cpp
├── hidboot.h
├── hidcomposite.cpp
├── hidcomposite.h
├── hidescriptorparser.cpp
├── hidescriptorparser.h
├── hiduniversal.cpp
├── hiduniversal.h
├── hidusagestr.h
├── hidusagetitlearrays.cpp
├── keywords.txt
├── library.json
├── library.properties
├── macros.h
├── masstorage.cpp
├── masstorage.h
├── max3421e.h
├── max_LCD.cpp
├── max_LCD.h
├── message.cpp
├── message.h
├── parsetools.cpp
├── parsetools.h
├── printhex.h
├── settings.h
├── sink_parser.h
├── usb_ch9.h
├── usbh_midi.cpp
├── usbh_midi.h
├── usbhid.cpp
├── usbhid.h
├── usbhost.h
├── usbhub.cpp
├── usbhub.h
├── version_helper.h
└── xboxEnums.h
├── Useful-Resources
├── Full-Webpage
│ ├── 假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out).html
│ └── 假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files
│ │ ├── 1050234869-lightbox_bundle.css
│ │ ├── 2080820689-widgets.js.download
│ │ ├── 2621646369-cmtfp.css
│ │ ├── 3416767676-css_bundle_v2.css
│ │ ├── 355184812-cmt__zh_tw.js.download
│ │ ├── 3858658042-comment_from_post_iframe.js.download
│ │ ├── 491815801-lbx__zh_tw.js.download
│ │ ├── EZf8jxdwqkL23uxFPDBdTiNZzxbWfe97GgGOcmp5ap4.js.download
│ │ ├── IMG_1820.JPG
│ │ ├── IMG_1988.JPG
│ │ ├── IMG_1998.JPG
│ │ ├── IMG_3558.JPG
│ │ ├── IMG_3619.JPG
│ │ ├── authorization.css
│ │ ├── blank.gif
│ │ ├── blogger_logo_round_35.png
│ │ ├── cb=gapi(1).loaded_0
│ │ ├── cb=gapi.loaded_0
│ │ ├── cb=gapi.loaded_1
│ │ ├── cb=gapi.loaded_2
│ │ ├── com.PNG
│ │ ├── comment-iframe.html
│ │ ├── control0.PNG
│ │ ├── control1.PNG
│ │ ├── control2.PNG
│ │ ├── control3.PNG
│ │ ├── control4.PNG
│ │ ├── control5.PNG
│ │ ├── control6.PNG
│ │ ├── control7.PNG
│ │ ├── dataout0.PNG
│ │ ├── dataout1.PNG
│ │ ├── dataout2.PNG
│ │ ├── dataout3.PNG
│ │ ├── dataout4.PNG
│ │ ├── dataout5.PNG
│ │ ├── dataout6.PNG
│ │ ├── dataout7.PNG
│ │ ├── dataout8.PNG
│ │ ├── dataout9.PNG
│ │ ├── datasheet.PNG
│ │ ├── element_main.js.download
│ │ ├── f(1).txt
│ │ ├── f.txt
│ │ ├── file0(1).PNG
│ │ ├── file0.PNG
│ │ ├── googlelogo_color_42x16dp.png
│ │ ├── icon18_edit_allbkg.gif
│ │ ├── icon18_wrench_allbkg.png
│ │ ├── jquery.min.js.download
│ │ ├── lazy.min.js.download
│ │ ├── loader.js.download
│ │ ├── main.js.download
│ │ ├── navbar.html
│ │ ├── platform_gapi.iframes.style.common.js.download
│ │ ├── plusone.js.download
│ │ ├── prettify.css
│ │ ├── related_tools_and_software.png
│ │ ├── s132-sd.PNG
│ │ ├── translate_24dp.png
│ │ └── translateelement.css
└── 假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out).mhtml
├── fritzing_sketch.fzz
├── fritzing_sketch_bb.png
├── xbox_usb Debug.launch
└── xbox_usb.ioc
/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode/
2 |
3 | # Ignore all files in the Debug folder except the ones ending in .elf
4 | Debug/*
5 | !Debug/*.elf
6 | .settings/
7 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | xbox_usb
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | com.st.stm32cube.ide.mcu.MCUProjectNature
23 | com.st.stm32cube.ide.mcu.MCUCubeProjectNature
24 | org.eclipse.cdt.core.cnature
25 | org.eclipse.cdt.core.ccnature
26 | com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature
27 | com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature
28 | com.st.stm32cube.ide.mcu.MCUEndUserDisabledTrustZoneProjectNature
29 | com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature
30 | com.st.stm32cube.ide.mcu.MCURootProjectNature
31 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
32 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
33 |
34 |
35 |
--------------------------------------------------------------------------------
/Arduino_libs/Arduino.h:
--------------------------------------------------------------------------------
1 | #ifndef __arduino_h__
2 | #define __arduino_h__
3 |
4 | #include
5 | #include "Print.h"
6 | #include "Stream.h"
7 |
8 | #include "SerialClass.h" // Arduino style Serial class
9 |
10 | #define min(a,b) ((a)<(b)?(a):(b))
11 | #define max(a,b) ((a)>(b)?(a):(b))
12 |
13 | #define PI M_PI
14 | #define RAD_TO_DEG (180.0 / M_PI)
15 |
16 | #define delay(ms) HAL_Delay(ms)
17 | #define delayMicroseconds(us) HAL_Delay(us/1000)
18 | #define millis() (HAL_GetTick() / 1)
19 | #define micros() HAL_GetTick()*1000
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/Arduino_libs/Print.h:
--------------------------------------------------------------------------------
1 | /*
2 | Print.h - Base class that provides print() and println()
3 | Copyright (c) 2008 David A. Mellis. All right reserved.
4 |
5 | This library is free software; you can redistribute it and/or
6 | modify it under the terms of the GNU Lesser General Public
7 | License as published by the Free Software Foundation; either
8 | version 2.1 of the License, or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public
16 | License along with this library; if not, write to the Free Software
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | #ifndef Print_h
21 | #define Print_h
22 |
23 | #include
24 | #include // for size_t
25 |
26 | #include "WString.h"
27 | #include "Printable.h"
28 |
29 | #define DEC 10
30 | #define HEX 16
31 | #define OCT 8
32 | #define BIN 2
33 |
34 | class Print
35 | {
36 | private:
37 | int write_error;
38 | size_t printNumber(unsigned long, uint8_t);
39 | size_t printFloat(double, uint8_t);
40 | protected:
41 | void setWriteError(int err = 1) { write_error = err; }
42 | public:
43 | Print() : write_error(0) {}
44 |
45 | int getWriteError() { return write_error; }
46 | void clearWriteError() { setWriteError(0); }
47 |
48 | virtual size_t write(uint8_t) = 0;
49 | size_t write(const char *str) {
50 | if (str == NULL) return 0;
51 | return write((const uint8_t *)str, strlen(str));
52 | }
53 | virtual size_t write(const uint8_t *buffer, size_t size);
54 | size_t write(const char *buffer, size_t size) {
55 | return write((const uint8_t *)buffer, size);
56 | }
57 |
58 | size_t print(const __FlashStringHelper *);
59 | size_t print(const String &);
60 | size_t print(const char[]);
61 | size_t print(char);
62 | size_t print(unsigned char, int = DEC);
63 | size_t print(int, int = DEC);
64 | size_t print(unsigned int, int = DEC);
65 | size_t print(long, int = DEC);
66 | size_t print(unsigned long, int = DEC);
67 | size_t print(double, int = 2);
68 | size_t print(const Printable&);
69 |
70 | size_t println(const __FlashStringHelper *);
71 | size_t println(const String &s);
72 | size_t println(const char[]);
73 | size_t println(char);
74 | size_t println(unsigned char, int = DEC);
75 | size_t println(int, int = DEC);
76 | size_t println(unsigned int, int = DEC);
77 | size_t println(long, int = DEC);
78 | size_t println(unsigned long, int = DEC);
79 | size_t println(double, int = 2);
80 | size_t println(const Printable&);
81 | size_t println(void);
82 | };
83 |
84 | #endif
85 |
--------------------------------------------------------------------------------
/Arduino_libs/Printable.h:
--------------------------------------------------------------------------------
1 | /*
2 | Printable.h - Interface class that allows printing of complex types
3 | Copyright (c) 2011 Adrian McEwen. All right reserved.
4 |
5 | This library is free software; you can redistribute it and/or
6 | modify it under the terms of the GNU Lesser General Public
7 | License as published by the Free Software Foundation; either
8 | version 2.1 of the License, or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public
16 | License along with this library; if not, write to the Free Software
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | #ifndef Printable_h
21 | #define Printable_h
22 |
23 | #include
24 |
25 | class Print;
26 |
27 | /** The Printable class provides a way for new classes to allow themselves to be printed.
28 | By deriving from Printable and implementing the printTo method, it will then be possible
29 | for users to print out instances of this class by passing them into the usual
30 | Print::print and Print::println methods.
31 | */
32 |
33 | class Printable
34 | {
35 | public:
36 | virtual size_t printTo(Print& p) const = 0;
37 | };
38 |
39 | #endif
40 |
41 |
--------------------------------------------------------------------------------
/Arduino_libs/README.md:
--------------------------------------------------------------------------------
1 | These libraries are necessary for the code to work with the [USB Host Shield library 2.0](https://github.com/felis/USB_Host_Shield_2.0).
2 |
3 | The [Print](Print.cpp), [Stream](Stream.cpp), [itoa](itoa.c), [Printable](Printable.h), [WString](WString.cpp), [dtostrf](avr/dtostrf.c), and [pgmspace](avr/pgmspace.h) where all copied from the Arduino Due core.
4 |
5 | The [newlib](newlib.c) is copied from: https://github.com/ObKo/stm32-cmake/tree/master/stm32-newlib.
6 |
7 | The [SerialClass](SerialClass.cpp) library was created, so Arduino style serial code works.
--------------------------------------------------------------------------------
/Arduino_libs/SerialClass.cpp:
--------------------------------------------------------------------------------
1 | #include "SerialClass.h"
2 |
3 | size_t SerialClass::write(uint8_t data) {
4 | return write(&data, 1);
5 | }
6 |
7 | size_t SerialClass::write(const uint8_t *buffer, size_t size) {
8 | uint8_t *pBuffer = (uint8_t*)buffer;
9 | HAL_UART_Transmit(pUART_Handle, pBuffer, size, HAL_MAX_DELAY);
10 | return size;
11 | }
12 |
13 | int SerialClass::read() {
14 | uint8_t data;
15 | HAL_UART_Receive(pUART_Handle, &data, 1, HAL_MAX_DELAY);
16 | return data;
17 | }
18 |
19 | int SerialClass::available() {
20 | return -1;
21 | }
22 |
23 | int SerialClass::peek() {
24 | return -1;
25 | }
26 |
27 | void SerialClass::flush() {
28 | }
29 |
--------------------------------------------------------------------------------
/Arduino_libs/SerialClass.h:
--------------------------------------------------------------------------------
1 | #ifndef __serial_h__
2 | #define __serial_h__
3 |
4 | #include "Stream.h"
5 | #include "stm32f4xx_hal.h"
6 |
7 | class SerialClass : public Stream {
8 | public:
9 | SerialClass(UART_HandleTypeDef *UART_Handle) : pUART_Handle(UART_Handle) {
10 | };
11 |
12 | size_t write(uint8_t data);
13 | size_t write(const uint8_t *buffer, size_t size);
14 | using Print::write; // Pull in write(const char *str) from Print
15 | int read();
16 |
17 | // These are NOT implemented!
18 | int available();
19 | int peek();
20 | void flush();
21 |
22 | private:
23 | UART_HandleTypeDef *pUART_Handle;
24 | };
25 |
26 | extern SerialClass Serial; // Create this constructor in your main.cpp
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/Arduino_libs/avr/dtostrf.c:
--------------------------------------------------------------------------------
1 | /*
2 | dtostrf - Emulation for dtostrf function from avr-libc
3 | Copyright (c) 2013 Arduino. All rights reserved.
4 | Written by Cristian Maglie
5 |
6 | This library is free software; you can redistribute it and/or
7 | modify it under the terms of the GNU Lesser General Public
8 | License as published by the Free Software Foundation; either
9 | version 2.1 of the License, or (at your option) any later version.
10 |
11 | This library 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 GNU
14 | Lesser General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public
17 | License along with this library; if not, write to the Free Software
18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 |
21 | #include
22 |
23 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout) {
24 | char fmt[20];
25 | sprintf(fmt, "%%%d.%df", width, prec);
26 | sprintf(sout, fmt, val);
27 | return sout;
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/Arduino_libs/avr/dtostrf.h:
--------------------------------------------------------------------------------
1 | /*
2 | dtostrf - Emulation for dtostrf function from avr-libc
3 | Copyright (c) 2013 Arduino. All rights reserved.
4 | Written by Cristian Maglie
5 |
6 | This library is free software; you can redistribute it and/or
7 | modify it under the terms of the GNU Lesser General Public
8 | License as published by the Free Software Foundation; either
9 | version 2.1 of the License, or (at your option) any later version.
10 |
11 | This library 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 GNU
14 | Lesser General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public
17 | License along with this library; if not, write to the Free Software
18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 |
21 | #ifdef __cplusplus
22 | extern "C" {
23 | #endif
24 |
25 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout);
26 |
27 | #ifdef __cplusplus
28 | }
29 | #endif
30 |
--------------------------------------------------------------------------------
/Arduino_libs/avr/pgmspace.h:
--------------------------------------------------------------------------------
1 | /*
2 | pgmspace.h - Definitions for compatibility with AVR pgmspace macros
3 |
4 | Copyright (c) 2015 Arduino LLC
5 |
6 | Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com)
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining a copy
9 | of this software and associated documentation files (the "Software"), to deal
10 | in the Software without restriction, including without limitation the rights
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | copies of the Software, and to permit persons to whom the Software is
13 | furnished to do so, subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included in
16 | all copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | THE SOFTWARE
25 | */
26 |
27 | #ifndef __PGMSPACE_H_
28 | #define __PGMSPACE_H_ 1
29 |
30 | #include
31 |
32 | #define PROGMEM
33 | #define PGM_P const char *
34 | #define PSTR(str) (str)
35 |
36 | #define _SFR_BYTE(n) (n)
37 |
38 | typedef void prog_void;
39 | typedef char prog_char;
40 | typedef unsigned char prog_uchar;
41 | typedef int8_t prog_int8_t;
42 | typedef uint8_t prog_uint8_t;
43 | typedef int16_t prog_int16_t;
44 | typedef uint16_t prog_uint16_t;
45 | typedef int32_t prog_int32_t;
46 | typedef uint32_t prog_uint32_t;
47 |
48 | #define memcpy_P(dest, src, num) memcpy((dest), (src), (num))
49 | #define strcpy_P(dest, src) strcpy((dest), (src))
50 | #define strcat_P(dest, src) strcat((dest), (src))
51 | #define strcmp_P(a, b) strcmp((a), (b))
52 | #define strstr_P(a, b) strstr((a), (b))
53 | #define strlen_P(a) strlen((a))
54 | #define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__)
55 |
56 | #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
57 | #define pgm_read_word(addr) (*(const unsigned short *)(addr))
58 | #define pgm_read_dword(addr) (*(const unsigned long *)(addr))
59 | #define pgm_read_float(addr) (*(const float *)(addr))
60 |
61 | #define pgm_read_byte_near(addr) pgm_read_byte(addr)
62 | #define pgm_read_word_near(addr) pgm_read_word(addr)
63 | #define pgm_read_dword_near(addr) pgm_read_dword(addr)
64 | #define pgm_read_float_near(addr) pgm_read_float(addr)
65 | #define pgm_read_byte_far(addr) pgm_read_byte(addr)
66 | #define pgm_read_word_far(addr) pgm_read_word(addr)
67 | #define pgm_read_dword_far(addr) pgm_read_dword(addr)
68 | #define pgm_read_float_far(addr) pgm_read_float(addr)
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/Arduino_libs/itoa.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2011 Arduino. All right reserved.
3 |
4 | This library is free software; you can redistribute it and/or
5 | modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation; either
7 | version 2.1 of the License, or (at your option) any later version.
8 |
9 | This library is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | See the GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public
15 | License along with this library; if not, write to the Free Software
16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef _ITOA_
20 | #define _ITOA_
21 |
22 | #ifdef __cplusplus
23 | extern "C"{
24 | #endif // __cplusplus
25 |
26 | #if 0
27 |
28 | extern void itoa( int n, char s[] ) ;
29 |
30 | #else
31 |
32 | extern char* itoa( int value, char *string, int radix ) ;
33 | extern char* ltoa( long value, char *string, int radix ) ;
34 | //extern char* utoa( unsigned long value, char *string, int radix ) ;
35 | extern char* ultoa( unsigned long value, char *string, int radix ) ;
36 | #endif /* 0 */
37 |
38 | #ifdef __cplusplus
39 | } // extern "C"
40 | #endif // __cplusplus
41 |
42 | #endif // _ITOA_
43 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | #THIS FILE IS AUTO GENERATED FROM THE TEMPLATE! DO NOT CHANGE!
2 | SET(CMAKE_SYSTEM_NAME Generic)
3 | SET(CMAKE_SYSTEM_VERSION 1)
4 | cmake_minimum_required(VERSION 3.7)
5 |
6 | # specify cross compilers and tools
7 | SET(CMAKE_C_COMPILER_WORKS 1)
8 | SET(CMAKE_C_COMPILER arm-none-eabi-gcc)
9 | SET(CMAKE_CXX_COMPILER_WORKS 1)
10 | SET(CMAKE_CXX_COMPILER arm-none-eabi-g++)
11 | set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
12 | set(CMAKE_AR arm-none-eabi-ar)
13 | set(CMAKE_OBJCOPY arm-none-eabi-objcopy)
14 | set(CMAKE_OBJDUMP arm-none-eabi-objdump)
15 | set(SIZE arm-none-eabi-size)
16 |
17 | SET(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/)
18 |
19 | #Uncomment for hardware floating point
20 | #SET(FPU_FLAGS "-mfloat-abi=hard -mfpu=fpv4-sp-d16")
21 | #add_definitions(-DARM_MATH_CM4 -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=1)
22 |
23 | #Uncomment for software floating point
24 | #SET(FPU_FLAGS "-mfloat-abi=soft")
25 |
26 | SET(COMMON_FLAGS
27 | "-mcpu=cortex-m4 ${FPU_FLAGS} -mthumb -mthumb-interwork -ffunction-sections -fdata-sections \
28 | -g -fno-common -fmessage-length=0 ")
29 |
30 | SET(CMAKE_CXX_FLAGS_INIT "${COMMON_FLAGS} -std=c++11")
31 | SET(CMAKE_C_FLAGS_INIT "${COMMON_FLAGS} -std=gnu99")
32 | SET(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,-gc-sections,--print-memory-usage -T ${LINKER_SCRIPT}")
33 |
34 | PROJECT(xbox_usb C CXX ASM)
35 | set(CMAKE_CXX_STANDARD 11)
36 |
37 | #add_definitions(-DARM_MATH_CM4 -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=1)
38 | add_definitions(-DUSE_HAL_DRIVER -DSTM32F4 -DARDUINO=100 -D__weak=__attribute__\(\(weak\)\) -D__packed=__attributes__\(\(__packed__\)\) -DSTM32F446xx -DDEBUG)
39 |
40 | file(GLOB_RECURSE SOURCES "Arduino_libs/*.*" "Core/*.*" "Drivers/*.*" "Middlewares/*.*" "USB_DEVICE/*.*" "USB_Host_Shield_2_0/*.*")
41 |
42 | include_directories(Core/Inc Drivers/STM32F4xx_HAL_Driver/Inc Drivers/STM32F4xx_HAL_Driver/Inc/Legacy Drivers/CMSIS/Device/ST/STM32F4xx/Include Drivers/CMSIS/Include USB_DEVICE/App USB_DEVICE/Target Middlewares/ST/STM32_USB_Device_Library/Core/Inc Middlewares/ST/STM32_USB_Device_Library/Class/HID/Inc Middlewares/Third_Party/FreeRTOS/Source/include Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F)
43 |
44 | add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT})
45 |
46 | set(CMAKE_EXE_LINKER_FLAGS
47 | "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map")
48 |
49 | set(HEX_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.hex)
50 | set(BIN_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.bin)
51 |
52 | add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
53 | COMMAND ${CMAKE_OBJCOPY} -Oihex $ ${HEX_FILE}
54 | COMMAND ${CMAKE_OBJCOPY} -Obinary $ ${BIN_FILE}
55 | COMMENT "Building ${HEX_FILE}
56 | Building ${BIN_FILE}")
57 |
--------------------------------------------------------------------------------
/CMakeLists_template.txt:
--------------------------------------------------------------------------------
1 | #${templateWarning}
2 | SET(CMAKE_SYSTEM_NAME Generic)
3 | SET(CMAKE_SYSTEM_VERSION 1)
4 | cmake_minimum_required(VERSION 3.7)
5 |
6 | # specify cross compilers and tools
7 | SET(CMAKE_C_COMPILER_WORKS 1)
8 | SET(CMAKE_C_COMPILER arm-none-eabi-gcc)
9 | SET(CMAKE_CXX_COMPILER_WORKS 1)
10 | SET(CMAKE_CXX_COMPILER arm-none-eabi-g++)
11 | set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
12 | set(CMAKE_AR arm-none-eabi-ar)
13 | set(CMAKE_OBJCOPY arm-none-eabi-objcopy)
14 | set(CMAKE_OBJDUMP arm-none-eabi-objdump)
15 | set(SIZE arm-none-eabi-size)
16 |
17 | SET(LINKER_SCRIPT $${CMAKE_SOURCE_DIR}/${linkerScript})
18 |
19 | #Uncomment for hardware floating point
20 | #SET(FPU_FLAGS "-mfloat-abi=hard -mfpu=fpv4-sp-d16")
21 | #add_definitions(-DARM_MATH_CM4 -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=1)
22 |
23 | #Uncomment for software floating point
24 | #SET(FPU_FLAGS "-mfloat-abi=soft")
25 |
26 | SET(COMMON_FLAGS
27 | "-mcpu=${mcpu} $${FPU_FLAGS} -mthumb -mthumb-interwork -ffunction-sections -fdata-sections \
28 | -g -fno-common -fmessage-length=0 ${linkerFlags}")
29 |
30 | SET(CMAKE_CXX_FLAGS_INIT "$${COMMON_FLAGS} -std=c++11")
31 | SET(CMAKE_C_FLAGS_INIT "$${COMMON_FLAGS} -std=gnu99")
32 | SET(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,-gc-sections,--print-memory-usage -T $${LINKER_SCRIPT}")
33 |
34 | PROJECT(${projectName} C CXX ASM)
35 | set(CMAKE_CXX_STANDARD 11)
36 |
37 | #add_definitions(-DARM_MATH_CM4 -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=1)
38 | add_definitions(${defines})
39 |
40 | file(GLOB_RECURSE SOURCES ${sources})
41 |
42 | include_directories(${includes})
43 |
44 | add_executable($${PROJECT_NAME}.elf $${SOURCES} $${LINKER_SCRIPT})
45 |
46 | set(CMAKE_EXE_LINKER_FLAGS
47 | "$${CMAKE_EXE_LINKER_FLAGS} -Wl,-Map=$${PROJECT_BINARY_DIR}/$${PROJECT_NAME}.map")
48 |
49 | set(HEX_FILE $${PROJECT_BINARY_DIR}/$${PROJECT_NAME}.hex)
50 | set(BIN_FILE $${PROJECT_BINARY_DIR}/$${PROJECT_NAME}.bin)
51 |
52 | add_custom_command(TARGET $${PROJECT_NAME}.elf POST_BUILD
53 | COMMAND $${CMAKE_OBJCOPY} -Oihex $ $${HEX_FILE}
54 | COMMAND $${CMAKE_OBJCOPY} -Obinary $ $${BIN_FILE}
55 | COMMENT "Building $${HEX_FILE}
56 | Building $${BIN_FILE}")
57 |
--------------------------------------------------------------------------------
/Core/Inc/main.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : main.h
5 | * @brief : Header for main.c file.
6 | * This file contains the common defines of the application.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2021 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under BSD 3-Clause license,
14 | * the "License"; You may not use this file except in compliance with the
15 | * License. You may obtain a copy of the License at:
16 | * opensource.org/licenses/BSD-3-Clause
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __MAIN_H
24 | #define __MAIN_H
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /* Includes ------------------------------------------------------------------*/
31 | #include "stm32f4xx_hal.h"
32 |
33 | /* Private includes ----------------------------------------------------------*/
34 | /* USER CODE BEGIN Includes */
35 |
36 | /* USER CODE END Includes */
37 |
38 | /* Exported types ------------------------------------------------------------*/
39 | /* USER CODE BEGIN ET */
40 |
41 | /* USER CODE END ET */
42 |
43 | /* Exported constants --------------------------------------------------------*/
44 | /* USER CODE BEGIN EC */
45 | /* USER CODE END EC */
46 |
47 | /* Exported macro ------------------------------------------------------------*/
48 | /* USER CODE BEGIN EM */
49 | extern void SystemClock_Config(void);
50 | /* USER CODE END EM */
51 |
52 | /* Exported functions prototypes ---------------------------------------------*/
53 | void Error_Handler(void);
54 |
55 | /* USER CODE BEGIN EFP */
56 |
57 | /* USER CODE END EFP */
58 |
59 | /* Private defines -----------------------------------------------------------*/
60 | #define B1_Pin GPIO_PIN_13
61 | #define B1_GPIO_Port GPIOC
62 | #define USART_TX_Pin GPIO_PIN_2
63 | #define USART_TX_GPIO_Port GPIOA
64 | #define USART_RX_Pin GPIO_PIN_3
65 | #define USART_RX_GPIO_Port GPIOA
66 | #define TMS_Pin GPIO_PIN_13
67 | #define TMS_GPIO_Port GPIOA
68 | #define TCK_Pin GPIO_PIN_14
69 | #define TCK_GPIO_Port GPIOA
70 | #define SWO_Pin GPIO_PIN_3
71 | #define SWO_GPIO_Port GPIOB
72 | /* USER CODE BEGIN Private defines */
73 | #define PC_SETUP 0
74 | #define OG_XBOX_SETUP 1
75 | /* USER CODE END Private defines */
76 |
77 | #ifdef __cplusplus
78 | }
79 | #endif
80 |
81 | #endif /* __MAIN_H */
82 |
83 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
84 |
--------------------------------------------------------------------------------
/Core/Inc/stm32f4xx_it.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file stm32f4xx_it.h
5 | * @brief This file contains the headers of the interrupt handlers.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2021 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* USER CODE END Header */
20 |
21 | /* Define to prevent recursive inclusion -------------------------------------*/
22 | #ifndef __STM32F4xx_IT_H
23 | #define __STM32F4xx_IT_H
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* Private includes ----------------------------------------------------------*/
30 | /* USER CODE BEGIN Includes */
31 |
32 | /* USER CODE END Includes */
33 |
34 | /* Exported types ------------------------------------------------------------*/
35 | /* USER CODE BEGIN ET */
36 |
37 | /* USER CODE END ET */
38 |
39 | /* Exported constants --------------------------------------------------------*/
40 | /* USER CODE BEGIN EC */
41 |
42 | /* USER CODE END EC */
43 |
44 | /* Exported macro ------------------------------------------------------------*/
45 | /* USER CODE BEGIN EM */
46 |
47 | /* USER CODE END EM */
48 |
49 | /* Exported functions prototypes ---------------------------------------------*/
50 | void NMI_Handler(void);
51 | void HardFault_Handler(void);
52 | void MemManage_Handler(void);
53 | void BusFault_Handler(void);
54 | void UsageFault_Handler(void);
55 | void DebugMon_Handler(void);
56 | void TIM8_UP_TIM13_IRQHandler(void);
57 | void TIM8_TRG_COM_TIM14_IRQHandler(void);
58 | void OTG_FS_IRQHandler(void);
59 | /* USER CODE BEGIN EFP */
60 |
61 | /* USER CODE END EFP */
62 |
63 | #ifdef __cplusplus
64 | }
65 | #endif
66 |
67 | #endif /* __STM32F4xx_IT_H */
68 |
69 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
70 |
--------------------------------------------------------------------------------
/Core/Inc/ux_manager.h:
--------------------------------------------------------------------------------
1 | //// ux_manager.h
2 | //
3 | //
4 | //
5 | //#ifndef UX_MGR
6 | //#define UX_MGR
7 | //
8 | //// includes
9 | //#include
10 | //#include "ssd1306.h"
11 | //
12 | //// typedefs
13 | //typedef enum Screens_{
14 | // MAIN,
15 | // SHOW_TEMP_AMB,
16 | // SHOW_COUNTER,
17 | // SHOW_TEMP_C_TC,
18 | // SHOW_TEMP_C_AMB,
19 | // SHOW_DIAG,
20 | // SHOW_SCREEN_NO,
21 | // SHOW_HUM,
22 | // SET_TEMP,
23 | // SET_HUM,
24 | // SET_TIME
25 | //// NUMBER_OF_SCREENS
26 | //} ui_screen;
27 | //
28 | //
29 | //typedef struct DWuint8_t_
30 | //{
31 | // char format[10];
32 | // char invalidMsg[4];
33 | // uint16_t xPos;
34 | // uint16_t yPos;
35 | // uint8_t valid;
36 | // uint8_t data;
37 | // uint8_t screen_no;
38 | //} DWuint8_t;
39 | //
40 | //
41 | //typedef struct DWint8_t_
42 | //{
43 | // char format[10];
44 | // char invalidMsg[4];
45 | // uint16_t xPos;
46 | // uint16_t yPos;
47 | // uint8_t valid;
48 | // int8_t data;
49 | //} DWint8_t;
50 | //
51 | //
52 | //typedef struct DWuint16_t_
53 | //{
54 | // char format[10];
55 | // char invalidMsg[4];
56 | // uint16_t xPos;
57 | // uint16_t yPos;
58 | // uint8_t valid;
59 | // uint16_t data;
60 | //} DWuint16_t;
61 | //
62 | //
63 | //typedef struct DWint16_t_
64 | //{
65 | // char format[10];
66 | // char invalidMsg[4];
67 | // uint16_t xPos;
68 | // uint16_t yPos;
69 | // uint8_t valid;
70 | // int16_t data;
71 | //} DWint16_t;
72 | //
73 | //
74 | //typedef struct DWstring_
75 | //{
76 | // char format[10];
77 | // char invalidMsg[4];
78 | // uint16_t xPos;
79 | // uint16_t yPos;
80 | // uint8_t valid;
81 | // char data[26];
82 | //} DWstring;
83 | //
84 | //
85 | //typedef struct DWfloat_
86 | //{
87 | // char format[10];
88 | // char invalidMsg[4];
89 | // uint16_t xPos;
90 | // uint16_t yPos;
91 | // uint8_t valid;
92 | // float data;
93 | // float data2;
94 | // uint16_t xPos2;
95 | // uint16_t yPos2;
96 | //} DWfloat;
97 | //
98 | //
99 | //// Global variables
100 | //// live screen data variables
101 | //extern ui_screen screenNumber;
102 | ////extern DWuint8_t counter;
103 | ////extern DWint8_t counter;
104 | //// display data
105 | //
106 | //
107 | //extern DWfloat tempInF_TC;
108 | //extern DWfloat tempInC_TC;
109 | //
110 | //extern DWfloat tempInF_amb;
111 | //extern DWfloat tempInC_amb;
112 | //
113 | //extern DWfloat show_diag;
114 | //extern DWfloat humidity;
115 | //extern DWfloat counter;
116 | //
117 | //// Global Constants
118 | //
119 | //
120 | //// exposed function prototypes
121 | //void SwitchScreens(ui_screen screen_no);
122 | ////void PrintTest(char * formater, uint16_t variable, uint8_t position);
123 | //uint8_t ProcessKeyCode (uint16_t key_code);
124 | //uint8_t ProcessKeyCodeInContext (uint16_t key_code);
125 | //void UpdateScreenValues(void);
126 | //uint8_t GetKeycode(void);
127 | //
128 | //#endif
129 |
--------------------------------------------------------------------------------
/Core/Src/freertos.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * File Name : freertos.c
5 | * Description : Code for freertos applications
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2021 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under Ultimate Liberty license
13 | * SLA0044, the "License"; You may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at:
15 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 | /* USER CODE END Header */
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | #include "FreeRTOS.h"
23 | #include "task.h"
24 | #include "main.h"
25 |
26 | /* Private includes ----------------------------------------------------------*/
27 | /* USER CODE BEGIN Includes */
28 |
29 | /* USER CODE END Includes */
30 |
31 | /* Private typedef -----------------------------------------------------------*/
32 | /* USER CODE BEGIN PTD */
33 |
34 | /* USER CODE END PTD */
35 |
36 | /* Private define ------------------------------------------------------------*/
37 | /* USER CODE BEGIN PD */
38 |
39 | /* USER CODE END PD */
40 |
41 | /* Private macro -------------------------------------------------------------*/
42 | /* USER CODE BEGIN PM */
43 |
44 | /* USER CODE END PM */
45 |
46 | /* Private variables ---------------------------------------------------------*/
47 | /* USER CODE BEGIN Variables */
48 |
49 | /* USER CODE END Variables */
50 |
51 | /* Private function prototypes -----------------------------------------------*/
52 | /* USER CODE BEGIN FunctionPrototypes */
53 |
54 | /* USER CODE END FunctionPrototypes */
55 |
56 | /* Private application code --------------------------------------------------*/
57 | /* USER CODE BEGIN Application */
58 |
59 | /* USER CODE END Application */
60 |
61 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
62 |
--------------------------------------------------------------------------------
/Core/Src/ssd1306_display.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "ssd1306.h"
4 | #include "ssd1306_tests.h"
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Core/Src/syscalls.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file syscalls.c
4 | * @author Auto-generated by STM32CubeIDE
5 | * @brief STM32CubeIDE Minimal System calls file
6 | *
7 | * For more information about which c-functions
8 | * need which of these lowlevel functions
9 | * please consult the Newlib libc-manual
10 | ******************************************************************************
11 | * @attention
12 | *
13 | * © Copyright (c) 2020 STMicroelectronics.
14 | * All rights reserved.
15 | *
16 | * This software component is licensed by ST under BSD 3-Clause license,
17 | * the "License"; You may not use this file except in compliance with the
18 | * License. You may obtain a copy of the License at:
19 | * opensource.org/licenses/BSD-3-Clause
20 | *
21 | ******************************************************************************
22 | */
23 |
24 | /* Includes */
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 |
34 |
35 | /* Variables */
36 | //#undef errno
37 | extern int errno;
38 | extern int __io_putchar(int ch) __attribute__((weak));
39 | extern int __io_getchar(void) __attribute__((weak));
40 |
41 | register char * stack_ptr asm("sp");
42 |
43 | char *__env[1] = { 0 };
44 | char **environ = __env;
45 |
46 |
47 | /* Functions */
48 | void initialise_monitor_handles()
49 | {
50 | }
51 |
52 | int _getpid(void)
53 | {
54 | return 1;
55 | }
56 |
57 | int _kill(int pid, int sig)
58 | {
59 | errno = EINVAL;
60 | return -1;
61 | }
62 |
63 | void _exit (int status)
64 | {
65 | _kill(status, -1);
66 | while (1) {} /* Make sure we hang here */
67 | }
68 |
69 | __attribute__((weak)) int _read(int file, char *ptr, int len)
70 | {
71 | int DataIdx;
72 |
73 | for (DataIdx = 0; DataIdx < len; DataIdx++)
74 | {
75 | *ptr++ = __io_getchar();
76 | }
77 |
78 | return len;
79 | }
80 |
81 | __attribute__((weak)) int _write(int file, char *ptr, int len)
82 | {
83 | int DataIdx;
84 |
85 | for (DataIdx = 0; DataIdx < len; DataIdx++)
86 | {
87 | __io_putchar(*ptr++);
88 | }
89 | return len;
90 | }
91 |
92 | int _close(int file)
93 | {
94 | return -1;
95 | }
96 |
97 |
98 | int _fstat(int file, struct stat *st)
99 | {
100 | st->st_mode = S_IFCHR;
101 | return 0;
102 | }
103 |
104 | int _isatty(int file)
105 | {
106 | return 1;
107 | }
108 |
109 | int _lseek(int file, int ptr, int dir)
110 | {
111 | return 0;
112 | }
113 |
114 | int _open(char *path, int flags, ...)
115 | {
116 | /* Pretend like we always fail */
117 | return -1;
118 | }
119 |
120 | int _wait(int *status)
121 | {
122 | errno = ECHILD;
123 | return -1;
124 | }
125 |
126 | int _unlink(char *name)
127 | {
128 | errno = ENOENT;
129 | return -1;
130 | }
131 |
132 | int _times(struct tms *buf)
133 | {
134 | return -1;
135 | }
136 |
137 | int _stat(char *file, struct stat *st)
138 | {
139 | st->st_mode = S_IFCHR;
140 | return 0;
141 | }
142 |
143 | int _link(char *old, char *new)
144 | {
145 | errno = EMLINK;
146 | return -1;
147 | }
148 |
149 | int _fork(void)
150 | {
151 | errno = EAGAIN;
152 | return -1;
153 | }
154 |
155 | int _execve(char *name, char **argv, char **env)
156 | {
157 | errno = ENOMEM;
158 | return -1;
159 | }
160 |
--------------------------------------------------------------------------------
/Core/Src/sysmem.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file sysmem.c
4 | * @author Generated by STM32CubeIDE
5 | * @brief STM32CubeIDE System Memory calls file
6 | *
7 | * For more information about which C functions
8 | * need which of these lowlevel functions
9 | * please consult the newlib libc manual
10 | ******************************************************************************
11 | * @attention
12 | *
13 | * © Copyright (c) 2020 STMicroelectronics.
14 | * All rights reserved.
15 | *
16 | * This software component is licensed by ST under BSD 3-Clause license,
17 | * the "License"; You may not use this file except in compliance with the
18 | * License. You may obtain a copy of the License at:
19 | * opensource.org/licenses/BSD-3-Clause
20 | *
21 | ******************************************************************************
22 | */
23 |
24 | /* Includes */
25 | #include
26 | #include
27 |
28 | /**
29 | * Pointer to the current high watermark of the heap usage
30 | */
31 | static uint8_t *__sbrk_heap_end = NULL;
32 |
33 | /**
34 | * @brief _sbrk() allocates memory to the newlib heap and is used by malloc
35 | * and others from the C library
36 | *
37 | * @verbatim
38 | * ############################################################################
39 | * # .data # .bss # newlib heap # MSP stack #
40 | * # # # # Reserved by _Min_Stack_Size #
41 | * ############################################################################
42 | * ^-- RAM start ^-- _end _estack, RAM end --^
43 | * @endverbatim
44 | *
45 | * This implementation starts allocating at the '_end' linker symbol
46 | * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack
47 | * The implementation considers '_estack' linker symbol to be RAM end
48 | * NOTE: If the MSP stack, at any point during execution, grows larger than the
49 | * reserved size, please increase the '_Min_Stack_Size'.
50 | *
51 | * @param incr Memory size
52 | * @return Pointer to allocated memory
53 | */
54 | void *_sbrk(ptrdiff_t incr)
55 | {
56 | extern uint8_t _end; /* Symbol defined in the linker script */
57 | extern uint8_t _estack; /* Symbol defined in the linker script */
58 | extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */
59 | const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size;
60 | const uint8_t *max_heap = (uint8_t *)stack_limit;
61 | uint8_t *prev_heap_end;
62 |
63 | /* Initialize heap end at first call */
64 | if (NULL == __sbrk_heap_end)
65 | {
66 | __sbrk_heap_end = &_end;
67 | }
68 |
69 | /* Protect heap from growing into the reserved MSP stack */
70 | if (__sbrk_heap_end + incr > max_heap)
71 | {
72 | errno = ENOMEM;
73 | return (void *)-1;
74 | }
75 |
76 | prev_heap_end = __sbrk_heap_end;
77 | __sbrk_heap_end += incr;
78 |
79 | return (void *)prev_heap_end;
80 | }
81 |
--------------------------------------------------------------------------------
/Debug/xbox_usb.elf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Debug/xbox_usb.elf
--------------------------------------------------------------------------------
/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h
--------------------------------------------------------------------------------
/Drivers/CMSIS/Include/cmsis_version.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file cmsis_version.h
3 | * @brief CMSIS Core(M) Version definitions
4 | * @version V5.0.2
5 | * @date 19. April 2017
6 | ******************************************************************************/
7 | /*
8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
9 | *
10 | * SPDX-License-Identifier: Apache-2.0
11 | *
12 | * Licensed under the Apache License, Version 2.0 (the License); you may
13 | * not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | #if defined ( __ICCARM__ )
26 | #pragma system_include /* treat file as system include file for MISRA check */
27 | #elif defined (__clang__)
28 | #pragma clang system_header /* treat file as system include file */
29 | #endif
30 |
31 | #ifndef __CMSIS_VERSION_H
32 | #define __CMSIS_VERSION_H
33 |
34 | /* CMSIS Version definitions */
35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */
37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
39 | #endif
40 |
--------------------------------------------------------------------------------
/Drivers/CMSIS/Include/tz_context.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * @file tz_context.h
3 | * @brief Context Management for Armv8-M TrustZone
4 | * @version V1.0.1
5 | * @date 10. January 2018
6 | ******************************************************************************/
7 | /*
8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved.
9 | *
10 | * SPDX-License-Identifier: Apache-2.0
11 | *
12 | * Licensed under the Apache License, Version 2.0 (the License); you may
13 | * not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | #if defined ( __ICCARM__ )
26 | #pragma system_include /* treat file as system include file for MISRA check */
27 | #elif defined (__clang__)
28 | #pragma clang system_header /* treat file as system include file */
29 | #endif
30 |
31 | #ifndef TZ_CONTEXT_H
32 | #define TZ_CONTEXT_H
33 |
34 | #include
35 |
36 | #ifndef TZ_MODULEID_T
37 | #define TZ_MODULEID_T
38 | /// \details Data type that identifies secure software modules called by a process.
39 | typedef uint32_t TZ_ModuleId_t;
40 | #endif
41 |
42 | /// \details TZ Memory ID identifies an allocated memory slot.
43 | typedef uint32_t TZ_MemoryId_t;
44 |
45 | /// Initialize secure context memory system
46 | /// \return execution status (1: success, 0: error)
47 | uint32_t TZ_InitContextSystem_S (void);
48 |
49 | /// Allocate context memory for calling secure software modules in TrustZone
50 | /// \param[in] module identifies software modules called from non-secure mode
51 | /// \return value != 0 id TrustZone memory slot identifier
52 | /// \return value 0 no memory available or internal error
53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module);
54 |
55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S
56 | /// \param[in] id TrustZone memory slot identifier
57 | /// \return execution status (1: success, 0: error)
58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id);
59 |
60 | /// Load secure context (called on RTOS thread context switch)
61 | /// \param[in] id TrustZone memory slot identifier
62 | /// \return execution status (1: success, 0: error)
63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id);
64 |
65 | /// Store secure context (called on RTOS thread context switch)
66 | /// \param[in] id TrustZone memory slot identifier
67 | /// \return execution status (1: success, 0: error)
68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id);
69 |
70 | #endif // TZ_CONTEXT_H
71 |
--------------------------------------------------------------------------------
/Drivers/SSD1306/ssd1306_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Private configuration file for the SSD1306 library.
3 | * This example is configured for STM32F0, I2C and including all fonts.
4 | */
5 |
6 | #ifndef __SSD1306_CONF_H__
7 | #define __SSD1306_CONF_H__
8 |
9 | // Choose a microcontroller family
10 | //#define STM32F0
11 | //#define STM32F1
12 | #define STM32F4
13 | //#define STM32L0
14 | //#define STM32L4
15 | //#define STM32F3
16 | //#define STM32H7
17 | //#define STM32F7
18 |
19 | // Choose a bus
20 | #define SSD1306_USE_I2C
21 | //#define SSD1306_USE_SPI
22 |
23 | // I2C Configuration
24 | #define SSD1306_I2C_PORT hi2c1
25 | #define SSD1306_I2C_ADDR (0x3C << 1)
26 |
27 | // SPI Configuration
28 | //#define SSD1306_SPI_PORT hspi1
29 | //#define SSD1306_CS_Port OLED_CS_GPIO_Port
30 | //#define SSD1306_CS_Pin OLED_CS_Pin
31 | //#define SSD1306_DC_Port OLED_DC_GPIO_Port
32 | //#define SSD1306_DC_Pin OLED_DC_Pin
33 | //#define SSD1306_Reset_Port OLED_Res_GPIO_Port
34 | //#define SSD1306_Reset_Pin OLED_Res_Pin
35 |
36 | // Mirror the screen if needed
37 | // #define SSD1306_MIRROR_VERT
38 | // #define SSD1306_MIRROR_HORIZ
39 |
40 | // Set inverse color if needed
41 | // # define SSD1306_INVERSE_COLOR
42 |
43 | // Include only needed fonts
44 | #define SSD1306_INCLUDE_FONT_6x8
45 | #define SSD1306_INCLUDE_FONT_7x10
46 | #define SSD1306_INCLUDE_FONT_11x18
47 | #define SSD1306_INCLUDE_FONT_16x26
48 |
49 | // Some OLEDs don't display anything in first two columns.
50 | // In this case change the following macro to 130.
51 | // The default value is 128.
52 | // #define SSD1306_WIDTH 130
53 |
54 | // The height can be changed as well if necessary.
55 | // It can be 32, 64 or 128. The default value is 64.
56 | // #define SSD1306_HEIGHT 64
57 |
58 | #endif /* __SSD1306_CONF_H__ */
59 |
--------------------------------------------------------------------------------
/Drivers/SSD1306/ssd1306_conf_template.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Private configuration file for the SSD1306 library.
3 | * This example is configured for STM32F0, I2C and including all fonts.
4 | */
5 |
6 | #ifndef __SSD1306_CONF_H__
7 | #define __SSD1306_CONF_H__
8 |
9 | // Choose a microcontroller family
10 | #define STM32F0
11 | //#define STM32F1
12 | //#define STM32F4
13 | //#define STM32L0
14 | //#define STM32L4
15 | //#define STM32F3
16 | //#define STM32H7
17 | //#define STM32F7
18 |
19 | // Choose a bus
20 | #define SSD1306_USE_I2C
21 | //#define SSD1306_USE_SPI
22 |
23 | // I2C Configuration
24 | #define SSD1306_I2C_PORT hi2c1
25 | #define SSD1306_I2C_ADDR (0x3C << 1)
26 |
27 | // SPI Configuration
28 | //#define SSD1306_SPI_PORT hspi1
29 | //#define SSD1306_CS_Port OLED_CS_GPIO_Port
30 | //#define SSD1306_CS_Pin OLED_CS_Pin
31 | //#define SSD1306_DC_Port OLED_DC_GPIO_Port
32 | //#define SSD1306_DC_Pin OLED_DC_Pin
33 | //#define SSD1306_Reset_Port OLED_Res_GPIO_Port
34 | //#define SSD1306_Reset_Pin OLED_Res_Pin
35 |
36 | // Mirror the screen if needed
37 | // #define SSD1306_MIRROR_VERT
38 | // #define SSD1306_MIRROR_HORIZ
39 |
40 | // Set inverse color if needed
41 | // # define SSD1306_INVERSE_COLOR
42 |
43 | // Include only needed fonts
44 | #define SSD1306_INCLUDE_FONT_6x8
45 | #define SSD1306_INCLUDE_FONT_7x10
46 | #define SSD1306_INCLUDE_FONT_11x18
47 | #define SSD1306_INCLUDE_FONT_16x26
48 |
49 | // Some OLEDs don't display anything in first two columns.
50 | // In this case change the following macro to 130.
51 | // The default value is 128.
52 | // #define SSD1306_WIDTH 130
53 |
54 | // The height can be changed as well if necessary.
55 | // It can be 32, 64 or 128. The default value is 64.
56 | // #define SSD1306_HEIGHT 64
57 |
58 | #endif /* __SSD1306_CONF_H__ */
59 |
--------------------------------------------------------------------------------
/Drivers/SSD1306/ssd1306_fonts.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #ifndef __SSD1306_FONTS_H__
4 | #define __SSD1306_FONTS_H__
5 |
6 | #include "ssd1306_conf.h"
7 |
8 | typedef struct {
9 | const uint8_t FontWidth; /*!< Font width in pixels */
10 | uint8_t FontHeight; /*!< Font height in pixels */
11 | const uint16_t *data; /*!< Pointer to data font data array */
12 | } FontDef;
13 |
14 | #ifdef SSD1306_INCLUDE_FONT_6x8
15 | extern FontDef Font_6x8;
16 | #endif
17 | #ifdef SSD1306_INCLUDE_FONT_7x10
18 | extern FontDef Font_7x10;
19 | #endif
20 | #ifdef SSD1306_INCLUDE_FONT_11x18
21 | extern FontDef Font_11x18;
22 | #endif
23 | #ifdef SSD1306_INCLUDE_FONT_16x26
24 | extern FontDef Font_16x26;
25 | #endif
26 | #endif // __SSD1306_FONTS_H__
27 |
--------------------------------------------------------------------------------
/Drivers/SSD1306/ssd1306_tests.h:
--------------------------------------------------------------------------------
1 | #ifndef __SSD1306_TEST_H__
2 | #define __SSD1306_TEST_H__
3 |
4 | #include <_ansi.h>
5 |
6 | _BEGIN_STD_C
7 |
8 | void ssd1306_TestBorder(void);
9 | void ssd1306_TestFonts(void);
10 | void ssd1306_TestFPS(void);
11 | void ssd1306_TestAll(void);
12 | void ssd1306_TestLine(void);
13 | void ssd1306_TestRectangle(void);
14 | void ssd1306_TestCircle(void);
15 | void ssd1306_TestArc(void);
16 | void ssd1306_TestPolyline(void);
17 |
18 |
19 |
20 | _END_STD_C
21 |
22 | #endif // __SSD1306_TEST_H__
23 |
--------------------------------------------------------------------------------
/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_hal_dma_ex.h
4 | * @author MCD Application Team
5 | * @brief Header file of DMA HAL extension module.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2017 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __STM32F4xx_HAL_DMA_EX_H
22 | #define __STM32F4xx_HAL_DMA_EX_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm32f4xx_hal_def.h"
30 |
31 | /** @addtogroup STM32F4xx_HAL_Driver
32 | * @{
33 | */
34 |
35 | /** @addtogroup DMAEx
36 | * @{
37 | */
38 |
39 | /* Exported types ------------------------------------------------------------*/
40 | /** @defgroup DMAEx_Exported_Types DMAEx Exported Types
41 | * @brief DMAEx Exported types
42 | * @{
43 | */
44 |
45 | /**
46 | * @brief HAL DMA Memory definition
47 | */
48 | typedef enum
49 | {
50 | MEMORY0 = 0x00U, /*!< Memory 0 */
51 | MEMORY1 = 0x01U /*!< Memory 1 */
52 | }HAL_DMA_MemoryTypeDef;
53 |
54 | /**
55 | * @}
56 | */
57 |
58 | /* Exported functions --------------------------------------------------------*/
59 | /** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions
60 | * @brief DMAEx Exported functions
61 | * @{
62 | */
63 |
64 | /** @defgroup DMAEx_Exported_Functions_Group1 Extended features functions
65 | * @brief Extended features functions
66 | * @{
67 | */
68 |
69 | /* IO operation functions *******************************************************/
70 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength);
71 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength);
72 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory);
73 |
74 | /**
75 | * @}
76 | */
77 | /**
78 | * @}
79 | */
80 |
81 | /* Private functions ---------------------------------------------------------*/
82 | /** @defgroup DMAEx_Private_Functions DMAEx Private Functions
83 | * @brief DMAEx Private functions
84 | * @{
85 | */
86 | /**
87 | * @}
88 | */
89 |
90 | /**
91 | * @}
92 | */
93 |
94 | /**
95 | * @}
96 | */
97 |
98 | #ifdef __cplusplus
99 | }
100 | #endif
101 |
102 | #endif /*__STM32F4xx_HAL_DMA_EX_H*/
103 |
104 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
105 |
--------------------------------------------------------------------------------
/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_hal_flash_ramfunc.h
4 | * @author MCD Application Team
5 | * @brief Header file of FLASH RAMFUNC driver.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2017 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __STM32F4xx_FLASH_RAMFUNC_H
22 | #define __STM32F4xx_FLASH_RAMFUNC_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
28 | defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
29 |
30 | /* Includes ------------------------------------------------------------------*/
31 | #include "stm32f4xx_hal_def.h"
32 |
33 | /** @addtogroup STM32F4xx_HAL_Driver
34 | * @{
35 | */
36 |
37 | /** @addtogroup FLASH_RAMFUNC
38 | * @{
39 | */
40 |
41 | /* Exported types ------------------------------------------------------------*/
42 | /* Exported macro ------------------------------------------------------------*/
43 | /* Exported functions --------------------------------------------------------*/
44 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions
45 | * @{
46 | */
47 |
48 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group1
49 | * @{
50 | */
51 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StopFlashInterfaceClk(void);
52 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StartFlashInterfaceClk(void);
53 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableFlashSleepMode(void);
54 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableFlashSleepMode(void);
55 | /**
56 | * @}
57 | */
58 |
59 | /**
60 | * @}
61 | */
62 |
63 | /**
64 | * @}
65 | */
66 |
67 | /**
68 | * @}
69 | */
70 |
71 | #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
72 | #ifdef __cplusplus
73 | }
74 | #endif
75 |
76 |
77 | #endif /* __STM32F4xx_FLASH_RAMFUNC_H */
78 |
79 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
80 |
--------------------------------------------------------------------------------
/IMG_20210315_002914.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/IMG_20210315_002914.jpg
--------------------------------------------------------------------------------
/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_req.h
4 | * @author MCD Application Team
5 | * @brief Header file for the usbd_req.c file
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2015 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under Ultimate Liberty license
13 | * SLA0044, the "License"; You may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at:
15 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __USB_REQUEST_H
22 | #define __USB_REQUEST_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "usbd_def.h"
30 |
31 |
32 | /** @addtogroup STM32_USB_DEVICE_LIBRARY
33 | * @{
34 | */
35 |
36 | /** @defgroup USBD_REQ
37 | * @brief header file for the usbd_req.c file
38 | * @{
39 | */
40 |
41 | /** @defgroup USBD_REQ_Exported_Defines
42 | * @{
43 | */
44 | /**
45 | * @}
46 | */
47 |
48 |
49 | /** @defgroup USBD_REQ_Exported_Types
50 | * @{
51 | */
52 | /**
53 | * @}
54 | */
55 |
56 |
57 |
58 | /** @defgroup USBD_REQ_Exported_Macros
59 | * @{
60 | */
61 | /**
62 | * @}
63 | */
64 |
65 | /** @defgroup USBD_REQ_Exported_Variables
66 | * @{
67 | */
68 | /**
69 | * @}
70 | */
71 |
72 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype
73 | * @{
74 | */
75 |
76 | USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
77 | USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
78 | USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
79 |
80 | void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
81 | void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata);
82 | void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len);
83 |
84 | /**
85 | * @}
86 | */
87 |
88 | #ifdef __cplusplus
89 | }
90 | #endif
91 |
92 | #endif /* __USB_REQUEST_H */
93 |
94 | /**
95 | * @}
96 | */
97 |
98 | /**
99 | * @}
100 | */
101 |
102 |
103 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
104 |
--------------------------------------------------------------------------------
/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_ioreq.h
4 | * @author MCD Application Team
5 | * @brief Header file for the usbd_ioreq.c file
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2015 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under Ultimate Liberty license
13 | * SLA0044, the "License"; You may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at:
15 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __USBD_IOREQ_H
22 | #define __USBD_IOREQ_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "usbd_def.h"
30 | #include "usbd_core.h"
31 |
32 | /** @addtogroup STM32_USB_DEVICE_LIBRARY
33 | * @{
34 | */
35 |
36 | /** @defgroup USBD_IOREQ
37 | * @brief header file for the usbd_ioreq.c file
38 | * @{
39 | */
40 |
41 | /** @defgroup USBD_IOREQ_Exported_Defines
42 | * @{
43 | */
44 | /**
45 | * @}
46 | */
47 |
48 |
49 | /** @defgroup USBD_IOREQ_Exported_Types
50 | * @{
51 | */
52 |
53 |
54 | /**
55 | * @}
56 | */
57 |
58 |
59 |
60 | /** @defgroup USBD_IOREQ_Exported_Macros
61 | * @{
62 | */
63 |
64 | /**
65 | * @}
66 | */
67 |
68 | /** @defgroup USBD_IOREQ_Exported_Variables
69 | * @{
70 | */
71 |
72 | /**
73 | * @}
74 | */
75 |
76 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype
77 | * @{
78 | */
79 |
80 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
81 | uint8_t *pbuf, uint32_t len);
82 |
83 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev,
84 | uint8_t *pbuf, uint32_t len);
85 |
86 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
87 | uint8_t *pbuf, uint32_t len);
88 |
89 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev,
90 | uint8_t *pbuf, uint32_t len);
91 |
92 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev);
93 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev);
94 |
95 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
96 |
97 | /**
98 | * @}
99 | */
100 |
101 | #ifdef __cplusplus
102 | }
103 | #endif
104 |
105 | #endif /* __USBD_IOREQ_H */
106 |
107 | /**
108 | * @}
109 | */
110 |
111 | /**
112 | * @}
113 | */
114 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
115 |
--------------------------------------------------------------------------------
/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/freertos_mpool.h:
--------------------------------------------------------------------------------
1 | /* --------------------------------------------------------------------------
2 | * Copyright (c) 2013-2020 Arm Limited. All rights reserved.
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the License); you may
7 | * not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * Name: freertos_mpool.h
19 | * Purpose: CMSIS RTOS2 wrapper for FreeRTOS
20 | *
21 | *---------------------------------------------------------------------------*/
22 |
23 | #ifndef FREERTOS_MPOOL_H_
24 | #define FREERTOS_MPOOL_H_
25 |
26 | #include
27 | #include "FreeRTOS.h"
28 | #include "semphr.h"
29 |
30 | /* Memory Pool implementation definitions */
31 | #define MPOOL_STATUS 0x5EED0000U
32 |
33 | /* Memory Block header */
34 | typedef struct {
35 | void *next; /* Pointer to next block */
36 | } MemPoolBlock_t;
37 |
38 | /* Memory Pool control block */
39 | typedef struct MemPoolDef_t {
40 | MemPoolBlock_t *head; /* Pointer to head block */
41 | SemaphoreHandle_t sem; /* Pool semaphore handle */
42 | uint8_t *mem_arr; /* Pool memory array */
43 | uint32_t mem_sz; /* Pool memory array size */
44 | const char *name; /* Pointer to name string */
45 | uint32_t bl_sz; /* Size of a single block */
46 | uint32_t bl_cnt; /* Number of blocks */
47 | uint32_t n; /* Block allocation index */
48 | volatile uint32_t status; /* Object status flags */
49 | #if (configSUPPORT_STATIC_ALLOCATION == 1)
50 | StaticSemaphore_t mem_sem; /* Semaphore object memory */
51 | #endif
52 | } MemPool_t;
53 |
54 | /* No need to hide static object type, just align to coding style */
55 | #define StaticMemPool_t MemPool_t
56 |
57 | /* Define memory pool control block size */
58 | #define MEMPOOL_CB_SIZE (sizeof(StaticMemPool_t))
59 |
60 | /* Define size of the byte array required to create count of blocks of given size */
61 | #define MEMPOOL_ARR_SIZE(bl_count, bl_size) (((((bl_size) + (4 - 1)) / 4) * 4)*(bl_count))
62 |
63 | #endif /* FREERTOS_MPOOL_H_ */
64 |
--------------------------------------------------------------------------------
/USB_DEVICE/App/usb_device.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : usb_device.c
5 | * @version : v1.0_Cube
6 | * @brief : This file implements the USB Device
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2021 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under Ultimate Liberty license
14 | * SLA0044, the "License"; You may not use this file except in compliance with
15 | * the License. You may obtain a copy of the License at:
16 | * www.st.com/SLA0044
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 |
24 | #include "usb_device.h"
25 | #include "usbd_core.h"
26 | #include "usbd_desc.h"
27 | #include "usbd_hid.h"
28 |
29 | /* USER CODE BEGIN Includes */
30 |
31 | /* USER CODE END Includes */
32 |
33 | /* USER CODE BEGIN PV */
34 | /* Private variables ---------------------------------------------------------*/
35 | uint8_t usb_failed2 = 0;
36 | /* USER CODE END PV */
37 |
38 | /* USER CODE BEGIN PFP */
39 | /* Private function prototypes -----------------------------------------------*/
40 |
41 | /* USER CODE END PFP */
42 |
43 | /* USB Device Core handle declaration. */
44 | USBD_HandleTypeDef hUsbDeviceFS;
45 |
46 | /*
47 | * -- Insert your variables declaration here --
48 | */
49 | /* USER CODE BEGIN 0 */
50 |
51 | /* USER CODE END 0 */
52 |
53 | /*
54 | * -- Insert your external function declaration here --
55 | */
56 | /* USER CODE BEGIN 1 */
57 |
58 | /* USER CODE END 1 */
59 |
60 | /**
61 | * Init USB device Library, add supported class and start the library
62 | * @retval None
63 | */
64 | void MX_USB_DEVICE_Init(void)
65 | {
66 | /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
67 |
68 | /* USER CODE END USB_DEVICE_Init_PreTreatment */
69 |
70 | /* Init Device Library, add supported class and start the library. */
71 | if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK)
72 | {
73 | usb_failed2 = 1;
74 | Error_Handler();
75 | }
76 | if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_HID) != USBD_OK)
77 | {
78 | usb_failed2 = 1;
79 | Error_Handler();
80 | }
81 | if (USBD_Start(&hUsbDeviceFS) != USBD_OK)
82 | {
83 | usb_failed2 = 1;
84 | Error_Handler();
85 | }
86 |
87 | /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */
88 |
89 | /* USER CODE END USB_DEVICE_Init_PostTreatment */
90 | }
91 |
92 | /**
93 | * @}
94 | */
95 |
96 | /**
97 | * @}
98 | */
99 |
100 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
101 |
--------------------------------------------------------------------------------
/USB_DEVICE/App/usb_device.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : usb_device.h
5 | * @version : v1.0_Cube
6 | * @brief : Header for usb_device.c file.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2021 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under Ultimate Liberty license
14 | * SLA0044, the "License"; You may not use this file except in compliance with
15 | * the License. You may obtain a copy of the License at:
16 | * www.st.com/SLA0044
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USB_DEVICE__H__
24 | #define __USB_DEVICE__H__
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /* Includes ------------------------------------------------------------------*/
31 | #include "stm32f4xx.h"
32 | #include "stm32f4xx_hal.h"
33 | #include "usbd_def.h"
34 |
35 | /* USER CODE BEGIN INCLUDE */
36 |
37 | /* USER CODE END INCLUDE */
38 |
39 | /** @addtogroup USBD_OTG_DRIVER
40 | * @{
41 | */
42 |
43 | /** @defgroup USBD_DEVICE USBD_DEVICE
44 | * @brief Device file for Usb otg low level driver.
45 | * @{
46 | */
47 |
48 | /** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables
49 | * @brief Public variables.
50 | * @{
51 | */
52 |
53 | /* Private variables ---------------------------------------------------------*/
54 | /* USER CODE BEGIN PV */
55 |
56 | /* USER CODE END PV */
57 |
58 | /* Private function prototypes -----------------------------------------------*/
59 | /* USER CODE BEGIN PFP */
60 |
61 | /* USER CODE END PFP */
62 |
63 | /*
64 | * -- Insert your variables declaration here --
65 | */
66 | /* USER CODE BEGIN VARIABLES */
67 |
68 | /* USER CODE END VARIABLES */
69 | /**
70 | * @}
71 | */
72 |
73 | /** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype
74 | * @brief Declaration of public functions for Usb device.
75 | * @{
76 | */
77 |
78 | /** USB Device initialization function. */
79 | void MX_USB_DEVICE_Init(void);
80 |
81 | /*
82 | * -- Insert functions declaration here --
83 | */
84 | /* USER CODE BEGIN FD */
85 |
86 | /* USER CODE END FD */
87 | /**
88 | * @}
89 | */
90 |
91 | /**
92 | * @}
93 | */
94 |
95 | /**
96 | * @}
97 | */
98 |
99 | #ifdef __cplusplus
100 | }
101 | #endif
102 |
103 | #endif /* __USB_DEVICE__H__ */
104 |
105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
106 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 | * text eol=lf
4 |
5 | # Custom for Visual Studio
6 | *.cs diff=csharp
7 | *.sln merge=union
8 | *.csproj merge=union
9 | *.vbproj merge=union
10 | *.fsproj merge=union
11 | *.dbproj merge=union
12 |
13 | # Standard to msysgit
14 | *.doc diff=astextplain
15 | *.DOC diff=astextplain
16 | *.docx diff=astextplain
17 | *.DOCX diff=astextplain
18 | *.dot diff=astextplain
19 | *.DOT diff=astextplain
20 | *.pdf diff=astextplain
21 | *.PDF diff=astextplain
22 | *.rtf diff=astextplain
23 | *.RTF diff=astextplain
24 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/.gitignore:
--------------------------------------------------------------------------------
1 | *.bak
2 | *.zip
3 | *.rar
4 | build/
5 | venv/
6 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "examples/testusbhostFAT/generic_storage"]
2 | path = examples/testusbhostFAT/generic_storage
3 | url = https://github.com/xxxajk/generic_storage
4 | [submodule "examples/testusbhostFAT/xmem2"]
5 | path = examples/testusbhostFAT/xmem2
6 | url = https://github.com/xxxajk/xmem2
7 | [submodule "examples/testusbhostFAT/Arduino_Makefile_master"]
8 | path = examples/testusbhostFAT/Arduino_Makefile_master
9 | url = https://github.com/xxxajk/Arduino_Makefile_master
10 | [submodule "examples/testusbhostFAT/RTClib"]
11 | path = examples/testusbhostFAT/RTClib
12 | url = https://github.com/xxxajk/RTClib
13 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/UHS2_gpio.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; either version 2 of the License, or
6 | (at your option) any later version.
7 |
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with this program; if not, write to the Free Software
15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 |
17 | Contact information
18 | -------------------
19 |
20 | Circuits At Home, LTD
21 | Web : http://www.circuitsathome.com
22 | e-mail : support@circuitsathome.com
23 |
24 | UHS2_GPIO implements "wiring" style GPIO access. Implemented by Brian Walton brian@riban.co.uk
25 | */
26 |
27 | #include "UHS2_gpio.h"
28 |
29 | /** @brief Implement an instance of a UHS2_GPIO object
30 | * @param pUSB Pointer to a UHS2 USB object
31 | */
32 | UHS2_GPIO::UHS2_GPIO(USB *pUsb) : m_pUsb(pUsb)
33 | {
34 | }
35 |
36 | /** @brief Set a GPIO output value
37 | * @param pin GPIO output pin on USB Host Shield to set
38 | * @param val Value to set the pin to (zero value will clear output, non-zero value will assert output)
39 | */
40 | void UHS2_GPIO::digitalWrite(uint8_t pin, uint8_t val) {
41 | if(pin > 7)
42 | return;
43 | uint8_t nValue = m_pUsb->gpioRdOutput();
44 | uint8_t nMask = 1 << pin;
45 | nValue &= (~nMask);
46 | if(val)
47 | nValue |= (nMask);
48 | m_pUsb->gpioWr(nValue);
49 | }
50 |
51 | /** @brief Read the value from a GPIO input pin
52 | * @param pin GPIO input pin on USB Host Shield to read
53 | * @retval int Value of GPIO input (-1 on fail)
54 | */
55 | int UHS2_GPIO::digitalRead(uint8_t pin) {
56 | if(pin > 7)
57 | return -1;
58 | uint8_t nMask = 1 << pin;
59 | uint8_t nValue = m_pUsb->gpioRd();
60 | return ((nValue & nMask)?1:0);
61 | }
62 |
63 | /** @brief Read the value from a GPIO output pin
64 | * @param pin GPIO output pin on USB Host Shield to read
65 | * @retval int Value of GPIO output (-1 on fail)
66 | * @note Value of MAX3421E output register, i.e. what the device has been set to, not the physical value on the pin
67 | */
68 | int UHS2_GPIO::digitalReadOutput(uint8_t pin) {
69 | if(pin > 7)
70 | return -1;
71 | uint8_t nMask = 1 << pin;
72 | uint8_t nValue = m_pUsb->gpioRdOutput();
73 | return ((nValue & nMask)?1:0);
74 | }
75 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/UHS2_gpio.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; either version 2 of the License, or
6 | (at your option) any later version.
7 |
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with this program; if not, write to the Free Software
15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 |
17 | Contact information
18 | -------------------
19 |
20 | Circuits At Home, LTD
21 | Web : http://www.circuitsathome.com
22 | e-mail : support@circuitsathome.com
23 |
24 | UHS2_GPIO implements "wiring" style GPIO access. Implemented by Brian Walton brian@riban.co.uk
25 | */
26 |
27 | #if !defined(__USB2_GPIO_H__)
28 | #define __USB2_GPIO_H__
29 |
30 | #include "Usb.h"
31 |
32 | class UHS2_GPIO {
33 | public:
34 | UHS2_GPIO(USB *pUsb);
35 |
36 | void digitalWrite(uint8_t pin, uint8_t val);
37 | int digitalRead(uint8_t pin);
38 | int digitalReadOutput(uint8_t pin);
39 |
40 | private:
41 | USB* m_pUsb;
42 | };
43 |
44 | #endif // __USB2_GPIO_H__
45 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/Usb.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; either version 2 of the License, or
6 | (at your option) any later version.
7 |
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with this program; if not, write to the Free Software
15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 |
17 | Contact information
18 | -------------------
19 |
20 | Circuits At Home, LTD
21 | Web : http://www.circuitsathome.com
22 | e-mail : support@circuitsathome.com
23 | */
24 | /* USB functions */
25 | #ifndef _usb_h_
26 | #define _usb_h_
27 |
28 | // WARNING: Do not change the order of includes, or stuff will break!
29 | #include
30 | #include
31 | #include
32 |
33 | // None of these should ever be included by a driver, or a user's sketch.
34 | #include "settings.h"
35 | #include "printhex.h"
36 | #include "message.h"
37 | #include "hexdump.h"
38 | #include "sink_parser.h"
39 | #include "max3421e.h"
40 | #include "address.h"
41 | #include "avrpins.h"
42 | #include "usb_ch9.h"
43 | #include "usbhost.h"
44 | #include "UsbCore.h"
45 | #include "parsetools.h"
46 | #include "confdescparser.h"
47 |
48 | #endif //_usb_h_
49 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/WiiCameraReadme.md:
--------------------------------------------------------------------------------
1 | Please see for the complete capabilities of the Wii camera. The IR camera code was written based on the above website and with support from Kristian Lauszus.
2 |
3 | This library is large, if you run into memory problems when uploading to the Arduino, disable serial debugging.
4 |
5 | To enable the IR camera code, simply set ```ENABLE_WII_IR_CAMERA``` to 1 in [settings.h](settings.h).
6 |
7 | This library implements the following settings:
8 |
9 | * Report sensitivity mode: 00 00 00 00 00 00 90 00 41 40 00 Suggested by inio (high sensitivity)
10 | * Data Format: Extended mode (0x03). Full mode is not working yet. The output reports 0x3e and 0x3f need tampering with
11 | * In this mode the camera outputs x and y coordinates and a size dimension for the 4 brightest points.
12 |
13 | Again, read through to get an understanding of the camera and its settings.
14 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/XBOXONESBT.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2020 Kristian Sloth Lauszus. All rights reserved.
2 |
3 | This software may be distributed and modified under the terms of the GNU
4 | General Public License version 2 (GPL2) as published by the Free Software
5 | Foundation and appearing in the file GPL2.TXT included in the packaging of
6 | this file. Please note that GPL2 Section 2[b] requires that all works based
7 | on this software must also be made publicly available under the terms of
8 | the GPL2 ("Copyleft").
9 |
10 | Contact information
11 | -------------------
12 |
13 | Kristian Sloth Lauszus
14 | Web : https://lauszus.com
15 | e-mail : lauszus@gmail.com
16 | */
17 |
18 | #ifndef _xboxonesbt_h_
19 | #define _xboxonesbt_h_
20 |
21 | #include "BTHID.h"
22 | #include "XBOXONESParser.h"
23 |
24 | /**
25 | * This class implements support for the Xbox One S controller via Bluetooth.
26 | * It uses the BTHID class for all the Bluetooth communication.
27 | */
28 | class XBOXONESBT : public BTHID, public XBOXONESParser {
29 | public:
30 | /**
31 | * Constructor for the XBOXONESBT class.
32 | * @param p Pointer to the BTD class instance.
33 | * @param pair Set this to true in order to pair with the device. If the argument is omitted then it will not pair with it. One can use ::PAIR to set it to true.
34 | */
35 | XBOXONESBT(BTD *p, bool pair = false) :
36 | BTHID(p, pair) {
37 | XBOXONESParser::Reset();
38 | pBtd->useSimplePairing = true; // The Xbox One S controller only works via simple pairing
39 | };
40 |
41 | /**
42 | * Used to check if a Xbox One S controller is connected.
43 | * @return Returns true if it is connected.
44 | */
45 | bool connected() {
46 | return BTHID::connected;
47 | };
48 |
49 | protected:
50 | /** @name BTHID implementation */
51 | /**
52 | * Used to parse Bluetooth HID data.
53 | * @param len The length of the incoming data.
54 | * @param buf Pointer to the data buffer.
55 | */
56 | virtual void ParseBTHIDData(uint8_t len, uint8_t *buf) {
57 | XBOXONESParser::Parse(len, buf);
58 | };
59 |
60 | /**
61 | * Called when a device is successfully initialized.
62 | * Use attachOnInit(void (*funcOnInit)(void)) to call your own function.
63 | * This is useful for instance if you want to set the LEDs in a specific way.
64 | */
65 | virtual void OnInitBTHID() {
66 | XBOXONESParser::Reset();
67 | };
68 |
69 | /** Used to reset the different buffers to there default values */
70 | virtual void ResetBTHID() {
71 | XBOXONESParser::Reset();
72 | };
73 | /**@}*/
74 |
75 | /** @name XBOXONESParser implementation */
76 | virtual void sendOutputReport(uint8_t *data, uint8_t nbytes) {
77 | // See: https://lore.kernel.org/patchwork/patch/973394/
78 | uint8_t buf[nbytes + 2];
79 | buf[0] = 0xA2; // HID BT DATA (0xA0) | Report Type (Output 0x02)
80 | buf[1] = 0x03; // Report ID
81 | memcpy(buf + 2, data, nbytes);
82 |
83 | // Send the Bluetooth DATA output report on the interrupt channel
84 | pBtd->L2CAP_Command(hci_handle, buf, sizeof(buf), interrupt_scid[0], interrupt_scid[1]);
85 | };
86 | /**@}*/
87 | };
88 | #endif
89 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/doc/README.md:
--------------------------------------------------------------------------------
1 | # USB Host Library Rev.2.0
2 |
3 | The code is released under the GNU General Public License.
4 | __________
5 | [](https://travis-ci.org/felis/USB_Host_Shield_2.0)
6 |
7 | # Documentation
8 |
9 | The documenation is automatically build using [Travis](https://travis-ci.com/) and hosted using [Github Pages](https://help.github.com/categories/github-pages-basics/).
10 |
11 | The library documentation is generated using [Doxygen](http://www.stack.nl/~dimitri/doxygen/) and can be found at the following link: .
12 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/doc/imageStyle.css:
--------------------------------------------------------------------------------
1 | .image
2 | {
3 | text-align: left;
4 | }
5 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/Bluetooth/BTHID/BTHID.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Example sketch for the HID Bluetooth library - developed by Kristian Lauszus
3 | For more information visit my blog: http://blog.tkjelectronics.dk/ or
4 | send me an e-mail: kristianl@tkjelectronics.com
5 | */
6 |
7 | #include
8 | #include
9 | #include "KeyboardParser.h"
10 | #include "MouseParser.h"
11 |
12 | // Satisfy the IDE, which needs to see the include statment in the ino too.
13 | #ifdef dobogusinclude
14 | #include
15 | #endif
16 | #include
17 |
18 | USB Usb;
19 | //USBHub Hub1(&Usb); // Some dongles have a hub inside
20 | BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
21 |
22 | /* You can create the instance of the class in two ways */
23 | // This will start an inquiry and then pair with your device - you only have to do this once
24 | // If you are using a Bluetooth keyboard, then you should type in the password on the keypad and then press enter
25 | BTHID bthid(&Btd, PAIR, "0000");
26 |
27 | // After that you can simply create the instance like so and then press any button on the device
28 | //BTHID bthid(&Btd);
29 |
30 | KbdRptParser keyboardPrs;
31 | MouseRptParser mousePrs;
32 |
33 | void setup() {
34 | Serial.begin(115200);
35 | #if !defined(__MIPSEL__)
36 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
37 | #endif
38 | if (Usb.Init() == -1) {
39 | Serial.print(F("\r\nOSC did not start"));
40 | while (1); // Halt
41 | }
42 |
43 | bthid.SetReportParser(KEYBOARD_PARSER_ID, &keyboardPrs);
44 | bthid.SetReportParser(MOUSE_PARSER_ID, &mousePrs);
45 |
46 | // If "Boot Protocol Mode" does not work, then try "Report Protocol Mode"
47 | // If that does not work either, then uncomment PRINTREPORT in BTHID.cpp to see the raw report
48 | bthid.setProtocolMode(USB_HID_BOOT_PROTOCOL); // Boot Protocol Mode
49 | //bthid.setProtocolMode(HID_RPT_PROTOCOL); // Report Protocol Mode
50 |
51 | Serial.print(F("\r\nHID Bluetooth Library Started"));
52 | }
53 | void loop() {
54 | Usb.Task();
55 | }
56 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/Bluetooth/BTHID/MouseParser.h:
--------------------------------------------------------------------------------
1 | #ifndef __mouserptparser_h__
2 | #define __mouserptparser_h__
3 |
4 | class MouseRptParser : public MouseReportParser {
5 | protected:
6 | virtual void OnMouseMove(MOUSEINFO *mi);
7 | virtual void OnLeftButtonUp(MOUSEINFO *mi);
8 | virtual void OnLeftButtonDown(MOUSEINFO *mi);
9 | virtual void OnRightButtonUp(MOUSEINFO *mi);
10 | virtual void OnRightButtonDown(MOUSEINFO *mi);
11 | virtual void OnMiddleButtonUp(MOUSEINFO *mi);
12 | virtual void OnMiddleButtonDown(MOUSEINFO *mi);
13 | };
14 |
15 | void MouseRptParser::OnMouseMove(MOUSEINFO *mi) {
16 | Serial.print(F("dx="));
17 | Serial.print(mi->dX, DEC);
18 | Serial.print(F(" dy="));
19 | Serial.println(mi->dY, DEC);
20 | };
21 |
22 | void MouseRptParser::OnLeftButtonUp(MOUSEINFO *mi) {
23 | Serial.println(F("L Butt Up"));
24 | };
25 |
26 | void MouseRptParser::OnLeftButtonDown(MOUSEINFO *mi) {
27 | Serial.println(F("L Butt Dn"));
28 | };
29 |
30 | void MouseRptParser::OnRightButtonUp(MOUSEINFO *mi) {
31 | Serial.println(F("R Butt Up"));
32 | };
33 |
34 | void MouseRptParser::OnRightButtonDown(MOUSEINFO *mi) {
35 | Serial.println(F("R Butt Dn"));
36 | };
37 |
38 | void MouseRptParser::OnMiddleButtonUp(MOUSEINFO *mi) {
39 | Serial.println(F("M Butt Up"));
40 | };
41 |
42 | void MouseRptParser::OnMiddleButtonDown(MOUSEINFO *mi) {
43 | Serial.println(F("M Butt Dn"));
44 | };
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/Bluetooth/SPP/SPP.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Example sketch for the RFCOMM/SPP Bluetooth library - developed by Kristian Lauszus
3 | For more information visit my blog: http://blog.tkjelectronics.dk/ or
4 | send me an e-mail: kristianl@tkjelectronics.com
5 | */
6 |
7 | #include
8 | #include
9 |
10 | // Satisfy the IDE, which needs to see the include statment in the ino too.
11 | #ifdef dobogusinclude
12 | #include
13 | #endif
14 | #include
15 |
16 | USB Usb;
17 | //USBHub Hub1(&Usb); // Some dongles have a hub inside
18 |
19 | BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
20 | /* You can create the instance of the class in two ways */
21 | SPP SerialBT(&Btd); // This will set the name to the defaults: "Arduino" and the pin to "0000"
22 | //SPP SerialBT(&Btd, "Lauszus's Arduino", "1234"); // You can also set the name and pin like so
23 |
24 | bool firstMessage = true;
25 |
26 | void setup() {
27 | Serial.begin(115200);
28 | #if !defined(__MIPSEL__)
29 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
30 | #endif
31 | if (Usb.Init() == -1) {
32 | Serial.print(F("\r\nOSC did not start"));
33 | while (1); //halt
34 | }
35 | Serial.print(F("\r\nSPP Bluetooth Library Started"));
36 | }
37 | void loop() {
38 | Usb.Task(); // The SPP data is actually not send until this is called, one could call SerialBT.send() directly as well
39 |
40 | if (SerialBT.connected) {
41 | if (firstMessage) {
42 | firstMessage = false;
43 | SerialBT.println(F("Hello from Arduino")); // Send welcome message
44 | }
45 | if (Serial.available())
46 | SerialBT.write(Serial.read());
47 | if (SerialBT.available())
48 | Serial.write(SerialBT.read());
49 | }
50 | else
51 | firstMessage = true;
52 | }
53 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/Bluetooth/SPPMulti/SPPMulti.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Example sketch for the RFCOMM/SPP Bluetooth library - developed by Kristian Lauszus
3 | For more information visit my blog: http://blog.tkjelectronics.dk/ or
4 | send me an e-mail: kristianl@tkjelectronics.com
5 | */
6 |
7 | #include
8 | #include
9 |
10 | // Satisfy IDE, which only needs to see the include statment in the ino.
11 | #ifdef dobogusinclude
12 | #include
13 | #endif
14 | #include
15 |
16 | USB Usb;
17 | //USBHub Hub1(&Usb); // Some dongles have a hub inside
18 |
19 | BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
20 |
21 | const uint8_t length = 2; // Set the number of instances here
22 | SPP *SerialBT[length]; // We will use this pointer to store the instances, you can easily make it larger if you like, but it will use a lot of RAM!
23 |
24 | bool firstMessage[length] = { true }; // Set all to true
25 |
26 | void setup() {
27 | for (uint8_t i = 0; i < length; i++)
28 | SerialBT[i] = new SPP(&Btd); // This will set the name to the default: "Arduino" and the pin to "0000" for all connections
29 |
30 | Serial.begin(115200);
31 | #if !defined(__MIPSEL__)
32 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
33 | #endif
34 | if (Usb.Init() == -1) {
35 | Serial.print(F("\r\nOSC did not start"));
36 | while (1); // Halt
37 | }
38 | Serial.print(F("\r\nSPP Bluetooth Library Started"));
39 | }
40 |
41 | void loop() {
42 | Usb.Task(); // The SPP data is actually not send until this is called, one could call SerialBT.send() directly as well
43 |
44 | for (uint8_t i = 0; i < length; i++) {
45 | if (SerialBT[i]->connected) {
46 | if (firstMessage[i]) {
47 | firstMessage[i] = false;
48 | SerialBT[i]->println(F("Hello from Arduino")); // Send welcome message
49 | }
50 | if (SerialBT[i]->available())
51 | Serial.write(SerialBT[i]->read());
52 | }
53 | else
54 | firstMessage[i] = true;
55 | }
56 |
57 | // Set the connection you want to send to using the first character
58 | // For instance "0Hello World" would send "Hello World" to connection 0
59 | if (Serial.available()) {
60 | delay(10); // Wait for the rest of the data to arrive
61 | uint8_t id = Serial.read() - '0'; // Convert from ASCII
62 | if (id < length && SerialBT[id]->connected) { // Make sure that the id is valid and make sure that a device is actually connected
63 | while (Serial.available()) // Check if data is available
64 | SerialBT[id]->write(Serial.read()); // Send the data
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/Bluetooth/WiiBalanceBoard/WiiBalanceBoard.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Example sketch for the Wii Balance Board Bluetooth library - developed by Kristian Lauszus
3 | For more information visit my blog: http://blog.tkjelectronics.dk/ or
4 | send me an e-mail: kristianl@tkjelectronics.com
5 | */
6 |
7 | #include
8 | #include
9 |
10 | // Satisfy the IDE, which needs to see the include statment in the ino too.
11 | #ifdef dobogusinclude
12 | #include
13 | #endif
14 | #include
15 |
16 | USB Usb;
17 | //USBHub Hub1(&Usb); // Some dongles have a hub inside
18 |
19 | BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
20 | /* You can create the instance of the class in two ways */
21 | WII Wii(&Btd, PAIR); // This will start an inquiry and then pair with your Wii Balance Board - you only have to do this once
22 | //WII Wii(&Btd); // After that you can simply create the instance like so and then press the power button on the Wii Balance Board
23 |
24 | void setup() {
25 | Serial.begin(115200);
26 | #if !defined(__MIPSEL__)
27 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
28 | #endif
29 | if (Usb.Init() == -1) {
30 | Serial.print(F("\r\nOSC did not start"));
31 | while (1); //halt
32 | }
33 | Serial.print(F("\r\nWii Balance Board Bluetooth Library Started"));
34 | }
35 | void loop() {
36 | Usb.Task();
37 | if (Wii.wiiBalanceBoardConnected) {
38 | Serial.print(F("\r\nWeight: "));
39 | for (uint8_t i = 0; i < 4; i++) {
40 | Serial.print(Wii.getWeight((BalanceBoardEnum)i));
41 | Serial.print(F("\t"));
42 | }
43 | Serial.print(F("Total Weight: "));
44 | Serial.print(Wii.getTotalWeight());
45 | if (Wii.getButtonClick(A)) {
46 | Serial.print(F("\r\nA"));
47 | //Wii.setLedToggle(LED1); // The Wii Balance Board has one LED as well
48 | Wii.disconnect();
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/GPIO/Blink/Blink.ino:
--------------------------------------------------------------------------------
1 | /* Example of reading and writing USB Host Shield GPI output
2 | This example uses "Wiring" style interface. See Blink_LowLevel for example of using low-level UHS interface
3 | Author: Brian Walton (brian@riban.co.uk)
4 | */
5 | #include
6 |
7 | // Satisfy the IDE, which needs to see the include statment in the ino too.
8 | #ifdef dobogusinclude
9 | #include
10 | #endif
11 |
12 | #define OUTPUT_PIN 0
13 |
14 | USB Usb; // Create an UHS2 interface object
15 | UHS2_GPIO Gpio(&Usb); // Create a GPIO object
16 |
17 | void setup() {
18 | Serial.begin( 115200 );
19 | #if !defined(__MIPSEL__)
20 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
21 | #endif
22 | Serial.println("Start");
23 |
24 | if (Usb.Init() == -1)
25 | Serial.println("OSC did not start.");
26 |
27 | delay( 200 );
28 | }
29 |
30 | void loop() {
31 | // Get the current output value, toggle then wait half a second
32 | int nValue = Gpio.digitalReadOutput(OUTPUT_PIN);
33 | nValue = (nValue ? 0 : 1);
34 | Gpio.digitalWrite(OUTPUT_PIN, nValue);
35 | Serial.print(nValue ? "+" : "."); // Debug to show what the output should be doing
36 | delay(500);
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/GPIO/Blink_LowLevel/Blink_LowLevel.ino:
--------------------------------------------------------------------------------
1 | /* Example of reading and writing USB Host Shield GPI output using low-level functions
2 | This example uses low-level UHS interface. See Blink for example of using "Wiring" style interface
3 | Author: Brian Walton (brian@riban.co.uk)
4 | */
5 | #include
6 |
7 | // Satisfy the IDE, which needs to see the include statment in the ino too.
8 | #ifdef dobogusinclude
9 | #include
10 | #endif
11 | #include
12 |
13 | USB Usb;
14 |
15 | void setup() {
16 | Serial.begin( 115200 );
17 | #if !defined(__MIPSEL__)
18 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
19 | #endif
20 | Serial.println("Start");
21 |
22 | if (Usb.Init() == -1)
23 | Serial.println("OSC did not start.");
24 |
25 | delay( 200 );
26 | }
27 |
28 | void loop() {
29 | // Get the current output value, toggle then wait half a second
30 | uint8_t nGPO = Usb.gpioRdOutput();
31 | uint8_t nValue = ((nGPO & 0x01) == 0x01) ? 0 : 1;
32 | nGPO &= 0xFE; // Clear bit 0
33 | nGPO |= nValue;
34 | Usb.gpioWr(nGPO);
35 | Serial.print(nValue ? "+" : "."); // Debug to show what the output should be doing
36 | delay(500);
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/GPIO/Input/Input.ino:
--------------------------------------------------------------------------------
1 | /* Example of reading USB Host Shield GPI input
2 | Author: Brian Walton (brian@riban.co.uk)
3 | */
4 | #include
5 |
6 | // Satisfy the IDE, which needs to see the include statment in the ino too.
7 | #ifdef dobogusinclude
8 | #include
9 | #endif
10 |
11 | #define INPUT_PIN 0
12 | #define OUTPUT_PIN 0
13 |
14 | USB Usb; // Create an UHS2 interface object
15 | UHS2_GPIO Gpio(&Usb); // Create a GPIO object
16 |
17 | void setup() {
18 | Serial.begin( 115200 );
19 | #if !defined(__MIPSEL__)
20 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
21 | #endif
22 | Serial.println("Start");
23 |
24 | if (Usb.Init() == -1)
25 | Serial.println("OSC did not start.");
26 |
27 | delay( 200 );
28 | }
29 |
30 | void loop() {
31 | // Get the value of input, set value of output
32 | int nValue = Gpio.digitalRead(INPUT_PIN);
33 | nValue = (nValue ? LOW : HIGH);
34 | Gpio.digitalWrite(OUTPUT_PIN, nValue);
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/HID/SRWS1/SRWS1.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2016 Kristian Lauszus, TKJ Electronics. All rights reserved.
2 |
3 | This software may be distributed and modified under the terms of the GNU
4 | General Public License version 2 (GPL2) as published by the Free Software
5 | Foundation and appearing in the file GPL2.TXT included in the packaging of
6 | this file. Please note that GPL2 Section 2[b] requires that all works based
7 | on this software must also be made publicly available under the terms of
8 | the GPL2 ("Copyleft").
9 |
10 | Contact information
11 | -------------------
12 |
13 | Kristian Lauszus, TKJ Electronics
14 | Web : http://www.tkjelectronics.com
15 | e-mail : kristianl@tkjelectronics.com
16 | */
17 |
18 | #include "SRWS1.h"
19 |
20 | void SRWS1::ParseHIDData(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {
21 | if (HIDUniversal::VID != STEELSERIES_VID || HIDUniversal::PID != STEELSERIES_SRWS1_PID) // Make sure the right device is actually connected
22 | return;
23 | #if 0
24 | if (len && buf) {
25 | Notify(PSTR("\r\n"), 0x80);
26 | for (uint8_t i = 0; i < len; i++) {
27 | D_PrintHex (buf[i], 0x80);
28 | Notify(PSTR(" "), 0x80);
29 | }
30 | }
31 | #endif
32 | memcpy(&srws1Data, buf, min(len, MFK_CASTUINT8T sizeof(srws1Data)));
33 |
34 | static SRWS1DataButtons oldButtonState;
35 | if (srws1Data.btn.val != oldButtonState.val) { // Check if anything has changed
36 | buttonClickState.val = srws1Data.btn.val & ~oldButtonState.val; // Update click state variable
37 | oldButtonState.val = srws1Data.btn.val;
38 | }
39 | }
40 |
41 | // See: https://github.com/torvalds/linux/blob/master/drivers/hid/hid-steelseries.c
42 | void SRWS1::setLeds(uint16_t leds) {
43 | uint8_t buf[3];
44 | buf[0] = 0x40; // Report ID
45 | buf[1] = leds & 0xFF;
46 | buf[2] = (leds >> 8) & 0x7F;
47 | pUsb->outTransfer(bAddress, epInfo[epInterruptOutIndex].epAddr, sizeof(buf), buf);
48 | }
49 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/HID/SRWS1/SRWS1.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2016 Kristian Lauszus, TKJ Electronics. All rights reserved.
2 |
3 | This software may be distributed and modified under the terms of the GNU
4 | General Public License version 2 (GPL2) as published by the Free Software
5 | Foundation and appearing in the file GPL2.TXT included in the packaging of
6 | this file. Please note that GPL2 Section 2[b] requires that all works based
7 | on this software must also be made publicly available under the terms of
8 | the GPL2 ("Copyleft").
9 |
10 | Contact information
11 | -------------------
12 |
13 | Kristian Lauszus, TKJ Electronics
14 | Web : http://www.tkjelectronics.com
15 | e-mail : kristianl@tkjelectronics.com
16 | */
17 |
18 | #ifndef __srws1_h__
19 | #define __srws1_h__
20 |
21 | #include
22 |
23 | #define STEELSERIES_VID 0x1038
24 | #define STEELSERIES_SRWS1_PID 0x1410
25 |
26 | enum DPADEnum {
27 | DPAD_UP = 0x0,
28 | DPAD_UP_RIGHT = 0x1,
29 | DPAD_RIGHT = 0x2,
30 | DPAD_RIGHT_DOWN = 0x3,
31 | DPAD_DOWN = 0x4,
32 | DPAD_DOWN_LEFT = 0x5,
33 | DPAD_LEFT = 0x6,
34 | DPAD_LEFT_UP = 0x7,
35 | DPAD_OFF = 0xF,
36 | };
37 |
38 | union SRWS1DataButtons {
39 | struct {
40 | uint8_t dpad : 4;
41 | uint8_t dummy : 3;
42 | uint8_t select : 1;
43 |
44 | uint8_t back : 1;
45 | uint8_t lookLeft : 1;
46 | uint8_t lights : 1;
47 | uint8_t lookBack : 1;
48 | uint8_t rearBrakeBalance : 1;
49 | uint8_t frontBrakeBalance : 1;
50 | uint8_t requestPit : 1;
51 | uint8_t leftGear : 1;
52 |
53 | uint8_t camera : 1;
54 | uint8_t lookRight : 1;
55 | uint8_t boost : 1;
56 | uint8_t horn : 1;
57 | uint8_t hud : 1;
58 | uint8_t launchControl : 1;
59 | uint8_t speedLimiter : 1;
60 | uint8_t rightGear : 1;
61 | } __attribute__((packed));
62 | uint32_t val : 24;
63 | } __attribute__((packed));
64 |
65 | struct SRWS1Data {
66 | int16_t tilt; // Range [-1800:1800]
67 | uint16_t rightTrigger : 12; // Range [0:1023] i.e. only 10 bits
68 | uint16_t leftTrigger : 12; // Range [0:1023] i.e. only 10 bits
69 | SRWS1DataButtons btn;
70 | uint8_t assists : 4;
71 | uint8_t steeringSensitivity : 4;
72 | uint8_t assistValues : 4;
73 | } __attribute__((packed));
74 |
75 | class SRWS1 : public HIDUniversal {
76 | public:
77 | SRWS1(USB *p) : HIDUniversal(p) {};
78 | bool connected() {
79 | return HIDUniversal::isReady() && HIDUniversal::VID == STEELSERIES_VID && HIDUniversal::PID == STEELSERIES_SRWS1_PID;
80 | };
81 | void setLeds(uint16_t leds);
82 | SRWS1Data srws1Data;
83 | SRWS1DataButtons buttonClickState;
84 |
85 | private:
86 | void ParseHIDData(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); // Called by the HIDUniversal library
87 | uint8_t OnInitSuccessful() { // Called by the HIDUniversal library on success
88 | if (HIDUniversal::VID != STEELSERIES_VID || HIDUniversal::PID != STEELSERIES_SRWS1_PID) // Make sure the right device is actually connected
89 | return 1;
90 | setLeds(0);
91 | return 0;
92 | };
93 | };
94 |
95 | #endif
96 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/HID/USBHIDBootMouse/USBHIDBootMouse.ino:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | // Satisfy the IDE, which needs to see the include statment in the ino too.
5 | #ifdef dobogusinclude
6 | #include
7 | #endif
8 | #include
9 |
10 | class MouseRptParser : public MouseReportParser
11 | {
12 | protected:
13 | void OnMouseMove (MOUSEINFO *mi);
14 | void OnLeftButtonUp (MOUSEINFO *mi);
15 | void OnLeftButtonDown (MOUSEINFO *mi);
16 | void OnRightButtonUp (MOUSEINFO *mi);
17 | void OnRightButtonDown (MOUSEINFO *mi);
18 | void OnMiddleButtonUp (MOUSEINFO *mi);
19 | void OnMiddleButtonDown (MOUSEINFO *mi);
20 | };
21 | void MouseRptParser::OnMouseMove(MOUSEINFO *mi)
22 | {
23 | Serial.print("dx=");
24 | Serial.print(mi->dX, DEC);
25 | Serial.print(" dy=");
26 | Serial.println(mi->dY, DEC);
27 | };
28 | void MouseRptParser::OnLeftButtonUp (MOUSEINFO *mi)
29 | {
30 | Serial.println("L Butt Up");
31 | };
32 | void MouseRptParser::OnLeftButtonDown (MOUSEINFO *mi)
33 | {
34 | Serial.println("L Butt Dn");
35 | };
36 | void MouseRptParser::OnRightButtonUp (MOUSEINFO *mi)
37 | {
38 | Serial.println("R Butt Up");
39 | };
40 | void MouseRptParser::OnRightButtonDown (MOUSEINFO *mi)
41 | {
42 | Serial.println("R Butt Dn");
43 | };
44 | void MouseRptParser::OnMiddleButtonUp (MOUSEINFO *mi)
45 | {
46 | Serial.println("M Butt Up");
47 | };
48 | void MouseRptParser::OnMiddleButtonDown (MOUSEINFO *mi)
49 | {
50 | Serial.println("M Butt Dn");
51 | };
52 |
53 | USB Usb;
54 | USBHub Hub(&Usb);
55 | HIDBoot HidMouse(&Usb);
56 |
57 | MouseRptParser Prs;
58 |
59 | void setup()
60 | {
61 | Serial.begin( 115200 );
62 | #if !defined(__MIPSEL__)
63 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
64 | #endif
65 | Serial.println("Start");
66 |
67 | if (Usb.Init() == -1)
68 | Serial.println("OSC did not start.");
69 |
70 | delay( 200 );
71 |
72 | HidMouse.SetReportParser(0, &Prs);
73 | }
74 |
75 | void loop()
76 | {
77 | Usb.Task();
78 | }
79 |
80 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/HID/USBHIDJoystick/USBHIDJoystick.ino:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | // Satisfy IDE, which only needs to see the include statment in the ino.
6 | #ifdef dobogusinclude
7 | #include
8 | #endif
9 | #include
10 |
11 | #include "hidjoystickrptparser.h"
12 |
13 | USB Usb;
14 | USBHub Hub(&Usb);
15 | HIDUniversal Hid(&Usb);
16 | JoystickEvents JoyEvents;
17 | JoystickReportParser Joy(&JoyEvents);
18 |
19 | void setup() {
20 | Serial.begin(115200);
21 | #if !defined(__MIPSEL__)
22 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
23 | #endif
24 | Serial.println("Start");
25 |
26 | if (Usb.Init() == -1)
27 | Serial.println("OSC did not start.");
28 |
29 | delay(200);
30 |
31 | if (!Hid.SetReportParser(0, &Joy))
32 | ErrorMessage (PSTR("SetReportParser"), 1);
33 | }
34 |
35 | void loop() {
36 | Usb.Task();
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/HID/USBHIDJoystick/hidjoystickrptparser.cpp:
--------------------------------------------------------------------------------
1 | #include "hidjoystickrptparser.h"
2 |
3 | JoystickReportParser::JoystickReportParser(JoystickEvents *evt) :
4 | joyEvents(evt),
5 | oldHat(0xDE),
6 | oldButtons(0) {
7 | for (uint8_t i = 0; i < RPT_GEMEPAD_LEN; i++)
8 | oldPad[i] = 0xD;
9 | }
10 |
11 | void JoystickReportParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {
12 | bool match = true;
13 |
14 | // Checking if there are changes in report since the method was last called
15 | for (uint8_t i = 0; i < RPT_GEMEPAD_LEN; i++)
16 | if (buf[i] != oldPad[i]) {
17 | match = false;
18 | break;
19 | }
20 |
21 | // Calling Game Pad event handler
22 | if (!match && joyEvents) {
23 | joyEvents->OnGamePadChanged((const GamePadEventData*)buf);
24 |
25 | for (uint8_t i = 0; i < RPT_GEMEPAD_LEN; i++) oldPad[i] = buf[i];
26 | }
27 |
28 | uint8_t hat = (buf[5] & 0xF);
29 |
30 | // Calling Hat Switch event handler
31 | if (hat != oldHat && joyEvents) {
32 | joyEvents->OnHatSwitch(hat);
33 | oldHat = hat;
34 | }
35 |
36 | uint16_t buttons = (0x0000 | buf[6]);
37 | buttons <<= 4;
38 | buttons |= (buf[5] >> 4);
39 | uint16_t changes = (buttons ^ oldButtons);
40 |
41 | // Calling Button Event Handler for every button changed
42 | if (changes) {
43 | for (uint8_t i = 0; i < 0x0C; i++) {
44 | uint16_t mask = (0x0001 << i);
45 |
46 | if (((mask & changes) > 0) && joyEvents) {
47 | if ((buttons & mask) > 0)
48 | joyEvents->OnButtonDn(i + 1);
49 | else
50 | joyEvents->OnButtonUp(i + 1);
51 | }
52 | }
53 | oldButtons = buttons;
54 | }
55 | }
56 |
57 | void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt) {
58 | Serial.print("X1: ");
59 | PrintHex (evt->X, 0x80);
60 | Serial.print("\tY1: ");
61 | PrintHex (evt->Y, 0x80);
62 | Serial.print("\tX2: ");
63 | PrintHex (evt->Z1, 0x80);
64 | Serial.print("\tY2: ");
65 | PrintHex (evt->Z2, 0x80);
66 | Serial.print("\tRz: ");
67 | PrintHex (evt->Rz, 0x80);
68 | Serial.println("");
69 | }
70 |
71 | void JoystickEvents::OnHatSwitch(uint8_t hat) {
72 | Serial.print("Hat Switch: ");
73 | PrintHex (hat, 0x80);
74 | Serial.println("");
75 | }
76 |
77 | void JoystickEvents::OnButtonUp(uint8_t but_id) {
78 | Serial.print("Up: ");
79 | Serial.println(but_id, DEC);
80 | }
81 |
82 | void JoystickEvents::OnButtonDn(uint8_t but_id) {
83 | Serial.print("Dn: ");
84 | Serial.println(but_id, DEC);
85 | }
86 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h:
--------------------------------------------------------------------------------
1 | #if !defined(__HIDJOYSTICKRPTPARSER_H__)
2 | #define __HIDJOYSTICKRPTPARSER_H__
3 |
4 | #include
5 |
6 | struct GamePadEventData {
7 | uint8_t X, Y, Z1, Z2, Rz;
8 | };
9 |
10 | class JoystickEvents {
11 | public:
12 | virtual void OnGamePadChanged(const GamePadEventData *evt);
13 | virtual void OnHatSwitch(uint8_t hat);
14 | virtual void OnButtonUp(uint8_t but_id);
15 | virtual void OnButtonDn(uint8_t but_id);
16 | };
17 |
18 | #define RPT_GEMEPAD_LEN 5
19 |
20 | class JoystickReportParser : public HIDReportParser {
21 | JoystickEvents *joyEvents;
22 |
23 | uint8_t oldPad[RPT_GEMEPAD_LEN];
24 | uint8_t oldHat;
25 | uint16_t oldButtons;
26 |
27 | public:
28 | JoystickReportParser(JoystickEvents *evt);
29 |
30 | virtual void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
31 | };
32 |
33 | #endif // __HIDJOYSTICKRPTPARSER_H__
34 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/HID/USBHIDMultimediaKbd/USBHIDMultimediaKbd.ino:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | // Satisfy the IDE, which needs to see the include statment in the ino too.
5 | #ifdef dobogusinclude
6 | #include
7 | #endif
8 | #include
9 |
10 | // Override HIDComposite to be able to select which interface we want to hook into
11 | class HIDSelector : public HIDComposite
12 | {
13 | public:
14 | HIDSelector(USB *p) : HIDComposite(p) {};
15 |
16 | protected:
17 | void ParseHIDData(USBHID *hid, uint8_t ep, bool is_rpt_id, uint8_t len, uint8_t *buf); // Called by the HIDComposite library
18 | bool SelectInterface(uint8_t iface, uint8_t proto);
19 | };
20 |
21 | // Return true for the interface we want to hook into
22 | bool HIDSelector::SelectInterface(uint8_t iface, uint8_t proto)
23 | {
24 | if (proto != 0)
25 | return true;
26 |
27 | return false;
28 | }
29 |
30 | // Will be called for all HID data received from the USB interface
31 | void HIDSelector::ParseHIDData(USBHID *hid, uint8_t ep, bool is_rpt_id, uint8_t len, uint8_t *buf) {
32 | #if 1
33 | if (len && buf) {
34 | Notify(PSTR("\r\n"), 0x80);
35 | for (uint8_t i = 0; i < len; i++) {
36 | D_PrintHex (buf[i], 0x80);
37 | Notify(PSTR(" "), 0x80);
38 | }
39 | }
40 | #endif
41 | }
42 |
43 | USB Usb;
44 | //USBHub Hub(&Usb);
45 | HIDSelector hidSelector(&Usb);
46 |
47 | void setup()
48 | {
49 | Serial.begin( 115200 );
50 | #if !defined(__MIPSEL__)
51 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
52 | #endif
53 | Serial.println("Start");
54 |
55 | if (Usb.Init() == -1)
56 | Serial.println("OSC did not start.");
57 |
58 | // Set this to higher values to enable more debug information
59 | // minimum 0x00, maximum 0xff, default 0x80
60 | UsbDEBUGlvl = 0xff;
61 |
62 | delay( 200 );
63 | }
64 |
65 | void loop()
66 | {
67 | Usb.Task();
68 | }
69 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/HID/USBHID_desc/USBHID_desc.ino:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include "pgmstrings.h"
6 |
7 | // Satisfy the IDE, which needs to see the include statment in the ino too.
8 | #ifdef dobogusinclude
9 | #include
10 | #endif
11 | #include
12 |
13 | class HIDUniversal2 : public HIDUniversal
14 | {
15 | public:
16 | HIDUniversal2(USB *usb) : HIDUniversal(usb) {};
17 |
18 | protected:
19 | uint8_t OnInitSuccessful();
20 | };
21 |
22 | uint8_t HIDUniversal2::OnInitSuccessful()
23 | {
24 | uint8_t rcode;
25 |
26 | HexDumper Hex;
27 | ReportDescParser Rpt;
28 |
29 | if ((rcode = GetReportDescr(0, &Hex)))
30 | goto FailGetReportDescr1;
31 |
32 | if ((rcode = GetReportDescr(0, &Rpt)))
33 | goto FailGetReportDescr2;
34 |
35 | return 0;
36 |
37 | FailGetReportDescr1:
38 | USBTRACE("GetReportDescr1:");
39 | goto Fail;
40 |
41 | FailGetReportDescr2:
42 | USBTRACE("GetReportDescr2:");
43 | goto Fail;
44 |
45 | Fail:
46 | Serial.println(rcode, HEX);
47 | Release();
48 | return rcode;
49 | }
50 |
51 | USB Usb;
52 | //USBHub Hub(&Usb);
53 | HIDUniversal2 Hid(&Usb);
54 | UniversalReportParser Uni;
55 |
56 | void setup()
57 | {
58 | Serial.begin( 115200 );
59 | #if !defined(__MIPSEL__)
60 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
61 | #endif
62 | Serial.println("Start");
63 |
64 | if (Usb.Init() == -1)
65 | Serial.println("OSC did not start.");
66 |
67 | delay( 200 );
68 |
69 | if (!Hid.SetReportParser(0, &Uni))
70 | ErrorMessage(PSTR("SetReportParser"), 1 );
71 | }
72 |
73 | void loop()
74 | {
75 | Usb.Task();
76 | }
77 |
78 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/HID/USBHID_desc/pgmstrings.h:
--------------------------------------------------------------------------------
1 | #if !defined(__PGMSTRINGS_H__)
2 | #define __PGMSTRINGS_H__
3 |
4 | #define LOBYTE(x) ((char*)(&(x)))[0]
5 | #define HIBYTE(x) ((char*)(&(x)))[1]
6 | #define BUFSIZE 256 //buffer size
7 |
8 |
9 | /* Print strings in Program Memory */
10 | const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t";
11 | const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: ";
12 | const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t";
13 | const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t";
14 | const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t";
15 | const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t";
16 | const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t";
17 | const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t";
18 | const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t";
19 | const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t";
20 | const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t";
21 | const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t";
22 | const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t";
23 | const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t";
24 | const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t";
25 | const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t";
26 | const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes";
27 | const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:";
28 | const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t";
29 | const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t";
30 | const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t";
31 | const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t";
32 | const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t";
33 | const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t";
34 | const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:";
35 | const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t";
36 | const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t";
37 | const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t";
38 | const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t";
39 | const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t";
40 | const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t";
41 | const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t";
42 | const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:";
43 | const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t";
44 | const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t";
45 | const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t";
46 | const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t";
47 | const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:";
48 | const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t";
49 | const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t";
50 | const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t";
51 |
52 | #endif // __PGMSTRINGS_H__
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/HID/le3dp/le3dp.ino:
--------------------------------------------------------------------------------
1 | /* Simplified Logitech Extreme 3D Pro Joystick Report Parser */
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | #include "le3dp_rptparser.h"
8 |
9 | // Satisfy the IDE, which needs to see the include statment in the ino too.
10 | #ifdef dobogusinclude
11 | #include
12 | #endif
13 | #include
14 |
15 | USB Usb;
16 | USBHub Hub(&Usb);
17 | HIDUniversal Hid(&Usb);
18 | JoystickEvents JoyEvents;
19 | JoystickReportParser Joy(&JoyEvents);
20 |
21 | void setup()
22 | {
23 | Serial.begin( 115200 );
24 | #if !defined(__MIPSEL__)
25 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
26 | #endif
27 | Serial.println("Start");
28 |
29 | if (Usb.Init() == -1)
30 | Serial.println("OSC did not start.");
31 |
32 | delay( 200 );
33 |
34 | if (!Hid.SetReportParser(0, &Joy))
35 | ErrorMessage(PSTR("SetReportParser"), 1 );
36 | }
37 |
38 | void loop()
39 | {
40 | Usb.Task();
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/HID/le3dp/le3dp_rptparser.cpp:
--------------------------------------------------------------------------------
1 | #include "le3dp_rptparser.h"
2 |
3 | JoystickReportParser::JoystickReportParser(JoystickEvents *evt) :
4 | joyEvents(evt)
5 | {}
6 |
7 | void JoystickReportParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
8 | {
9 | bool match = true;
10 |
11 | // Checking if there are changes in report since the method was last called
12 | for (uint8_t i=0; iOnGamePadChanged((const GamePadEventData*)buf);
21 |
22 | for (uint8_t i=0; i(evt->x, 0x80);
30 | Serial.print(" Y: ");
31 | PrintHex(evt->y, 0x80);
32 | Serial.print(" Hat Switch: ");
33 | PrintHex(evt->hat, 0x80);
34 | Serial.print(" Twist: ");
35 | PrintHex(evt->twist, 0x80);
36 | Serial.print(" Slider: ");
37 | PrintHex(evt->slider, 0x80);
38 | Serial.print(" Buttons A: ");
39 | PrintHex(evt->buttons_a, 0x80);
40 | Serial.print(" Buttons B: ");
41 | PrintHex(evt->buttons_b, 0x80);
42 | Serial.println("");
43 | }
44 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/HID/le3dp/le3dp_rptparser.h:
--------------------------------------------------------------------------------
1 | #if !defined(__HIDJOYSTICKRPTPARSER_H__)
2 | #define __HIDJOYSTICKRPTPARSER_H__
3 |
4 | #include
5 |
6 | struct GamePadEventData
7 | {
8 | union { //axes and hut switch
9 | uint32_t axes;
10 | struct {
11 | uint32_t x : 10;
12 | uint32_t y : 10;
13 | uint32_t hat : 4;
14 | uint32_t twist : 8;
15 | };
16 | };
17 | uint8_t buttons_a;
18 | uint8_t slider;
19 | uint8_t buttons_b;
20 | };
21 |
22 | class JoystickEvents
23 | {
24 | public:
25 | virtual void OnGamePadChanged(const GamePadEventData *evt);
26 | };
27 |
28 | #define RPT_GAMEPAD_LEN sizeof(GamePadEventData)/sizeof(uint8_t)
29 |
30 | class JoystickReportParser : public HIDReportParser
31 | {
32 | JoystickEvents *joyEvents;
33 |
34 | uint8_t oldPad[RPT_GAMEPAD_LEN];
35 |
36 | public:
37 | JoystickReportParser(JoystickEvents *evt);
38 |
39 | virtual void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
40 | };
41 |
42 | #endif // __HIDJOYSTICKRPTPARSER_H__
43 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/HID/scale/scale.ino:
--------------------------------------------------------------------------------
1 | /* Digital Scale Output. Written for Stamps.com Model 510 */
2 | /* 5lb Digital Scale; any HID scale with Usage page 0x8d should work */
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | #include "scale_rptparser.h"
9 |
10 | // Satisfy the IDE, which needs to see the include statment in the ino too.
11 | #ifdef dobogusinclude
12 | #include
13 | #endif
14 | #include
15 |
16 | USB Usb;
17 | USBHub Hub(&Usb);
18 | HIDUniversal Hid(&Usb);
19 | Max_LCD LCD(&Usb);
20 | ScaleEvents ScaleEvents(&LCD);
21 | ScaleReportParser Scale(&ScaleEvents);
22 |
23 | void setup()
24 | {
25 | Serial.begin( 115200 );
26 | #if !defined(__MIPSEL__)
27 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
28 | #endif
29 | Serial.println("Start");
30 |
31 | if (Usb.Init() == -1)
32 | Serial.println("OSC did not start.");
33 |
34 | // set up the LCD's number of rows and columns:
35 | LCD.begin(16, 2);
36 | LCD.clear();
37 | LCD.home();
38 | LCD.setCursor(0,0);
39 | LCD.write('R');
40 |
41 | delay( 200 );
42 |
43 | if (!Hid.SetReportParser(0, &Scale))
44 | ErrorMessage(PSTR("SetReportParser"), 1 );
45 | }
46 |
47 | void loop()
48 | {
49 | Usb.Task();
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/HID/scale/scale_rptparser.h:
--------------------------------------------------------------------------------
1 | #if !defined(__SCALERPTPARSER_H__)
2 | #define __SCALERPTPARSER_H__
3 |
4 | #include
5 | #include
6 |
7 | /* Scale status constants */
8 | #define REPORT_FAULT 0x01
9 | #define ZEROED 0x02
10 | #define WEIGHING 0x03
11 | #define WEIGHT_VALID 0x04
12 | #define WEIGHT_NEGATIVE 0x05
13 | #define OVERWEIGHT 0x06
14 | #define CALIBRATE_ME 0x07
15 | #define ZERO_ME 0x08
16 |
17 | /* input data report */
18 | struct ScaleEventData
19 | {
20 | uint8_t reportID; //must be 3
21 | uint8_t status;
22 | uint8_t unit;
23 | int8_t exp; //scale factor for the weight
24 | uint16_t weight; //
25 | };
26 |
27 | class ScaleEvents
28 | {
29 |
30 | Max_LCD* pLcd;
31 |
32 | void LcdPrint( const char* str );
33 |
34 | public:
35 |
36 | ScaleEvents( Max_LCD* pLCD );
37 |
38 | virtual void OnScaleChanged(const ScaleEventData *evt);
39 | };
40 |
41 | #define RPT_SCALE_LEN sizeof(ScaleEventData)/sizeof(uint8_t)
42 |
43 | class ScaleReportParser : public HIDReportParser
44 | {
45 | ScaleEvents *scaleEvents;
46 |
47 | uint8_t oldScale[RPT_SCALE_LEN];
48 |
49 | public:
50 | ScaleReportParser(ScaleEvents *evt);
51 |
52 | virtual void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
53 | };
54 |
55 | #endif // __SCALERPTPARSER_H__
56 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/HID/t16km/t16km.ino:
--------------------------------------------------------------------------------
1 | /* Simplified Thrustmaster T.16000M FCS Joystick Report Parser */
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | // Satisfy the IDE, which needs to see the include statment in the ino too.
8 | #ifdef dobogusinclude
9 | #include
10 | #endif
11 | #include
12 |
13 | // Thrustmaster T.16000M HID report
14 | struct GamePadEventData
15 | {
16 | uint16_t buttons;
17 | uint8_t hat;
18 | uint16_t x;
19 | uint16_t y;
20 | uint8_t twist;
21 | uint8_t slider;
22 | }__attribute__((packed));
23 |
24 | class JoystickEvents
25 | {
26 | public:
27 | virtual void OnGamePadChanged(const GamePadEventData *evt);
28 | };
29 |
30 | #define RPT_GAMEPAD_LEN sizeof(GamePadEventData)
31 |
32 | class JoystickReportParser : public HIDReportParser
33 | {
34 | JoystickEvents *joyEvents;
35 |
36 | uint8_t oldPad[RPT_GAMEPAD_LEN];
37 |
38 | public:
39 | JoystickReportParser(JoystickEvents *evt);
40 |
41 | virtual void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
42 | };
43 |
44 |
45 | JoystickReportParser::JoystickReportParser(JoystickEvents *evt) :
46 | joyEvents(evt)
47 | {}
48 |
49 | void JoystickReportParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
50 | {
51 | // Checking if there are changes in report since the method was last called
52 | bool match = (sizeof(oldPad) == len) && (memcmp(oldPad, buf, len) == 0);
53 |
54 | // Calling Game Pad event handler
55 | if (!match && joyEvents) {
56 | joyEvents->OnGamePadChanged((const GamePadEventData*)buf);
57 | memcpy(oldPad, buf, len);
58 | }
59 | }
60 |
61 | void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt)
62 | {
63 | Serial.print("X: ");
64 | PrintHex(evt->x, 0x80);
65 | Serial.print(" Y: ");
66 | PrintHex(evt->y, 0x80);
67 | Serial.print(" Hat Switch: ");
68 | PrintHex(evt->hat, 0x80);
69 | Serial.print(" Twist: ");
70 | PrintHex(evt->twist, 0x80);
71 | Serial.print(" Slider: ");
72 | PrintHex(evt->slider, 0x80);
73 | Serial.print(" Buttons: ");
74 | PrintHex(evt->buttons, 0x80);
75 | Serial.println();
76 | }
77 |
78 | USB Usb;
79 | USBHub Hub(&Usb);
80 | HIDUniversal Hid(&Usb);
81 | JoystickEvents JoyEvents;
82 | JoystickReportParser Joy(&JoyEvents);
83 |
84 | void setup()
85 | {
86 | Serial.begin( 115200 );
87 | #if !defined(__MIPSEL__)
88 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
89 | #endif
90 | Serial.println("Start");
91 |
92 | if (Usb.Init() == -1)
93 | Serial.println("OSC did not start.");
94 |
95 | delay( 200 );
96 |
97 | if (!Hid.SetReportParser(0, &Joy))
98 | ErrorMessage(PSTR("SetReportParser"), 1 );
99 | }
100 |
101 | void loop()
102 | {
103 | Usb.Task();
104 | }
105 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/MiniDSP/MiniDSP.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Example sketch for the MiniDSP 2x4HD library - developed by Dennis Frett
3 | */
4 |
5 | #include
6 |
7 | // Satisfy the IDE, which needs to see the include statment in the ino too.
8 | #ifdef dobogusinclude
9 | #include
10 | #endif
11 | #include
12 |
13 | USB Usb;
14 | MiniDSP MiniDSP(&Usb);
15 |
16 | void OnMiniDSPConnected() {
17 | Serial.println("MiniDSP connected");
18 | }
19 |
20 | void OnVolumeChange(uint8_t volume) {
21 | Serial.println("Volume is: " + String(volume));
22 | }
23 |
24 | void OnMutedChange(bool isMuted) {
25 | Serial.println("Muted status: " + String(isMuted ? "muted" : "unmuted"));
26 | }
27 |
28 | void setup() {
29 | Serial.begin(115200);
30 | #if !defined(__MIPSEL__)
31 | while(!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
32 | #endif
33 | if(Usb.Init() == -1) {
34 | Serial.print(F("\r\nOSC did not start"));
35 | while(1); // Halt
36 | }
37 | Serial.println(F("\r\nMiniDSP 2x4HD Library Started"));
38 |
39 | // Register callbacks.
40 | MiniDSP.attachOnInit(&OnMiniDSPConnected);
41 | MiniDSP.attachOnVolumeChange(&OnVolumeChange);
42 | MiniDSP.attachOnMutedChange(&OnMutedChange);
43 | }
44 |
45 | void loop() {
46 | Usb.Task();
47 | }
48 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/PSBuzz/PSBuzz.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Example sketch for the Playstation Buzz library - developed by Kristian Lauszus
3 | For more information visit my blog: http://blog.tkjelectronics.dk/ or
4 | send me an e-mail: kristianl@tkjelectronics.com
5 | */
6 |
7 | #include
8 |
9 | // Satisfy the IDE, which needs to see the include statment in the ino too.
10 | #ifdef dobogusinclude
11 | #include
12 | #endif
13 | #include
14 |
15 | USB Usb;
16 | PSBuzz Buzz(&Usb);
17 |
18 | void setup() {
19 | Serial.begin(115200);
20 | #if !defined(__MIPSEL__)
21 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
22 | #endif
23 | if (Usb.Init() == -1) {
24 | Serial.print(F("\r\nOSC did not start"));
25 | while (1); // Halt
26 | }
27 | Serial.println(F("\r\nPS Buzz Library Started"));
28 | }
29 |
30 | void loop() {
31 | Usb.Task();
32 |
33 | if (Buzz.connected()) {
34 | for (uint8_t i = 0; i < 4; i++) {
35 | if (Buzz.getButtonClick(RED, i)) {
36 | Buzz.setLedToggle(i); // Toggle the LED
37 | Serial.println(F("RED"));
38 | }
39 | if (Buzz.getButtonClick(YELLOW, i))
40 | Serial.println(F("YELLOW"));
41 | if (Buzz.getButtonClick(GREEN, i))
42 | Serial.println(F("GREEN"));
43 | if (Buzz.getButtonClick(ORANGE, i))
44 | Serial.println(F("ORANGE"));
45 | if (Buzz.getButtonClick(BLUE, i))
46 | Serial.println(F("BLUE"));
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/USBH_MIDI/USBH_MIDI_dump/USBH_MIDI_dump.ino:
--------------------------------------------------------------------------------
1 | /*
2 | *******************************************************************************
3 | * USB-MIDI dump utility
4 | * Copyright (C) 2013-2017 Yuuichi Akagawa
5 | *
6 | * for use with USB Host Shield 2.0 from Circuitsathome.com
7 | * https://github.com/felis/USB_Host_Shield_2.0
8 | *
9 | * This is sample program. Do not expect perfect behavior.
10 | *******************************************************************************
11 | */
12 |
13 | #include
14 | #include
15 |
16 | // Satisfy the IDE, which needs to see the include statment in the ino too.
17 | #ifdef dobogusinclude
18 | #include
19 | #endif
20 | #include
21 |
22 | USB Usb;
23 | //USBHub Hub(&Usb);
24 | USBH_MIDI Midi(&Usb);
25 |
26 | void MIDI_poll();
27 |
28 | uint16_t pid, vid;
29 |
30 | void setup()
31 | {
32 | vid = pid = 0;
33 | Serial.begin(115200);
34 |
35 | if (Usb.Init() == -1) {
36 | while (1); //halt
37 | }//if (Usb.Init() == -1...
38 | delay( 200 );
39 | }
40 |
41 | void loop()
42 | {
43 | Usb.Task();
44 | //uint32_t t1 = (uint32_t)micros();
45 | if ( Midi ) {
46 | MIDI_poll();
47 | }
48 | }
49 |
50 | // Poll USB MIDI Controler and send to serial MIDI
51 | void MIDI_poll()
52 | {
53 | char buf[20];
54 | uint8_t bufMidi[64];
55 | uint16_t rcvd;
56 |
57 | if (Midi.idVendor() != vid || Midi.idProduct() != pid) {
58 | vid = Midi.idVendor();
59 | pid = Midi.idProduct();
60 | sprintf(buf, "VID:%04X, PID:%04X", vid, pid);
61 | Serial.println(buf);
62 | }
63 | if (Midi.RecvData( &rcvd, bufMidi) == 0 ) {
64 | uint32_t time = (uint32_t)millis();
65 | sprintf(buf, "%04X%04X: ", (uint16_t)(time >> 16), (uint16_t)(time & 0xFFFF)); // Split variable to prevent warnings on the ESP8266 platform
66 | Serial.print(buf);
67 | Serial.print(rcvd);
68 | Serial.print(':');
69 | for (int i = 0; i < 64; i++) {
70 | sprintf(buf, " %02X", bufMidi[i]);
71 | Serial.print(buf);
72 | }
73 | Serial.println("");
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/USBH_MIDI/USB_MIDI_converter/USB_MIDI_converter.ino:
--------------------------------------------------------------------------------
1 | /*
2 | *******************************************************************************
3 | * USB-MIDI to Legacy Serial MIDI converter
4 | * Copyright (C) 2012-2020 Yuuichi Akagawa
5 | *
6 | * Idea from LPK25 USB-MIDI to Serial MIDI converter
7 | * by Collin Cunningham - makezine.com, narbotic.com
8 | *
9 | * This is sample program. Do not expect perfect behavior.
10 | *******************************************************************************
11 | */
12 |
13 | #include
14 | #include
15 |
16 | // Satisfy the IDE, which needs to see the include statment in the ino too.
17 | #ifdef dobogusinclude
18 | #include
19 | #endif
20 | #include
21 |
22 | #ifdef USBCON
23 | #define _MIDI_SERIAL_PORT Serial1
24 | #else
25 | #define _MIDI_SERIAL_PORT Serial
26 | #endif
27 |
28 | // Set to 1 if you want to wait for the Serial MIDI transmission to complete.
29 | // For more information, see https://github.com/felis/USB_Host_Shield_2.0/issues/570
30 | #define ENABLE_MIDI_SERIAL_FLUSH 0
31 |
32 | //////////////////////////
33 | // MIDI Pin assign
34 | // 2 : GND
35 | // 4 : +5V(Vcc) with 220ohm
36 | // 5 : TX
37 | //////////////////////////
38 |
39 | USB Usb;
40 | USBH_MIDI Midi(&Usb);
41 |
42 | void MIDI_poll();
43 | void doDelay(uint32_t t1, uint32_t t2, uint32_t delayTime);
44 |
45 | void setup()
46 | {
47 | _MIDI_SERIAL_PORT.begin(31250);
48 |
49 | if (Usb.Init() == -1) {
50 | while (1); //halt
51 | }//if (Usb.Init() == -1...
52 | delay( 200 );
53 | }
54 |
55 | void loop()
56 | {
57 | Usb.Task();
58 | uint32_t t1 = (uint32_t)micros();
59 | if ( Midi ) {
60 | MIDI_poll();
61 | }
62 | //delay(1ms)
63 | doDelay(t1, (uint32_t)micros(), 1000);
64 | }
65 |
66 | // Poll USB MIDI Controler and send to serial MIDI
67 | void MIDI_poll()
68 | {
69 | uint8_t outBuf[ 3 ];
70 | uint8_t size;
71 |
72 | do {
73 | if ( (size = Midi.RecvData(outBuf)) > 0 ) {
74 | //MIDI Output
75 | _MIDI_SERIAL_PORT.write(outBuf, size);
76 | #if ENABLE_MIDI_SERIAL_FLUSH
77 | _MIDI_SERIAL_PORT.flush();
78 | #endif
79 | }
80 | } while (size > 0);
81 | }
82 |
83 | // Delay time (max 16383 us)
84 | void doDelay(uint32_t t1, uint32_t t2, uint32_t delayTime)
85 | {
86 | uint32_t t3;
87 |
88 | t3 = t2 - t1;
89 | if ( t3 < delayTime ) {
90 | delayMicroseconds(delayTime - t3);
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/USBH_MIDI/USB_MIDI_converter_multi/USB_MIDI_converter_multi.ino:
--------------------------------------------------------------------------------
1 | /*
2 | *******************************************************************************
3 | * USB-MIDI to Legacy Serial MIDI converter
4 | * Copyright (C) 2012-2020 Yuuichi Akagawa
5 | *
6 | * Idea from LPK25 USB-MIDI to Serial MIDI converter
7 | * by Collin Cunningham - makezine.com, narbotic.com
8 | *
9 | * This is sample program. Do not expect perfect behavior.
10 | *******************************************************************************
11 | */
12 |
13 | #include
14 | #include
15 |
16 | // Satisfy the IDE, which needs to see the include statment in the ino too.
17 | #ifdef dobogusinclude
18 | #include
19 | #endif
20 | #include
21 |
22 | #ifdef USBCON
23 | #define _MIDI_SERIAL_PORT Serial1
24 | #else
25 | #define _MIDI_SERIAL_PORT Serial
26 | #endif
27 |
28 | // Set to 1 if you want to wait for the Serial MIDI transmission to complete.
29 | // For more information, see https://github.com/felis/USB_Host_Shield_2.0/issues/570
30 | #define ENABLE_MIDI_SERIAL_FLUSH 0
31 |
32 | //////////////////////////
33 | // MIDI Pin assign
34 | // 2 : GND
35 | // 4 : +5V(Vcc) with 220ohm
36 | // 5 : TX
37 | //////////////////////////
38 |
39 | USB Usb;
40 | USBHub Hub1(&Usb);
41 | USBH_MIDI Midi1(&Usb);
42 | USBH_MIDI Midi2(&Usb);
43 |
44 | void MIDI_poll();
45 | void doDelay(uint32_t t1, uint32_t t2, uint32_t delayTime);
46 |
47 | void setup()
48 | {
49 | _MIDI_SERIAL_PORT.begin(31250);
50 |
51 | if (Usb.Init() == -1) {
52 | while (1); //halt
53 | }//if (Usb.Init() == -1...
54 | delay( 200 );
55 | }
56 |
57 | void loop()
58 | {
59 | Usb.Task();
60 | uint32_t t1 = (uint32_t)micros();
61 | if ( Midi1 ) {
62 | MIDI_poll(Midi1);
63 | }
64 | if ( Midi2 ) {
65 | MIDI_poll(Midi2);
66 | }
67 | //delay(1ms)
68 | doDelay(t1, (uint32_t)micros(), 1000);
69 | }
70 |
71 | // Poll USB MIDI Controler and send to serial MIDI
72 | void MIDI_poll(USBH_MIDI &Midi)
73 | {
74 | uint8_t outBuf[ 3 ];
75 | uint8_t size;
76 |
77 | do {
78 | if ( (size = Midi.RecvData(outBuf)) > 0 ) {
79 | //MIDI Output
80 | _MIDI_SERIAL_PORT.write(outBuf, size);
81 | #if ENABLE_MIDI_SERIAL_FLUSH
82 | _MIDI_SERIAL_PORT.flush();
83 | #endif
84 | }
85 | } while (size > 0);
86 | }
87 |
88 | // Delay time (max 16383 us)
89 | void doDelay(uint32_t t1, uint32_t t2, uint32_t delayTime)
90 | {
91 | uint32_t t3;
92 |
93 | t3 = t2 - t1;
94 | if ( t3 < delayTime ) {
95 | delayMicroseconds(delayTime - t3);
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/USBH_MIDI/eVY1_sample/eVY1_sample.ino:
--------------------------------------------------------------------------------
1 | /*
2 | *******************************************************************************
3 | * eVY1 Shield sample - Say 'Konnichiwa'
4 | * Copyright (C) 2014-2016 Yuuichi Akagawa
5 | *
6 | * This is sample program. Do not expect perfect behavior.
7 | *******************************************************************************
8 | */
9 | #include
10 | #include
11 |
12 | // Satisfy the IDE, which needs to see the include statment in the ino too.
13 | #ifdef dobogusinclude
14 | #include
15 | #endif
16 | #include
17 |
18 | USB Usb;
19 | //USBHub Hub(&Usb);
20 | USBH_MIDI Midi(&Usb);
21 |
22 | void MIDI_poll();
23 | void noteOn(uint8_t note);
24 | void noteOff(uint8_t note);
25 |
26 | uint16_t pid, vid;
27 | uint8_t exdata[] = {
28 | 0xf0, 0x43, 0x79, 0x09, 0x00, 0x50, 0x10,
29 | 'k', ' ', 'o', ',', //Ko
30 | 'N', '\\', ',', //N
31 | 'J', ' ', 'i', ',', //Ni
32 | 't', 'S', ' ', 'i', ',', //Chi
33 | 'w', ' ', 'a', //Wa
34 | 0x00, 0xf7
35 | };
36 |
37 | void setup()
38 | {
39 | vid = pid = 0;
40 | Serial.begin(115200);
41 |
42 | if (Usb.Init() == -1) {
43 | while (1); //halt
44 | }//if (Usb.Init() == -1...
45 | delay( 200 );
46 | }
47 |
48 | void loop()
49 | {
50 | Usb.Task();
51 | if( Midi ) {
52 | MIDI_poll();
53 | noteOn(0x3f);
54 | delay(400);
55 | noteOff(0x3f);
56 | delay(100);
57 | }
58 | }
59 |
60 | // Poll USB MIDI Controler
61 | void MIDI_poll()
62 | {
63 | uint8_t inBuf[ 3 ];
64 |
65 | //first call?
66 | if (Midi.idVendor() != vid || Midi.idProduct() != pid) {
67 | vid = Midi.idVendor(); pid = Midi.idProduct();
68 | Midi.SendSysEx(exdata, sizeof(exdata));
69 | delay(500);
70 | }
71 | Midi.RecvData(inBuf);
72 | }
73 |
74 | //note On
75 | void noteOn(uint8_t note)
76 | {
77 | uint8_t buf[3];
78 | buf[0] = 0x90;
79 | buf[1] = note;
80 | buf[2] = 0x7f;
81 | Midi.SendData(buf);
82 | }
83 |
84 | //note Off
85 | void noteOff(uint8_t note)
86 | {
87 | uint8_t buf[3];
88 | buf[0] = 0x80;
89 | buf[1] = note;
90 | buf[2] = 0x00;
91 | Midi.SendData(buf);
92 | }
93 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/USB_desc/pgmstrings.h:
--------------------------------------------------------------------------------
1 | #if !defined(__PGMSTRINGS_H__)
2 | #define __PGMSTRINGS_H__
3 |
4 | #define LOBYTE(x) ((char*)(&(x)))[0]
5 | #define HIBYTE(x) ((char*)(&(x)))[1]
6 | #define BUFSIZE 256 //buffer size
7 |
8 |
9 | /* Print strings in Program Memory */
10 | const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t";
11 | const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: ";
12 | const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t";
13 | const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t";
14 | const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t";
15 | const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t";
16 | const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t";
17 | const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t";
18 | const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t";
19 | const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t";
20 | const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t";
21 | const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t";
22 | const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t";
23 | const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t";
24 | const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t";
25 | const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t";
26 | const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes";
27 | const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:";
28 | const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t";
29 | const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t";
30 | const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t";
31 | const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t";
32 | const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t";
33 | const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t";
34 | const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:";
35 | const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t";
36 | const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t";
37 | const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t";
38 | const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t";
39 | const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t";
40 | const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t";
41 | const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t";
42 | const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:";
43 | const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t";
44 | const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t";
45 | const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t";
46 | const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t";
47 | const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:";
48 | const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t";
49 | const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t";
50 | const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t";
51 |
52 | #endif // __PGMSTRINGS_H__
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/acm/acm_terminal/acm_terminal.ino:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "pgmstrings.h"
5 |
6 | // Satisfy the IDE, which needs to see the include statment in the ino too.
7 | #ifdef dobogusinclude
8 | #include
9 | #endif
10 | #include
11 |
12 | class ACMAsyncOper : public CDCAsyncOper
13 | {
14 | public:
15 | uint8_t OnInit(ACM *pacm);
16 | };
17 |
18 | uint8_t ACMAsyncOper::OnInit(ACM *pacm)
19 | {
20 | uint8_t rcode;
21 | // Set DTR = 1 RTS=1
22 | rcode = pacm->SetControlLineState(3);
23 |
24 | if (rcode)
25 | {
26 | ErrorMessage(PSTR("SetControlLineState"), rcode);
27 | return rcode;
28 | }
29 |
30 | LINE_CODING lc;
31 | lc.dwDTERate = 115200;
32 | lc.bCharFormat = 0;
33 | lc.bParityType = 0;
34 | lc.bDataBits = 8;
35 |
36 | rcode = pacm->SetLineCoding(&lc);
37 |
38 | if (rcode)
39 | ErrorMessage(PSTR("SetLineCoding"), rcode);
40 |
41 | return rcode;
42 | }
43 |
44 | USB Usb;
45 | //USBHub Hub(&Usb);
46 | ACMAsyncOper AsyncOper;
47 | ACM Acm(&Usb, &AsyncOper);
48 |
49 | void setup()
50 | {
51 | Serial.begin( 115200 );
52 | #if !defined(__MIPSEL__)
53 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
54 | #endif
55 | Serial.println("Start");
56 |
57 | if (Usb.Init() == -1)
58 | Serial.println("OSCOKIRQ failed to assert");
59 |
60 | delay( 200 );
61 | }
62 |
63 | void loop()
64 | {
65 | Usb.Task();
66 |
67 | if( Acm.isReady()) {
68 | uint8_t rcode;
69 |
70 | /* reading the keyboard */
71 | if(Serial.available()) {
72 | uint8_t data= Serial.read();
73 | /* sending to the phone */
74 | rcode = Acm.SndData(1, &data);
75 | if (rcode)
76 | ErrorMessage(PSTR("SndData"), rcode);
77 | }//if(Serial.available()...
78 |
79 | delay(50);
80 |
81 | /* reading the phone */
82 | /* buffer size must be greater or equal to max.packet size */
83 | /* it it set to 64 (largest possible max.packet size) here, can be tuned down
84 | for particular endpoint */
85 | uint8_t buf[64];
86 | uint16_t rcvd = 64;
87 | rcode = Acm.RcvData(&rcvd, buf);
88 | if (rcode && rcode != hrNAK)
89 | ErrorMessage(PSTR("Ret"), rcode);
90 |
91 | if( rcvd ) { //more than zero bytes received
92 | for(uint16_t i=0; i < rcvd; i++ ) {
93 | Serial.print((char)buf[i]); //printing on the screen
94 | }
95 | }
96 | delay(10);
97 | }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING..
98 | }
99 |
100 |
101 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/acm/acm_terminal/pgmstrings.h:
--------------------------------------------------------------------------------
1 | #if !defined(__PGMSTRINGS_H__)
2 | #define __PGMSTRINGS_H__
3 |
4 | #define LOBYTE(x) ((char*)(&(x)))[0]
5 | #define HIBYTE(x) ((char*)(&(x)))[1]
6 | #define BUFSIZE 256 //buffer size
7 |
8 |
9 | /* Print strings in Program Memory */
10 | const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t";
11 | const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: ";
12 | const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t";
13 | const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t";
14 | const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t";
15 | const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t";
16 | const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t";
17 | const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t";
18 | const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t";
19 | const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t";
20 | const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t";
21 | const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t";
22 | const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t";
23 | const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t";
24 | const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t";
25 | const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t";
26 | const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes";
27 | const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:";
28 | const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t";
29 | const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t";
30 | const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t";
31 | const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t";
32 | const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t";
33 | const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t";
34 | const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:";
35 | const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t";
36 | const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t";
37 | const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t";
38 | const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t";
39 | const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t";
40 | const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t";
41 | const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t";
42 | const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:";
43 | const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t";
44 | const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t";
45 | const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t";
46 | const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t";
47 | const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:";
48 | const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t";
49 | const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t";
50 | const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t";
51 |
52 | #endif // __PGMSTRINGS_H__
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino:
--------------------------------------------------------------------------------
1 | // The source for the Android application can be found at the following link: https://github.com/Lauszus/ArduinoBlinkLED
2 | // The code for the Android application is heavily based on this guide: http://allaboutee.com/2011/12/31/arduino-adk-board-blink-an-led-with-your-phone-code-and-explanation/ by Miguel
3 | #include
4 |
5 | //
6 | // CAUTION! WARNING! ATTENTION! VORSICHT! ADVARSEL! ¡CUIDADO! ВНИМАНИЕ!
7 | //
8 | // Pin 13 is occupied by the SCK pin on various Arduino boards,
9 | // including Uno, Duemilanove, etc., so use a different pin for those boards.
10 | //
11 | // CAUTION! WARNING! ATTENTION! VORSICHT! ADVARSEL! ¡CUIDADO! ВНИМАНИЕ!
12 | //
13 | #if defined(LED_BUILTIN)
14 | #define LED LED_BUILTIN // Use built in LED
15 | #else
16 | #define LED 9 // Set to something here that makes sense for your board.
17 | #endif
18 |
19 |
20 | // Satisfy IDE, which only needs to see the include statment in the ino.
21 | #ifdef dobogusinclude
22 | #include
23 | #endif
24 | #include
25 |
26 | USB Usb;
27 | ADK adk(&Usb, "TKJElectronics", // Manufacturer Name
28 | "ArduinoBlinkLED", // Model Name
29 | "Example sketch for the USB Host Shield", // Description (user-visible string)
30 | "1.0", // Version
31 | "http://www.tkjelectronics.dk/uploads/ArduinoBlinkLED.apk", // URL (web page to visit if no installed apps support the accessory)
32 | "123456789"); // Serial Number (optional)
33 |
34 | uint32_t timer;
35 | bool connected;
36 |
37 | void setup() {
38 | Serial.begin(115200);
39 | #if !defined(__MIPSEL__)
40 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
41 | #endif
42 | if (Usb.Init() == -1) {
43 | Serial.print("\r\nOSCOKIRQ failed to assert");
44 | while (1); // halt
45 | }
46 | pinMode(LED, OUTPUT);
47 | Serial.print("\r\nArduino Blink LED Started");
48 | }
49 |
50 | void loop() {
51 | Usb.Task();
52 |
53 | if (adk.isReady()) {
54 | if (!connected) {
55 | connected = true;
56 | Serial.print(F("\r\nConnected to accessory"));
57 | }
58 |
59 | uint8_t msg[1];
60 | uint16_t len = sizeof(msg);
61 | uint8_t rcode = adk.RcvData(&len, msg);
62 | if (rcode && rcode != hrNAK) {
63 | Serial.print(F("\r\nData rcv: "));
64 | Serial.print(rcode, HEX);
65 | } else if (len > 0) {
66 | Serial.print(F("\r\nData Packet: "));
67 | Serial.print(msg[0]);
68 | digitalWrite(LED, msg[0] ? HIGH : LOW);
69 | }
70 |
71 | if ((int32_t)((uint32_t)millis() - timer) >= 1000) { // Send data every 1s
72 | timer = (uint32_t)millis();
73 | rcode = adk.SndData(sizeof(timer), (uint8_t*)&timer);
74 | if (rcode && rcode != hrNAK) {
75 | Serial.print(F("\r\nData send: "));
76 | Serial.print(rcode, HEX);
77 | } else if (rcode != hrNAK) {
78 | Serial.print(F("\r\nTimer: "));
79 | Serial.print(timer);
80 | }
81 | }
82 | } else {
83 | if (connected) {
84 | connected = false;
85 | Serial.print(F("\r\nDisconnected from accessory"));
86 | digitalWrite(LED, LOW);
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/adk/adk_barcode/adk_barcode.ino:
--------------------------------------------------------------------------------
1 | /**/
2 | /* A sketch demonstrating data exchange between two USB devices - a HID barcode scanner and ADK-compatible Android phone */
3 | /**/
4 | #include
5 | #include
6 | #include
7 |
8 | // Satisfy IDE, which only needs to see the include statment in the ino.
9 | #ifdef dobogusinclude
10 | #include
11 | #endif
12 | #include
13 |
14 | USB Usb;
15 | USBHub Hub1(&Usb);
16 | USBHub Hub2(&Usb);
17 | HIDBoot HidKeyboard(&Usb);
18 |
19 | ADK adk(&Usb,"Circuits@Home, ltd.",
20 | "USB Host Shield",
21 | "Arduino Terminal for Android",
22 | "1.0",
23 | "http://www.circuitsathome.com",
24 | "0000000000000001");
25 |
26 |
27 | class KbdRptParser : public KeyboardReportParser
28 | {
29 |
30 | protected:
31 | void OnKeyDown (uint8_t mod, uint8_t key);
32 | void OnKeyPressed(uint8_t key);
33 | };
34 |
35 | void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
36 | {
37 | uint8_t c = OemToAscii(mod, key);
38 |
39 | if (c)
40 | OnKeyPressed(c);
41 | }
42 |
43 | /* what to do when symbol arrives */
44 | void KbdRptParser::OnKeyPressed(uint8_t key)
45 | {
46 | const char* new_line = "\n";
47 | uint8_t rcode;
48 | uint8_t keylcl;
49 |
50 | if( adk.isReady() == false ) {
51 | return;
52 | }
53 |
54 | keylcl = key;
55 |
56 | if( keylcl == 0x13 ) {
57 | rcode = adk.SndData( strlen( new_line ), (uint8_t *)new_line );
58 | if (rcode && rcode != hrNAK) {
59 | Serial.print(F("\r\nData send: "));
60 | Serial.print(rcode, HEX);
61 | }
62 | }
63 | else {
64 | rcode = adk.SndData( 1, &keylcl );
65 | if (rcode && rcode != hrNAK) {
66 | Serial.print(F("\r\nData send: "));
67 | Serial.print(rcode, HEX);
68 | }
69 | }
70 |
71 | Serial.print((char) keylcl );
72 | Serial.print(" : ");
73 | Serial.println( keylcl, HEX );
74 | };
75 |
76 | KbdRptParser Prs;
77 |
78 | void setup()
79 | {
80 | Serial.begin(115200);
81 | #if !defined(__MIPSEL__)
82 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
83 | #endif
84 | Serial.println("\r\nADK demo start");
85 |
86 | if (Usb.Init() == -1) {
87 | Serial.println("OSCOKIRQ failed to assert");
88 | while(1); //halt
89 | }//if (Usb.Init() == -1...
90 |
91 | HidKeyboard.SetReportParser(0, &Prs);
92 |
93 | delay( 200 );
94 | }
95 |
96 | void loop()
97 | {
98 | Usb.Task();
99 | }
100 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/adk/demokit_20/demokit_20.ino:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | // Satisfy IDE, which only needs to see the include statment in the ino.
5 | #ifdef dobogusinclude
6 | #include
7 | #endif
8 | #include
9 |
10 | USB Usb;
11 | USBHub hub0(&Usb);
12 | USBHub hub1(&Usb);
13 | ADK adk(&Usb, "Google, Inc.",
14 | "DemoKit",
15 | "DemoKit Arduino Board",
16 | "1.0",
17 | "http://www.android.com",
18 | "0000000012345678");
19 | uint8_t b, b1;
20 |
21 |
22 | #define LED1_RED 3
23 | #define BUTTON1 2
24 |
25 | #ifdef ESP32
26 | #define LED1_RED_CHANNEL 0
27 | #endif
28 |
29 | void init_buttons()
30 | {
31 | pinMode(BUTTON1, INPUT);
32 |
33 | // enable the internal pullups
34 | digitalWrite(BUTTON1, HIGH);
35 | }
36 |
37 | void init_leds()
38 | {
39 | digitalWrite(LED1_RED, 0);
40 |
41 | #ifdef ESP32
42 | ledcAttachPin(LED1_RED, LED1_RED_CHANNEL); // Assign LED pin to channel 0
43 | ledcSetup(LED1_RED_CHANNEL, 12000, 8); // 12 kHz PWM, 8-bit resolution
44 | #else
45 | pinMode(LED1_RED, OUTPUT);
46 | #endif
47 | }
48 |
49 | void setup()
50 | {
51 | Serial.begin(115200);
52 | #if !defined(__MIPSEL__)
53 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
54 | #endif
55 | Serial.println("\r\nADK demo start");
56 |
57 | if (Usb.Init() == -1) {
58 | Serial.println("OSCOKIRQ failed to assert");
59 | while (1); //halt
60 | }//if (Usb.Init() == -1...
61 |
62 | init_leds();
63 | init_buttons();
64 | b1 = digitalRead(BUTTON1);
65 | }
66 |
67 | void loop()
68 | {
69 | uint8_t rcode;
70 | uint8_t msg[3] = { 0x00 };
71 | Usb.Task();
72 |
73 | if ( adk.isReady() == false ) {
74 | #ifdef ESP32
75 | ledcWrite(LED1_RED_CHANNEL, 255);
76 | #else
77 | analogWrite(LED1_RED, 255);
78 | #endif
79 | return;
80 | }
81 | uint16_t len = sizeof(msg);
82 |
83 | rcode = adk.RcvData(&len, msg);
84 | if ( rcode ) {
85 | USBTRACE2("Data rcv. :", rcode );
86 | }
87 | if (len > 0) {
88 | USBTRACE("\r\nData Packet.");
89 | // assumes only one command per packet
90 | if (msg[0] == 0x2) {
91 | switch ( msg[1] ) {
92 | case 0:
93 | #ifdef ESP32
94 | ledcWrite(LED1_RED_CHANNEL, 255 - msg[2]);
95 | #else
96 | analogWrite(LED1_RED, 255 - msg[2]);
97 | #endif
98 | break;
99 | }//switch( msg[1]...
100 | }//if (msg[0] == 0x2...
101 | }//if( len > 0...
102 |
103 | msg[0] = 0x1;
104 |
105 | b = digitalRead(BUTTON1);
106 | if (b != b1) {
107 | USBTRACE("\r\nButton state changed");
108 | msg[1] = 0;
109 | msg[2] = b ? 0 : 1;
110 | rcode = adk.SndData( 3, msg );
111 | if ( rcode ) {
112 | USBTRACE2("Button send: ", rcode );
113 | }
114 | b1 = b;
115 | }//if (b != b1...
116 |
117 |
118 | delay( 10 );
119 | }
120 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/adk/term_test/term_test.ino:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | // Satisfy IDE, which only needs to see the include statment in the ino.
5 | #ifdef dobogusinclude
6 | #include
7 | #endif
8 | #include
9 |
10 | USB Usb;
11 | //USBHub Hub(&Usb);
12 |
13 | ADK adk(&Usb, "Circuits@Home, ltd.",
14 | "USB Host Shield",
15 | "Arduino Terminal for Android",
16 | "1.0",
17 | "http://www.circuitsathome.com",
18 | "0000000000000001");
19 |
20 | void setup()
21 | {
22 | Serial.begin(115200);
23 | #if !defined(__MIPSEL__)
24 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
25 | #endif
26 | Serial.println("\r\nADK demo start");
27 |
28 | if (Usb.Init() == -1) {
29 | Serial.println("OSCOKIRQ failed to assert");
30 | while (1); //halt
31 | }//if (Usb.Init() == -1...
32 | }
33 |
34 | void loop()
35 | {
36 | uint8_t rcode;
37 | uint8_t msg[64] = { 0x00 };
38 | const char* recv = "Received: ";
39 |
40 | Usb.Task();
41 |
42 | if ( adk.isReady() == false ) {
43 | return;
44 | }
45 | uint16_t len = 64;
46 |
47 | rcode = adk.RcvData(&len, msg);
48 | if ( rcode & ( rcode != hrNAK )) {
49 | USBTRACE2("Data rcv. :", rcode );
50 | }
51 | if (len > 0) {
52 | USBTRACE("\r\nData Packet.");
53 |
54 | for ( uint8_t i = 0; i < len; i++ ) {
55 | Serial.print((char)msg[i]);
56 | }
57 | /* sending back what was received */
58 | rcode = adk.SndData( strlen( recv ), (uint8_t *)recv );
59 | if (rcode && rcode != hrNAK) {
60 | Serial.print(F("\r\nData send: "));
61 | Serial.print(rcode, HEX);
62 | }
63 | rcode = adk.SndData( strlen(( char * )msg ), msg );
64 | if (rcode && rcode != hrNAK) {
65 | Serial.print(F("\r\nData send: "));
66 | Serial.print(rcode, HEX);
67 | }
68 |
69 | }//if( len > 0 )...
70 |
71 | delay( 1000 );
72 | }
73 |
74 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/adk/term_time/term_time.ino:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | // Satisfy IDE, which only needs to see the include statment in the ino.
5 | #ifdef dobogusinclude
6 | #include
7 | #endif
8 | #include
9 |
10 | USB Usb;
11 |
12 | ADK adk(&Usb, "Circuits@Home, ltd.",
13 | "USB Host Shield",
14 | "Arduino Terminal for Android",
15 | "1.0",
16 | "http://www.circuitsathome.com",
17 | "0000000000000001");
18 |
19 | void setup()
20 | {
21 | Serial.begin(115200);
22 | #if !defined(__MIPSEL__)
23 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
24 | #endif
25 | Serial.println("\r\nADK demo start");
26 |
27 | if (Usb.Init() == -1) {
28 | Serial.println("OSCOKIRQ failed to assert");
29 | while (1); //halt
30 | }//if (Usb.Init() == -1...
31 | }
32 |
33 | void loop()
34 | {
35 | uint8_t buf[ 12 ] = { 0 }; //buffer to convert unsigned long to ASCII
36 | const char* sec_ela = " seconds elapsed\r";
37 | uint8_t rcode;
38 |
39 | Usb.Task();
40 | if ( adk.isReady() == false ) {
41 | return;
42 | }
43 |
44 | ultoa((uint32_t)millis() / 1000, (char *)buf, 10 );
45 |
46 | rcode = adk.SndData( strlen((char *)buf), buf );
47 | if (rcode && rcode != hrNAK) {
48 | Serial.print(F("\r\nData send: "));
49 | Serial.print(rcode, HEX);
50 | }
51 | rcode = adk.SndData( strlen( sec_ela), (uint8_t *)sec_ela );
52 | if (rcode && rcode != hrNAK) {
53 | Serial.print(F("\r\nData send: "));
54 | Serial.print(rcode, HEX);
55 | }
56 |
57 | delay( 1000 );
58 | }
59 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/cdc_XR21B1411/XR_terminal/XR_terminal.ino:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | // Satisfy IDE, which only needs to see the include statment in the ino.
4 | #ifdef dobogusinclude
5 | #include
6 | #endif
7 | #include
8 |
9 | class ACMAsyncOper : public CDCAsyncOper
10 | {
11 | public:
12 | uint8_t OnInit(ACM *pacm);
13 | };
14 |
15 | uint8_t ACMAsyncOper::OnInit(ACM *pacm)
16 | {
17 | uint8_t rcode;
18 | // Set DTR = 1 RTS=1
19 | rcode = pacm->SetControlLineState(3);
20 |
21 | if (rcode)
22 | {
23 | ErrorMessage(PSTR("SetControlLineState"), rcode);
24 | return rcode;
25 | }
26 |
27 | LINE_CODING lc;
28 | lc.dwDTERate = 115200;
29 | lc.bCharFormat = 0;
30 | lc.bParityType = 0;
31 | lc.bDataBits = 8;
32 |
33 | rcode = pacm->SetLineCoding(&lc);
34 |
35 | if (rcode)
36 | ErrorMessage(PSTR("SetLineCoding"), rcode);
37 |
38 | return rcode;
39 | }
40 |
41 | USB Usb;
42 | ACMAsyncOper AsyncOper;
43 | XR21B1411 Acm(&Usb, &AsyncOper);
44 |
45 | void setup() {
46 | Serial.begin( 115200 );
47 | #if !defined(__MIPSEL__)
48 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
49 | #endif
50 | Serial.println("\r\n\r\nStart");
51 |
52 | if (Usb.Init() == -1) Serial.println("OSCOKIRQ failed to assert");
53 | }
54 |
55 | void loop() {
56 | Usb.Task();
57 | if( Acm.isReady()) {
58 | uint8_t rcode;
59 | uint8_t buf[1];
60 | uint16_t rcvd = 1;
61 |
62 | /* read keyboard */
63 | if(Serial.available()) {
64 | uint8_t data = Serial.read();
65 | /* send */
66 | rcode = Acm.SndData(1, &data);
67 | if (rcode)
68 | ErrorMessage(PSTR("SndData"), rcode);
69 | }
70 |
71 | /* read XR serial */
72 | rcode = Acm.RcvData(&rcvd, buf);
73 | if (rcode && rcode != hrNAK)
74 | ErrorMessage(PSTR("Ret"), rcode);
75 |
76 | if( rcvd ) { //more than zero bytes received
77 | for(uint16_t i=0; i < rcvd; i++ ) {
78 | Serial.print((char)buf[i]);
79 | }
80 | }
81 | }
82 | }
83 |
84 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/ftdi/USBFTDILoopback/USBFTDILoopback.ino:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "pgmstrings.h"
5 |
6 | // Satisfy the IDE, which needs to see the include statment in the ino too.
7 | #ifdef dobogusinclude
8 | #include
9 | #endif
10 | #include
11 |
12 | class FTDIAsync : public FTDIAsyncOper
13 | {
14 | public:
15 | uint8_t OnInit(FTDI *pftdi);
16 | };
17 |
18 | uint8_t FTDIAsync::OnInit(FTDI *pftdi)
19 | {
20 | uint8_t rcode = 0;
21 |
22 | rcode = pftdi->SetBaudRate(115200);
23 |
24 | if (rcode)
25 | {
26 | ErrorMessage(PSTR("SetBaudRate"), rcode);
27 | return rcode;
28 | }
29 | rcode = pftdi->SetFlowControl(FTDI_SIO_DISABLE_FLOW_CTRL);
30 |
31 | if (rcode)
32 | ErrorMessage(PSTR("SetFlowControl"), rcode);
33 |
34 | return rcode;
35 | }
36 |
37 | USB Usb;
38 | //USBHub Hub(&Usb);
39 | FTDIAsync FtdiAsync;
40 | FTDI Ftdi(&Usb, &FtdiAsync);
41 |
42 | void setup()
43 | {
44 | Serial.begin( 115200 );
45 | #if !defined(__MIPSEL__)
46 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
47 | #endif
48 | Serial.println("Start");
49 |
50 | if (Usb.Init() == -1)
51 | Serial.println("OSC did not start.");
52 |
53 | delay( 200 );
54 | }
55 |
56 | void loop()
57 | {
58 | Usb.Task();
59 |
60 | if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
61 | {
62 | uint8_t rcode;
63 | char strbuf[] = "DEADBEEF";
64 | //char strbuf[] = "The quick brown fox jumps over the lazy dog";
65 | //char strbuf[] = "This string contains 61 character to demonstrate FTDI buffers"; //add one symbol to it to see some garbage
66 | Serial.print(".");
67 |
68 | rcode = Ftdi.SndData(strlen(strbuf), (uint8_t*)strbuf);
69 |
70 | if (rcode)
71 | ErrorMessage(PSTR("SndData"), rcode);
72 |
73 | delay(50);
74 |
75 | uint8_t buf[64];
76 |
77 | for (uint8_t i=0; i<64; i++)
78 | buf[i] = 0;
79 |
80 | uint16_t rcvd = 64;
81 | rcode = Ftdi.RcvData(&rcvd, buf);
82 |
83 | if (rcode && rcode != hrNAK)
84 | ErrorMessage(PSTR("Ret"), rcode);
85 |
86 | // The device reserves the first two bytes of data
87 | // to contain the current values of the modem and line status registers.
88 | if (rcvd > 2)
89 | Serial.print((char*)(buf+2));
90 |
91 | delay(10);
92 | }
93 | }
94 |
95 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/ftdi/USBFTDILoopback/pgmstrings.h:
--------------------------------------------------------------------------------
1 | #if !defined(__PGMSTRINGS_H__)
2 | #define __PGMSTRINGS_H__
3 |
4 | #define LOBYTE(x) ((char*)(&(x)))[0]
5 | #define HIBYTE(x) ((char*)(&(x)))[1]
6 | #define BUFSIZE 256 //buffer size
7 |
8 |
9 | /* Print strings in Program Memory */
10 | const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t";
11 | const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: ";
12 | const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t";
13 | const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t";
14 | const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t";
15 | const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t";
16 | const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t";
17 | const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t";
18 | const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t";
19 | const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t";
20 | const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t";
21 | const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t";
22 | const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t";
23 | const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t";
24 | const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t";
25 | const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t";
26 | const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes";
27 | const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:";
28 | const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t";
29 | const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t";
30 | const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t";
31 | const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t";
32 | const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t";
33 | const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t";
34 | const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:";
35 | const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t";
36 | const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t";
37 | const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t";
38 | const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t";
39 | const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t";
40 | const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t";
41 | const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t";
42 | const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:";
43 | const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t";
44 | const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t";
45 | const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t";
46 | const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t";
47 | const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:";
48 | const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t";
49 | const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t";
50 | const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t";
51 |
52 | #endif // __PGMSTRINGS_H__
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/hub_demo/pgmstrings.h:
--------------------------------------------------------------------------------
1 | #if !defined(__PGMSTRINGS_H__)
2 | #define __PGMSTRINGS_H__
3 |
4 | #define LOBYTE(x) ((char*)(&(x)))[0]
5 | #define HIBYTE(x) ((char*)(&(x)))[1]
6 | #define BUFSIZE 256 //buffer size
7 |
8 |
9 | /* Print strings in Program Memory */
10 | const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t";
11 | const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: ";
12 | const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t";
13 | const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t";
14 | const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t";
15 | const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t";
16 | const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t";
17 | const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t";
18 | const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t";
19 | const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t";
20 | const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t";
21 | const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t";
22 | const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t";
23 | const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t";
24 | const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t";
25 | const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t";
26 | const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes";
27 | const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:";
28 | const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t";
29 | const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t";
30 | const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t";
31 | const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t";
32 | const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t";
33 | const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t";
34 | const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:";
35 | const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t";
36 | const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t";
37 | const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t";
38 | const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t";
39 | const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t";
40 | const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t";
41 | const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t";
42 | const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:";
43 | const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t";
44 | const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t";
45 | const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t";
46 | const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t";
47 | const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:";
48 | const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t";
49 | const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t";
50 | const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t";
51 |
52 | #endif // __PGMSTRINGS_H__
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/max_LCD/max_LCD.ino:
--------------------------------------------------------------------------------
1 | // Just a copy of the HelloWorld example bundled with the LiquidCrystal library in the Arduino IDE
2 |
3 | // HD44780 compatible LCD display via MAX3421E GPOUT support header
4 | // pinout: D[4-7] -> GPOUT[4-7], RS-> GPOUT[2], E ->GPOUT[3]
5 |
6 | #include
7 |
8 | // Satisfy IDE, which only needs to see the include statment in the ino.
9 | #ifdef dobogusinclude
10 | #include
11 | #endif
12 | #include
13 |
14 | USB Usb;
15 | Max_LCD lcd(&Usb);
16 |
17 | void setup() {
18 | // Set up the LCD's number of columns and rows:
19 | lcd.begin(16, 2);
20 | // Print a message to the LCD.
21 | lcd.print("Hello, World!");
22 | }
23 |
24 | void loop() {
25 | // Set the cursor to column 0, line 1 (note: line 1 is the second row, since counting begins with 0):
26 | lcd.setCursor(0, 1);
27 | // Print the number of seconds since reset:
28 | lcd.print((uint32_t)millis() / 1000);
29 | }
30 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/pl2303/pl2303_gprs_terminal/pl2303_gprs_terminal.ino:
--------------------------------------------------------------------------------
1 | /* Arduino terminal for PL2303 USB to serial converter and DealeXtreme GPRS modem. */
2 | /* USB support */
3 | #include
4 | /* CDC support */
5 | #include
6 | #include
7 |
8 | // Satisfy the IDE, which needs to see the include statment in the ino too.
9 | #ifdef dobogusinclude
10 | #include
11 | #endif
12 | #include
13 |
14 | class PLAsyncOper : public CDCAsyncOper
15 | {
16 | public:
17 | uint8_t OnInit(ACM *pacm);
18 | };
19 |
20 | uint8_t PLAsyncOper::OnInit(ACM *pacm)
21 | {
22 | uint8_t rcode;
23 |
24 | // Set DTR = 1
25 | rcode = pacm->SetControlLineState(1);
26 |
27 | if (rcode)
28 | {
29 | ErrorMessage(PSTR("SetControlLineState"), rcode);
30 | return rcode;
31 | }
32 |
33 | LINE_CODING lc;
34 | //lc.dwDTERate = 9600;
35 | lc.dwDTERate = 115200;
36 | lc.bCharFormat = 0;
37 | lc.bParityType = 0;
38 | lc.bDataBits = 8;
39 |
40 | rcode = pacm->SetLineCoding(&lc);
41 |
42 | if (rcode)
43 | ErrorMessage(PSTR("SetLineCoding"), rcode);
44 |
45 | return rcode;
46 | }
47 | USB Usb;
48 | //USBHub Hub(&Usb);
49 | PLAsyncOper AsyncOper;
50 | PL2303 Pl(&Usb, &AsyncOper);
51 |
52 | void setup()
53 | {
54 | Serial.begin( 115200 );
55 | #if !defined(__MIPSEL__)
56 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
57 | #endif
58 | Serial.println("Start");
59 |
60 | if (Usb.Init() == -1)
61 | Serial.println("OSCOKIRQ failed to assert");
62 |
63 | delay( 200 );
64 | }
65 |
66 | void loop()
67 | {
68 | Usb.Task();
69 |
70 | if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
71 | {
72 | uint8_t rcode;
73 |
74 | /* reading the keyboard */
75 | if(Serial.available()) {
76 | uint8_t data= Serial.read();
77 |
78 | /* sending to the phone */
79 | rcode = Pl.SndData(1, &data);
80 | if (rcode)
81 | ErrorMessage(PSTR("SndData"), rcode);
82 | }//if(Serial.available()...
83 |
84 | /* reading the converter */
85 | /* buffer size must be greater or equal to max.packet size */
86 | /* it it set to 64 (largest possible max.packet size) here, can be tuned down
87 | for particular endpoint */
88 | uint8_t buf[64];
89 | uint16_t rcvd = 64;
90 | rcode = Pl.RcvData(&rcvd, buf);
91 | if (rcode && rcode != hrNAK)
92 | ErrorMessage(PSTR("Ret"), rcode);
93 |
94 | if( rcvd ) { //more than zero bytes received
95 | for(uint16_t i=0; i < rcvd; i++ ) {
96 | Serial.print((char)buf[i]); //printing on the screen
97 | }
98 | }//if( rcvd ...
99 | }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING..
100 | }
101 |
102 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/pl2303/pl2303_gps/pl2303_gps.ino:
--------------------------------------------------------------------------------
1 | /* USB Host to PL2303-based USB GPS unit interface */
2 | /* Navibee GM720 receiver - Sirf Star III */
3 | /* USB support */
4 | #include
5 | /* CDC support */
6 | #include
7 | #include
8 |
9 | // Satisfy the IDE, which needs to see the include statment in the ino too.
10 | #ifdef dobogusinclude
11 | #include
12 | #endif
13 | #include
14 |
15 | class PLAsyncOper : public CDCAsyncOper {
16 | public:
17 | uint8_t OnInit(ACM *pacm);
18 | };
19 |
20 | uint8_t PLAsyncOper::OnInit(ACM *pacm) {
21 | uint8_t rcode;
22 |
23 | // Set DTR = 1
24 | rcode = pacm->SetControlLineState(1);
25 |
26 | if(rcode) {
27 | ErrorMessage(PSTR("SetControlLineState"), rcode);
28 | return rcode;
29 | }
30 |
31 | LINE_CODING lc;
32 | lc.dwDTERate = 4800; //default serial speed of GPS unit
33 | lc.bCharFormat = 0;
34 | lc.bParityType = 0;
35 | lc.bDataBits = 8;
36 |
37 | rcode = pacm->SetLineCoding(&lc);
38 |
39 | if(rcode)
40 | ErrorMessage(PSTR("SetLineCoding"), rcode);
41 |
42 | return rcode;
43 | }
44 |
45 | USB Usb;
46 | USBHub Hub(&Usb);
47 | PLAsyncOper AsyncOper;
48 | PL2303 Pl(&Usb, &AsyncOper);
49 | uint32_t read_delay;
50 | #define READ_DELAY 100
51 |
52 | void setup() {
53 | Serial.begin(115200);
54 | #if !defined(__MIPSEL__)
55 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
56 | #endif
57 | Serial.println("Start");
58 |
59 | if(Usb.Init() == -1)
60 | Serial.println("OSCOKIRQ failed to assert");
61 |
62 | delay(200);
63 | }
64 |
65 | void loop() {
66 | uint8_t rcode;
67 | uint8_t buf[64]; //serial buffer equals Max.packet size of bulk-IN endpoint
68 | uint16_t rcvd = 64;
69 |
70 | Usb.Task();
71 |
72 | if(Pl.isReady()) {
73 | /* reading the GPS */
74 | if((int32_t)((uint32_t)millis() - read_delay) >= 0L) {
75 | read_delay += READ_DELAY;
76 | rcode = Pl.RcvData(&rcvd, buf);
77 | if(rcode && rcode != hrNAK)
78 | ErrorMessage(PSTR("Ret"), rcode);
79 | if(rcvd) { //more than zero bytes received
80 | for(uint16_t i = 0; i < rcvd; i++) {
81 | Serial.print((char)buf[i]); //printing on the screen
82 | }//for( uint16_t i=0; i < rcvd; i++...
83 | }//if( rcvd
84 | }//if( read_delay > millis()...
85 | }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING..
86 | }
87 |
88 |
89 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/testusbhostFAT/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # These are set for a mega 1280 + quadram plus my serial patch.
3 | # If you lack quadram, or want to disable LFN, just change _FS_TINY=1 _USE_LFN=0
4 | #
5 | # If your board is a mega 2560 comment out the following two lines
6 | BOARD = mega
7 |
8 | BOARD_SUB = mega.menu.cpu.atmega1280
9 | PROGRAMMER = arduino
10 |
11 | # ...and then uncomment out the following two lines
12 | #BOARD_SUB = mega.menu.cpu.atmega2560
13 | #PROGRAMMER = wiring
14 |
15 | #BOARD = teensypp2
16 | #BOARD = teensy3
17 | #BOARD = teensy31
18 |
19 | # set your Arduino tty port here
20 | PORT = /dev/ttyUSB0
21 |
22 | EXTRA_FLAGS = -D _USE_LFN=3
23 |
24 | # change to 0 if you have quadram to take advantage of caching FAT
25 | EXTRA_FLAGS += -D _FS_TINY=1
26 |
27 |
28 | EXTRA_FLAGS += -D _MAX_SS=512
29 |
30 |
31 | # Don't worry if you don't have external RAM, xmem2 detects this situation.
32 | # You *WILL* be wanting to get some kind of external ram on your mega in order to
33 | # do anything that is intense.
34 | EXTRA_FLAGS += -D EXT_RAM_STACK=1
35 | EXTRA_FLAGS += -D EXT_RAM_HEAP=1
36 |
37 |
38 | # These are no longer needed for the demo to work.
39 | # In the event you need more ram, uncomment these 3 lines.
40 | #EXTRA_FLAGS += -D DISABLE_SERIAL1
41 | #EXTRA_FLAGS += -D DISABLE_SERIAL2
42 | #EXTRA_FLAGS += -D DISABLE_SERIAL3
43 |
44 | #
45 | # Advanced debug on Serial3
46 | #
47 |
48 | # uncomment the next two to enable debug on Serial3
49 | EXTRA_FLAGS += -D USB_HOST_SERIAL=Serial3
50 | #EXTRA_FLAGS += -D DEBUG_USB_HOST
51 |
52 | # The following are the libraries used.
53 | LIB_DIRS += ../../
54 | LIB_DIRS += ../testusbhostFAT/xmem2
55 | LIB_DIRS += ../testusbhostFAT/generic_storage
56 | LIB_DIRS += ../testusbhostFAT/RTClib
57 | LIB_DIRS += $(ARD_HOME)/libraries/Wire
58 | LIB_DIRS += $(ARD_HOME)/libraries/Wire/utility
59 | LIB_DIRS += $(ARD_HOME)/hardware/arduino/$(BUILD_ARCH)/libraries/Wire
60 | LIB_DIRS += $(ARD_HOME)/hardware/arduino/$(BUILD_ARCH)/libraries/Wire/utility
61 | LIB_DIRS += $(ARD_HOME)/hardware/arduino/$(BUILD_ARCH)/libraries/SPI
62 |
63 | # And finally, the part that brings everything together for you.
64 | include Arduino_Makefile_master/_Makefile.master
65 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/examples/testusbhostFAT/README.md:
--------------------------------------------------------------------------------
1 | This small sketch tests the USB host shield mass storage library.
2 |
3 | __Note:__ This will not run a Arduino Uno due to the limited ram available in the ATmega328p.
4 |
5 | The Arduino Mega (ATmega1280) and the Arduino Mega 2560 (ATmega2560) are confirmed to work with this test code.
6 |
7 | To compile this example you will need the following libraries as well:
8 |
9 | * [xmem2](https://github.com/xxxajk/xmem2)
10 | * [generic_storage FATfs](https://github.com/xxxajk/generic_storage)
11 | * [RTClib](https://github.com/xxxajk/RTClib)
12 |
13 | The following shield is recommended for larger projects: .
14 |
15 | You may use the bundled [Makefile](Makefile) to compile the code instead of the Arduino IDE if you have problems or want a smaller binary. The master makefile is bundled as a submodule, but can also be downloaded manually at the following link: .
16 |
17 | To download the USB Host library and all the needed libraries for this test.
18 |
19 | Run the following command in a terminal application:
20 |
21 | ```
22 | git clone --recursive https://github.com/felis/USB_Host_Shield_2.0
23 | ```
24 |
25 | If you want to update all the submodules run:
26 |
27 | ```
28 | git submodule foreach --recursive git pull origin master
29 | ```
30 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/hexdump.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; either version 2 of the License, or
6 | (at your option) any later version.
7 |
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with this program; if not, write to the Free Software
15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 |
17 | Contact information
18 | -------------------
19 |
20 | Circuits At Home, LTD
21 | Web : http://www.circuitsathome.com
22 | e-mail : support@circuitsathome.com
23 | */
24 |
25 | #if !defined(_usb_h_) || defined(__HEXDUMP_H__)
26 | #error "Never include hexdump.h directly; include Usb.h instead"
27 | #else
28 | #define __HEXDUMP_H__
29 |
30 | extern int UsbDEBUGlvl;
31 |
32 | template
33 | class HexDumper : public BASE_CLASS {
34 | uint8_t byteCount;
35 | OFFSET_TYPE byteTotal;
36 |
37 | public:
38 |
39 | HexDumper() : byteCount(0), byteTotal(0) {
40 | };
41 |
42 | void Initialize() {
43 | byteCount = 0;
44 | byteTotal = 0;
45 | };
46 |
47 | void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset);
48 | };
49 |
50 | template
51 | void HexDumper::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset __attribute__((unused))) {
52 | if(UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug.
53 | for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) {
54 | if(!byteCount) {
55 | PrintHex (byteTotal, 0x80);
56 | E_Notify(PSTR(": "), 0x80);
57 | }
58 | PrintHex (pbuf[j], 0x80);
59 | E_Notify(PSTR(" "), 0x80);
60 |
61 | if(byteCount == 15) {
62 | E_Notify(PSTR("\r\n"), 0x80);
63 | byteCount = 0xFF;
64 | }
65 | }
66 | }
67 | }
68 |
69 | #endif // __HEXDUMP_H__
70 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/hiduniversal.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 |
3 | This software may be distributed and modified under the terms of the GNU
4 | General Public License version 2 (GPL2) as published by the Free Software
5 | Foundation and appearing in the file GPL2.TXT included in the packaging of
6 | this file. Please note that GPL2 Section 2[b] requires that all works based
7 | on this software must also be made publicly available under the terms of
8 | the GPL2 ("Copyleft").
9 |
10 | Contact information
11 | -------------------
12 |
13 | Circuits At Home, LTD
14 | Web : http://www.circuitsathome.com
15 | e-mail : support@circuitsathome.com
16 | */
17 |
18 | #include "hiduniversal.h"
19 |
20 | uint8_t HIDUniversal::Poll() {
21 | uint8_t rcode = 0;
22 |
23 | if(!bPollEnable)
24 | return 0;
25 |
26 | if((int32_t)((uint32_t)millis() - qNextPollTime) >= 0L) {
27 | qNextPollTime = (uint32_t)millis() + pollInterval;
28 |
29 | uint8_t buf[constBuffLen];
30 |
31 | for(uint8_t i = 0; i < bNumIface; i++) {
32 | uint8_t index = hidInterfaces[i].epIndex[epInterruptInIndex];
33 | uint16_t read = (uint16_t)epInfo[index].maxPktSize;
34 |
35 | ZeroMemory(constBuffLen, buf);
36 |
37 | uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[index].epAddr, &read, buf);
38 |
39 | if(rcode) {
40 | if(rcode != hrNAK)
41 | USBTRACE3("(hiduniversal.h) Poll:", rcode, 0x81);
42 | return rcode;
43 | }
44 |
45 | if(read > constBuffLen)
46 | read = constBuffLen;
47 |
48 | // TODO: handle read == 0 ? continue like HIDComposite,
49 | // return early like in the error case above?
50 | // Either way passing an empty buffer to the functions below
51 | // probably makes no sense?
52 |
53 | #if 0
54 | Notify(PSTR("\r\nBuf: "), 0x80);
55 |
56 | for(uint8_t i = 0; i < read; i++) {
57 | D_PrintHex (buf[i], 0x80);
58 | Notify(PSTR(" "), 0x80);
59 | }
60 |
61 | Notify(PSTR("\r\n"), 0x80);
62 | #endif
63 | ParseHIDData(this, bHasReportId, (uint8_t)read, buf);
64 |
65 | HIDReportParser *prs = GetReportParser(((bHasReportId) ? *buf : 0));
66 |
67 | if(prs)
68 | prs->Parse(this, bHasReportId, (uint8_t)read, buf);
69 | }
70 | }
71 | return rcode;
72 | }
73 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/hiduniversal.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 |
3 | This software may be distributed and modified under the terms of the GNU
4 | General Public License version 2 (GPL2) as published by the Free Software
5 | Foundation and appearing in the file GPL2.TXT included in the packaging of
6 | this file. Please note that GPL2 Section 2[b] requires that all works based
7 | on this software must also be made publicly available under the terms of
8 | the GPL2 ("Copyleft").
9 |
10 | Contact information
11 | -------------------
12 |
13 | Circuits At Home, LTD
14 | Web : http://www.circuitsathome.com
15 | e-mail : support@circuitsathome.com
16 | */
17 |
18 | #if !defined(__HIDUNIVERSAL_H__)
19 | #define __HIDUNIVERSAL_H__
20 |
21 | #include "hidcomposite.h"
22 |
23 | class HIDUniversal : public HIDComposite {
24 |
25 | bool SelectInterface(uint8_t iface __attribute__((unused)), uint8_t proto __attribute__((unused))) final {
26 | // the original HIDUniversal didn't have this at all so make it a no-op
27 | // (and made it final so users don't override this - if they want to use
28 | // SelectInterface() they should be deriving from HIDComposite directly)
29 | return true;
30 | }
31 |
32 | void ParseHIDData(USBHID *hid, uint8_t ep __attribute__((unused)), bool is_rpt_id, uint8_t len, uint8_t *buf) final {
33 | // override the HIDComposite version of this method to call the HIDUniversal version
34 | // (which doesn't use the endpoint), made it final to make sure users
35 | // of HIDUniversal override the right version of ParseHIDData() (the other one, below)
36 | ParseHIDData(hid, is_rpt_id, len, buf);
37 | }
38 |
39 | protected:
40 | virtual void ParseHIDData(USBHID *hid __attribute__((unused)), bool is_rpt_id __attribute__((unused)), uint8_t len __attribute__((unused)), uint8_t *buf __attribute__((unused))) {
41 | return;
42 | }
43 |
44 | public:
45 | HIDUniversal(USB *p) : HIDComposite(p) {}
46 |
47 | uint8_t Poll() override;
48 |
49 | // UsbConfigXtracter implementation
50 | void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep) override
51 | {
52 | // If the first configuration satisfies, the others are not considered.
53 | if(bNumEP > 1 && conf != bConfNum)
54 | return;
55 | // otherwise HIDComposite does what HIDUniversal needs
56 | HIDComposite::EndpointXtract(conf, iface, alt, proto, ep);
57 | }
58 | };
59 |
60 | #endif // __HIDUNIVERSAL_H__
61 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/library.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "USB-Host-Shield-20",
3 | "keywords": "usb, host, ftdi, adk, acm, pl2303, hid, bluetooth, spp, ps3, ps4, ps5, buzz, xbox, wii, mass storage",
4 | "description": "Revision 2.0 of MAX3421E-based USB Host Shield Library",
5 | "authors":
6 | [
7 | {
8 | "name": "Oleg Mazurov",
9 | "email": "mazurov@circuitsathome.com",
10 | "url": "http://www.circuitsathome.com",
11 | "maintainer": true
12 | },
13 | {
14 | "name": "Alexei Glushchenko",
15 | "email": "alex-gl@mail.ru"
16 | },
17 | {
18 | "name": "Kristian Sloth Lauszus",
19 | "email": "lauszus@gmail.com",
20 | "url": "https://lauszus.com",
21 | "maintainer": true
22 | },
23 | {
24 | "name": "Andrew Kroll",
25 | "email": "xxxajk@gmail.com",
26 | "maintainer": true
27 | }
28 | ],
29 | "repository":
30 | {
31 | "type": "git",
32 | "url": "https://github.com/felis/USB_Host_Shield_2.0.git"
33 | },
34 | "version": "1.4.0",
35 | "license": "GPL-2.0",
36 | "examples":
37 | [
38 | "examples/*/*.ino",
39 | "examples/*/*/*.ino"
40 | ],
41 | "frameworks":
42 | [
43 | "arduino",
44 | "spl"
45 | ],
46 | "platforms":
47 | [
48 | "atmelavr",
49 | "intel_arc32",
50 | "teensy",
51 | "atmelsam",
52 | "nordicnrf51",
53 | "ststm32",
54 | "espressif8266",
55 | "espressif32"
56 | ]
57 | }
58 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/library.properties:
--------------------------------------------------------------------------------
1 | name=USB Host Shield Library 2.0
2 | version=1.4.0
3 | author=Oleg Mazurov (Circuits@Home) , Kristian Sloth Lauszus , Andrew Kroll , Alexei Glushchenko (Circuits@Home)
4 | maintainer=Oleg Mazurov (Circuits@Home) , Kristian Sloth Lauszus , Andrew Kroll
5 | sentence=Revision 2.0 of MAX3421E-based USB Host Shield Library.
6 | paragraph=Supports HID devices, FTDI, ADK, ACM, PL2303, Bluetooth HID devices, SPP communication and mass storage devices. Furthermore it supports PS3, PS4, PS5, PS Buzz, Wii and Xbox controllers.
7 | category=Other
8 | url=https://github.com/felis/USB_Host_Shield_2.0
9 | architectures=*
10 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/message.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; either version 2 of the License, or
6 | (at your option) any later version.
7 |
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with this program; if not, write to the Free Software
15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 |
17 | Contact information
18 | -------------------
19 |
20 | Circuits At Home, LTD
21 | Web : http://www.circuitsathome.com
22 | e-mail : support@circuitsathome.com
23 | */
24 | #if !defined(_usb_h_) || defined(__MESSAGE_H__)
25 | #error "Never include message.h directly; include Usb.h instead"
26 | #else
27 | #define __MESSAGE_H__
28 |
29 | extern int UsbDEBUGlvl;
30 |
31 | void E_Notify(char const * msg, int lvl);
32 | void E_Notify(uint8_t b, int lvl);
33 | void E_NotifyStr(char const * msg, int lvl);
34 | void E_Notifyc(char c, int lvl);
35 |
36 | #ifdef DEBUG_USB_HOST
37 | #define Notify E_Notify
38 | #define NotifyStr E_NotifyStr
39 | #define Notifyc E_Notifyc
40 | void NotifyFailGetDevDescr(uint8_t reason);
41 | void NotifyFailSetDevTblEntry(uint8_t reason);
42 | void NotifyFailGetConfDescr(uint8_t reason);
43 | void NotifyFailSetConfDescr(uint8_t reason);
44 | void NotifyFailGetDevDescr(void);
45 | void NotifyFailSetDevTblEntry(void);
46 | void NotifyFailGetConfDescr(void);
47 | void NotifyFailSetConfDescr(void);
48 | void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID);
49 | void NotifyFail(uint8_t rcode);
50 | #else
51 | #define Notify(...) ((void)0)
52 | #define NotifyStr(...) ((void)0)
53 | #define Notifyc(...) ((void)0)
54 | #define NotifyFailGetDevDescr(...) ((void)0)
55 | #define NotifyFailSetDevTblEntry(...) ((void)0)
56 | #define NotifyFailGetConfDescr(...) ((void)0)
57 | #define NotifyFailGetDevDescr(...) ((void)0)
58 | #define NotifyFailSetDevTblEntry(...) ((void)0)
59 | #define NotifyFailGetConfDescr(...) ((void)0)
60 | #define NotifyFailSetConfDescr(...) ((void)0)
61 | #define NotifyFailUnknownDevice(...) ((void)0)
62 | #define NotifyFail(...) ((void)0)
63 | #endif
64 |
65 | template
66 | void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) {
67 | #ifdef DEBUG_USB_HOST
68 | Notify(msg, level);
69 | Notify(PSTR(": "), level);
70 | D_PrintHex (rcode, level);
71 | Notify(PSTR("\r\n"), level);
72 | #endif
73 | }
74 |
75 | template
76 | void ErrorMessage(char const * msg __attribute__((unused)), ERROR_TYPE rcode __attribute__((unused)) = 0) {
77 | #ifdef DEBUG_USB_HOST
78 | Notify(msg, 0x80);
79 | Notify(PSTR(": "), 0x80);
80 | D_PrintHex (rcode, 0x80);
81 | Notify(PSTR("\r\n"), 0x80);
82 | #endif
83 | }
84 |
85 | #endif // __MESSAGE_H__
86 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/parsetools.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; either version 2 of the License, or
6 | (at your option) any later version.
7 |
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with this program; if not, write to the Free Software
15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 |
17 | Contact information
18 | -------------------
19 |
20 | Circuits At Home, LTD
21 | Web : http://www.circuitsathome.com
22 | e-mail : support@circuitsathome.com
23 | */
24 | #include "Usb.h"
25 |
26 | bool MultiByteValueParser::Parse(uint8_t **pp, uint16_t *pcntdn) {
27 | if(!pBuf) {
28 | Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80);
29 | return false;
30 | }
31 | for(; countDown && (*pcntdn); countDown--, (*pcntdn)--, (*pp)++)
32 | pBuf[valueSize - countDown] = (**pp);
33 |
34 | if(countDown)
35 | return false;
36 |
37 | countDown = valueSize;
38 | return true;
39 | }
40 |
41 | bool PTPListParser::Parse(uint8_t **pp, uint16_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) {
42 | switch(nStage) {
43 | case 0:
44 | pBuf->valueSize = lenSize;
45 | theParser.Initialize(pBuf);
46 | nStage = 1;
47 | // fall through
48 |
49 | case 1:
50 | if(!theParser.Parse(pp, pcntdn))
51 | return false;
52 |
53 | arLen = 0;
54 | arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue));
55 | arLenCntdn = arLen;
56 | nStage = 2;
57 | // fall through
58 |
59 | case 2:
60 | pBuf->valueSize = valSize;
61 | theParser.Initialize(pBuf);
62 | nStage = 3;
63 | // fall through
64 |
65 | case 3:
66 | for(; arLenCntdn; arLenCntdn--) {
67 | if(!theParser.Parse(pp, pcntdn))
68 | return false;
69 |
70 | if(pf)
71 | pf(pBuf, (arLen - arLenCntdn), me);
72 | }
73 |
74 | nStage = 0;
75 | }
76 | return true;
77 | }
78 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/printhex.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; either version 2 of the License, or
6 | (at your option) any later version.
7 |
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with this program; if not, write to the Free Software
15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 |
17 | Contact information
18 | -------------------
19 |
20 | Circuits At Home, LTD
21 | Web : http://www.circuitsathome.com
22 | e-mail : support@circuitsathome.com
23 | */
24 |
25 | #if !defined(_usb_h_) || defined(__PRINTHEX_H__)
26 | #error "Never include printhex.h directly; include Usb.h instead"
27 | #else
28 | #define __PRINTHEX_H__
29 |
30 | void E_Notifyc(char c, int lvl);
31 |
32 | template
33 | void PrintHex(T val, int lvl) {
34 | int num_nibbles = sizeof (T) * 2;
35 |
36 | do {
37 | char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f);
38 | if(v > 57) v += 7;
39 | E_Notifyc(v, lvl);
40 | } while(--num_nibbles);
41 | }
42 |
43 | template
44 | void PrintBin(T val, int lvl) {
45 | for(T mask = (((T)1) << ((sizeof (T) << 3) - 1)); mask; mask >>= 1)
46 | if(val & mask)
47 | E_Notifyc('1', lvl);
48 | else
49 | E_Notifyc('0', lvl);
50 | }
51 |
52 | template
53 | void SerialPrintHex(T val) {
54 | int num_nibbles = sizeof (T) * 2;
55 |
56 | do {
57 | char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f);
58 | if(v > 57) v += 7;
59 | USB_HOST_SERIAL.print(v);
60 | } while(--num_nibbles);
61 | }
62 |
63 | template
64 | void PrintHex2(Print *prn, T val) {
65 | T mask = (((T)1) << (((sizeof (T) << 1) - 1) << 2));
66 |
67 | while(mask > 1) {
68 | if(val < mask)
69 | prn->print("0");
70 |
71 | mask >>= 4;
72 | }
73 | prn->print((T)val, HEX);
74 | }
75 |
76 | template void D_PrintHex(T val __attribute__((unused)), int lvl __attribute__((unused))) {
77 | #ifdef DEBUG_USB_HOST
78 | PrintHex (val, lvl);
79 | #endif
80 | }
81 |
82 | template
83 | void D_PrintBin(T val, int lvl) {
84 | #ifdef DEBUG_USB_HOST
85 | PrintBin (val, lvl);
86 | #endif
87 | }
88 |
89 |
90 |
91 | #endif // __PRINTHEX_H__
92 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/sink_parser.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; either version 2 of the License, or
6 | (at your option) any later version.
7 |
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with this program; if not, write to the Free Software
15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 |
17 | Contact information
18 | -------------------
19 |
20 | Circuits At Home, LTD
21 | Web : http://www.circuitsathome.com
22 | e-mail : support@circuitsathome.com
23 | */
24 |
25 | #if !defined(_usb_h_) || defined(__SINK_PARSER_H__)
26 | #error "Never include hexdump.h directly; include Usb.h instead"
27 | #else
28 | #define __SINK_PARSER_H__
29 |
30 | extern int UsbDEBUGlvl;
31 |
32 | // This parser does absolutely nothing with the data, just swallows it.
33 |
34 | template
35 | class SinkParser : public BASE_CLASS {
36 | public:
37 |
38 | SinkParser() {
39 | };
40 |
41 | void Initialize() {
42 | };
43 |
44 | void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) {
45 | };
46 | };
47 |
48 |
49 | #endif // __HEXDUMP_H__
50 |
--------------------------------------------------------------------------------
/USB_Host_Shield_2_0/xboxEnums.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved.
2 |
3 | This software may be distributed and modified under the terms of the GNU
4 | General Public License version 2 (GPL2) as published by the Free Software
5 | Foundation and appearing in the file GPL2.TXT included in the packaging of
6 | this file. Please note that GPL2 Section 2[b] requires that all works based
7 | on this software must also be made publicly available under the terms of
8 | the GPL2 ("Copyleft").
9 |
10 | Contact information
11 | -------------------
12 |
13 | Kristian Lauszus, TKJ Electronics
14 | Web : http://www.tkjelectronics.com
15 | e-mail : kristianl@tkjelectronics.com
16 | */
17 |
18 | #ifndef _xboxenums_h
19 | #define _xboxenums_h
20 |
21 | #include "controllerEnums.h"
22 |
23 | /** Enum used to set special LED modes supported by the Xbox controller. */
24 | enum LEDModeEnum {
25 | ROTATING = 0x0A,
26 | FASTBLINK = 0x0B,
27 | SLOWBLINK = 0x0C,
28 | ALTERNATING = 0x0D,
29 | };
30 |
31 | /** Used to set the LEDs on the controllers */
32 | const uint8_t XBOX_LEDS[] PROGMEM = {
33 | 0x00, // OFF
34 | 0x02, // LED1
35 | 0x03, // LED2
36 | 0x04, // LED3
37 | 0x05, // LED4
38 | 0x01, // ALL - Used to blink all LEDs
39 | };
40 | /** Buttons on the controllers */
41 | const uint16_t XBOX_BUTTONS[] PROGMEM = {
42 | 0x0100, // UP
43 | 0x0800, // RIGHT
44 | 0x0200, // DOWN
45 | 0x0400, // LEFT
46 |
47 | 0x2000, // BACK
48 | 0x1000, // START
49 | 0x4000, // L3
50 | 0x8000, // R3
51 |
52 | 0, 0, // Skip L2 and R2 as these are analog buttons
53 | 0x0001, // L1
54 | 0x0002, // R1
55 |
56 | 0x0020, // B
57 | 0x0010, // A
58 | 0x0040, // X
59 | 0x0080, // Y
60 |
61 | 0x0004, // XBOX
62 | 0x0008, // SYNC
63 | };
64 |
65 | #endif
66 |
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/IMG_1820.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/IMG_1820.JPG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/IMG_1988.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/IMG_1988.JPG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/IMG_1998.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/IMG_1998.JPG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/IMG_3558.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/IMG_3558.JPG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/IMG_3619.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/IMG_3619.JPG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/authorization.css:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/blank.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/blank.gif
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/blogger_logo_round_35.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/blogger_logo_round_35.png
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/com.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/com.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/control0.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/control0.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/control1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/control1.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/control2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/control2.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/control3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/control3.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/control4.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/control4.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/control5.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/control5.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/control6.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/control6.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/control7.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/control7.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout0.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout0.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout1.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout2.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout3.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout4.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout4.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout5.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout5.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout6.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout6.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout7.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout7.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout8.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout8.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout9.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/dataout9.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/datasheet.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/datasheet.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/f.txt:
--------------------------------------------------------------------------------
1 | window['google_empty_script_included'] = true;
2 |
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/file0(1).PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/file0(1).PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/file0.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/file0.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/googlelogo_color_42x16dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/googlelogo_color_42x16dp.png
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/icon18_edit_allbkg.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/icon18_edit_allbkg.gif
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/icon18_wrench_allbkg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/icon18_wrench_allbkg.png
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.clo,.opn,.pun{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.kwd,.tag,.typ{font-weight:700}.str{color:#060}.kwd{color:#006}.com{color:#600;font-style:italic}.typ{color:#404}.lit{color:#044}.clo,.opn,.pun{color:#440}.tag{color:#006}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/related_tools_and_software.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/related_tools_and_software.png
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/s132-sd.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/s132-sd.PNG
--------------------------------------------------------------------------------
/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/translate_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/Useful-Resources/Full-Webpage/假濕汀的Blogger._ STM32F401_411 USB-Device HID Test(Control in_out & Interrupt in_out)_files/translate_24dp.png
--------------------------------------------------------------------------------
/fritzing_sketch.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/fritzing_sketch.fzz
--------------------------------------------------------------------------------
/fritzing_sketch_bb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MasterJubei/OGX_STM32/826f88400d8fa616b251b7fc63f9810fa85cc878/fritzing_sketch_bb.png
--------------------------------------------------------------------------------