From ff45c13498fda95e3b82e432211abd8270280f0c Mon Sep 17 00:00:00 2001 From: sys64738 Date: Sat, 19 Jun 2021 22:26:18 +0200 Subject: [PATCH] bleh --- CMakeLists.txt | 5 ++++- README.md | 8 +++++--- src/cdc_serprog.c | 4 +--- src/protos.h | 1 + src/vnd_i2ctinyusb.c | 37 ++++++++++++++++++++++++++++++------- 5 files changed, 41 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba03c27..7b018bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ option(USE_USBCDC_FOR_STDIO "Export an extra USB-CDC interface for stdio, instea set(FAMILY "rp2040" CACHE STRING "Board/MCU family, decides which drivers to use. Set to RP2040 by default.") set(BOARD "raspberry_pi_pico" CACHE STRING "Board used, determines the pinout. Defaults to the Raspberry Pi Pico.") -# use directory name for project id +# use directory name for project id # FIXME: use fixed project name get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) set(PROJECT ${BOARD}-${PROJECT}) @@ -33,6 +33,9 @@ if(FAMILY STREQUAL "rp2040") family_initialize_project(PROJECT ${CMAKE_CURRENT_LIST_DIR}) # calls pico_sdk_init() #pico_sdk_init() + pico_set_program_name(PROJECT "${PROJECT}") + pico_set_program_version(PROJECT "0.1") + add_executable(${PROJECT}) # need uart stdio, usb is busy doing other stuff diff --git a/README.md b/README.md index ea7ecbc..041bbf5 100644 --- a/README.md +++ b/README.md @@ -169,7 +169,8 @@ libco is licensed under the [ISC license](https://opensource.org/licenses/ISC) to use the UART interface as a loopback thing. - [ ] I2C support by emulating the I2C Tiny USB - [ ] Expose RP2040-internal temperature ADC on I2C-over-USB bus? - - ~~Does SMBus stuff need special treatment here?~~ No. + - ~~Does SMBus stuff need special treatment here?~~ ~~No.~~ Actually, some + parts do, but, laziness. - [ ] 10-bit I2C address support (Needs poking at the Pico SDK, as it only supports 7-bit ones). - [ ] Host-side script that is an XVC (or hw_server) cable and communicates @@ -184,11 +185,12 @@ libco is licensed under the [ISC license](https://opensource.org/licenses/ISC) - https://github.com/Xilinx/XilinxVirtualCable/ - https://github.com/derekmulcahy/xvcpi - OpenOCD as XVC client?? +- [ ] SUMP logic analyzer? + - see also [this](https://github.com/perexg/picoprobe-sump) +- [ ] Segger RTT? - [ ] Maybe use the ADCs for something? - [ ] General generic manual GPIO mode - [ ] SD/MMC/SDIO (will be a pain) -- [ ] SUMP logic analyzer????? - - see also [this](https://github.com/perexg/picoprobe-sump) - [ ] AVR programming (USBavr emulation?) - AVR ISP is hardly used anymore - TPI/UPDI requires 5V levels, Pico doesn't do that :/ diff --git a/src/cdc_serprog.c b/src/cdc_serprog.c index 24fac74..319c479 100644 --- a/src/cdc_serprog.c +++ b/src/cdc_serprog.c @@ -37,9 +37,7 @@ static const uint8_t serprog_cmdmap[32] = { 0, // 58..5f 0, // rest is 0 }; -static const char serprog_pgmname[16] = { - 'D','a','p','p','e','r','M','i','m','e','-','J','T','A','G',0 // TODO -}; +static const char serprog_pgmname[16] = INFO_PRODUCT_BARE; static uint8_t rx_buf[CFG_TUD_CDC_RX_BUFSIZE]; static uint8_t tx_buf[CFG_TUD_CDC_TX_BUFSIZE]; diff --git a/src/protos.h b/src/protos.h index c03a390..5d796dc 100644 --- a/src/protos.h +++ b/src/protos.h @@ -7,6 +7,7 @@ #include "protocfg.h" #define INFO_MANUFACTURER "BLAHAJ CTF" +#define INFO_PRODUCT_BARE "Dragnbus" #define INFO_PRODUCT(board) "Dragnbus (" board ")" #ifdef DBOARD_HAS_UART diff --git a/src/vnd_i2ctinyusb.c b/src/vnd_i2ctinyusb.c index 8c07c83..46379e0 100644 --- a/src/vnd_i2ctinyusb.c +++ b/src/vnd_i2ctinyusb.c @@ -51,10 +51,33 @@ static uint16_t iub_open(uint8_t rhport, tusb_desc_interface_t const* itf_desc, } static bool iub_ctl_req(uint8_t rhport, uint8_t stage, tusb_control_request_t const* req) { - if (stage == CONTROL_STAGE_DATA) { - // TODO: should URB_CONTROL out data be read in this stage???? - return true; - } +// if (stage == CONTROL_STAGE_DATA && req->bmRequestType_bit.type == TUSB_REQ_TYPE_VENDOR) { +// // TODO: should URB_CONTROL out data be read in this stage???? +// // FIXME: cond ^ has false-positives! +// // FIXME: handle 0-byte writes in SETUP stage +// // FIXME: use curcmd var for eliminating false-positives +// // FIXME: other stuff??? +// if (req->bRequest >= ITU_CMD_I2C_IO && req->bRequest <= ITU_CMD_I2C_IO_BEGINEND +// /*&& curcmd.cmd == req->bRequest && curcmd.flags == req->wValue +// && curcmd.addr == req->wIndex && curcmd.len == req->wLength*/) { +// uint8_t buf[req->wLength]; +// bool rv = tud_control_xfer(rhport, req, buf, req->wLength); +// printf("write addr=%04hx len=%04hx ", req->wIndex, req->wLength); +// if (rv) { +// printf("data=%02x %02x...\n", buf[0], buf[1]); +// status = i2ctu_write(req->wValue, req->bRequest & ITU_CMD_I2C_IO_DIR_MASK, +// req->wIndex, buf, sizeof buf); +// } else { +// printf("no data :/\n"); +// status = ITU_STATUS_ADDR_NAK; +// } +// return rv; +// } else { +// //printf("I2C-Tiny-USB: bad command in DATA stage\n"); +// //return false; +// } +// return true; +// } if (stage != CONTROL_STAGE_SETUP) return true; @@ -130,8 +153,8 @@ static bool iub_ctl_req(uint8_t rhport, uint8_t stage, tusb_control_request_t co printf("data=%02x %02x...\n", buf[0], buf[1]); return tud_control_xfer(rhport, req, buf, req->wLength); } else { // write - printf("write addr=%04hx len=%04hx ", req->wIndex, req->wLength); - // FIXME: THIS NO WORKY! STUFF IN BUFFER IS NONSENSE + return true; // handled in DATA stage + /*// FIXME: THIS NO WORKY! STUFF IN BUFFER IS NONSENSE bool rv = tud_control_xfer(rhport, req, buf, req->wLength); if (rv) { printf("data=%02x %02x...\n", buf[0], buf[1]); @@ -141,7 +164,7 @@ static bool iub_ctl_req(uint8_t rhport, uint8_t stage, tusb_control_request_t co printf("no data :/\n"); status = ITU_STATUS_ADDR_NAK; } - return rv; + return rv;*/ } } break;