2021-02-12 19:01:14 -05:00
|
|
|
/*
|
|
|
|
* This file is part of the MicroPython project, http://micropython.org/
|
|
|
|
*
|
|
|
|
* The MIT License (MIT)
|
|
|
|
*
|
2021-02-15 20:06:18 -05:00
|
|
|
* Copyright (c) 2021 Dan Halbert for Adafruit Industries
|
2021-02-12 19:01:14 -05:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2021-02-15 20:06:18 -05:00
|
|
|
#include "py/gc.h"
|
2021-02-12 19:01:14 -05:00
|
|
|
#include "py/obj.h"
|
|
|
|
#include "py/mphal.h"
|
|
|
|
#include "py/runtime.h"
|
|
|
|
#include "py/objtuple.h"
|
2021-02-15 20:06:18 -05:00
|
|
|
#include "shared-bindings/usb_cdc/__init__.h"
|
2021-02-12 19:01:14 -05:00
|
|
|
#include "shared-bindings/usb_cdc/Serial.h"
|
2021-04-27 23:53:23 -04:00
|
|
|
#include "supervisor/usb.h"
|
|
|
|
|
2021-02-12 19:01:14 -05:00
|
|
|
#include "tusb.h"
|
|
|
|
|
feat: add Blues Swan R5 support
complete pin mapping for Feather pins
stubbed out files needed for complilation. still to be modified
0 out all CPY modules in mpconfigboard.mk until we get the build running
add csv for pin generation for STM32L4R5
add F4R5 references in peripherals files
refactored out board files BECAUSE I AM AN IDIOT; add L4 series system clocks file from CubeMX
took a guess at the number of USB endpoint pairs to get the build done
guess was close, but wrong. It is 8
clean up peripheral DEFs
Fixes build error:
```
In file included from ../../py/mpstate.h:33,
from ../../py/mpstate.c:27:
../../py/misc.h: In function 'vstr_str':
../../py/misc.h:196:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
static inline char *vstr_str(vstr_t *vstr) {
^~~~~~
```
Sleuthing steps:
* verify that the feather_stm32f4_express board builds correctly
* put a `#error` at the bottom of the `mpstate.c` file.
* build for the feather and swan boards, with V=2 to capture the build command for that file.
* use a differencing tool to inspect the differences between the two invocations
* inspecting the differences, I saw a missing `-mcpu=cortex-m4` I tested by adding that to the Swan build command. The file built fine (stopping at the hard error, but no other warnings.)
A grep through the sources revealed where this flag was being set for the stm ports.
With this commit, the build gets further, but does not complete. The next exciting episode in this unfolding coding saga is just a commit away!
working build with minimal set of modules for the Blues Swan r5
chore:change header copyright name to Blues Wireless Contributors
USB operational. Fixed up clocks to be hardwired for LSE no HSE case. (Trying to combine HSE in there made the code much more complex, and I don't have a board to test it out on.)
USART working
adds support for `ENABLE_3V3` and `DISCHARGE_3V3` pins. I am surprised that pin definitions are quite low-level and don't include default direction and state, so the code currently has to initialize `ENABLE_3V3` pin as output. The LED takes over a second to discharge, so I wonder if the board startup code is not having the desired affect.
short circuit implementation of backup memory for the STM32L4
all the ports
remove company name from board name to be consistent with the Arduino board definition.
add default pins for I2C, SPI and UART, so that `board.I2C` et al. works as expected. Confirmed I2C timing.
fix board name
fix incorrect pin definition. add test to allow manual check of each output pin
analog IO
code changes for WebUSB. Doesn't appear to work, will revisit later.
ensure that `sys.platform` is available
checkin missing file
feat: make room for a larger filesystem so the sensor tutorial will fit on the device.
fix:(stm32l4r5zi.csv): merged AF0-7 and AF8-15 into single lines and removed extraneous headers mixed in with the data.
fix(parse_af_csv.py): pin index in the csv is 0 not 1, and AF index made 1 larger
chore(Swan R5): update peripherals pins from `parse_af_csv.py` output
optimize flash sector access
2021-07-29 18:06:31 -04:00
|
|
|
#if CIRCUITPY_USB_VENDOR
|
2021-09-28 17:13:04 -04:00
|
|
|
// todo - this doesn't feel like it should be here.
|
feat: add Blues Swan R5 support
complete pin mapping for Feather pins
stubbed out files needed for complilation. still to be modified
0 out all CPY modules in mpconfigboard.mk until we get the build running
add csv for pin generation for STM32L4R5
add F4R5 references in peripherals files
refactored out board files BECAUSE I AM AN IDIOT; add L4 series system clocks file from CubeMX
took a guess at the number of USB endpoint pairs to get the build done
guess was close, but wrong. It is 8
clean up peripheral DEFs
Fixes build error:
```
In file included from ../../py/mpstate.h:33,
from ../../py/mpstate.c:27:
../../py/misc.h: In function 'vstr_str':
../../py/misc.h:196:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
static inline char *vstr_str(vstr_t *vstr) {
^~~~~~
```
Sleuthing steps:
* verify that the feather_stm32f4_express board builds correctly
* put a `#error` at the bottom of the `mpstate.c` file.
* build for the feather and swan boards, with V=2 to capture the build command for that file.
* use a differencing tool to inspect the differences between the two invocations
* inspecting the differences, I saw a missing `-mcpu=cortex-m4` I tested by adding that to the Swan build command. The file built fine (stopping at the hard error, but no other warnings.)
A grep through the sources revealed where this flag was being set for the stm ports.
With this commit, the build gets further, but does not complete. The next exciting episode in this unfolding coding saga is just a commit away!
working build with minimal set of modules for the Blues Swan r5
chore:change header copyright name to Blues Wireless Contributors
USB operational. Fixed up clocks to be hardwired for LSE no HSE case. (Trying to combine HSE in there made the code much more complex, and I don't have a board to test it out on.)
USART working
adds support for `ENABLE_3V3` and `DISCHARGE_3V3` pins. I am surprised that pin definitions are quite low-level and don't include default direction and state, so the code currently has to initialize `ENABLE_3V3` pin as output. The LED takes over a second to discharge, so I wonder if the board startup code is not having the desired affect.
short circuit implementation of backup memory for the STM32L4
all the ports
remove company name from board name to be consistent with the Arduino board definition.
add default pins for I2C, SPI and UART, so that `board.I2C` et al. works as expected. Confirmed I2C timing.
fix board name
fix incorrect pin definition. add test to allow manual check of each output pin
analog IO
code changes for WebUSB. Doesn't appear to work, will revisit later.
ensure that `sys.platform` is available
checkin missing file
feat: make room for a larger filesystem so the sensor tutorial will fit on the device.
fix:(stm32l4r5zi.csv): merged AF0-7 and AF8-15 into single lines and removed extraneous headers mixed in with the data.
fix(parse_af_csv.py): pin index in the csv is 0 not 1, and AF index made 1 larger
chore(Swan R5): update peripherals pins from `parse_af_csv.py` output
optimize flash sector access
2021-07-29 18:06:31 -04:00
|
|
|
#include "supervisor/memory.h"
|
|
|
|
#endif
|
|
|
|
|
2021-02-15 20:06:18 -05:00
|
|
|
#if CFG_TUD_CDC != 2
|
|
|
|
#error CFG_TUD_CDC must be exactly 2
|
|
|
|
#endif
|
2021-02-12 19:01:14 -05:00
|
|
|
|
2021-04-20 22:20:34 -04:00
|
|
|
static const uint8_t usb_cdc_descriptor_template[] = {
|
|
|
|
// CDC IAD Descriptor
|
|
|
|
0x08, // 0 bLength
|
|
|
|
0x0B, // 1 bDescriptorType: IAD Descriptor
|
|
|
|
0xFF, // 2 bFirstInterface [SET AT RUNTIME]
|
|
|
|
#define CDC_FIRST_INTERFACE_INDEX 2
|
|
|
|
0x02, // 3 bInterfaceCount: 2
|
|
|
|
0x02, // 4 bFunctionClass: COMM
|
|
|
|
0x02, // 5 bFunctionSubclass: ACM
|
|
|
|
0x00, // 6 bFunctionProtocol: NONE
|
|
|
|
0x00, // 7 iFunction
|
|
|
|
|
|
|
|
// CDC Comm Interface Descriptor
|
|
|
|
0x09, // 8 bLength
|
|
|
|
0x04, // 9 bDescriptorType (Interface)
|
|
|
|
0xFF, // 10 bInterfaceNumber [SET AT RUNTIME]
|
|
|
|
#define CDC_COMM_INTERFACE_INDEX 10
|
|
|
|
0x00, // 11 bAlternateSetting
|
|
|
|
0x01, // 12 bNumEndpoints 1
|
|
|
|
0x02, // 13 bInterfaceClass: COMM
|
|
|
|
0x02, // 14 bInterfaceSubClass: ACM
|
|
|
|
0x00, // 15 bInterfaceProtocol: NONE
|
|
|
|
0xFF, // 16 iInterface (String Index)
|
|
|
|
#define CDC_COMM_INTERFACE_STRING_INDEX 16
|
|
|
|
|
|
|
|
// CDC Header Descriptor
|
|
|
|
0x05, // 17 bLength
|
|
|
|
0x24, // 18 bDescriptorType: CLASS SPECIFIC INTERFACE
|
|
|
|
0x00, // 19 bDescriptorSubtype: NONE
|
|
|
|
0x10, 0x01, // 20,21 bcdCDC: 1.10
|
|
|
|
|
|
|
|
// CDC Call Management Descriptor
|
|
|
|
0x05, // 22 bLength
|
|
|
|
0x24, // 23 bDescriptorType: CLASS SPECIFIC INTERFACE
|
|
|
|
0x01, // 24 bDescriptorSubtype: CALL MANAGEMENT
|
|
|
|
0x01, // 25 bmCapabilities
|
|
|
|
0xFF, // 26 bDataInterface [SET AT RUNTIME]
|
|
|
|
#define CDC_CALL_MANAGEMENT_DATA_INTERFACE_INDEX 26
|
|
|
|
|
|
|
|
// CDC Abstract Control Management Descriptor
|
|
|
|
0x04, // 27 bLength
|
|
|
|
0x24, // 28 bDescriptorType: CLASS SPECIFIC INTERFACE
|
|
|
|
0x02, // 29 bDescriptorSubtype: ABSTRACT CONTROL MANAGEMENT
|
|
|
|
0x02, // 30 bmCapabilities
|
|
|
|
|
|
|
|
// CDC Union Descriptor
|
|
|
|
0x05, // 31 bLength
|
|
|
|
0x24, // 32 bDescriptorType: CLASS SPECIFIC INTERFACE
|
|
|
|
0x06, // 33 bDescriptorSubtype: CDC
|
|
|
|
0xFF, // 34 bMasterInterface [SET AT RUNTIME]
|
|
|
|
#define CDC_UNION_MASTER_INTERFACE_INDEX 34
|
|
|
|
0xFF, // 35 bSlaveInterface_list (1 item)
|
|
|
|
#define CDC_UNION_SLAVE_INTERFACE_INDEX 35
|
|
|
|
|
|
|
|
// CDC Control IN Endpoint Descriptor
|
|
|
|
0x07, // 36 bLength
|
|
|
|
0x05, // 37 bDescriptorType (Endpoint)
|
2021-04-27 23:53:23 -04:00
|
|
|
0xFF, // 38 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | number]
|
2021-04-20 22:20:34 -04:00
|
|
|
#define CDC_CONTROL_IN_ENDPOINT_INDEX 38
|
|
|
|
0x03, // 39 bmAttributes (Interrupt)
|
|
|
|
0x40, 0x00, // 40, 41 wMaxPacketSize 64
|
|
|
|
0x10, // 42 bInterval 16 (unit depends on device speed)
|
|
|
|
|
|
|
|
// CDC Data Interface
|
|
|
|
0x09, // 43 bLength
|
|
|
|
0x04, // 44 bDescriptorType (Interface)
|
|
|
|
0xFF, // 45 bInterfaceNumber [SET AT RUNTIME]
|
|
|
|
#define CDC_DATA_INTERFACE_INDEX 45
|
|
|
|
0x00, // 46 bAlternateSetting
|
|
|
|
0x02, // 47 bNumEndpoints 2
|
|
|
|
0x0A, // 48 bInterfaceClass: DATA
|
|
|
|
0x00, // 49 bInterfaceSubClass: NONE
|
|
|
|
0x00, // 50 bInterfaceProtocol
|
|
|
|
0x05, // 51 iInterface (String Index)
|
|
|
|
#define CDC_DATA_INTERFACE_STRING_INDEX 51
|
|
|
|
|
|
|
|
// CDC Data OUT Endpoint Descriptor
|
|
|
|
0x07, // 52 bLength
|
|
|
|
0x05, // 53 bDescriptorType (Endpoint)
|
|
|
|
0xFF, // 54 bEndpointAddress (OUT/H2D) [SET AT RUNTIME]
|
|
|
|
#define CDC_DATA_OUT_ENDPOINT_INDEX 54
|
|
|
|
0x02, // 55 bmAttributes (Bulk)
|
2021-05-19 07:35:17 -04:00
|
|
|
#if USB_HIGHSPEED
|
2021-05-18 11:02:16 -04:00
|
|
|
0x00, 0x02, // 56,57 wMaxPacketSize 512
|
2021-05-19 07:35:17 -04:00
|
|
|
#else
|
2021-04-20 22:20:34 -04:00
|
|
|
0x40, 0x00, // 56,57 wMaxPacketSize 64
|
2021-05-19 07:35:17 -04:00
|
|
|
#endif
|
2021-04-20 22:20:34 -04:00
|
|
|
0x00, // 58 bInterval 0 (unit depends on device speed)
|
|
|
|
|
|
|
|
// CDC Data IN Endpoint Descriptor
|
|
|
|
0x07, // 59 bLength
|
|
|
|
0x05, // 60 bDescriptorType (Endpoint)
|
2021-04-27 23:53:23 -04:00
|
|
|
0xFF, // 61 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | number]
|
2021-04-20 22:20:34 -04:00
|
|
|
#define CDC_DATA_IN_ENDPOINT_INDEX 61
|
|
|
|
0x02, // 62 bmAttributes (Bulk)
|
2021-05-19 07:35:17 -04:00
|
|
|
#if USB_HIGHSPEED
|
2021-05-18 11:02:16 -04:00
|
|
|
0x00, 0x02, // 63,64 wMaxPacketSize 512
|
2021-05-19 07:35:17 -04:00
|
|
|
#else
|
2021-04-20 22:20:34 -04:00
|
|
|
0x40, 0x00, // 63,64 wMaxPacketSize 64
|
2021-05-19 07:35:17 -04:00
|
|
|
#endif
|
2021-04-20 22:20:34 -04:00
|
|
|
0x00, // 65 bInterval 0 (unit depends on device speed)
|
|
|
|
};
|
|
|
|
|
2021-05-03 22:22:29 -04:00
|
|
|
static const char console_cdc_comm_interface_name[] = USB_INTERFACE_NAME " CDC control";
|
2021-04-27 23:53:23 -04:00
|
|
|
static const char data_cdc_comm_interface_name[] = USB_INTERFACE_NAME " CDC2 control";
|
2021-05-03 22:22:29 -04:00
|
|
|
static const char console_cdc_data_interface_name[] = USB_INTERFACE_NAME " CDC data";
|
2021-04-27 23:53:23 -04:00
|
|
|
static const char data_cdc_data_interface_name[] = USB_INTERFACE_NAME " CDC2 data";
|
2021-04-26 23:54:01 -04:00
|
|
|
|
2021-06-02 11:29:56 -04:00
|
|
|
// .idx is set later.
|
|
|
|
|
2021-05-03 22:22:29 -04:00
|
|
|
static usb_cdc_serial_obj_t usb_cdc_console_obj = {
|
2021-04-26 23:54:01 -04:00
|
|
|
.base.type = &usb_cdc_serial_type,
|
|
|
|
.timeout = -1.0f,
|
|
|
|
.write_timeout = -1.0f,
|
|
|
|
};
|
|
|
|
|
|
|
|
static usb_cdc_serial_obj_t usb_cdc_data_obj = {
|
|
|
|
.base.type = &usb_cdc_serial_type,
|
|
|
|
.timeout = -1.0f,
|
|
|
|
.write_timeout = -1.0f,
|
|
|
|
};
|
|
|
|
|
2021-05-03 22:22:29 -04:00
|
|
|
static bool usb_cdc_console_is_enabled;
|
2021-04-27 14:37:36 -04:00
|
|
|
static bool usb_cdc_data_is_enabled;
|
|
|
|
|
2021-04-28 23:48:26 -04:00
|
|
|
void usb_cdc_set_defaults(void) {
|
2021-06-02 11:29:56 -04:00
|
|
|
common_hal_usb_cdc_enable(CIRCUITPY_USB_CDC_CONSOLE_ENABLED_DEFAULT,
|
|
|
|
CIRCUITPY_USB_CDC_DATA_ENABLED_DEFAULT);
|
2021-04-28 23:48:26 -04:00
|
|
|
}
|
|
|
|
|
2021-05-03 22:22:29 -04:00
|
|
|
bool usb_cdc_console_enabled(void) {
|
|
|
|
return usb_cdc_console_is_enabled;
|
2021-04-27 14:37:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool usb_cdc_data_enabled(void) {
|
2021-04-27 23:53:23 -04:00
|
|
|
return usb_cdc_data_is_enabled;
|
2021-04-27 14:37:36 -04:00
|
|
|
}
|
|
|
|
|
2021-04-20 22:20:34 -04:00
|
|
|
size_t usb_cdc_descriptor_length(void) {
|
|
|
|
return sizeof(usb_cdc_descriptor_template);
|
|
|
|
}
|
|
|
|
|
2021-05-13 21:49:04 -04:00
|
|
|
size_t usb_cdc_add_descriptor(uint8_t *descriptor_buf, descriptor_counts_t *descriptor_counts, uint8_t *current_interface_string, bool console) {
|
2021-04-27 23:53:23 -04:00
|
|
|
memcpy(descriptor_buf, usb_cdc_descriptor_template, sizeof(usb_cdc_descriptor_template));
|
2021-04-21 23:25:36 -04:00
|
|
|
|
|
|
|
// Store comm interface number.
|
2021-05-13 21:49:04 -04:00
|
|
|
descriptor_buf[CDC_FIRST_INTERFACE_INDEX] = descriptor_counts->current_interface;
|
|
|
|
descriptor_buf[CDC_COMM_INTERFACE_INDEX] = descriptor_counts->current_interface;
|
|
|
|
descriptor_buf[CDC_UNION_MASTER_INTERFACE_INDEX] = descriptor_counts->current_interface;
|
|
|
|
descriptor_counts->current_interface++;
|
2021-04-21 23:25:36 -04:00
|
|
|
|
|
|
|
// Now store data interface number.
|
2021-05-13 21:49:04 -04:00
|
|
|
descriptor_buf[CDC_CALL_MANAGEMENT_DATA_INTERFACE_INDEX] = descriptor_counts->current_interface;
|
|
|
|
descriptor_buf[CDC_UNION_SLAVE_INTERFACE_INDEX] = descriptor_counts->current_interface;
|
|
|
|
descriptor_buf[CDC_DATA_INTERFACE_INDEX] = descriptor_counts->current_interface;
|
|
|
|
descriptor_counts->current_interface++;
|
2021-04-21 23:25:36 -04:00
|
|
|
|
2021-04-27 23:53:23 -04:00
|
|
|
descriptor_buf[CDC_CONTROL_IN_ENDPOINT_INDEX] = 0x80 | (
|
2021-05-03 22:22:29 -04:00
|
|
|
console
|
2021-05-13 21:49:04 -04:00
|
|
|
? (USB_CDC_EP_NUM_NOTIFICATION ? USB_CDC_EP_NUM_NOTIFICATION : descriptor_counts->current_endpoint)
|
|
|
|
: (USB_CDC2_EP_NUM_NOTIFICATION ? USB_CDC2_EP_NUM_NOTIFICATION : descriptor_counts->current_endpoint));
|
|
|
|
descriptor_counts->num_in_endpoints++;
|
|
|
|
descriptor_counts->current_endpoint++;
|
2021-04-21 23:25:36 -04:00
|
|
|
|
2021-04-27 23:53:23 -04:00
|
|
|
descriptor_buf[CDC_DATA_IN_ENDPOINT_INDEX] = 0x80 | (
|
2021-05-03 22:22:29 -04:00
|
|
|
console
|
2021-05-13 21:49:04 -04:00
|
|
|
? (USB_CDC_EP_NUM_DATA_IN ? USB_CDC_EP_NUM_DATA_IN : descriptor_counts->current_endpoint)
|
|
|
|
: (USB_CDC2_EP_NUM_DATA_IN ? USB_CDC2_EP_NUM_DATA_IN : descriptor_counts->current_endpoint));
|
|
|
|
descriptor_counts->num_in_endpoints++;
|
|
|
|
descriptor_buf[CDC_DATA_OUT_ENDPOINT_INDEX] =
|
|
|
|
console
|
|
|
|
? (USB_CDC_EP_NUM_DATA_OUT ? USB_CDC_EP_NUM_DATA_OUT : descriptor_counts->current_endpoint)
|
|
|
|
: (USB_CDC2_EP_NUM_DATA_OUT ? USB_CDC2_EP_NUM_DATA_OUT : descriptor_counts->current_endpoint);
|
|
|
|
descriptor_counts->num_out_endpoints++;
|
|
|
|
descriptor_counts->current_endpoint++;
|
2021-04-21 23:25:36 -04:00
|
|
|
|
|
|
|
usb_add_interface_string(*current_interface_string,
|
2021-05-03 22:22:29 -04:00
|
|
|
console ? console_cdc_comm_interface_name : data_cdc_comm_interface_name);
|
2021-04-21 23:25:36 -04:00
|
|
|
descriptor_buf[CDC_COMM_INTERFACE_STRING_INDEX] = *current_interface_string;
|
|
|
|
(*current_interface_string)++;
|
|
|
|
|
|
|
|
usb_add_interface_string(*current_interface_string,
|
2021-05-03 22:22:29 -04:00
|
|
|
console ? console_cdc_data_interface_name : data_cdc_data_interface_name);
|
2021-04-21 23:25:36 -04:00
|
|
|
descriptor_buf[CDC_DATA_INTERFACE_STRING_INDEX] = *current_interface_string;
|
|
|
|
(*current_interface_string)++;
|
2021-04-20 22:20:34 -04:00
|
|
|
|
2021-04-27 23:53:23 -04:00
|
|
|
return sizeof(usb_cdc_descriptor_template);
|
2021-04-20 22:20:34 -04:00
|
|
|
}
|
|
|
|
|
2021-05-03 22:22:29 -04:00
|
|
|
bool common_hal_usb_cdc_disable(void) {
|
|
|
|
return common_hal_usb_cdc_enable(false, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool common_hal_usb_cdc_enable(bool console, bool data) {
|
2021-04-13 23:33:44 -04:00
|
|
|
// We can't change the descriptors once we're connected.
|
2021-04-14 22:10:09 -04:00
|
|
|
if (tud_connected()) {
|
2021-04-13 23:33:44 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-04-29 17:41:43 -04:00
|
|
|
// Right now these objects contain no heap objects, but if that changes,
|
|
|
|
// they will need to be protected against gc.
|
|
|
|
|
2021-06-02 11:29:56 -04:00
|
|
|
// Assign only as many idx values as necessary. They must start at 0.
|
|
|
|
uint8_t idx = 0;
|
2021-05-03 22:22:29 -04:00
|
|
|
usb_cdc_console_is_enabled = console;
|
|
|
|
usb_cdc_set_console(console ? MP_OBJ_FROM_PTR(&usb_cdc_console_obj) : mp_const_none);
|
2021-06-02 11:29:56 -04:00
|
|
|
if (console) {
|
|
|
|
usb_cdc_console_obj.idx = idx;
|
|
|
|
idx++;
|
|
|
|
}
|
2021-04-14 22:10:09 -04:00
|
|
|
|
2021-05-03 22:22:29 -04:00
|
|
|
usb_cdc_data_is_enabled = data;
|
|
|
|
usb_cdc_set_data(data ? MP_OBJ_FROM_PTR(&usb_cdc_data_obj) : mp_const_none);
|
2021-06-02 11:29:56 -04:00
|
|
|
if (data) {
|
|
|
|
usb_cdc_data_obj.idx = idx;
|
|
|
|
}
|
|
|
|
|
2021-04-14 22:10:09 -04:00
|
|
|
|
2021-04-13 23:33:44 -04:00
|
|
|
return true;
|
|
|
|
}
|
feat: add Blues Swan R5 support
complete pin mapping for Feather pins
stubbed out files needed for complilation. still to be modified
0 out all CPY modules in mpconfigboard.mk until we get the build running
add csv for pin generation for STM32L4R5
add F4R5 references in peripherals files
refactored out board files BECAUSE I AM AN IDIOT; add L4 series system clocks file from CubeMX
took a guess at the number of USB endpoint pairs to get the build done
guess was close, but wrong. It is 8
clean up peripheral DEFs
Fixes build error:
```
In file included from ../../py/mpstate.h:33,
from ../../py/mpstate.c:27:
../../py/misc.h: In function 'vstr_str':
../../py/misc.h:196:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
static inline char *vstr_str(vstr_t *vstr) {
^~~~~~
```
Sleuthing steps:
* verify that the feather_stm32f4_express board builds correctly
* put a `#error` at the bottom of the `mpstate.c` file.
* build for the feather and swan boards, with V=2 to capture the build command for that file.
* use a differencing tool to inspect the differences between the two invocations
* inspecting the differences, I saw a missing `-mcpu=cortex-m4` I tested by adding that to the Swan build command. The file built fine (stopping at the hard error, but no other warnings.)
A grep through the sources revealed where this flag was being set for the stm ports.
With this commit, the build gets further, but does not complete. The next exciting episode in this unfolding coding saga is just a commit away!
working build with minimal set of modules for the Blues Swan r5
chore:change header copyright name to Blues Wireless Contributors
USB operational. Fixed up clocks to be hardwired for LSE no HSE case. (Trying to combine HSE in there made the code much more complex, and I don't have a board to test it out on.)
USART working
adds support for `ENABLE_3V3` and `DISCHARGE_3V3` pins. I am surprised that pin definitions are quite low-level and don't include default direction and state, so the code currently has to initialize `ENABLE_3V3` pin as output. The LED takes over a second to discharge, so I wonder if the board startup code is not having the desired affect.
short circuit implementation of backup memory for the STM32L4
all the ports
remove company name from board name to be consistent with the Arduino board definition.
add default pins for I2C, SPI and UART, so that `board.I2C` et al. works as expected. Confirmed I2C timing.
fix board name
fix incorrect pin definition. add test to allow manual check of each output pin
analog IO
code changes for WebUSB. Doesn't appear to work, will revisit later.
ensure that `sys.platform` is available
checkin missing file
feat: make room for a larger filesystem so the sensor tutorial will fit on the device.
fix:(stm32l4r5zi.csv): merged AF0-7 and AF8-15 into single lines and removed extraneous headers mixed in with the data.
fix(parse_af_csv.py): pin index in the csv is 0 not 1, and AF index made 1 larger
chore(Swan R5): update peripherals pins from `parse_af_csv.py` output
optimize flash sector access
2021-07-29 18:06:31 -04:00
|
|
|
|
|
|
|
#if CIRCUITPY_USB_VENDOR
|
|
|
|
#include "usb_vendor_descriptors.h"
|
|
|
|
|
|
|
|
#define BOS_TOTAL_LEN (TUD_BOS_DESC_LEN + TUD_BOS_WEBUSB_DESC_LEN + TUD_BOS_MICROSOFT_OS_DESC_LEN)
|
|
|
|
|
|
|
|
#define MS_OS_20_DESC_LEN 0xB2
|
|
|
|
|
|
|
|
// BOS Descriptor is required for webUSB
|
|
|
|
uint8_t const desc_bos[] =
|
|
|
|
{
|
2021-09-28 17:13:04 -04:00
|
|
|
// total length, number of device caps
|
|
|
|
TUD_BOS_DESCRIPTOR(BOS_TOTAL_LEN, 2),
|
feat: add Blues Swan R5 support
complete pin mapping for Feather pins
stubbed out files needed for complilation. still to be modified
0 out all CPY modules in mpconfigboard.mk until we get the build running
add csv for pin generation for STM32L4R5
add F4R5 references in peripherals files
refactored out board files BECAUSE I AM AN IDIOT; add L4 series system clocks file from CubeMX
took a guess at the number of USB endpoint pairs to get the build done
guess was close, but wrong. It is 8
clean up peripheral DEFs
Fixes build error:
```
In file included from ../../py/mpstate.h:33,
from ../../py/mpstate.c:27:
../../py/misc.h: In function 'vstr_str':
../../py/misc.h:196:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
static inline char *vstr_str(vstr_t *vstr) {
^~~~~~
```
Sleuthing steps:
* verify that the feather_stm32f4_express board builds correctly
* put a `#error` at the bottom of the `mpstate.c` file.
* build for the feather and swan boards, with V=2 to capture the build command for that file.
* use a differencing tool to inspect the differences between the two invocations
* inspecting the differences, I saw a missing `-mcpu=cortex-m4` I tested by adding that to the Swan build command. The file built fine (stopping at the hard error, but no other warnings.)
A grep through the sources revealed where this flag was being set for the stm ports.
With this commit, the build gets further, but does not complete. The next exciting episode in this unfolding coding saga is just a commit away!
working build with minimal set of modules for the Blues Swan r5
chore:change header copyright name to Blues Wireless Contributors
USB operational. Fixed up clocks to be hardwired for LSE no HSE case. (Trying to combine HSE in there made the code much more complex, and I don't have a board to test it out on.)
USART working
adds support for `ENABLE_3V3` and `DISCHARGE_3V3` pins. I am surprised that pin definitions are quite low-level and don't include default direction and state, so the code currently has to initialize `ENABLE_3V3` pin as output. The LED takes over a second to discharge, so I wonder if the board startup code is not having the desired affect.
short circuit implementation of backup memory for the STM32L4
all the ports
remove company name from board name to be consistent with the Arduino board definition.
add default pins for I2C, SPI and UART, so that `board.I2C` et al. works as expected. Confirmed I2C timing.
fix board name
fix incorrect pin definition. add test to allow manual check of each output pin
analog IO
code changes for WebUSB. Doesn't appear to work, will revisit later.
ensure that `sys.platform` is available
checkin missing file
feat: make room for a larger filesystem so the sensor tutorial will fit on the device.
fix:(stm32l4r5zi.csv): merged AF0-7 and AF8-15 into single lines and removed extraneous headers mixed in with the data.
fix(parse_af_csv.py): pin index in the csv is 0 not 1, and AF index made 1 larger
chore(Swan R5): update peripherals pins from `parse_af_csv.py` output
optimize flash sector access
2021-07-29 18:06:31 -04:00
|
|
|
|
2021-09-28 17:13:04 -04:00
|
|
|
// Vendor Code, iLandingPage
|
|
|
|
TUD_BOS_WEBUSB_DESCRIPTOR(VENDOR_REQUEST_WEBUSB, 1),
|
feat: add Blues Swan R5 support
complete pin mapping for Feather pins
stubbed out files needed for complilation. still to be modified
0 out all CPY modules in mpconfigboard.mk until we get the build running
add csv for pin generation for STM32L4R5
add F4R5 references in peripherals files
refactored out board files BECAUSE I AM AN IDIOT; add L4 series system clocks file from CubeMX
took a guess at the number of USB endpoint pairs to get the build done
guess was close, but wrong. It is 8
clean up peripheral DEFs
Fixes build error:
```
In file included from ../../py/mpstate.h:33,
from ../../py/mpstate.c:27:
../../py/misc.h: In function 'vstr_str':
../../py/misc.h:196:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
static inline char *vstr_str(vstr_t *vstr) {
^~~~~~
```
Sleuthing steps:
* verify that the feather_stm32f4_express board builds correctly
* put a `#error` at the bottom of the `mpstate.c` file.
* build for the feather and swan boards, with V=2 to capture the build command for that file.
* use a differencing tool to inspect the differences between the two invocations
* inspecting the differences, I saw a missing `-mcpu=cortex-m4` I tested by adding that to the Swan build command. The file built fine (stopping at the hard error, but no other warnings.)
A grep through the sources revealed where this flag was being set for the stm ports.
With this commit, the build gets further, but does not complete. The next exciting episode in this unfolding coding saga is just a commit away!
working build with minimal set of modules for the Blues Swan r5
chore:change header copyright name to Blues Wireless Contributors
USB operational. Fixed up clocks to be hardwired for LSE no HSE case. (Trying to combine HSE in there made the code much more complex, and I don't have a board to test it out on.)
USART working
adds support for `ENABLE_3V3` and `DISCHARGE_3V3` pins. I am surprised that pin definitions are quite low-level and don't include default direction and state, so the code currently has to initialize `ENABLE_3V3` pin as output. The LED takes over a second to discharge, so I wonder if the board startup code is not having the desired affect.
short circuit implementation of backup memory for the STM32L4
all the ports
remove company name from board name to be consistent with the Arduino board definition.
add default pins for I2C, SPI and UART, so that `board.I2C` et al. works as expected. Confirmed I2C timing.
fix board name
fix incorrect pin definition. add test to allow manual check of each output pin
analog IO
code changes for WebUSB. Doesn't appear to work, will revisit later.
ensure that `sys.platform` is available
checkin missing file
feat: make room for a larger filesystem so the sensor tutorial will fit on the device.
fix:(stm32l4r5zi.csv): merged AF0-7 and AF8-15 into single lines and removed extraneous headers mixed in with the data.
fix(parse_af_csv.py): pin index in the csv is 0 not 1, and AF index made 1 larger
chore(Swan R5): update peripherals pins from `parse_af_csv.py` output
optimize flash sector access
2021-07-29 18:06:31 -04:00
|
|
|
|
2021-09-28 17:13:04 -04:00
|
|
|
// Microsoft OS 2.0 descriptor
|
|
|
|
TUD_BOS_MS_OS_20_DESCRIPTOR(MS_OS_20_DESC_LEN, VENDOR_REQUEST_MICROSOFT)
|
feat: add Blues Swan R5 support
complete pin mapping for Feather pins
stubbed out files needed for complilation. still to be modified
0 out all CPY modules in mpconfigboard.mk until we get the build running
add csv for pin generation for STM32L4R5
add F4R5 references in peripherals files
refactored out board files BECAUSE I AM AN IDIOT; add L4 series system clocks file from CubeMX
took a guess at the number of USB endpoint pairs to get the build done
guess was close, but wrong. It is 8
clean up peripheral DEFs
Fixes build error:
```
In file included from ../../py/mpstate.h:33,
from ../../py/mpstate.c:27:
../../py/misc.h: In function 'vstr_str':
../../py/misc.h:196:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
static inline char *vstr_str(vstr_t *vstr) {
^~~~~~
```
Sleuthing steps:
* verify that the feather_stm32f4_express board builds correctly
* put a `#error` at the bottom of the `mpstate.c` file.
* build for the feather and swan boards, with V=2 to capture the build command for that file.
* use a differencing tool to inspect the differences between the two invocations
* inspecting the differences, I saw a missing `-mcpu=cortex-m4` I tested by adding that to the Swan build command. The file built fine (stopping at the hard error, but no other warnings.)
A grep through the sources revealed where this flag was being set for the stm ports.
With this commit, the build gets further, but does not complete. The next exciting episode in this unfolding coding saga is just a commit away!
working build with minimal set of modules for the Blues Swan r5
chore:change header copyright name to Blues Wireless Contributors
USB operational. Fixed up clocks to be hardwired for LSE no HSE case. (Trying to combine HSE in there made the code much more complex, and I don't have a board to test it out on.)
USART working
adds support for `ENABLE_3V3` and `DISCHARGE_3V3` pins. I am surprised that pin definitions are quite low-level and don't include default direction and state, so the code currently has to initialize `ENABLE_3V3` pin as output. The LED takes over a second to discharge, so I wonder if the board startup code is not having the desired affect.
short circuit implementation of backup memory for the STM32L4
all the ports
remove company name from board name to be consistent with the Arduino board definition.
add default pins for I2C, SPI and UART, so that `board.I2C` et al. works as expected. Confirmed I2C timing.
fix board name
fix incorrect pin definition. add test to allow manual check of each output pin
analog IO
code changes for WebUSB. Doesn't appear to work, will revisit later.
ensure that `sys.platform` is available
checkin missing file
feat: make room for a larger filesystem so the sensor tutorial will fit on the device.
fix:(stm32l4r5zi.csv): merged AF0-7 and AF8-15 into single lines and removed extraneous headers mixed in with the data.
fix(parse_af_csv.py): pin index in the csv is 0 not 1, and AF index made 1 larger
chore(Swan R5): update peripherals pins from `parse_af_csv.py` output
optimize flash sector access
2021-07-29 18:06:31 -04:00
|
|
|
};
|
|
|
|
|
2021-09-28 17:13:04 -04:00
|
|
|
uint8_t const *tud_descriptor_bos_cb(void) {
|
|
|
|
return desc_bos;
|
feat: add Blues Swan R5 support
complete pin mapping for Feather pins
stubbed out files needed for complilation. still to be modified
0 out all CPY modules in mpconfigboard.mk until we get the build running
add csv for pin generation for STM32L4R5
add F4R5 references in peripherals files
refactored out board files BECAUSE I AM AN IDIOT; add L4 series system clocks file from CubeMX
took a guess at the number of USB endpoint pairs to get the build done
guess was close, but wrong. It is 8
clean up peripheral DEFs
Fixes build error:
```
In file included from ../../py/mpstate.h:33,
from ../../py/mpstate.c:27:
../../py/misc.h: In function 'vstr_str':
../../py/misc.h:196:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
static inline char *vstr_str(vstr_t *vstr) {
^~~~~~
```
Sleuthing steps:
* verify that the feather_stm32f4_express board builds correctly
* put a `#error` at the bottom of the `mpstate.c` file.
* build for the feather and swan boards, with V=2 to capture the build command for that file.
* use a differencing tool to inspect the differences between the two invocations
* inspecting the differences, I saw a missing `-mcpu=cortex-m4` I tested by adding that to the Swan build command. The file built fine (stopping at the hard error, but no other warnings.)
A grep through the sources revealed where this flag was being set for the stm ports.
With this commit, the build gets further, but does not complete. The next exciting episode in this unfolding coding saga is just a commit away!
working build with minimal set of modules for the Blues Swan r5
chore:change header copyright name to Blues Wireless Contributors
USB operational. Fixed up clocks to be hardwired for LSE no HSE case. (Trying to combine HSE in there made the code much more complex, and I don't have a board to test it out on.)
USART working
adds support for `ENABLE_3V3` and `DISCHARGE_3V3` pins. I am surprised that pin definitions are quite low-level and don't include default direction and state, so the code currently has to initialize `ENABLE_3V3` pin as output. The LED takes over a second to discharge, so I wonder if the board startup code is not having the desired affect.
short circuit implementation of backup memory for the STM32L4
all the ports
remove company name from board name to be consistent with the Arduino board definition.
add default pins for I2C, SPI and UART, so that `board.I2C` et al. works as expected. Confirmed I2C timing.
fix board name
fix incorrect pin definition. add test to allow manual check of each output pin
analog IO
code changes for WebUSB. Doesn't appear to work, will revisit later.
ensure that `sys.platform` is available
checkin missing file
feat: make room for a larger filesystem so the sensor tutorial will fit on the device.
fix:(stm32l4r5zi.csv): merged AF0-7 and AF8-15 into single lines and removed extraneous headers mixed in with the data.
fix(parse_af_csv.py): pin index in the csv is 0 not 1, and AF index made 1 larger
chore(Swan R5): update peripherals pins from `parse_af_csv.py` output
optimize flash sector access
2021-07-29 18:06:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define MS_OS_20_ITF_NUM_MAGIC 0x5b
|
|
|
|
#define MS_OS_20_ITF_NUM_OFFSET 22
|
|
|
|
|
|
|
|
const uint8_t ms_os_20_descriptor_template[] =
|
|
|
|
{
|
2021-09-28 17:13:04 -04:00
|
|
|
// 10 Set header: length, type, windows version, total length
|
|
|
|
U16_TO_U8S_LE(0x000A), U16_TO_U8S_LE(MS_OS_20_SET_HEADER_DESCRIPTOR), U32_TO_U8S_LE(0x06030000), U16_TO_U8S_LE(MS_OS_20_DESC_LEN),
|
|
|
|
|
|
|
|
// 8 Configuration subset header: length, type, configuration index, reserved, configuration total length
|
|
|
|
U16_TO_U8S_LE(0x0008), U16_TO_U8S_LE(MS_OS_20_SUBSET_HEADER_CONFIGURATION), 0, 0, U16_TO_U8S_LE(MS_OS_20_DESC_LEN - 0x0A),
|
|
|
|
|
|
|
|
// 8 Function Subset header: length, type, first interface, reserved, subset length
|
|
|
|
U16_TO_U8S_LE(0x0008), U16_TO_U8S_LE(MS_OS_20_SUBSET_HEADER_FUNCTION), /* 22 */ MS_OS_20_ITF_NUM_MAGIC, 0, U16_TO_U8S_LE(MS_OS_20_DESC_LEN - 0x0A - 0x08),
|
|
|
|
|
|
|
|
// 20 MS OS 2.0 Compatible ID descriptor: length, type, compatible ID, sub compatible ID
|
|
|
|
U16_TO_U8S_LE(0x0014), U16_TO_U8S_LE(MS_OS_20_FEATURE_COMPATBLE_ID), 'W', 'I', 'N', 'U', 'S', 'B', 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // sub-compatible
|
|
|
|
|
|
|
|
// MS OS 2.0 Registry property descriptor: length, type
|
|
|
|
U16_TO_U8S_LE(MS_OS_20_DESC_LEN - 0x0A - 0x08 - 0x08 - 0x14), U16_TO_U8S_LE(MS_OS_20_FEATURE_REG_PROPERTY),
|
|
|
|
U16_TO_U8S_LE(0x0007), U16_TO_U8S_LE(0x002A), // wPropertyDataType, wPropertyNameLength and PropertyName "DeviceInterfaceGUIDs\0" in UTF-16
|
|
|
|
'D', 0x00, 'e', 0x00, 'v', 0x00, 'i', 0x00, 'c', 0x00, 'e', 0x00, 'I', 0x00, 'n', 0x00, 't', 0x00, 'e', 0x00,
|
|
|
|
'r', 0x00, 'f', 0x00, 'a', 0x00, 'c', 0x00, 'e', 0x00, 'G', 0x00, 'U', 0x00, 'I', 0x00, 'D', 0x00, 's', 0x00, 0x00, 0x00,
|
|
|
|
U16_TO_U8S_LE(0x0050), // wPropertyDataLength
|
|
|
|
// bPropertyData: “{975F44D9-0D08-43FD-8B3E-127CA8AFFF9D}”.
|
|
|
|
'{', 0x00, '9', 0x00, '7', 0x00, '5', 0x00, 'F', 0x00, '4', 0x00, '4', 0x00, 'D', 0x00, '9', 0x00, '-', 0x00,
|
|
|
|
'0', 0x00, 'D', 0x00, '0', 0x00, '8', 0x00, '-', 0x00, '4', 0x00, '3', 0x00, 'F', 0x00, 'D', 0x00, '-', 0x00,
|
|
|
|
'8', 0x00, 'B', 0x00, '3', 0x00, 'E', 0x00, '-', 0x00, '1', 0x00, '2', 0x00, '7', 0x00, 'C', 0x00, 'A', 0x00,
|
|
|
|
'8', 0x00, 'A', 0x00, 'F', 0x00, 'F', 0x00, 'F', 0x00, '9', 0x00, 'D', 0x00, '}', 0x00, 0x00, 0x00, 0x00, 0x00
|
feat: add Blues Swan R5 support
complete pin mapping for Feather pins
stubbed out files needed for complilation. still to be modified
0 out all CPY modules in mpconfigboard.mk until we get the build running
add csv for pin generation for STM32L4R5
add F4R5 references in peripherals files
refactored out board files BECAUSE I AM AN IDIOT; add L4 series system clocks file from CubeMX
took a guess at the number of USB endpoint pairs to get the build done
guess was close, but wrong. It is 8
clean up peripheral DEFs
Fixes build error:
```
In file included from ../../py/mpstate.h:33,
from ../../py/mpstate.c:27:
../../py/misc.h: In function 'vstr_str':
../../py/misc.h:196:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
static inline char *vstr_str(vstr_t *vstr) {
^~~~~~
```
Sleuthing steps:
* verify that the feather_stm32f4_express board builds correctly
* put a `#error` at the bottom of the `mpstate.c` file.
* build for the feather and swan boards, with V=2 to capture the build command for that file.
* use a differencing tool to inspect the differences between the two invocations
* inspecting the differences, I saw a missing `-mcpu=cortex-m4` I tested by adding that to the Swan build command. The file built fine (stopping at the hard error, but no other warnings.)
A grep through the sources revealed where this flag was being set for the stm ports.
With this commit, the build gets further, but does not complete. The next exciting episode in this unfolding coding saga is just a commit away!
working build with minimal set of modules for the Blues Swan r5
chore:change header copyright name to Blues Wireless Contributors
USB operational. Fixed up clocks to be hardwired for LSE no HSE case. (Trying to combine HSE in there made the code much more complex, and I don't have a board to test it out on.)
USART working
adds support for `ENABLE_3V3` and `DISCHARGE_3V3` pins. I am surprised that pin definitions are quite low-level and don't include default direction and state, so the code currently has to initialize `ENABLE_3V3` pin as output. The LED takes over a second to discharge, so I wonder if the board startup code is not having the desired affect.
short circuit implementation of backup memory for the STM32L4
all the ports
remove company name from board name to be consistent with the Arduino board definition.
add default pins for I2C, SPI and UART, so that `board.I2C` et al. works as expected. Confirmed I2C timing.
fix board name
fix incorrect pin definition. add test to allow manual check of each output pin
analog IO
code changes for WebUSB. Doesn't appear to work, will revisit later.
ensure that `sys.platform` is available
checkin missing file
feat: make room for a larger filesystem so the sensor tutorial will fit on the device.
fix:(stm32l4r5zi.csv): merged AF0-7 and AF8-15 into single lines and removed extraneous headers mixed in with the data.
fix(parse_af_csv.py): pin index in the csv is 0 not 1, and AF index made 1 larger
chore(Swan R5): update peripherals pins from `parse_af_csv.py` output
optimize flash sector access
2021-07-29 18:06:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
TU_VERIFY_STATIC(sizeof(ms_os_20_descriptor_template) == MS_OS_20_DESC_LEN, "Incorrect size");
|
|
|
|
|
|
|
|
static const uint8_t usb_vendor_descriptor_template[] = {
|
|
|
|
// Vendor Descriptor
|
|
|
|
0x09, // 0 bLength
|
|
|
|
0x04, // 1 bDescriptorType (Interface)
|
|
|
|
0xFF, // 2 bInterfaceNumber [SET AT RUNTIME]
|
|
|
|
#define VENDOR_INTERFACE_INDEX 2
|
|
|
|
0x00, // 3 bAlternateSetting
|
|
|
|
0x02, // 4 bNumEndpoints 2
|
|
|
|
0xFF, // 5 bInterfaceClass: Vendor Specific
|
|
|
|
0x00, // 6 bInterfaceSubClass: NONE
|
|
|
|
0x00, // 7 bInterfaceProtocol: NONE
|
|
|
|
0xFF, // 8 iInterface (String Index)
|
|
|
|
#define VENDOR_INTERFACE_STRING_INDEX 8
|
|
|
|
|
|
|
|
// Vendor OUT Endpoint Descriptor
|
|
|
|
0x07, // 9 bLength
|
|
|
|
0x05, // 10 bDescriptorType (Endpoint)
|
|
|
|
0xFF, // 11 bEndpointAddress (IN/D2H) [SET AT RUNTIME: number]
|
|
|
|
#define VENDOR_OUT_ENDPOINT_INDEX 11
|
|
|
|
0x02, // 12 bmAttributes (Bulk)
|
2021-09-28 17:13:04 -04:00
|
|
|
#if USB_HIGHSPEED
|
feat: add Blues Swan R5 support
complete pin mapping for Feather pins
stubbed out files needed for complilation. still to be modified
0 out all CPY modules in mpconfigboard.mk until we get the build running
add csv for pin generation for STM32L4R5
add F4R5 references in peripherals files
refactored out board files BECAUSE I AM AN IDIOT; add L4 series system clocks file from CubeMX
took a guess at the number of USB endpoint pairs to get the build done
guess was close, but wrong. It is 8
clean up peripheral DEFs
Fixes build error:
```
In file included from ../../py/mpstate.h:33,
from ../../py/mpstate.c:27:
../../py/misc.h: In function 'vstr_str':
../../py/misc.h:196:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
static inline char *vstr_str(vstr_t *vstr) {
^~~~~~
```
Sleuthing steps:
* verify that the feather_stm32f4_express board builds correctly
* put a `#error` at the bottom of the `mpstate.c` file.
* build for the feather and swan boards, with V=2 to capture the build command for that file.
* use a differencing tool to inspect the differences between the two invocations
* inspecting the differences, I saw a missing `-mcpu=cortex-m4` I tested by adding that to the Swan build command. The file built fine (stopping at the hard error, but no other warnings.)
A grep through the sources revealed where this flag was being set for the stm ports.
With this commit, the build gets further, but does not complete. The next exciting episode in this unfolding coding saga is just a commit away!
working build with minimal set of modules for the Blues Swan r5
chore:change header copyright name to Blues Wireless Contributors
USB operational. Fixed up clocks to be hardwired for LSE no HSE case. (Trying to combine HSE in there made the code much more complex, and I don't have a board to test it out on.)
USART working
adds support for `ENABLE_3V3` and `DISCHARGE_3V3` pins. I am surprised that pin definitions are quite low-level and don't include default direction and state, so the code currently has to initialize `ENABLE_3V3` pin as output. The LED takes over a second to discharge, so I wonder if the board startup code is not having the desired affect.
short circuit implementation of backup memory for the STM32L4
all the ports
remove company name from board name to be consistent with the Arduino board definition.
add default pins for I2C, SPI and UART, so that `board.I2C` et al. works as expected. Confirmed I2C timing.
fix board name
fix incorrect pin definition. add test to allow manual check of each output pin
analog IO
code changes for WebUSB. Doesn't appear to work, will revisit later.
ensure that `sys.platform` is available
checkin missing file
feat: make room for a larger filesystem so the sensor tutorial will fit on the device.
fix:(stm32l4r5zi.csv): merged AF0-7 and AF8-15 into single lines and removed extraneous headers mixed in with the data.
fix(parse_af_csv.py): pin index in the csv is 0 not 1, and AF index made 1 larger
chore(Swan R5): update peripherals pins from `parse_af_csv.py` output
optimize flash sector access
2021-07-29 18:06:31 -04:00
|
|
|
0x00, 0x02, // 13,14 wMaxPacketSize 512
|
2021-09-28 17:13:04 -04:00
|
|
|
#else
|
feat: add Blues Swan R5 support
complete pin mapping for Feather pins
stubbed out files needed for complilation. still to be modified
0 out all CPY modules in mpconfigboard.mk until we get the build running
add csv for pin generation for STM32L4R5
add F4R5 references in peripherals files
refactored out board files BECAUSE I AM AN IDIOT; add L4 series system clocks file from CubeMX
took a guess at the number of USB endpoint pairs to get the build done
guess was close, but wrong. It is 8
clean up peripheral DEFs
Fixes build error:
```
In file included from ../../py/mpstate.h:33,
from ../../py/mpstate.c:27:
../../py/misc.h: In function 'vstr_str':
../../py/misc.h:196:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
static inline char *vstr_str(vstr_t *vstr) {
^~~~~~
```
Sleuthing steps:
* verify that the feather_stm32f4_express board builds correctly
* put a `#error` at the bottom of the `mpstate.c` file.
* build for the feather and swan boards, with V=2 to capture the build command for that file.
* use a differencing tool to inspect the differences between the two invocations
* inspecting the differences, I saw a missing `-mcpu=cortex-m4` I tested by adding that to the Swan build command. The file built fine (stopping at the hard error, but no other warnings.)
A grep through the sources revealed where this flag was being set for the stm ports.
With this commit, the build gets further, but does not complete. The next exciting episode in this unfolding coding saga is just a commit away!
working build with minimal set of modules for the Blues Swan r5
chore:change header copyright name to Blues Wireless Contributors
USB operational. Fixed up clocks to be hardwired for LSE no HSE case. (Trying to combine HSE in there made the code much more complex, and I don't have a board to test it out on.)
USART working
adds support for `ENABLE_3V3` and `DISCHARGE_3V3` pins. I am surprised that pin definitions are quite low-level and don't include default direction and state, so the code currently has to initialize `ENABLE_3V3` pin as output. The LED takes over a second to discharge, so I wonder if the board startup code is not having the desired affect.
short circuit implementation of backup memory for the STM32L4
all the ports
remove company name from board name to be consistent with the Arduino board definition.
add default pins for I2C, SPI and UART, so that `board.I2C` et al. works as expected. Confirmed I2C timing.
fix board name
fix incorrect pin definition. add test to allow manual check of each output pin
analog IO
code changes for WebUSB. Doesn't appear to work, will revisit later.
ensure that `sys.platform` is available
checkin missing file
feat: make room for a larger filesystem so the sensor tutorial will fit on the device.
fix:(stm32l4r5zi.csv): merged AF0-7 and AF8-15 into single lines and removed extraneous headers mixed in with the data.
fix(parse_af_csv.py): pin index in the csv is 0 not 1, and AF index made 1 larger
chore(Swan R5): update peripherals pins from `parse_af_csv.py` output
optimize flash sector access
2021-07-29 18:06:31 -04:00
|
|
|
0x40, 0x00, // 13,14 wMaxPacketSize 64
|
2021-09-28 17:13:04 -04:00
|
|
|
#endif
|
feat: add Blues Swan R5 support
complete pin mapping for Feather pins
stubbed out files needed for complilation. still to be modified
0 out all CPY modules in mpconfigboard.mk until we get the build running
add csv for pin generation for STM32L4R5
add F4R5 references in peripherals files
refactored out board files BECAUSE I AM AN IDIOT; add L4 series system clocks file from CubeMX
took a guess at the number of USB endpoint pairs to get the build done
guess was close, but wrong. It is 8
clean up peripheral DEFs
Fixes build error:
```
In file included from ../../py/mpstate.h:33,
from ../../py/mpstate.c:27:
../../py/misc.h: In function 'vstr_str':
../../py/misc.h:196:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
static inline char *vstr_str(vstr_t *vstr) {
^~~~~~
```
Sleuthing steps:
* verify that the feather_stm32f4_express board builds correctly
* put a `#error` at the bottom of the `mpstate.c` file.
* build for the feather and swan boards, with V=2 to capture the build command for that file.
* use a differencing tool to inspect the differences between the two invocations
* inspecting the differences, I saw a missing `-mcpu=cortex-m4` I tested by adding that to the Swan build command. The file built fine (stopping at the hard error, but no other warnings.)
A grep through the sources revealed where this flag was being set for the stm ports.
With this commit, the build gets further, but does not complete. The next exciting episode in this unfolding coding saga is just a commit away!
working build with minimal set of modules for the Blues Swan r5
chore:change header copyright name to Blues Wireless Contributors
USB operational. Fixed up clocks to be hardwired for LSE no HSE case. (Trying to combine HSE in there made the code much more complex, and I don't have a board to test it out on.)
USART working
adds support for `ENABLE_3V3` and `DISCHARGE_3V3` pins. I am surprised that pin definitions are quite low-level and don't include default direction and state, so the code currently has to initialize `ENABLE_3V3` pin as output. The LED takes over a second to discharge, so I wonder if the board startup code is not having the desired affect.
short circuit implementation of backup memory for the STM32L4
all the ports
remove company name from board name to be consistent with the Arduino board definition.
add default pins for I2C, SPI and UART, so that `board.I2C` et al. works as expected. Confirmed I2C timing.
fix board name
fix incorrect pin definition. add test to allow manual check of each output pin
analog IO
code changes for WebUSB. Doesn't appear to work, will revisit later.
ensure that `sys.platform` is available
checkin missing file
feat: make room for a larger filesystem so the sensor tutorial will fit on the device.
fix:(stm32l4r5zi.csv): merged AF0-7 and AF8-15 into single lines and removed extraneous headers mixed in with the data.
fix(parse_af_csv.py): pin index in the csv is 0 not 1, and AF index made 1 larger
chore(Swan R5): update peripherals pins from `parse_af_csv.py` output
optimize flash sector access
2021-07-29 18:06:31 -04:00
|
|
|
0x0, // 15 bInterval 0
|
|
|
|
|
|
|
|
// Vendor IN Endpoint Descriptor
|
|
|
|
0x07, // 16 bLength
|
|
|
|
0x05, // 17 bDescriptorType (Endpoint)
|
|
|
|
0xFF, // 18 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | number]
|
|
|
|
#define VENDOR_IN_ENDPOINT_INDEX 18
|
|
|
|
0x02, // 19 bmAttributes (Bulk)
|
|
|
|
0x40, 0x00, // 20, 21 wMaxPacketSize 64
|
|
|
|
0x0 // 22 bInterval 0
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char vendor_interface_name[] = USB_INTERFACE_NAME " WebUSB";
|
|
|
|
|
|
|
|
|
|
|
|
bool usb_vendor_enabled(void) {
|
|
|
|
return usb_cdc_console_enabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t usb_vendor_descriptor_length(void) {
|
|
|
|
return sizeof(usb_vendor_descriptor_template);
|
|
|
|
}
|
|
|
|
|
|
|
|
static supervisor_allocation *ms_os_20_descriptor_allocation;
|
|
|
|
|
|
|
|
size_t vendor_ms_os_20_descriptor_length() {
|
|
|
|
return sizeof(ms_os_20_descriptor_template);
|
|
|
|
}
|
2021-09-28 17:13:04 -04:00
|
|
|
uint8_t const *vendor_ms_os_20_descriptor() {
|
feat: add Blues Swan R5 support
complete pin mapping for Feather pins
stubbed out files needed for complilation. still to be modified
0 out all CPY modules in mpconfigboard.mk until we get the build running
add csv for pin generation for STM32L4R5
add F4R5 references in peripherals files
refactored out board files BECAUSE I AM AN IDIOT; add L4 series system clocks file from CubeMX
took a guess at the number of USB endpoint pairs to get the build done
guess was close, but wrong. It is 8
clean up peripheral DEFs
Fixes build error:
```
In file included from ../../py/mpstate.h:33,
from ../../py/mpstate.c:27:
../../py/misc.h: In function 'vstr_str':
../../py/misc.h:196:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
static inline char *vstr_str(vstr_t *vstr) {
^~~~~~
```
Sleuthing steps:
* verify that the feather_stm32f4_express board builds correctly
* put a `#error` at the bottom of the `mpstate.c` file.
* build for the feather and swan boards, with V=2 to capture the build command for that file.
* use a differencing tool to inspect the differences between the two invocations
* inspecting the differences, I saw a missing `-mcpu=cortex-m4` I tested by adding that to the Swan build command. The file built fine (stopping at the hard error, but no other warnings.)
A grep through the sources revealed where this flag was being set for the stm ports.
With this commit, the build gets further, but does not complete. The next exciting episode in this unfolding coding saga is just a commit away!
working build with minimal set of modules for the Blues Swan r5
chore:change header copyright name to Blues Wireless Contributors
USB operational. Fixed up clocks to be hardwired for LSE no HSE case. (Trying to combine HSE in there made the code much more complex, and I don't have a board to test it out on.)
USART working
adds support for `ENABLE_3V3` and `DISCHARGE_3V3` pins. I am surprised that pin definitions are quite low-level and don't include default direction and state, so the code currently has to initialize `ENABLE_3V3` pin as output. The LED takes over a second to discharge, so I wonder if the board startup code is not having the desired affect.
short circuit implementation of backup memory for the STM32L4
all the ports
remove company name from board name to be consistent with the Arduino board definition.
add default pins for I2C, SPI and UART, so that `board.I2C` et al. works as expected. Confirmed I2C timing.
fix board name
fix incorrect pin definition. add test to allow manual check of each output pin
analog IO
code changes for WebUSB. Doesn't appear to work, will revisit later.
ensure that `sys.platform` is available
checkin missing file
feat: make room for a larger filesystem so the sensor tutorial will fit on the device.
fix:(stm32l4r5zi.csv): merged AF0-7 and AF8-15 into single lines and removed extraneous headers mixed in with the data.
fix(parse_af_csv.py): pin index in the csv is 0 not 1, and AF index made 1 larger
chore(Swan R5): update peripherals pins from `parse_af_csv.py` output
optimize flash sector access
2021-07-29 18:06:31 -04:00
|
|
|
return (uint8_t *)ms_os_20_descriptor_allocation->ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
size_t usb_vendor_add_descriptor(uint8_t *descriptor_buf, descriptor_counts_t *descriptor_counts, uint8_t *current_interface_string) {
|
|
|
|
|
2021-09-28 17:13:04 -04:00
|
|
|
if (ms_os_20_descriptor_template[MS_OS_20_ITF_NUM_OFFSET] == MS_OS_20_ITF_NUM_MAGIC) {
|
|
|
|
ms_os_20_descriptor_allocation =
|
feat: add Blues Swan R5 support
complete pin mapping for Feather pins
stubbed out files needed for complilation. still to be modified
0 out all CPY modules in mpconfigboard.mk until we get the build running
add csv for pin generation for STM32L4R5
add F4R5 references in peripherals files
refactored out board files BECAUSE I AM AN IDIOT; add L4 series system clocks file from CubeMX
took a guess at the number of USB endpoint pairs to get the build done
guess was close, but wrong. It is 8
clean up peripheral DEFs
Fixes build error:
```
In file included from ../../py/mpstate.h:33,
from ../../py/mpstate.c:27:
../../py/misc.h: In function 'vstr_str':
../../py/misc.h:196:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
static inline char *vstr_str(vstr_t *vstr) {
^~~~~~
```
Sleuthing steps:
* verify that the feather_stm32f4_express board builds correctly
* put a `#error` at the bottom of the `mpstate.c` file.
* build for the feather and swan boards, with V=2 to capture the build command for that file.
* use a differencing tool to inspect the differences between the two invocations
* inspecting the differences, I saw a missing `-mcpu=cortex-m4` I tested by adding that to the Swan build command. The file built fine (stopping at the hard error, but no other warnings.)
A grep through the sources revealed where this flag was being set for the stm ports.
With this commit, the build gets further, but does not complete. The next exciting episode in this unfolding coding saga is just a commit away!
working build with minimal set of modules for the Blues Swan r5
chore:change header copyright name to Blues Wireless Contributors
USB operational. Fixed up clocks to be hardwired for LSE no HSE case. (Trying to combine HSE in there made the code much more complex, and I don't have a board to test it out on.)
USART working
adds support for `ENABLE_3V3` and `DISCHARGE_3V3` pins. I am surprised that pin definitions are quite low-level and don't include default direction and state, so the code currently has to initialize `ENABLE_3V3` pin as output. The LED takes over a second to discharge, so I wonder if the board startup code is not having the desired affect.
short circuit implementation of backup memory for the STM32L4
all the ports
remove company name from board name to be consistent with the Arduino board definition.
add default pins for I2C, SPI and UART, so that `board.I2C` et al. works as expected. Confirmed I2C timing.
fix board name
fix incorrect pin definition. add test to allow manual check of each output pin
analog IO
code changes for WebUSB. Doesn't appear to work, will revisit later.
ensure that `sys.platform` is available
checkin missing file
feat: make room for a larger filesystem so the sensor tutorial will fit on the device.
fix:(stm32l4r5zi.csv): merged AF0-7 and AF8-15 into single lines and removed extraneous headers mixed in with the data.
fix(parse_af_csv.py): pin index in the csv is 0 not 1, and AF index made 1 larger
chore(Swan R5): update peripherals pins from `parse_af_csv.py` output
optimize flash sector access
2021-07-29 18:06:31 -04:00
|
|
|
allocate_memory(align32_size(sizeof(ms_os_20_descriptor_template)),
|
|
|
|
/*high_address*/ false, /*movable*/ false);
|
|
|
|
uint8_t *ms_os_20_descriptor_buf = (uint8_t *)ms_os_20_descriptor_allocation->ptr;
|
|
|
|
memcpy(ms_os_20_descriptor_buf, ms_os_20_descriptor_template, sizeof(ms_os_20_descriptor_template));
|
|
|
|
ms_os_20_descriptor_buf[MS_OS_20_ITF_NUM_OFFSET] = descriptor_counts->current_interface;
|
|
|
|
ms_os_20_descriptor_buf[VENDOR_IN_ENDPOINT_INDEX] = 0x80 | descriptor_counts->current_endpoint;
|
|
|
|
ms_os_20_descriptor_buf[VENDOR_OUT_ENDPOINT_INDEX] = descriptor_counts->current_endpoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(descriptor_buf, usb_vendor_descriptor_template, sizeof(usb_vendor_descriptor_template));
|
|
|
|
|
|
|
|
descriptor_buf[VENDOR_INTERFACE_INDEX] = descriptor_counts->current_interface;
|
|
|
|
descriptor_counts->current_interface++;
|
|
|
|
|
|
|
|
descriptor_buf[VENDOR_IN_ENDPOINT_INDEX] = 0x80 | descriptor_counts->current_endpoint;
|
|
|
|
descriptor_counts->num_in_endpoints++;
|
|
|
|
descriptor_buf[VENDOR_OUT_ENDPOINT_INDEX] = descriptor_counts->current_endpoint;
|
|
|
|
descriptor_counts->num_out_endpoints++;
|
|
|
|
descriptor_counts->current_endpoint++;
|
|
|
|
|
|
|
|
usb_add_interface_string(*current_interface_string, vendor_interface_name);
|
|
|
|
descriptor_buf[VENDOR_INTERFACE_STRING_INDEX] = *current_interface_string;
|
|
|
|
(*current_interface_string)++;
|
|
|
|
|
|
|
|
return sizeof(usb_vendor_descriptor_template);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-09-28 12:53:26 -04:00
|
|
|
#endif
|