Skip to content

Commit

Permalink
Merge #19027 #19256
Browse files Browse the repository at this point in the history
19027: sys/fmt: optimize scn_u32_dec scn_u32_hex r=benpicco a=kfessel

### Contribution description

Improves the compilation result for `scn_u32_dec` `scn_u32_hex` especially on `cortex-m` reducing either stack usage and or code size.

This makes use of unsigned int overflow (slightly less better without doing that `hexn`).

See godbolt (original versions got an `o` attached, modified versions got `k`s) all functions are  marked `_S_` defined to `static`

by assigning the global at end the compiled function can be changed (`deco deck  hexo hexk hexkk hexn`)

this PR is `hexkk` and `deck` 

### Testing procedure

run unit-test/test-fmt

```
<RIOT>/tests/unittests$ make tests-fmt
<RIOT>/tests/unittests$ make term
```

### Issues/PRs references

[godbolt](https://godbolt.org/z/MzT1zh4q1)

19256: pkg/tinyusb: add GD32VF103 support r=benpicco a=gschorcht

### Contribution description

This PR provides the tinyUSB support for GD32VF103 and enables the `tinyusb_device` feature as well as `stdio_tinyusb_cdc_acm` for GD32VF103 boards.

### Testing procedure

```
BOARD=sipeeed-longan-nano make -C tests/shell flash term
```
should work

### Issues/PRs references


Co-authored-by: Karl Fessel <karl.fessel@ovgu.de>
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
  • Loading branch information
3 people authored Feb 17, 2023
3 parents 6f6727d + 18a783d + f0041c9 commit 4931440
Show file tree
Hide file tree
Showing 18 changed files with 1,809 additions and 19 deletions.
63 changes: 63 additions & 0 deletions boards/common/gd32v/include/cfg_usbdev_default.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (C) 2023 Gunar Schorcht <gunar@schorcht.net>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup boards_common_gd32v
* @{
*
* @file
* @brief Default USB OTG configuration for GD32 RISC-V board
*
* @author Gunar Schorcht <gunar@schorcht.net>
*/

#ifndef CFG_USBDEV_DEFAULT_H
#define CFG_USBDEV_DEFAULT_H

#include "vendor/usbdev_gd32v.h"
#include "usbdev_synopsys_dwc2.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @name USB OTG configuration
* @{
*/
/**
* @brief Enable the full speed USB OTG peripheral
*/
#define DWC2_USB_OTG_FS_ENABLED

/**
* @brief Common USB OTG FS configuration
*/
static const dwc2_usb_otg_fshs_config_t dwc2_usb_otg_fshs_config[] = {
{
.periph = USB_OTG_FS_PERIPH_BASE,
.type = DWC2_USB_OTG_FS,
.phy = DWC2_USB_OTG_PHY_BUILTIN,
.rcu_mask = RCU_AHBEN_USBFSEN_Msk,
.bus = AHB,
.irqn = USBFS_IRQn,
}
};

/**
* @brief Number of available USB OTG peripherals
*/
#define USBDEV_NUMOF ARRAY_SIZE(dwc2_usb_otg_fshs_config)
/** @} */

#ifdef __cplusplus
}
#endif

#endif /* CFG_USBDEV_DEFAULT_H */
/** @} */
7 changes: 7 additions & 0 deletions boards/common/gd32v/include/periph_common_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@
extern "C" {
#endif

#if defined(MODULE_USBDEV_SYNOPSYS_DWC2) || defined(MODULE_TINYUSB_DEVICE)
/* If the USB OTG peripheral is used, the USB clock of 48 MHz is derived by
* dividing the PLL clock by 1, 1.5, 2, or 2.5. That is the maximum core clock
* frequency can be 96 MHz. */
#define CLOCK_CORECLOCK MHZ(96) /**< CPU clock frequency in Hz */
#else
#define CLOCK_CORECLOCK MHZ(108) /**< CPU clock frequency in Hz */
#endif

#define CLOCK_AHB CLOCK_CORECLOCK /**< Equal to the CPU clock */
#define CLOCK_APB1 CLOCK_AHB/2 /**< Half AHB clock */
Expand Down
2 changes: 2 additions & 0 deletions boards/seeedstudio-gd32/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ config BOARD_SEEEDSTUDIO_GD32
select CPU_MODEL_GD32VF103VBT6
select BOARD_HAS_HXTAL
select BOARD_HAS_LXTAL
select HAS_HIGHLEVEL_STDIO
select HAS_PERIPH_ADC
select HAS_PERIPH_I2C
select HAS_PERIPH_PWM
select HAS_PERIPH_SPI
select HAS_PERIPH_TIMER
select HAS_PERIPH_UART
select HAS_TINYUSB_DEVICE
select HAVE_SAUL_GPIO

source "$(RIOTBOARD)/common/gd32v/Kconfig"
1 change: 1 addition & 0 deletions boards/seeedstudio-gd32/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif

include $(RIOTBOARD)/common/makefiles/stdio_tinyusb_cdc_acm.dep.mk
include $(RIOTBOARD)/common/gd32v/Makefile.dep
6 changes: 5 additions & 1 deletion boards/seeedstudio-gd32/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart

include $(RIOTBOARD)/common/gd32v/Makefile.features
# Other features provided by the board (in alphabetical order)
FEATURES_PROVIDED += highlevel_stdio
FEATURES_PROVIDED += tinyusb_device

include $(RIOTBOARD)/common/gd32v/Makefile.features
1 change: 1 addition & 0 deletions boards/seeedstudio-gd32/Makefile.include
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
PORT_LINUX ?= /dev/ttyACM0
include $(RIOTBOARD)/common/gd32v/Makefile.include
1 change: 1 addition & 0 deletions boards/seeedstudio-gd32/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "cfg_spi_default.h"
#include "cfg_timer_default.h"
#include "cfg_uart_default.h"
#include "cfg_usbdev_default.h"

#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 2 additions & 0 deletions boards/sipeed-longan-nano/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ config BOARD_SIPEED_LONGAN_NANO
select CPU_MODEL_GD32VF103CBT6
select BOARD_HAS_HXTAL
select BOARD_HAS_LXTAL
select HAS_HIGHLEVEL_STDIO
select HAS_PERIPH_ADC
select HAS_PERIPH_DAC
select HAS_PERIPH_I2C
select HAS_PERIPH_PWM
select HAS_PERIPH_SPI
select HAS_PERIPH_TIMER
select HAS_PERIPH_UART
select HAS_TINYUSB_DEVICE
select HAVE_SAUL_GPIO

select HAVE_MTD_SDCARD_DEFAULT
Expand Down
1 change: 1 addition & 0 deletions boards/sipeed-longan-nano/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ ifneq (,$(filter vfs_default,$(USEMODULE)))
USEMODULE += mtd
endif

include $(RIOTBOARD)/common/makefiles/stdio_tinyusb_cdc_acm.dep.mk
include $(RIOTBOARD)/common/gd32v/Makefile.dep
4 changes: 4 additions & 0 deletions boards/sipeed-longan-nano/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += sdcard_spi

# Other features provided by the board (in alphabetical order)
FEATURES_PROVIDED += highlevel_stdio
FEATURES_PROVIDED += tinyusb_device

include $(RIOTBOARD)/common/gd32v/Makefile.features
1 change: 1 addition & 0 deletions boards/sipeed-longan-nano/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
PORT_LINUX ?= /dev/ttyACM0
PROGRAMMER ?= dfu-util
include $(RIOTBOARD)/common/gd32v/Makefile.include
1 change: 1 addition & 0 deletions boards/sipeed-longan-nano/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "cfg_spi_default.h"
#include "cfg_timer_default.h"
#include "cfg_uart_default.h"
#include "cfg_usbdev_default.h"

#ifdef __cplusplus
extern "C" {
Expand Down
Loading

0 comments on commit 4931440

Please sign in to comment.