mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-16 05:42:56 +00:00
fix usb pin config with idf latest
This commit is contained in:
parent
440e23c491
commit
d407341d1e
@ -25,11 +25,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../board.h"
|
#include "../board.h"
|
||||||
#include "driver/gpio.h"
|
#include "esp_rom_gpio.h"
|
||||||
#include "driver/periph_ctrl.h"
|
#include "hal/gpio_ll.h"
|
||||||
#include "hal/usb_hal.h"
|
#include "hal/usb_hal.h"
|
||||||
#include "soc/usb_periph.h"
|
#include "soc/usb_periph.h"
|
||||||
|
#include "driver/periph_ctrl.h"
|
||||||
#include "driver/rmt.h"
|
#include "driver/rmt.h"
|
||||||
#include "led_strip/include/led_strip.h"
|
#include "led_strip/include/led_strip.h"
|
||||||
|
|
||||||
@ -38,11 +38,10 @@
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
#define LED_PIN 45
|
#define LED_PIN 45
|
||||||
|
|
||||||
#define BUTTON_PIN 0
|
#define BUTTON_PIN 0
|
||||||
#define BUTTON_STATE_ACTIVE 0
|
#define BUTTON_STATE_ACTIVE 0
|
||||||
|
|
||||||
|
static void configure_pins(usb_hal_context_t *usb);
|
||||||
static led_strip_t *strip;
|
static led_strip_t *strip;
|
||||||
|
|
||||||
// Initialize on-board peripherals : led, button, uart and USB
|
// Initialize on-board peripherals : led, button, uart and USB
|
||||||
@ -72,10 +71,33 @@ void board_init(void)
|
|||||||
.use_external_phy = false // use built-in PHY
|
.use_external_phy = false // use built-in PHY
|
||||||
};
|
};
|
||||||
usb_hal_init(&hal);
|
usb_hal_init(&hal);
|
||||||
|
configure_pins(&hal);
|
||||||
|
}
|
||||||
|
|
||||||
// Pin drive strength
|
static void configure_pins(usb_hal_context_t *usb)
|
||||||
gpio_set_drive_capability(USBPHY_DM_NUM, GPIO_DRIVE_CAP_3);
|
{
|
||||||
gpio_set_drive_capability(USBPHY_DP_NUM, GPIO_DRIVE_CAP_3);
|
/* usb_periph_iopins currently configures USB_OTG as USB Device.
|
||||||
|
* Introduce additional parameters in usb_hal_context_t when adding support
|
||||||
|
* for USB Host.
|
||||||
|
*/
|
||||||
|
for (const usb_iopin_dsc_t *iopin = usb_periph_iopins; iopin->pin != -1; ++iopin) {
|
||||||
|
if ((usb->use_external_phy) || (iopin->ext_phy_only == 0)) {
|
||||||
|
esp_rom_gpio_pad_select_gpio(iopin->pin);
|
||||||
|
if (iopin->is_output) {
|
||||||
|
esp_rom_gpio_connect_out_signal(iopin->pin, iopin->func, false, false);
|
||||||
|
} else {
|
||||||
|
esp_rom_gpio_connect_in_signal(iopin->pin, iopin->func, false);
|
||||||
|
if ((iopin->pin != GPIO_FUNC_IN_LOW) && (iopin->pin != GPIO_FUNC_IN_HIGH)) {
|
||||||
|
gpio_ll_input_enable(&GPIO, iopin->pin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
esp_rom_gpio_pad_unhold(iopin->pin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!usb->use_external_phy) {
|
||||||
|
gpio_set_drive_capability(USBPHY_DM_NUM, GPIO_DRIVE_CAP_3);
|
||||||
|
gpio_set_drive_capability(USBPHY_DP_NUM, GPIO_DRIVE_CAP_3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn LED on or off
|
// Turn LED on or off
|
||||||
|
@ -25,11 +25,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../board.h"
|
#include "../board.h"
|
||||||
#include "driver/gpio.h"
|
#include "esp_rom_gpio.h"
|
||||||
#include "driver/periph_ctrl.h"
|
#include "hal/gpio_ll.h"
|
||||||
#include "hal/usb_hal.h"
|
#include "hal/usb_hal.h"
|
||||||
#include "soc/usb_periph.h"
|
#include "soc/usb_periph.h"
|
||||||
|
|
||||||
|
#include "driver/periph_ctrl.h"
|
||||||
#include "driver/rmt.h"
|
#include "driver/rmt.h"
|
||||||
#include "led_strip/include/led_strip.h"
|
#include "led_strip/include/led_strip.h"
|
||||||
|
|
||||||
@ -41,11 +42,10 @@
|
|||||||
// however earlier revision v1.1 WS2812 is connected to GPIO 17
|
// however earlier revision v1.1 WS2812 is connected to GPIO 17
|
||||||
//#define LED_PIN 17 // v1.1
|
//#define LED_PIN 17 // v1.1
|
||||||
#define LED_PIN 18 // v1.2 and later
|
#define LED_PIN 18 // v1.2 and later
|
||||||
|
|
||||||
#define BUTTON_PIN 0
|
#define BUTTON_PIN 0
|
||||||
#define BUTTON_STATE_ACTIVE 0
|
#define BUTTON_STATE_ACTIVE 0
|
||||||
|
|
||||||
|
static void configure_pins(usb_hal_context_t *usb);
|
||||||
static led_strip_t *strip;
|
static led_strip_t *strip;
|
||||||
|
|
||||||
// Initialize on-board peripherals : led, button, uart and USB
|
// Initialize on-board peripherals : led, button, uart and USB
|
||||||
@ -75,10 +75,33 @@ void board_init(void)
|
|||||||
.use_external_phy = false // use built-in PHY
|
.use_external_phy = false // use built-in PHY
|
||||||
};
|
};
|
||||||
usb_hal_init(&hal);
|
usb_hal_init(&hal);
|
||||||
|
configure_pins(&hal);
|
||||||
|
}
|
||||||
|
|
||||||
// Pin drive strength
|
static void configure_pins(usb_hal_context_t *usb)
|
||||||
gpio_set_drive_capability(USBPHY_DM_NUM, GPIO_DRIVE_CAP_3);
|
{
|
||||||
gpio_set_drive_capability(USBPHY_DP_NUM, GPIO_DRIVE_CAP_3);
|
/* usb_periph_iopins currently configures USB_OTG as USB Device.
|
||||||
|
* Introduce additional parameters in usb_hal_context_t when adding support
|
||||||
|
* for USB Host.
|
||||||
|
*/
|
||||||
|
for (const usb_iopin_dsc_t *iopin = usb_periph_iopins; iopin->pin != -1; ++iopin) {
|
||||||
|
if ((usb->use_external_phy) || (iopin->ext_phy_only == 0)) {
|
||||||
|
esp_rom_gpio_pad_select_gpio(iopin->pin);
|
||||||
|
if (iopin->is_output) {
|
||||||
|
esp_rom_gpio_connect_out_signal(iopin->pin, iopin->func, false, false);
|
||||||
|
} else {
|
||||||
|
esp_rom_gpio_connect_in_signal(iopin->pin, iopin->func, false);
|
||||||
|
if ((iopin->pin != GPIO_FUNC_IN_LOW) && (iopin->pin != GPIO_FUNC_IN_HIGH)) {
|
||||||
|
gpio_ll_input_enable(&GPIO, iopin->pin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
esp_rom_gpio_pad_unhold(iopin->pin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!usb->use_external_phy) {
|
||||||
|
gpio_set_drive_capability(USBPHY_DM_NUM, GPIO_DRIVE_CAP_3);
|
||||||
|
gpio_set_drive_capability(USBPHY_DP_NUM, GPIO_DRIVE_CAP_3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn LED on or off
|
// Turn LED on or off
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
CFLAGS += \
|
CFLAGS += \
|
||||||
-ffunction-sections \
|
|
||||||
-fdata-sections \
|
|
||||||
-Wl,--gc-sections \
|
|
||||||
-mthumb \
|
-mthumb \
|
||||||
-mabi=aapcs-linux \
|
-mabi=aapcs-linux \
|
||||||
-mcpu=cortex-m0plus \
|
-mcpu=cortex-m0plus \
|
||||||
@ -9,9 +6,7 @@ CFLAGS += \
|
|||||||
-D__SAMD11D14AM__ \
|
-D__SAMD11D14AM__ \
|
||||||
-DCONF_DFLL_OVERWRITE_CALIBRATION=0 \
|
-DCONF_DFLL_OVERWRITE_CALIBRATION=0 \
|
||||||
-DOSC32K_OVERWRITE_CALIBRATION=0 \
|
-DOSC32K_OVERWRITE_CALIBRATION=0 \
|
||||||
-DCFG_TUSB_MCU=OPT_MCU_SAMD11 \
|
-DCFG_TUSB_MCU=OPT_MCU_SAMD11
|
||||||
-fshort-enums \
|
|
||||||
-Os
|
|
||||||
|
|
||||||
# All source paths should be relative to the top level.
|
# All source paths should be relative to the top level.
|
||||||
LD_FILE = hw/bsp/$(BOARD)/samd11d14am_flash.ld
|
LD_FILE = hw/bsp/$(BOARD)/samd11d14am_flash.ld
|
||||||
@ -50,4 +45,3 @@ JLINK_IF = swd
|
|||||||
# flash using edbg
|
# flash using edbg
|
||||||
flash: $(BUILD)/$(BOARD)-firmware.bin
|
flash: $(BUILD)/$(BOARD)-firmware.bin
|
||||||
edbg -b -t samd11 -e -pv -f $<
|
edbg -b -t samd11 -e -pv -f $<
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user