mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
update g4 bsp
This commit is contained in:
parent
cd76193f3c
commit
51acc3e1b9
@ -1,20 +1,22 @@
|
||||
# Install python3 HID package https://pypi.org/project/hid/
|
||||
import hid
|
||||
|
||||
USB_VID = 0xcafe
|
||||
# default is TinyUSB (0xcafe), Adafruit (0x239a), RaspberryPi (0x2e8a), Espressif (0x303a) VID
|
||||
USB_VID = (0xcafe, 0x239a, 0x2e8a, 0x303a)
|
||||
|
||||
print("Openning HID device with VID = 0x%X" % USB_VID)
|
||||
print("VID list: " + ", ".join('%02x' % v for v in USB_VID))
|
||||
|
||||
for dict in hid.enumerate(USB_VID):
|
||||
print(dict)
|
||||
dev = hid.Device(dict['vendor_id'], dict['product_id'])
|
||||
if dev:
|
||||
while True:
|
||||
# Get input from console and encode to UTF8 for array of chars.
|
||||
# hid generic inout is single report therefore by HIDAPI requirement
|
||||
# it must be preceeded with 0x00 as dummy reportID
|
||||
str_out = b'\x00'
|
||||
str_out += input("Send text to HID Device : ").encode('utf-8')
|
||||
dev.write(str_out)
|
||||
str_in = dev.read(64)
|
||||
print("Received from HID Device:", str_in, '\n')
|
||||
for vid in USB_VID:
|
||||
for dict in hid.enumerate(vid):
|
||||
print(dict)
|
||||
dev = hid.Device(dict['vendor_id'], dict['product_id'])
|
||||
if dev:
|
||||
while True:
|
||||
# Get input from console and encode to UTF8 for array of chars.
|
||||
# hid generic inout is single report therefore by HIDAPI requirement
|
||||
# it must be preceeded with 0x00 as dummy reportID
|
||||
str_out = b'\x00'
|
||||
str_out += input("Send text to HID Device : ").encode('utf-8')
|
||||
dev.write(str_out)
|
||||
str_in = dev.read(64)
|
||||
print("Received from HID Device:", str_in, '\n')
|
||||
|
@ -67,28 +67,28 @@ static inline void board_clock_init(void)
|
||||
HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST);
|
||||
|
||||
// Initializes the CPU, AHB and APB busses clocks
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV4;
|
||||
RCC_OscInitStruct.PLL.PLLN = 50;
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
|
||||
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
|
||||
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV4;
|
||||
RCC_OscInitStruct.PLL.PLLN = 50;
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
|
||||
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
|
||||
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
|
||||
HAL_RCC_OscConfig(&RCC_OscInitStruct);
|
||||
|
||||
// Initializes the CPU, AHB and APB busses clocks
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_8);
|
||||
|
||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
|
||||
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL;
|
||||
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
|
||||
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) ;
|
||||
|
||||
#if 0 // TODO need to check if USB clock is enabled
|
||||
|
@ -1,4 +1,6 @@
|
||||
CFLAGS += -DSTM32G474xx
|
||||
CFLAGS += \
|
||||
-DSTM32G474xx \
|
||||
-DHSE_VALUE=24000000
|
||||
|
||||
LD_FILE = $(BOARD_PATH)/STM32G474RETx_FLASH.ld
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user