Skip to content

Commit 43f7ca7

Browse files
committed
Incorporate feedback:
* Clean up board defines. * Add flush on eject and stay ejected. * Swith back to NONE protocol for CDC.
1 parent 688f0e3 commit 43f7ca7

File tree

10 files changed

+23
-16
lines changed

10 files changed

+23
-16
lines changed

ports/atmel-samd/boards/arduino_zero/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define MICROPY_HW_LED_TX &pin_PA27
66
#define MICROPY_HW_LED_RX &pin_PB03
77

8-
#define MICROPY_PORT_A (PORT_PA24 | PORT_PA25 | PORT_PA27)
8+
#define MICROPY_PORT_A (PORT_PA27)
99
#define MICROPY_PORT_B (PORT_PB03)
1010
#define MICROPY_PORT_C (0)
1111

ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#define SPI_FLASH_CS_PIN &pin_PB22
1515

1616
// These are pins not to reset.
17-
// PA24 and PA25 are USB.
1817
#define MICROPY_PORT_A (0)
1918
#define MICROPY_PORT_B (0)
2019
#define MICROPY_PORT_C (0)

ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
#define SPI_FLASH_CS_PIN &pin_PA07
1010

1111
// These are pins not to reset.
12+
// NeoPixel and for the display: Reset, Command or data, and Chip select
1213
#define MICROPY_PORT_A ( PORT_PA01 | PORT_PA12 | PORT_PA27 | PORT_PA28)
14+
// Data and Clock for the display
1315
#define MICROPY_PORT_B ( PORT_PB22 | PORT_PB23 )
1416
#define MICROPY_PORT_C ( 0 )
1517

ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#define MICROPY_HW_BOARD_NAME "Adafruit Metro M0 Express"
22
#define MICROPY_HW_MCU_NAME "samd21g18"
33

4-
//#define MICROPY_HW_LED_TX &pin_PA27
5-
//#define MICROPY_HW_LED_RX &pin_PA31
4+
#define MICROPY_HW_LED_TX &pin_PA27
5+
// Comment this out if you have trouble connecting over SWD. It's one of the SWD pins.
6+
#define MICROPY_HW_LED_RX &pin_PA31
67

78
#define MICROPY_HW_NEOPIXEL (&pin_PA30)
89

@@ -15,7 +16,7 @@
1516
#define SPI_FLASH_CS_PIN &pin_PA13
1617

1718
// These are pins not to reset.
18-
#define MICROPY_PORT_A (PORT_PA24 | PORT_PA25 | PORT_PA30 | PORT_PA31)
19+
#define MICROPY_PORT_A (0)
1920
#define MICROPY_PORT_B (0)
2021
#define MICROPY_PORT_C (0)
2122

ports/atmel-samd/boards/trinket_m0/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define MICROPY_HW_APA102_MOSI (&pin_PA00)
66
#define MICROPY_HW_APA102_SCK (&pin_PA01)
77

8-
#define MICROPY_PORT_A (PORT_PA00 | PORT_PA01 | PORT_PA24 | PORT_PA25)
8+
#define MICROPY_PORT_A (PORT_PA00 | PORT_PA01)
99
#define MICROPY_PORT_B (0)
1010
#define MICROPY_PORT_C (0)
1111

ports/atmel-samd/common-hal/microcontroller/Pin.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,7 @@ void reset_all_pins(void) {
5353
// Do not full reset USB or SWD lines.
5454
pin_mask[0] &= ~(PORT_PA24 | PORT_PA25 | PORT_PA30 | PORT_PA31);
5555

56-
#ifdef SAMD21
57-
pin_mask[0] &= ~(PORT_PA31);
58-
#endif
59-
6056
for (uint32_t i = 0; i < PORT_COUNT; i++) {
61-
pin_mask[i] &= ~(PORT_PA31);
6257
pin_mask[i] &= ~never_reset_pins[i];
6358
}
6459

supervisor/shared/external_flash/external_flash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* The MIT License (MIT)
55
*
6-
* Copyright (c) 2013, 2014 Damien P. George
6+
* Copyright (c) 2018 Scott Shawcroft for Adafruit Industries LLC
77
*
88
* Permission is hereby granted, free of charge, to any person obtaining a copy
99
* of this software and associated documentation files (the "Software"), to deal

supervisor/shared/usb/usb_msc_flash.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838

3939
#define MSC_FLASH_BLOCK_SIZE 512
4040

41+
static bool ejected[1];
42+
4143
// The root FS is always at the end of the list.
4244
static fs_user_mount_t* get_vfs(int lun) {
4345
// TODO(tannewt): Return the mount which matches the lun where 0 is the end
@@ -60,7 +62,7 @@ static fs_user_mount_t* get_vfs(int lun) {
6062
// - READ10 and WRITE10 have their own callbacks
6163
int32_t tud_msc_scsi_cb (uint8_t lun, const uint8_t scsi_cmd[16], void* buffer, uint16_t bufsize) {
6264
const void* response = NULL;
63-
uint16_t resplen = 0;
65+
int32_t resplen = 0;
6466

6567
switch ( scsi_cmd[0] ) {
6668
case SCSI_CMD_TEST_UNIT_READY:
@@ -73,6 +75,9 @@ int32_t tud_msc_scsi_cb (uint8_t lun, const uint8_t scsi_cmd[16], void* buffer,
7375
if (current_mount == NULL) {
7476
resplen = -1;
7577
}
78+
if (ejected[lun]) {
79+
resplen = -1;
80+
}
7681
}
7782
break;
7883

@@ -96,6 +101,11 @@ int32_t tud_msc_scsi_cb (uint8_t lun, const uint8_t scsi_cmd[16], void* buffer,
96101
if (current_mount == NULL) {
97102
resplen = -1;
98103
}
104+
if (disk_ioctl(current_mount, CTRL_SYNC, NULL) != RES_OK) {
105+
resplen = -1;
106+
} else {
107+
ejected[lun] = true;
108+
}
99109
}
100110
}
101111
}

tools/gen_usb_descriptor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def strings_in_order(cls):
8080
description="CDC comm",
8181
bInterfaceClass=cdc.CDC_CLASS_COMM, # Communications Device Class
8282
bInterfaceSubClass=cdc.CDC_SUBCLASS_ACM, # Abstract control model
83-
bInterfaceProtocol=cdc.CDC_PROTOCOL_V25TER,
83+
bInterfaceProtocol=cdc.CDC_PROTOCOL_NONE,
8484
iInterface=StringIndex.index("CircuitPython CDC control"),
8585
subdescriptors=[
8686
cdc.Header(
@@ -254,7 +254,7 @@ def strings_in_order(cls):
254254
bInterfaceCount=len(cdc_interfaces),
255255
bFunctionClass=cdc.CDC_CLASS_COMM, # Communications Device Class
256256
bFunctionSubClass=cdc.CDC_SUBCLASS_ACM, # Abstract control model
257-
bFunctionProtocol=cdc.CDC_PROTOCOL_V25TER) # TODO(tannewt): can this be NONE (aka 0)?
257+
bFunctionProtocol=cdc.CDC_PROTOCOL_NONE)
258258

259259
# audio_iad = standard.InterfaceAssociationDescriptor(
260260
# description="Audio IAD",

0 commit comments

Comments
 (0)