Skip to content

Commit

Permalink
Merge pull request #80 from hathach/develop
Browse files Browse the repository at this point in the history
 added usbd_edpt_xfer/usbd_edpt_busy to replace dcd_edpt_transfer/dcd_edpt_busy()
  • Loading branch information
hathach committed Jun 10, 2019
2 parents 69e9821 + 7156bfb commit 3934928
Show file tree
Hide file tree
Showing 347 changed files with 16,861 additions and 49,955 deletions.
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
/.metadata
html
latex
test_old
tests/build
test/_build
*.d
*.o
*.launch
*.P
*.map
*.axf
*.jlink
*.emSession
*.elf
*.ind
.env
/tests/lpc175x_6x/build/
/tests/lpc18xx_43xx/build/
/examples/*/*/build-*
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
[submodule "hw/mcu/microchip/samd/asf4"]
path = hw/mcu/microchip/samd/asf4
url = https://github.com/adafruit/asf4.git
[submodule "tests/vendor/unity"]
path = tests/vendor/unity
url = https://github.com/ThrowTheSwitch/Unity.git
[submodule "hw/mcu/st/stm32lib"]
path = hw/mcu/st/stm32lib
url = https://github.com/hathach/stm32lib.git
Expand Down
28 changes: 17 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@ language: c
dist: xenial
compiler:
- gcc
env:
- TRAVIS_SDK=arm

before_script:
- function var_search () { case "$1" in *$2*) true;; *) false;; esac; }
- sudo dpkg --add-architecture i386

- (! var_search "${TRAVIS_SDK-}" arm || (wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2018q2-1~trusty1_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb))
- sudo apt-get install -y realpath
addons:
apt:
sources:
- sourceline: "ppa:team-gcc-arm-embedded/ppa"
packages:
- python3
- ruby
- gcc-arm-embedded

- realpath --version
- gcc --version
- (! var_search "${TRAVIS_SDK-}" arm || arm-none-eabi-gcc --version)
install:
- gem install ceedling

before_script:
- arm-none-eabi-gcc --version

script:
# Build all examples
- python3 tools/build_all.py
# Run unit tests
- cd test
- ceedling test:all
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ TinyUSB is an open-source cross-platform USB Host/Device stack for embedded syst
│   └── mcu # Low level mcu core & peripheral drivers
├── lib # Sources from 3rd party such as freeRTOS, fatfs ...
├── src # All sources files for TinyUSB stack itself.
├── tests # Unit tests for the stack
├── test # Unit tests for the stack
└── tools # Files used internally
```

Expand Down Expand Up @@ -77,6 +77,7 @@ TinyUSB is currently used by these other projects:

* [Adafruit nRF52 Arduino](https://github.com/adafruit/Adafruit_nRF52_Arduino)
* [Adafruit nRF52 Bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader)
* [Adafruit SAMD Arduino](https://github.com/adafruit/ArduinoCore-samd)
* [CircuitPython](https://github.com/adafruit/circuitpython)
* [TinyUSB Arduino Library](https://github.com/adafruit/Adafruit_TinyUSB_Arduino)

Expand Down
2 changes: 1 addition & 1 deletion examples/device/cdc_msc_hid/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void hid_task(void)
tud_hid_mouse_report(REPORT_ID_MOUSE, 0x00, delta, delta, 0, 0);

// delay a bit before attempt to send keyboard report
board_delay(2);
board_delay(10);
}
}

Expand Down
5 changes: 4 additions & 1 deletion examples/device/cdc_msc_hid/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#endif

#ifndef CFG_TUSB_MEM_ALIGN
#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4)
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
#endif

//--------------------------------------------------------------------
Expand Down Expand Up @@ -95,6 +95,9 @@
// Should be sufficient to hold ID (if any) + Data
#define CFG_TUD_HID_BUFSIZE 16

#define CFG_TUD_MIDI_RX_BUFSIZE 512
#define CFG_TUD_MIDI_TX_BUFSIZE 512

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion examples/device/cdc_msc_hid_freertos/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#endif

#ifndef CFG_TUSB_MEM_ALIGN
#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4)
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
#endif

//--------------------------------------------------------------------
Expand Down
15 changes: 12 additions & 3 deletions examples/device/hid_generic_inout/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,18 @@
* It will receive data from Host (In endpoint) and echo back (Out endpoint).
* HID Report descriptor use vendor for usage page (using template TUD_HID_REPORT_DESC_GENERIC_INOUT)
*
* Run 'python3 hid_test.py' on your PC to send and receive data to this device.
* Python and `hid` package is required, for installation please follow
* https://pypi.org/project/hid/
* There are 2 ways to test the sketch
* 1. Using nodejs
* - Install nodejs and nmp to your PC
* - Install execellent node-hid (https://github.com/node-hid/node-hid) by
* $ npm install node-hid
* - Run provided hid test script
* $ node hid_test.js
*
* 2. Using python hidRun
* - Python and `hid` package is required, for installation please follow https://pypi.org/project/hid/
* - Run provided hid test script to send and receive data to this device.
* $ python3 hid_test.py
*/

//--------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion examples/device/hid_generic_inout/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#endif

#ifndef CFG_TUSB_MEM_ALIGN
#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4)
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
#endif

//--------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion examples/device/msc_dual_lun/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#endif

#ifndef CFG_TUSB_MEM_ALIGN
#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4)
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
#endif

//--------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion examples/host/cdc_msc_hid/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
#endif

#ifndef CFG_TUSB_MEM_ALIGN
#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4)
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
#endif

//--------------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions examples/make.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ CP = cp
RM = rm
PYTHON ?= python

check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined make flag: $1$(if $2, ($2))))

# Select the board to build for.
ifeq ($(BOARD),)
$(info You must provide a BOARD parameter with 'BOARD=')
Expand Down
2 changes: 1 addition & 1 deletion examples/obsolete/host/src/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X
#define CFG_TUSB_MEM_SECTION // LPC17xx USB DMA can access all address
#elif (CFG_TUSB_MCU == OPT_MCU_LPC43XX)
#define CFG_TUSB_MEM_SECTION ATTR_SECTION(.data.$RAM3)
#define CFG_TUSB_MEM_SECTION TU_ATTR_SECTION(.data.$RAM3)
#endif

#elif defined __CC_ARM // Compiled with Keil armcc
Expand Down
1 change: 1 addition & 0 deletions examples/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ SRC_C += \
src/class/msc/msc_device.c \
src/class/cdc/cdc_device.c \
src/class/hid/hid_device.c \
src/class/midi/midi_device.c \
src/tusb.c \
src/portable/$(VENDOR)/$(CHIP_FAMILY)/dcd_$(CHIP_FAMILY).c

Expand Down
6 changes: 5 additions & 1 deletion hw/bsp/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ static inline void board_led_off(void)
static inline void board_delay(uint32_t ms)
{
uint32_t start_ms = board_millis();
while( board_millis() - start_ms < ms) {}
while (board_millis() - start_ms < ms)
{
// take chance to run usb background
tud_task();
}
}

static inline int8_t board_uart_getchar(void)
Expand Down
9 changes: 7 additions & 2 deletions hw/bsp/feather_nrf52840_express/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,10 @@ JLINK_IF = swd
# For uf2 conversion
UF2_FAMILY = 0xADA52840

# flash using jlink
flash: flash-jlink
$(BUILD)/$(BOARD)-firmware.zip: $(BUILD)/$(BOARD)-firmware.hex
adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@

# flash using adafruit-nrfutil dfu
flash: $(BUILD)/$(BOARD)-firmware.zip
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200
28 changes: 14 additions & 14 deletions src/class/cdc/cdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ typedef enum
// FUNCTIONAL DESCRIPTOR (COMMUNICATION INTERFACE)
//--------------------------------------------------------------------+
/// Header Functional Descriptor (Communication Interface)
typedef struct ATTR_PACKED
typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
Expand All @@ -221,7 +221,7 @@ typedef struct ATTR_PACKED
}cdc_desc_func_header_t;

/// Union Functional Descriptor (Communication Interface)
typedef struct ATTR_PACKED
typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
Expand All @@ -231,7 +231,7 @@ typedef struct ATTR_PACKED
}cdc_desc_func_union_t;

#define cdc_desc_func_union_n_t(no_slave)\
struct ATTR_PACKED { \
struct TU_ATTR_PACKED { \
uint8_t bLength ;\
uint8_t bDescriptorType ;\
uint8_t bDescriptorSubType ;\
Expand All @@ -240,7 +240,7 @@ typedef struct ATTR_PACKED
}

/// Country Selection Functional Descriptor (Communication Interface)
typedef struct ATTR_PACKED
typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
Expand All @@ -250,7 +250,7 @@ typedef struct ATTR_PACKED
}cdc_desc_func_country_selection_t;

#define cdc_desc_func_country_selection_n_t(no_country) \
struct ATTR_PACKED {\
struct TU_ATTR_PACKED {\
uint8_t bLength ;\
uint8_t bDescriptorType ;\
uint8_t bDescriptorSubType ;\
Expand All @@ -264,7 +264,7 @@ typedef struct ATTR_PACKED

/// \brief Call Management Functional Descriptor
/// \details This functional descriptor describes the processing of calls for the Communications Class interface.
typedef struct ATTR_PACKED
typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
Expand All @@ -280,7 +280,7 @@ typedef struct ATTR_PACKED
}cdc_desc_func_call_management_t;


typedef struct ATTR_PACKED
typedef struct TU_ATTR_PACKED
{
uint8_t support_comm_request : 1; ///< Device supports the request combination of Set_Comm_Feature, Clear_Comm_Feature, and Get_Comm_Feature.
uint8_t support_line_request : 1; ///< Device supports the request combination of Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding, and the notification Serial_State.
Expand All @@ -293,7 +293,7 @@ TU_VERIFY_STATIC(sizeof(cdc_acm_capability_t) == 1, "mostly problem with compile

/// \brief Abstract Control Management Functional Descriptor
/// \details This functional descriptor describes the commands supported by by the Communications Class interface with SubClass code of \ref CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL
typedef struct ATTR_PACKED
typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
Expand All @@ -303,7 +303,7 @@ typedef struct ATTR_PACKED

/// \brief Direct Line Management Functional Descriptor
/// \details This functional descriptor describes the commands supported by the Communications Class interface with SubClass code of \ref CDC_FUNC_DESC_DIRECT_LINE_MANAGEMENT
typedef struct ATTR_PACKED
typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
Expand All @@ -319,7 +319,7 @@ typedef struct ATTR_PACKED
/// \brief Telephone Ringer Functional Descriptor
/// \details The Telephone Ringer functional descriptor describes the ringer capabilities supported by the Communications Class interface,
/// with the SubClass code of \ref CDC_COMM_SUBCLASS_TELEPHONE_CONTROL_MODEL
typedef struct ATTR_PACKED
typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
Expand All @@ -331,7 +331,7 @@ typedef struct ATTR_PACKED
/// \brief Telephone Operational Modes Functional Descriptor
/// \details The Telephone Operational Modes functional descriptor describes the operational modes supported by
/// the Communications Class interface, with the SubClass code of \ref CDC_COMM_SUBCLASS_TELEPHONE_CONTROL_MODEL
typedef struct ATTR_PACKED
typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
Expand All @@ -347,7 +347,7 @@ typedef struct ATTR_PACKED
/// \brief Telephone Call and Line State Reporting Capabilities Descriptor
/// \details The Telephone Call and Line State Reporting Capabilities functional descriptor describes the abilities of a
/// telephone device to report optional call and line states.
typedef struct ATTR_PACKED
typedef struct TU_ATTR_PACKED
{
uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
Expand All @@ -371,7 +371,7 @@ static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc)
//--------------------------------------------------------------------+
// Requests
//--------------------------------------------------------------------+
typedef struct ATTR_PACKED
typedef struct TU_ATTR_PACKED
{
uint32_t bit_rate;
uint8_t stop_bits; ///< 0: 1 stop bit - 1: 1.5 stop bits - 2: 2 stop bits
Expand All @@ -381,7 +381,7 @@ typedef struct ATTR_PACKED

TU_VERIFY_STATIC(sizeof(cdc_line_coding_t) == 7, "size is not correct");

typedef struct ATTR_PACKED
typedef struct TU_ATTR_PACKED
{
uint16_t dte_is_present : 1; ///< Indicates to DCE if DTE is presentor not. This signal corresponds to V.24 signal 108/2 and RS-232 signal DTR.
uint16_t half_duplex_carrier_control : 1;
Expand Down
Loading

0 comments on commit 3934928

Please sign in to comment.