feat: Switch to USB HID, now fully available
This commit is contained in:
parent
3258b84795
commit
c3582e8e2b
|
@ -34,11 +34,42 @@
|
|||
#include "gpio.h"
|
||||
#include "gpio_struct.h"
|
||||
#include "timer_struct.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "esp8266/pin_mux_register.h"
|
||||
#define GPIO_PIN_REG_0 PERIPHS_IO_MUX_GPIO0_U
|
||||
#define GPIO_PIN_REG_1 PERIPHS_IO_MUX_U0TXD_U
|
||||
#define GPIO_PIN_REG_2 PERIPHS_IO_MUX_GPIO2_U
|
||||
#define GPIO_PIN_REG_3 PERIPHS_IO_MUX_U0RXD_U
|
||||
#define GPIO_PIN_REG_4 PERIPHS_IO_MUX_GPIO4_U
|
||||
#define GPIO_PIN_REG_5 PERIPHS_IO_MUX_GPIO5_U
|
||||
#define GPIO_PIN_REG_6 PERIPHS_IO_MUX_SD_CLK_U
|
||||
#define GPIO_PIN_REG_7 PERIPHS_IO_MUX_SD_DATA0_U
|
||||
#define GPIO_PIN_REG_8 PERIPHS_IO_MUX_SD_DATA1_U
|
||||
#define GPIO_PIN_REG_9 PERIPHS_IO_MUX_SD_DATA2_U
|
||||
#define GPIO_PIN_REG_10 PERIPHS_IO_MUX_SD_DATA3_U
|
||||
#define GPIO_PIN_REG_11 PERIPHS_IO_MUX_SD_CMD_U
|
||||
#define GPIO_PIN_REG_12 PERIPHS_IO_MUX_MTDI_U
|
||||
#define GPIO_PIN_REG_13 PERIPHS_IO_MUX_MTCK_U
|
||||
#define GPIO_PIN_REG_14 PERIPHS_IO_MUX_MTMS_U
|
||||
#define GPIO_PIN_REG_15 PERIPHS_IO_MUX_MTDO_U
|
||||
#define GPIO_PIN_REG_16 PAD_XPD_DCDC_CONF
|
||||
#define GPIO_PIN_REG(i) \
|
||||
(i==0) ? GPIO_PIN_REG_0: \
|
||||
(i==1) ? GPIO_PIN_REG_1: \
|
||||
(i==2) ? GPIO_PIN_REG_2: \
|
||||
(i==3) ? GPIO_PIN_REG_3: \
|
||||
(i==4) ? GPIO_PIN_REG_4: \
|
||||
(i==5) ? GPIO_PIN_REG_5: \
|
||||
(i==6) ? GPIO_PIN_REG_6: \
|
||||
(i==7) ? GPIO_PIN_REG_7: \
|
||||
(i==8) ? GPIO_PIN_REG_8: \
|
||||
(i==9) ? GPIO_PIN_REG_9: \
|
||||
(i==10)? GPIO_PIN_REG_10: \
|
||||
(i==11)? GPIO_PIN_REG_11: \
|
||||
(i==12)? GPIO_PIN_REG_12: \
|
||||
(i==13)? GPIO_PIN_REG_13: \
|
||||
(i==14)? GPIO_PIN_REG_14: \
|
||||
(i==15)? GPIO_PIN_REG_15: \
|
||||
GPIO_PIN_REG_16
|
||||
//**************************************************************************************************
|
||||
/**
|
||||
\defgroup DAP_Config_Debug_gr CMSIS-DAP Debug Unit Information
|
||||
|
@ -63,7 +94,7 @@ This information includes:
|
|||
|
||||
/// Processor Clock of the Cortex-M MCU used in the Debug Unit.
|
||||
/// This value is used to calculate the SWD/JTAG clock speed.
|
||||
#define CPU_CLOCK 160000000U ///< Specifies the CPU Clock in Hz.
|
||||
#define CPU_CLOCK 160000000 ///< Specifies the CPU Clock in Hz.
|
||||
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<160MHz
|
||||
|
||||
/// Number of processor cycles for I/O Port write operations.
|
||||
|
@ -80,7 +111,7 @@ This information includes:
|
|||
|
||||
/// Indicate that JTAG communication mode is available at the Debug Port.
|
||||
/// This information is returned by the command \ref DAP_Info as part of <b>Capabilities</b>.
|
||||
#define DAP_JTAG 1 ///< JTAG Mode: 1 = available, 0 = not available.
|
||||
#define DAP_JTAG 0 ///< JTAG Mode: 1 = available, 0 = not available.
|
||||
|
||||
/// Configure maximum number of JTAG devices on the scan chain connected to the Debug Access Port.
|
||||
/// This setting impacts the RAM requirements of the Debug Unit. Valid range is 1 .. 255.
|
||||
|
@ -100,7 +131,7 @@ This information includes:
|
|||
/// This configuration settings is used to optimize the communication performance with the
|
||||
/// debugger and depends on the USB peripheral. Typical vales are 64 for Full-speed USB HID or WinUSB,
|
||||
/// 1024 for High-speed USB HID and 512 for High-speed USB WinUSB.
|
||||
#define DAP_PACKET_SIZE 512U ///< Specifies Packet Size in bytes.
|
||||
#define DAP_PACKET_SIZE 64U ///< Specifies Packet Size in bytes.
|
||||
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<< 512 for High-speed USB WinUSB.
|
||||
|
||||
/// Maximum Package Buffers for Command and Response data.
|
||||
|
@ -111,22 +142,22 @@ This information includes:
|
|||
|
||||
/// Indicate that UART Serial Wire Output (SWO) trace is available.
|
||||
/// This information is returned by the command \ref DAP_Info as part of <b>Capabilities</b>.
|
||||
#define SWO_UART 1 ///< SWO UART: 1 = available, 0 = not available.
|
||||
#define SWO_UART 0 ///< SWO UART: 1 = available, 0 = not available.
|
||||
|
||||
/// Maximum SWO UART Baudrate.
|
||||
#define SWO_UART_MAX_BAUDRATE (115200U*40U) ///< SWO UART Maximum Baudrate in Hz.
|
||||
#define SWO_UART_MAX_BAUDRATE (115200U * 40U) ///< SWO UART Maximum Baudrate in Hz.
|
||||
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<< 5MHz
|
||||
//// TODO: uncertain value
|
||||
|
||||
/// Indicate that Manchester Serial Wire Output (SWO) trace is available.
|
||||
/// This information is returned by the command \ref DAP_Info as part of <b>Capabilities</b>.
|
||||
#define SWO_MANCHESTER 1 ///< SWO Manchester: 1 = available, 0 = not available.
|
||||
#define SWO_MANCHESTER 0 ///< SWO Manchester: 1 = available, 0 = not available.
|
||||
|
||||
/// SWO Trace Buffer Size.
|
||||
#define SWO_BUFFER_SIZE 4096U ///< SWO Trace Buffer Size in bytes (must be 2^n).
|
||||
|
||||
/// SWO Streaming Trace.
|
||||
#define SWO_STREAM 1 ///< SWO Streaming Trace: 1 = available, 0 = not available.
|
||||
#define SWO_STREAM 0 ///< SWO Streaming Trace: 1 = available, 0 = not available.
|
||||
|
||||
/// Clock frequency of the Test Domain Timer. Timer value is returned with \ref TIMESTAMP_GET.
|
||||
#define TIMESTAMP_CLOCK 5000000U ///< Timestamp clock in Hz (0 = timestamps not supported).
|
||||
|
@ -168,7 +199,7 @@ __STATIC_INLINE uint8_t DAP_GetVendorString(char *str)
|
|||
__STATIC_INLINE uint8_t DAP_GetProductString(char *str)
|
||||
{
|
||||
//(void)str;
|
||||
strcpy(str, "CMSIS-DAP v2");
|
||||
strcpy(str, "CMSIS-DAP v2");
|
||||
return (sizeof("CMSIS-DAP v2"));
|
||||
}
|
||||
|
||||
|
@ -180,7 +211,7 @@ __STATIC_INLINE uint8_t DAP_GetProductString(char *str)
|
|||
*/
|
||||
__STATIC_INLINE uint8_t DAP_GetSerNumString(char *str)
|
||||
{
|
||||
strcpy(str, "1234");
|
||||
strcpy(str, "1234");
|
||||
return (sizeof("1234"));
|
||||
}
|
||||
|
||||
|
@ -189,14 +220,14 @@ __STATIC_INLINE uint8_t DAP_GetSerNumString(char *str)
|
|||
// Modify your pins here
|
||||
|
||||
// ATTENTION: DO NOT USE RTC GPIO16
|
||||
#define PIN_SWDIO 2
|
||||
#define PIN_SWCLK 0
|
||||
#define PIN_TDO 4
|
||||
#define PIN_TDI 5
|
||||
#define PIN_nTRST 1 // optional
|
||||
#define PIN_nRESET 16
|
||||
#define PIN_SWDIO 4
|
||||
#define PIN_SWCLK 5
|
||||
#define PIN_TDO 13
|
||||
#define PIN_TDI 12
|
||||
#define PIN_nTRST 0 // optional
|
||||
#define PIN_nRESET 14
|
||||
// LED_BUILTIN
|
||||
#define PIN_LED_CONNECTED 13
|
||||
#define PIN_LED_CONNECTED 2
|
||||
// LED_BUILTIN
|
||||
#define PIN_LED_RUNNING 15
|
||||
|
||||
|
@ -244,16 +275,49 @@ of the same I/O port. The following SWDIO I/O Pin functions are provided:
|
|||
*/
|
||||
__STATIC_INLINE void PORT_JTAG_SETUP(void)
|
||||
{
|
||||
gpio_set_direction(PIN_SWCLK, GPIO_MODE_OUTPUT);
|
||||
gpio_set_direction(PIN_SWDIO, GPIO_MODE_OUTPUT);
|
||||
gpio_pin_reg_t pin_reg;
|
||||
|
||||
gpio_set_direction(PIN_TDO, GPIO_MODE_DEF_INPUT);
|
||||
gpio_set_direction(PIN_TDI, GPIO_MODE_OUTPUT);
|
||||
// gpio_set_direction(PIN_SWCLK, GPIO_MODE_OUTPUT);
|
||||
// gpio_set_direction(PIN_SWDIO, GPIO_MODE_OUTPUT);
|
||||
GPIO.enable_w1ts |= (0x1 << PIN_SWCLK);
|
||||
GPIO.pin[PIN_SWCLK].driver = 0;
|
||||
pin_reg.val = READ_PERI_REG(GPIO_PIN_REG(PIN_SWCLK));
|
||||
pin_reg.pullup = 0;
|
||||
WRITE_PERI_REG(GPIO_PIN_REG(PIN_SWCLK), pin_reg.val);
|
||||
GPIO.enable_w1ts |= (0x1 << PIN_SWDIO);
|
||||
GPIO.pin[PIN_SWDIO].driver = 0;
|
||||
pin_reg.val = READ_PERI_REG(GPIO_PIN_REG(PIN_SWDIO));
|
||||
pin_reg.pullup = 0;
|
||||
WRITE_PERI_REG(GPIO_PIN_REG(PIN_SWDIO), pin_reg.val);
|
||||
|
||||
gpio_set_direction(PIN_nTRST, GPIO_MODE_OUTPUT_OD);
|
||||
gpio_set_direction(PIN_nRESET, GPIO_MODE_OUTPUT_OD);
|
||||
gpio_set_pull_mode(PIN_nTRST, GPIO_PULLUP_ONLY);
|
||||
gpio_set_pull_mode(PIN_nRESET, GPIO_PULLUP_ONLY);
|
||||
// gpio_set_direction(PIN_TDO, GPIO_MODE_DEF_INPUT);
|
||||
GPIO.enable_w1tc |= (0x1 << PIN_TDO);
|
||||
GPIO.pin[PIN_TDO].driver = 0;
|
||||
pin_reg.val = READ_PERI_REG(GPIO_PIN_REG(PIN_TDO));
|
||||
pin_reg.pullup = 0;
|
||||
WRITE_PERI_REG(GPIO_PIN_REG(PIN_TDO), pin_reg.val);
|
||||
// gpio_set_direction(PIN_TDI, GPIO_MODE_OUTPUT);
|
||||
GPIO.enable_w1ts |= (0x1 << PIN_TDI);
|
||||
GPIO.pin[PIN_TDI].driver = 0;
|
||||
pin_reg.val = READ_PERI_REG(GPIO_PIN_REG(PIN_TDI));
|
||||
pin_reg.pullup = 0;
|
||||
WRITE_PERI_REG(GPIO_PIN_REG(PIN_TDI), pin_reg.val);
|
||||
|
||||
// gpio_set_direction(PIN_nTRST, GPIO_MODE_OUTPUT_OD);
|
||||
// gpio_set_direction(PIN_nRESET, GPIO_MODE_OUTPUT_OD);
|
||||
GPIO.enable_w1tc |= (0x1 << PIN_nTRST);
|
||||
GPIO.pin[PIN_nTRST].driver = 1;
|
||||
GPIO.enable_w1tc |= (0x1 << PIN_nRESET);
|
||||
GPIO.pin[PIN_nRESET].driver = 1;
|
||||
|
||||
// gpio_set_pull_mode(PIN_nTRST, GPIO_PULLUP_ONLY);
|
||||
// gpio_set_pull_mode(PIN_nRESET, GPIO_PULLUP_ONLY);
|
||||
pin_reg.val = READ_PERI_REG(GPIO_PIN_REG(PIN_nTRST));
|
||||
pin_reg.pullup = 1;
|
||||
WRITE_PERI_REG(GPIO_PIN_REG(PIN_nTRST), pin_reg.val);
|
||||
pin_reg.val = READ_PERI_REG(GPIO_PIN_REG(PIN_nRESET));
|
||||
pin_reg.pullup = 1;
|
||||
WRITE_PERI_REG(GPIO_PIN_REG(PIN_nRESET), pin_reg.val);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -265,16 +329,49 @@ __STATIC_INLINE void PORT_JTAG_SETUP(void)
|
|||
*/
|
||||
__STATIC_INLINE void PORT_SWD_SETUP(void)
|
||||
{
|
||||
gpio_set_direction(PIN_SWCLK, GPIO_MODE_OUTPUT);
|
||||
gpio_set_direction(PIN_SWDIO, GPIO_MODE_OUTPUT);
|
||||
gpio_pin_reg_t pin_reg;
|
||||
|
||||
gpio_set_direction(PIN_TDO, GPIO_MODE_DEF_INPUT);
|
||||
gpio_set_direction(PIN_TDI, GPIO_MODE_OUTPUT);
|
||||
// gpio_set_direction(PIN_SWCLK, GPIO_MODE_OUTPUT);
|
||||
// gpio_set_direction(PIN_SWDIO, GPIO_MODE_OUTPUT);
|
||||
GPIO.enable_w1ts |= (0x1 << PIN_SWCLK);
|
||||
GPIO.pin[PIN_SWCLK].driver = 0;
|
||||
pin_reg.val = READ_PERI_REG(GPIO_PIN_REG(PIN_SWCLK));
|
||||
pin_reg.pullup = 0;
|
||||
WRITE_PERI_REG(GPIO_PIN_REG(PIN_SWCLK), pin_reg.val);
|
||||
GPIO.enable_w1ts |= (0x1 << PIN_SWDIO);
|
||||
GPIO.pin[PIN_SWDIO].driver = 0;
|
||||
pin_reg.val = READ_PERI_REG(GPIO_PIN_REG(PIN_SWDIO));
|
||||
pin_reg.pullup = 0;
|
||||
WRITE_PERI_REG(GPIO_PIN_REG(PIN_SWDIO), pin_reg.val);
|
||||
|
||||
gpio_set_direction(PIN_nTRST, GPIO_MODE_OUTPUT_OD);
|
||||
gpio_set_direction(PIN_nRESET, GPIO_MODE_OUTPUT_OD);
|
||||
gpio_set_pull_mode(PIN_nTRST, GPIO_PULLUP_ONLY);
|
||||
gpio_set_pull_mode(PIN_nRESET, GPIO_PULLUP_ONLY);
|
||||
// gpio_set_direction(PIN_TDO, GPIO_MODE_DEF_INPUT);
|
||||
GPIO.enable_w1tc |= (0x1 << PIN_TDO);
|
||||
GPIO.pin[PIN_TDO].driver = 0;
|
||||
pin_reg.val = READ_PERI_REG(GPIO_PIN_REG(PIN_TDO));
|
||||
pin_reg.pullup = 0;
|
||||
WRITE_PERI_REG(GPIO_PIN_REG(PIN_TDO), pin_reg.val);
|
||||
// gpio_set_direction(PIN_TDI, GPIO_MODE_OUTPUT);
|
||||
GPIO.enable_w1ts |= (0x1 << PIN_TDI);
|
||||
GPIO.pin[PIN_TDI].driver = 0;
|
||||
pin_reg.val = READ_PERI_REG(GPIO_PIN_REG(PIN_TDI));
|
||||
pin_reg.pullup = 0;
|
||||
WRITE_PERI_REG(GPIO_PIN_REG(PIN_TDI), pin_reg.val);
|
||||
|
||||
// gpio_set_direction(PIN_nTRST, GPIO_MODE_OUTPUT_OD);
|
||||
// gpio_set_direction(PIN_nRESET, GPIO_MODE_OUTPUT_OD);
|
||||
GPIO.enable_w1tc |= (0x1 << PIN_nTRST);
|
||||
GPIO.pin[PIN_nTRST].driver = 1;
|
||||
GPIO.enable_w1tc |= (0x1 << PIN_nRESET);
|
||||
GPIO.pin[PIN_nRESET].driver = 1;
|
||||
|
||||
// gpio_set_pull_mode(PIN_nTRST, GPIO_PULLUP_ONLY);
|
||||
// gpio_set_pull_mode(PIN_nRESET, GPIO_PULLUP_ONLY);
|
||||
pin_reg.val = READ_PERI_REG(GPIO_PIN_REG(PIN_nTRST));
|
||||
pin_reg.pullup = 1;
|
||||
WRITE_PERI_REG(GPIO_PIN_REG(PIN_nTRST), pin_reg.val);
|
||||
pin_reg.val = READ_PERI_REG(GPIO_PIN_REG(PIN_nRESET));
|
||||
pin_reg.pullup = 1;
|
||||
WRITE_PERI_REG(GPIO_PIN_REG(PIN_nRESET), pin_reg.val);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -286,14 +383,31 @@ __STATIC_INLINE void PORT_SWD_SETUP(void)
|
|||
__STATIC_INLINE void PORT_OFF(void)
|
||||
{
|
||||
// Will be called when the DAP disconnected
|
||||
gpio_set_direction(PIN_SWCLK, GPIO_MODE_DEF_DISABLE);
|
||||
gpio_set_direction(PIN_SWDIO, GPIO_MODE_DEF_DISABLE);
|
||||
// gpio_set_direction(PIN_SWCLK, GPIO_MODE_DEF_DISABLE);
|
||||
// gpio_set_direction(PIN_SWDIO, GPIO_MODE_DEF_DISABLE);
|
||||
|
||||
gpio_set_direction(PIN_TDO, GPIO_MODE_DEF_DISABLE);
|
||||
gpio_set_direction(PIN_TDI, GPIO_MODE_DEF_DISABLE);
|
||||
// gpio_set_direction(PIN_TDO, GPIO_MODE_DEF_DISABLE);
|
||||
// gpio_set_direction(PIN_TDI, GPIO_MODE_DEF_DISABLE);
|
||||
|
||||
gpio_set_direction(PIN_nTRST, GPIO_MODE_DEF_DISABLE);
|
||||
gpio_set_direction(PIN_nRESET, GPIO_MODE_DEF_DISABLE);
|
||||
// gpio_set_direction(PIN_nTRST, GPIO_MODE_DEF_DISABLE);
|
||||
// gpio_set_direction(PIN_nRESET, GPIO_MODE_DEF_DISABLE);
|
||||
GPIO.pin[PIN_SWCLK].driver = 0;
|
||||
GPIO.enable_w1tc |= (0x1 << PIN_SWCLK);
|
||||
|
||||
GPIO.pin[PIN_SWDIO].driver = 0;
|
||||
GPIO.enable_w1tc |= (0x1 << PIN_SWDIO);
|
||||
|
||||
GPIO.pin[PIN_TDO].driver = 0;
|
||||
GPIO.enable_w1tc |= (0x1 << PIN_TDO);
|
||||
|
||||
GPIO.pin[PIN_TDI].driver = 0;
|
||||
GPIO.enable_w1tc |= (0x1 << PIN_TDI);
|
||||
|
||||
GPIO.pin[PIN_nTRST].driver = 0;
|
||||
GPIO.enable_w1tc |= (0x1 << PIN_nTRST);
|
||||
|
||||
GPIO.pin[PIN_nRESET].driver = 0;
|
||||
GPIO.enable_w1tc |= (0x1 << PIN_nRESET);
|
||||
}
|
||||
|
||||
// SWCLK/TCK I/O pin -------------------------------------
|
||||
|
@ -306,7 +420,7 @@ __STATIC_INLINE void PORT_OFF(void)
|
|||
__STATIC_FORCEINLINE uint32_t PIN_SWCLK_TCK_IN(void)
|
||||
{
|
||||
////TODO: can we set to 0?
|
||||
return ((GPIO.in >> PIN_SWCLK) & 0x1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -338,7 +452,7 @@ __STATIC_FORCEINLINE void PIN_SWCLK_TCK_CLR(void)
|
|||
*/
|
||||
__STATIC_FORCEINLINE uint32_t PIN_SWDIO_TMS_IN(void)
|
||||
{
|
||||
return ((GPIO.in >> PIN_SWDIO) & 0x1);
|
||||
return ((GPIO.in >> PIN_SWDIO) & 0x1) ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -368,7 +482,7 @@ __STATIC_FORCEINLINE void PIN_SWDIO_TMS_CLR(void)
|
|||
*/
|
||||
__STATIC_FORCEINLINE uint32_t PIN_SWDIO_IN(void)
|
||||
{
|
||||
return ((GPIO.in >> PIN_SWDIO) & 0x1);
|
||||
return ((GPIO.in >> PIN_SWDIO) & 0x1) ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -388,11 +502,13 @@ __STATIC_FORCEINLINE void PIN_SWDIO_OUT(uint32_t bit)
|
|||
{
|
||||
//set bit
|
||||
GPIO.out_w1ts |= (0x1 << PIN_SWDIO);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//reset bit
|
||||
GPIO.out_w1tc |= (0x1 << PIN_SWDIO);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -407,6 +523,7 @@ __STATIC_FORCEINLINE void PIN_SWDIO_OUT_ENABLE(void)
|
|||
|
||||
// set \ref gpio_set_direction -> OUTPUT
|
||||
GPIO.enable_w1ts |= (0x1 << PIN_SWDIO);
|
||||
GPIO.pin[PIN_SWDIO].driver = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -420,6 +537,7 @@ __STATIC_FORCEINLINE void PIN_SWDIO_OUT_DISABLE(void)
|
|||
// set \ref gpio_set_dircetion -> INPUT
|
||||
// esp8266 input is always connected
|
||||
GPIO.enable_w1tc |= (0x1 << PIN_SWDIO);
|
||||
GPIO.pin[PIN_SWDIO].driver = 0;
|
||||
}
|
||||
|
||||
// TDI Pin I/O ---------------------------------------------
|
||||
|
@ -431,7 +549,7 @@ __STATIC_FORCEINLINE void PIN_SWDIO_OUT_DISABLE(void)
|
|||
*/
|
||||
__STATIC_FORCEINLINE uint32_t PIN_TDI_IN(void)
|
||||
{
|
||||
return ((GPIO.in >> PIN_TDI) & 0x1);
|
||||
return ((GPIO.in >> PIN_TDI) & 0x1) ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -446,11 +564,13 @@ __STATIC_FORCEINLINE void PIN_TDI_OUT(uint32_t bit)
|
|||
{
|
||||
//set bit
|
||||
GPIO.out_w1ts |= (0x1 << PIN_TDI);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//reset bit
|
||||
GPIO.out_w1tc |= (0x1 << PIN_TDI);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -463,7 +583,7 @@ __STATIC_FORCEINLINE void PIN_TDI_OUT(uint32_t bit)
|
|||
*/
|
||||
__STATIC_FORCEINLINE uint32_t PIN_TDO_IN(void)
|
||||
{
|
||||
return ((GPIO.in >> PIN_TDI) & 0x1);
|
||||
return ((GPIO.in >> PIN_TDO) & 0x1) ? 1 : 0;
|
||||
}
|
||||
|
||||
// nTRST Pin I/O -------------------------------------------
|
||||
|
@ -475,7 +595,7 @@ __STATIC_FORCEINLINE uint32_t PIN_TDO_IN(void)
|
|||
*/
|
||||
__STATIC_FORCEINLINE uint32_t PIN_nTRST_IN(void)
|
||||
{
|
||||
return ((GPIO.in >> PIN_nTRST) & 0x1);
|
||||
return 0; // not available
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -487,17 +607,18 @@ __STATIC_FORCEINLINE uint32_t PIN_nTRST_IN(void)
|
|||
*/
|
||||
__STATIC_FORCEINLINE void PIN_nTRST_OUT(uint32_t bit)
|
||||
{
|
||||
////TODO: What does this mean? ? ?
|
||||
if ((bit & 1U) == 1)
|
||||
{
|
||||
//set bit
|
||||
GPIO.out_w1ts |= (0x1 << PIN_nTRST);
|
||||
}
|
||||
else
|
||||
{
|
||||
//reset bit
|
||||
GPIO.out_w1tc |= (0x1 << PIN_nTRST);
|
||||
}
|
||||
// ////TODO: What does this mean? ? ?
|
||||
// if ((bit & 1U) == 1)
|
||||
// {
|
||||
// //set bit
|
||||
// GPIO.out_w1ts |= (0x1 << PIN_nTRST);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //reset bit
|
||||
// GPIO.out_w1tc |= (0x1 << PIN_nTRST);
|
||||
// }
|
||||
; // not available
|
||||
}
|
||||
|
||||
// nRESET Pin I/O------------------------------------------
|
||||
|
@ -509,7 +630,7 @@ __STATIC_FORCEINLINE void PIN_nTRST_OUT(uint32_t bit)
|
|||
*/
|
||||
__STATIC_FORCEINLINE uint32_t PIN_nRESET_IN(void)
|
||||
{
|
||||
return ((GPIO.in >> PIN_nRESET) & 0x1);
|
||||
return ((GPIO.in >> PIN_nRESET) & 0x1) ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,11 +19,18 @@
|
|||
#include "usb_defs.h"
|
||||
#include "MSOS20Descriptors.h"
|
||||
|
||||
// const char *strings_list[] = {
|
||||
// 0, // reserved: available languages
|
||||
// "windowsair",
|
||||
// "CMSIS-DAP v2",
|
||||
// "1234",
|
||||
// };
|
||||
|
||||
const char *strings_list[] = {
|
||||
0, // reserved: available languages
|
||||
"windowsair",
|
||||
"CMSIS-DAP v2",
|
||||
"1234",
|
||||
0, // reserved: available languages
|
||||
"windowsair",
|
||||
"esp8266 CMSIS-DAP",
|
||||
"1234",
|
||||
};
|
||||
// handle functions
|
||||
static void handleGetDescriptor(usbip_stage2_header *header);
|
||||
|
@ -106,6 +113,10 @@ void handleUSBControlRequest(usbip_stage2_header *header)
|
|||
break;
|
||||
|
||||
case 0x80: // *IMPORTANT*
|
||||
#if (USE_WINUSB == 0)
|
||||
case 0x81:
|
||||
#endif
|
||||
{
|
||||
switch (header->u.cmd_submit.request.bRequest)
|
||||
{
|
||||
case USB_REQ_GET_CONFIGURATION:
|
||||
|
@ -125,6 +136,8 @@ void handleUSBControlRequest(usbip_stage2_header *header)
|
|||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
#if (USE_WINUSB == 1)
|
||||
case 0x81: // ignore...
|
||||
switch (header->u.cmd_submit.request.bRequest)
|
||||
{
|
||||
|
@ -147,7 +160,7 @@ void handleUSBControlRequest(usbip_stage2_header *header)
|
|||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
#endif
|
||||
case 0x82: // ignore...
|
||||
switch (header->u.cmd_submit.request.bRequest)
|
||||
{
|
||||
|
@ -182,8 +195,22 @@ void handleUSBControlRequest(usbip_stage2_header *header)
|
|||
header->u.cmd_submit.request.bmRequestType, header->u.cmd_submit.request.bRequest, *wIndex);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0x21: // Set_Idle for HID
|
||||
switch (header->u.cmd_submit.request.bRequest)
|
||||
{
|
||||
case USB_REQ_SET_IDLE:
|
||||
os_printf("* SET IDLE\r\n");
|
||||
send_stage2_submit(header, 0, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
os_printf("USB unknown request, bmRequestType:%d,bRequest:%d\r\n",
|
||||
header->u.cmd_submit.request.bmRequestType, header->u.cmd_submit.request.bRequest);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
os_printf("USB unknown request, bmRequestType:%d,bRequest:%d\r\n",
|
||||
header->u.cmd_submit.request.bmRequestType, header->u.cmd_submit.request.bRequest);
|
||||
|
@ -222,7 +249,7 @@ static void handleGetDescriptor(usbip_stage2_header *header)
|
|||
break;
|
||||
|
||||
case USB_DT_STRING:
|
||||
os_printf("* GET 0x03 STRING DESCRIPTOR\r\n");
|
||||
//os_printf("* GET 0x03 STRING DESCRIPTOR\r\n");
|
||||
|
||||
if (header->u.cmd_submit.request.wValue.u8lo == 0)
|
||||
{
|
||||
|
@ -231,27 +258,27 @@ static void handleGetDescriptor(usbip_stage2_header *header)
|
|||
}
|
||||
else if (header->u.cmd_submit.request.wValue.u8lo != 0xee)
|
||||
{
|
||||
os_printf("low bit : %d\r\n", (int)header->u.cmd_submit.request.wValue.u8lo);
|
||||
os_printf("high bit : %d\r\n", (int)header->u.cmd_submit.request.wValue.u8hi);
|
||||
//os_printf("low bit : %d\r\n", (int)header->u.cmd_submit.request.wValue.u8lo);
|
||||
//os_printf("high bit : %d\r\n", (int)header->u.cmd_submit.request.wValue.u8hi);
|
||||
int slen = strlen(strings_list[header->u.cmd_submit.request.wValue.u8lo]);
|
||||
int wslen = slen * 2;
|
||||
int buff_len = sizeof(usb_string_descriptor) + wslen;
|
||||
char temp_buff[256];
|
||||
char temp_buff[64];
|
||||
usb_string_descriptor *desc = (usb_string_descriptor *)temp_buff;
|
||||
desc->bLength = buff_len;
|
||||
desc->bDescriptorType = USB_DT_STRING;
|
||||
for (int i = 0; i < slen; i++)
|
||||
{
|
||||
desc->wData[i] = strings_list[header->u.cmd_submit.request.wValue.u8lo][i];
|
||||
send_stage2_submit_data(header, 0, (uint8_t *)temp_buff, buff_len);
|
||||
|
||||
}
|
||||
send_stage2_submit_data(header, 0, (uint8_t *)temp_buff, buff_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
os_printf("low bit : %d\r\n", (int)header->u.cmd_submit.request.wValue.u8lo);
|
||||
os_printf("high bit : %d\r\n", (int)header->u.cmd_submit.request.wValue.u8hi);
|
||||
os_printf("***Unsupported String descriptor***\r\n");
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -293,8 +320,14 @@ static void handleGetDescriptor(usbip_stage2_header *header)
|
|||
os_printf("* GET 0x0F BOS DESCRIPTOR\r\n");
|
||||
send_stage2_submit_data(header, 0, bosDescriptor, sizeof(bosDescriptor));
|
||||
break;
|
||||
case USB_DT_HID_REPORT:
|
||||
os_printf("* GET 0x22 HID REPORT DESCRIPTOR");
|
||||
send_stage2_submit_data(header, 0, (void *)kHidReportDescriptor, sizeof(kHidReportDescriptor));
|
||||
break;
|
||||
default:
|
||||
os_printf("USB unknown Get Descriptor requested:%d\r\n", header->u.cmd_submit.request.wValue.u8lo);
|
||||
os_printf("low bit :%d\r\n",header->u.cmd_submit.request.wValue.u8lo);
|
||||
os_printf("high bit :%d\r\n",header->u.cmd_submit.request.wValue.u8hi);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ const uint8_t kUSBd0DeviceDescriptor[0x12] =
|
|||
|
||||
|
||||
// Standard Interface Descriptor
|
||||
|
||||
#if (USE_WINUSB ==1)
|
||||
const uint8_t kUSBd0InterfaceDescriptor[0x1E]=
|
||||
{
|
||||
0x09, // bLength
|
||||
|
@ -118,8 +120,58 @@ const uint8_t kUSBd0InterfaceDescriptor[0x1E]=
|
|||
|
||||
};
|
||||
|
||||
#else
|
||||
const uint8_t kUSBd0InterfaceDescriptor[0x20]=
|
||||
{
|
||||
0x09, // bLength
|
||||
USB_DT_INTERFACE, // bDescriptorType
|
||||
USBD_CUSTOM_CLASS0_IF0_NUM, // bInterfaceNumber
|
||||
USBD_CUSTOM_CLASS0_IF0_ALT, // bAlternateSetting
|
||||
0x02, // bNumEndpoints ----> 2 endpoint for USB HID
|
||||
//
|
||||
USBD_CUSTOM_CLASS0_IF0_CLASS, // bInterfaceClass
|
||||
USBD_CUSTOM_CLASS0_IF0_SUBCLASS, // bInterfaceSubClass
|
||||
USBD_CUSTOM_CLASS0_IF0_PROTOCOL, // bInterfaceProtocol
|
||||
0x00, // iInterface
|
||||
// Index of string descriptor describing this interface
|
||||
|
||||
// HID Descriptor
|
||||
0x09, // bLength
|
||||
0x21, // bDescriptorType
|
||||
0x11, 0x01, // bcdHID
|
||||
0x00, // bCountryCode
|
||||
0x01, // bNumDescriptors
|
||||
0x22, // bDescriptorType1
|
||||
0x21, 0x00, // wDescriptorLength1
|
||||
|
||||
// Standard Endpoint Descriptor
|
||||
|
||||
// We perform all transfer operations on Pysical endpoint 1.
|
||||
|
||||
/* Pysical endpoint 1 */
|
||||
|
||||
0x07, // bLength
|
||||
USB_DT_ENDPOINT, // bDescriptorType
|
||||
0x81, // bEndpointAddress
|
||||
USB_ENDPOINT_ATTR_INTERRUPT, // bmAttributes
|
||||
USBShort(64), // wMaxPacketSize
|
||||
0xff, // bInterval
|
||||
|
||||
/* Pysical endpoint 1 */
|
||||
|
||||
0x07, // bLength
|
||||
USB_DT_ENDPOINT, // bDescriptorType
|
||||
0x01, // bEndpointAddress
|
||||
USB_ENDPOINT_ATTR_INTERRUPT, // bmAttributes
|
||||
USBShort(64), // wMaxPacketSize
|
||||
0xff, // bInterval
|
||||
};
|
||||
#endif
|
||||
|
||||
// Standard Configuration Descriptor
|
||||
#define LENGTHOFCONFIGDESCRIPTOR 9
|
||||
|
||||
#if (USE_WINUSB == 1)
|
||||
const uint8_t kUSBd0ConfigDescriptor[LENGTHOFCONFIGDESCRIPTOR] =
|
||||
{
|
||||
// Configuration descriptor header.
|
||||
|
@ -139,6 +191,52 @@ const uint8_t kUSBd0ConfigDescriptor[LENGTHOFCONFIGDESCRIPTOR] =
|
|||
USBD0_CFG_DESC_BMAXPOWER, // bMaxPower
|
||||
};
|
||||
|
||||
#else
|
||||
const uint8_t kUSBd0ConfigDescriptor[LENGTHOFCONFIGDESCRIPTOR] =
|
||||
{
|
||||
// Configuration descriptor header.
|
||||
|
||||
0x09, // bLength
|
||||
USB_DT_CONFIGURATION, // bDescriptorType
|
||||
|
||||
USBShort((sizeof(kUSBd0InterfaceDescriptor)) + (LENGTHOFCONFIGDESCRIPTOR)),
|
||||
// wTotalLength
|
||||
|
||||
0x01, // bNumInterfaces
|
||||
// There is only one interface in the CMSIS-DAP project
|
||||
0x01, // bConfigurationValue: 0x01 is used to select this configuration */
|
||||
0x00, // iConfiguration: no string to describe this configuration */
|
||||
USBD0_CFG_DESC_BMATTRIBUTES, // bmAttributes
|
||||
|
||||
USBD0_CFG_DESC_BMAXPOWER, // bMaxPower
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
// USB HID Report Descriptor
|
||||
const uint8_t kHidReportDescriptor[0x21] = {
|
||||
0x06, 0x00, 0xFF, // Usage Page (Vendor Defined 0xFF00)
|
||||
0x09, 0x01, // Usage (0x01)
|
||||
0xA1, 0x01, // Collection (Application)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x26, 0xFF, 0x00, // Logical Maximum (255)
|
||||
0x75, 0x08, // Report Size (8)
|
||||
0x95, 0x40, // Report Count (64)
|
||||
0x09, 0x01, // Usage (0x01)
|
||||
0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
|
||||
0x95, 0x40, // Report Count (64)
|
||||
0x09, 0x01, // Usage (0x01)
|
||||
0x91, 0x02, // Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
|
||||
0x95, 0x01, // Report Count (1)
|
||||
0x09, 0x01, // Usage (0x01)
|
||||
0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
|
||||
0xC0, // End Collection
|
||||
// 33 bytes
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,34 +1,39 @@
|
|||
#ifndef __USBD_CONFIG_H__
|
||||
#define __USBD_CONFIG_H__
|
||||
|
||||
#define USE_WINUSB 0
|
||||
|
||||
// Vendor ID assigned by USB-IF (idVendor).
|
||||
#define USBD0_DEV_DESC_IDVENDOR 0xC251
|
||||
#define USBD0_DEV_DESC_IDVENDOR 0xC251
|
||||
// Product ID assigned by manufacturer (idProduct).
|
||||
#define USBD0_DEV_DESC_IDPRODUCT 0xF00A
|
||||
#define USBD0_DEV_DESC_IDPRODUCT 0xF00A
|
||||
// Device Release Number in binary-coded decimal (bcdDevice).
|
||||
#define USBD0_DEV_DESC_BCDDEVICE 0x0100
|
||||
#define USBD0_DEV_DESC_BCDDEVICE 0x0100
|
||||
|
||||
// Maximum packet size for Endpoint 0 (bMaxPacketSize0).
|
||||
#define USBD0_MAX_PACKET0 64
|
||||
#define USBD0_MAX_PACKET0 64
|
||||
|
||||
// If disabled Serial Number String will not be assigned to USB Device.
|
||||
#define USBD0_STR_DESC_SER_EN 1
|
||||
#define USBD0_STR_DESC_SER_EN 1
|
||||
|
||||
// bmAttributes
|
||||
#define USBD0_CFG_DESC_BMATTRIBUTES 0x80
|
||||
#define USBD0_CFG_DESC_BMATTRIBUTES 0x80
|
||||
|
||||
// bMaxPower
|
||||
#define USBD0_CFG_DESC_BMAXPOWER 250
|
||||
|
||||
#define USBD0_CFG_DESC_BMAXPOWER 250
|
||||
|
||||
// Interface Number
|
||||
#define USBD_CUSTOM_CLASS0_IF0_NUM 0
|
||||
#define USBD_CUSTOM_CLASS0_IF0_NUM 0
|
||||
|
||||
// Alternate Setting
|
||||
#define USBD_CUSTOM_CLASS0_IF0_ALT 0
|
||||
#define USBD_CUSTOM_CLASS0_IF0_ALT 0
|
||||
|
||||
// Class Code
|
||||
#define USBD_CUSTOM_CLASS0_IF0_CLASS 0xFF // 0xFF: Vendor Specific
|
||||
#if (USE_WINUSB == 1)
|
||||
#define USBD_CUSTOM_CLASS0_IF0_CLASS 0xFF // 0xFF: Vendor Specific
|
||||
#else
|
||||
#define USBD_CUSTOM_CLASS0_IF0_CLASS 0x03 // 0x03: HID class
|
||||
#endif
|
||||
|
||||
// Subclass Code
|
||||
#define USBD_CUSTOM_CLASS0_IF0_SUBCLASS 0x00
|
||||
|
@ -36,19 +41,26 @@
|
|||
// Protocol Code
|
||||
#define USBD_CUSTOM_CLASS0_IF0_PROTOCOL 0x00
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
|
||||
// common part
|
||||
extern const uint8_t kUSBd0DeviceDescriptor[0x12];
|
||||
extern const uint8_t kUSBd0InterfaceDescriptor[0x1E];
|
||||
extern const uint8_t kUSBd0ConfigDescriptor[0x09];
|
||||
extern const uint8_t kLangDescriptor[0x04];
|
||||
extern const uint8_t kManufacturerString[0x28];
|
||||
extern const uint8_t kProductString[0x18];
|
||||
extern const uint8_t kSerialNumberString[0x1A];
|
||||
|
||||
#if (USE_WINUSB == 1)
|
||||
extern const uint8_t kUSBd0InterfaceDescriptor[0x1E];
|
||||
extern const uint8_t kUSBd0ConfigDescriptor[0x09];
|
||||
extern const uint8_t kInterfaceString[0x2C];
|
||||
|
||||
#else
|
||||
extern const uint8_t kUSBd0InterfaceDescriptor[0x20];
|
||||
extern const uint8_t kUSBd0ConfigDescriptor[0x09];
|
||||
extern const uint8_t kInterfaceString[0x2C];
|
||||
extern const uint8_t kHidReportDescriptor[0x21];
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -98,6 +98,14 @@ typedef struct
|
|||
#define USB_REQ_GET_INTERFACE 10
|
||||
#define USB_REQ_SET_INTERFACE 11
|
||||
#define USB_REQ_SET_SYNCH_FRAME 12
|
||||
|
||||
// USB HID Request
|
||||
#define USB_REQ_GET_REPORT 0x01
|
||||
#define USB_REQ_GET_IDLE 0x02
|
||||
#define USB_REQ_GET_PROTOCOL 0x03
|
||||
#define USB_REQ_SET_REPORT 0x09
|
||||
#define USB_REQ_SET_IDLE 0X0A
|
||||
#define USB_REQ_SET_PROTOCOL 0X0B
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
@ -115,6 +123,9 @@ typedef struct
|
|||
#define USB_DT_OTG 9
|
||||
#define USB_DT_DEBUG 10
|
||||
#define USB_DT_INTERFACE_ASSOCIATION 11
|
||||
/* USB HID */
|
||||
#define USB_DT_HID 0x21
|
||||
#define USB_DT_HID_REPORT 0x22
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "DAP.h"
|
||||
#include "esp_libc.h"
|
||||
////TODO: Merge this
|
||||
#define DAP_PACKET_SIZE 512
|
||||
#define DAP_PACKET_SIZE 64
|
||||
|
||||
static uint8_t data_out[DAP_PACKET_SIZE];
|
||||
static int dap_respond = 0;
|
||||
|
@ -40,7 +40,7 @@ void handle_dap_data_response(usbip_stage2_header *header)
|
|||
|
||||
//os_printf("*** Will respond");
|
||||
|
||||
send_stage2_submit_data(header, 0, data_out, (dap_respond & 0x0000FFFF));
|
||||
send_stage2_submit_data(header, 0, data_out, DAP_PACKET_SIZE);
|
||||
dap_respond = 0;
|
||||
//os_printf("*** RESPONDED ***");
|
||||
}
|
||||
|
|
|
@ -140,9 +140,9 @@ void app_main()
|
|||
DAP_Setup(); // DAP Setup
|
||||
|
||||
xTaskCreate(timer_create_task, "timer_create", 512, NULL, 10, NULL);
|
||||
xTaskCreate(tcp_server_task, "tcp_server", 4096, NULL, 5, NULL);
|
||||
xTaskCreate(tcp_server_task, "tcp_server", 4096, NULL, 20, NULL);
|
||||
// SWO Trace Task
|
||||
xTaskCreate(SWO_Thread, "swo_task", 1024, NULL, 6, NULL);
|
||||
xTaskCreate(usart_monitor_task, "uart_task", 512, NULL, 6, NULL);
|
||||
//xTaskCreate(SWO_Thread, "swo_task", 1024, NULL, 6, NULL);
|
||||
//xTaskCreate(usart_monitor_task, "uart_task", 512, NULL, 6, NULL);
|
||||
|
||||
}
|
||||
|
|
|
@ -31,9 +31,10 @@
|
|||
|
||||
uint8_t kState = ACCEPTING;
|
||||
int kSock = -1;
|
||||
|
||||
void tcp_server_task(void *pvParameters)
|
||||
{
|
||||
uint8_t rx_buffer[2048];
|
||||
uint8_t tcp_rx_buffer[256];
|
||||
char addr_str[128];
|
||||
int addr_family;
|
||||
int ip_protocol;
|
||||
|
@ -101,7 +102,7 @@ void tcp_server_task(void *pvParameters)
|
|||
|
||||
while (1)
|
||||
{
|
||||
int len = recv(kSock, rx_buffer, 2047, 0);
|
||||
int len = recv(kSock, tcp_rx_buffer, 255, 0);
|
||||
// Error occured during receiving
|
||||
if (len < 0)
|
||||
{
|
||||
|
@ -117,19 +118,19 @@ void tcp_server_task(void *pvParameters)
|
|||
// Data received
|
||||
else
|
||||
{
|
||||
#ifdef CONFIG_EXAMPLE_IPV6
|
||||
// Get the sender's ip address as string
|
||||
if (sourceAddr.sin6_family == PF_INET)
|
||||
{
|
||||
inet_ntoa_r(((struct sockaddr_in *)&sourceAddr)->sin_addr.s_addr, addr_str, sizeof(addr_str) - 1);
|
||||
}
|
||||
else if (sourceAddr.sin6_family == PF_INET6)
|
||||
{
|
||||
inet6_ntoa_r(sourceAddr.sin6_addr, addr_str, sizeof(addr_str) - 1);
|
||||
}
|
||||
#else
|
||||
inet_ntoa_r(((struct sockaddr_in *)&sourceAddr)->sin_addr.s_addr, addr_str, sizeof(addr_str) - 1);
|
||||
#endif
|
||||
// #ifdef CONFIG_EXAMPLE_IPV6
|
||||
// // Get the sender's ip address as string
|
||||
// if (sourceAddr.sin6_family == PF_INET)
|
||||
// {
|
||||
// inet_ntoa_r(((struct sockaddr_in *)&sourceAddr)->sin_addr.s_addr, addr_str, sizeof(addr_str) - 1);
|
||||
// }
|
||||
// else if (sourceAddr.sin6_family == PF_INET6)
|
||||
// {
|
||||
// inet6_ntoa_r(sourceAddr.sin6_addr, addr_str, sizeof(addr_str) - 1);
|
||||
// }
|
||||
// #else
|
||||
// inet_ntoa_r(((struct sockaddr_in *)&sourceAddr)->sin_addr.s_addr, addr_str, sizeof(addr_str) - 1);
|
||||
// #endif
|
||||
|
||||
switch (kState)
|
||||
{
|
||||
|
@ -137,11 +138,11 @@ void tcp_server_task(void *pvParameters)
|
|||
kState = ATTACHING;
|
||||
|
||||
case ATTACHING:
|
||||
attach(rx_buffer, len);
|
||||
attach(tcp_rx_buffer, len);
|
||||
break;
|
||||
|
||||
case EMULATING:
|
||||
emulate(rx_buffer, len);
|
||||
emulate(tcp_rx_buffer, len);
|
||||
break;
|
||||
default:
|
||||
os_printf("unkonw kstate!\r\n");
|
||||
|
|
|
@ -31,6 +31,9 @@ static void handle_unlink(usbip_stage2_header *header);
|
|||
// unlink helper function
|
||||
static void send_stage2_unlink(usbip_stage2_header *req_header);
|
||||
|
||||
static void fast_submit_reply(usbip_stage2_header *req_header);
|
||||
|
||||
|
||||
int attach(uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
int command = read_stage1_command(buffer, length);
|
||||
|
@ -197,6 +200,7 @@ int emulate(uint8_t *buffer, uint32_t length)
|
|||
|
||||
default:
|
||||
os_printf("emulate unknown command:%d\r\n", command);
|
||||
handle_submit((usbip_stage2_header *)buffer);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -278,12 +282,12 @@ static int handle_submit(usbip_stage2_header *header)
|
|||
case 0x01:
|
||||
if (header->base.direction == 0)
|
||||
{
|
||||
// os_printf("EP 01 DATA FROM HOST");
|
||||
//os_printf("EP 01 DATA FROM HOST");
|
||||
handle_dap_data_request(header);
|
||||
}
|
||||
else
|
||||
{
|
||||
os_printf("EP 01 DATA TO HOST\r\n");
|
||||
// os_printf("EP 01 DATA TO HOST\r\n");
|
||||
handle_dap_data_response(header);
|
||||
}
|
||||
break;
|
||||
|
|
10
sdkconfig
10
sdkconfig
|
@ -25,7 +25,7 @@ CONFIG_ESPTOOLPY_BAUD_921600B=y
|
|||
# CONFIG_ESPTOOLPY_BAUD_2MB is not set
|
||||
# CONFIG_ESPTOOLPY_BAUD_OTHER is not set
|
||||
CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200
|
||||
CONFIG_ESPTOOLPY_BAUD=921600
|
||||
CONFIG_ESPTOOLPY_BAUD=115200
|
||||
CONFIG_ESPTOOLPY_COMPRESSED=y
|
||||
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
|
||||
# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set
|
||||
|
@ -42,10 +42,10 @@ CONFIG_SPI_FLASH_FREQ=0x0
|
|||
# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set
|
||||
# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set
|
||||
# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
|
||||
# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE="8MB"
|
||||
CONFIG_SPI_FLASH_SIZE=0x800000
|
||||
# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE="16MB"
|
||||
CONFIG_SPI_FLASH_SIZE=0x1000000
|
||||
CONFIG_ESPTOOLPY_BEFORE_RESET=y
|
||||
# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set
|
||||
CONFIG_ESPTOOLPY_BEFORE="default_reset"
|
||||
|
|
Loading…
Reference in New Issue