mirror of
https://github.com/aprochazka/ProfilometerProbe.git
synced 2025-06-30 09:37:22 +02:00
add TinyUSB
This commit is contained in:
1
Firmware/Core/Inc/main.h
Executable file → Normal file
1
Firmware/Core/Inc/main.h
Executable file → Normal file
@ -37,6 +37,7 @@ extern "C"
|
||||
#include <string.h>
|
||||
#include "stdbool.h"
|
||||
#include "tusb.h"
|
||||
#include "Cam.h"
|
||||
|
||||
// #include "portable/st/synopsys/dcd_synopsys.c"
|
||||
// #include "portable/st/synopsys/synopsys_common.h"
|
||||
|
@ -51,9 +51,9 @@ extern "C"
|
||||
|
||||
#define CFG_TUSB_MCU OPT_MCU_STM32L4
|
||||
#define CFG_TUSB_OS OPT_OS_NONE
|
||||
#define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED
|
||||
#define BOARD_DEVICE_RHPORT_NUM 0
|
||||
#define CFG_TUSB_RHPORT_MODE (OPT_MODE_DEVICE | OPT_MODE_FULL_SPEED)
|
||||
#define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_HIGH_SPEED
|
||||
#define BOARD_DEVICE_RHPORT_NUM 1
|
||||
#define CFG_TUSB_RHPORT_MODE (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED)
|
||||
|
||||
// defined by compiler flags for flexibility
|
||||
#ifndef CFG_TUSB_MCU
|
||||
|
47
Firmware/Core/Src/main.c
Executable file → Normal file
47
Firmware/Core/Src/main.c
Executable file → Normal file
@ -68,6 +68,37 @@ static void MX_USB_PCD_Init(void);
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
void cdc_task(void)
|
||||
{
|
||||
// connected() check for DTR bit
|
||||
// Most but not all terminal client set this when making connection
|
||||
// if ( tud_cdc_connected() )
|
||||
{
|
||||
|
||||
// connected and there are data available
|
||||
if (tud_cdc_available())
|
||||
{
|
||||
Debug_LED_On();
|
||||
|
||||
// read data
|
||||
char buf[64];
|
||||
uint32_t count = tud_cdc_read(buf, sizeof(buf));
|
||||
(void)count;
|
||||
|
||||
//char buf_2[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
|
||||
//uint32_t count_2 = 10;
|
||||
// Echo back
|
||||
// Note: Skip echo by commenting out write() and write_flush()
|
||||
// for throughput test e.g
|
||||
// $ dd if=/dev/zero of=/dev/ttyACM0 count=10000
|
||||
tud_cdc_write(buf, count);
|
||||
//tud_cdc_n_write(10, buf_2, count_2);
|
||||
tud_cdc_write_flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/**
|
||||
@ -77,7 +108,6 @@ static void MX_USB_PCD_Init(void);
|
||||
int main(void)
|
||||
{
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/* MCU Configuration--------------------------------------------------------*/
|
||||
@ -86,7 +116,6 @@ int main(void)
|
||||
HAL_Init();
|
||||
|
||||
/* USER CODE BEGIN Init */
|
||||
// tusb_init();
|
||||
|
||||
/* USER CODE END Init */
|
||||
|
||||
@ -94,6 +123,7 @@ int main(void)
|
||||
SystemClock_Config();
|
||||
|
||||
/* USER CODE BEGIN SysInit */
|
||||
HAL_PWREx_EnableVddUSB();
|
||||
|
||||
/* USER CODE END SysInit */
|
||||
|
||||
@ -105,21 +135,24 @@ int main(void)
|
||||
MX_I2C1_Init();
|
||||
MX_USB_PCD_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
tud_init(BOARD_DEVICE_RHPORT_NUM);
|
||||
|
||||
// HAL_Delay(10);
|
||||
// SPI_Init(&hspi1);
|
||||
HAL_Delay(10);
|
||||
SPI_Init(&hspi1);
|
||||
|
||||
// Wait for power stabilization
|
||||
// HAL_Delay(1000);
|
||||
HAL_Delay(1000);
|
||||
|
||||
// Cam_Init(&hi2c1, &hspi1);
|
||||
//Cam_Init(&hi2c1, &hspi1);
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Infinite loop */
|
||||
/* USER CODE BEGIN WHILE */
|
||||
while (1)
|
||||
{
|
||||
// tud_task();
|
||||
tud_task();
|
||||
cdc_task();
|
||||
|
||||
/*
|
||||
Cam_Capture(&hspi1);
|
||||
|
||||
|
@ -250,8 +250,8 @@ void USB_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN USB_IRQn 0 */
|
||||
|
||||
// tud_int_handler(0);
|
||||
// return;
|
||||
tud_int_handler(BOARD_DEVICE_RHPORT_NUM);
|
||||
return;
|
||||
/* USER CODE END USB_IRQn 0 */
|
||||
HAL_PCD_IRQHandler(&hpcd_USB_FS);
|
||||
/* USER CODE BEGIN USB_IRQn 1 */
|
||||
|
@ -1 +0,0 @@
|
||||
../../CODE_OF_CONDUCT.rst
|
@ -1 +0,0 @@
|
||||
../../CONTRIBUTORS.rst
|
0
Firmware/Core/tinyusb/hw/bsp/nrf/boards/adafruit_clue/nrf52840_s140_v6.ld
Executable file → Normal file
0
Firmware/Core/tinyusb/hw/bsp/nrf/boards/adafruit_clue/nrf52840_s140_v6.ld
Executable file → Normal file
0
Firmware/Core/tinyusb/hw/bsp/nrf/boards/arduino_nano33_ble/arduino_nano33_ble.ld
Executable file → Normal file
0
Firmware/Core/tinyusb/hw/bsp/nrf/boards/arduino_nano33_ble/arduino_nano33_ble.ld
Executable file → Normal file
0
Firmware/Core/tinyusb/hw/bsp/nrf/boards/circuitplayground_bluefruit/nrf52840_s140_v6.ld
Executable file → Normal file
0
Firmware/Core/tinyusb/hw/bsp/nrf/boards/circuitplayground_bluefruit/nrf52840_s140_v6.ld
Executable file → Normal file
0
Firmware/Core/tinyusb/hw/mcu/sony/cxd56/tools/flash_writer.py
Executable file → Normal file
0
Firmware/Core/tinyusb/hw/mcu/sony/cxd56/tools/flash_writer.py
Executable file → Normal file
0
Firmware/Core/tinyusb/src/class/bth/bth_device.c
Executable file → Normal file
0
Firmware/Core/tinyusb/src/class/bth/bth_device.c
Executable file → Normal file
0
Firmware/Core/tinyusb/src/class/bth/bth_device.h
Executable file → Normal file
0
Firmware/Core/tinyusb/src/class/bth/bth_device.h
Executable file → Normal file
0
Firmware/Core/tinyusb/tools/pcapng_to_corpus.py
Executable file → Normal file
0
Firmware/Core/tinyusb/tools/pcapng_to_corpus.py
Executable file → Normal file
Reference in New Issue
Block a user