File tree Expand file tree Collapse file tree 12 files changed +127
-26
lines changed
circuitplayground_express Expand file tree Collapse file tree 12 files changed +127
-26
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,7 @@ SRC_C = \
190190 main.c \
191191 moduos.c \
192192 mphalport.c \
193+ reset.c \
193194 samd21_pins.c \
194195 shared_dma.c \
195196 rgb_led_status.c \
Original file line number Diff line number Diff line change 22#include <stdbool.h>
33#include <stdint.h>
44
5+ #include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6+
57#ifndef CONF_USB_H_INCLUDED
68#define CONF_USB_H_INCLUDED
79
@@ -55,7 +57,8 @@ extern void mp_cdc_disable(uint8_t port);
5557
5658#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
5759void usb_rx_notify (void );
58- #define UDI_CDC_SET_CODING_EXT (port ,cfg )
60+ #define UDI_CDC_SET_CODING_EXT (port ,cfg ) usb_coding_notify(port, cfg)
61+ void usb_coding_notify (uint8_t port , usb_cdc_line_coding_t * coding );
5962#define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
6063void usb_dtr_notify (uint8_t port , bool set );
6164#define UDI_CDC_SET_RTS_EXT (port ,set ) usb_rts_notify(port, set)
Original file line number Diff line number Diff line change 22#include <stdbool.h>
33#include <stdint.h>
44
5+ #include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6+
57#ifndef CONF_USB_H_INCLUDED
68#define CONF_USB_H_INCLUDED
79
@@ -55,7 +57,8 @@ extern void mp_cdc_disable(uint8_t port);
5557
5658#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
5759void usb_rx_notify (void );
58- #define UDI_CDC_SET_CODING_EXT (port ,cfg )
60+ #define UDI_CDC_SET_CODING_EXT (port ,cfg ) usb_coding_notify(port, cfg)
61+ void usb_coding_notify (uint8_t port , usb_cdc_line_coding_t * coding );
5962#define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
6063void usb_dtr_notify (uint8_t port , bool set );
6164#define UDI_CDC_SET_RTS_EXT (port ,set ) usb_rts_notify(port, set)
Original file line number Diff line number Diff line change 22#include <stdbool.h>
33#include <stdint.h>
44
5+ #include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6+
57#ifndef CONF_USB_H_INCLUDED
68#define CONF_USB_H_INCLUDED
79
@@ -55,7 +57,8 @@ extern void mp_cdc_disable(uint8_t port);
5557
5658#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
5759void usb_rx_notify (void );
58- #define UDI_CDC_SET_CODING_EXT (port ,cfg )
60+ #define UDI_CDC_SET_CODING_EXT (port ,cfg ) usb_coding_notify(port, cfg)
61+ void usb_coding_notify (uint8_t port , usb_cdc_line_coding_t * coding );
5962#define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
6063void usb_dtr_notify (uint8_t port , bool set );
6164#define UDI_CDC_SET_RTS_EXT (port ,set ) usb_rts_notify(port, set)
Original file line number Diff line number Diff line change 22#include <stdbool.h>
33#include <stdint.h>
44
5+ #include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6+
57#ifndef CONF_USB_H_INCLUDED
68#define CONF_USB_H_INCLUDED
79
@@ -55,7 +57,8 @@ extern void mp_cdc_disable(uint8_t port);
5557
5658#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
5759void usb_rx_notify (void );
58- #define UDI_CDC_SET_CODING_EXT (port ,cfg )
60+ #define UDI_CDC_SET_CODING_EXT (port ,cfg ) usb_coding_notify(port, cfg)
61+ void usb_coding_notify (uint8_t port , usb_cdc_line_coding_t * coding );
5962#define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
6063void usb_dtr_notify (uint8_t port , bool set );
6164#define UDI_CDC_SET_RTS_EXT (port ,set ) usb_rts_notify(port, set)
Original file line number Diff line number Diff line change 22#include <stdbool.h>
33#include <stdint.h>
44
5+ #include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6+
57#ifndef CONF_USB_H_INCLUDED
68#define CONF_USB_H_INCLUDED
79
@@ -55,7 +57,8 @@ extern void mp_cdc_disable(uint8_t port);
5557
5658#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
5759void usb_rx_notify (void );
58- #define UDI_CDC_SET_CODING_EXT (port ,cfg )
60+ #define UDI_CDC_SET_CODING_EXT (port ,cfg ) usb_coding_notify(port, cfg)
61+ void usb_coding_notify (uint8_t port , usb_cdc_line_coding_t * coding );
5962#define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
6063void usb_dtr_notify (uint8_t port , bool set );
6164#define UDI_CDC_SET_RTS_EXT (port ,set ) usb_rts_notify(port, set)
Original file line number Diff line number Diff line change 22#include <stdbool.h>
33#include <stdint.h>
44
5+ #include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6+
57#ifndef CONF_USB_H_INCLUDED
68#define CONF_USB_H_INCLUDED
79
@@ -55,7 +57,8 @@ extern void mp_cdc_disable(uint8_t port);
5557
5658#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
5759void usb_rx_notify (void );
58- #define UDI_CDC_SET_CODING_EXT (port ,cfg )
60+ #define UDI_CDC_SET_CODING_EXT (port ,cfg ) usb_coding_notify(port, cfg)
61+ void usb_coding_notify (uint8_t port , usb_cdc_line_coding_t * coding );
5962#define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
6063void usb_dtr_notify (uint8_t port , bool set );
6164#define UDI_CDC_SET_RTS_EXT (port ,set ) usb_rts_notify(port, set)
Original file line number Diff line number Diff line change 22#include <stdbool.h>
33#include <stdint.h>
44
5+ #include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6+
57#ifndef CONF_USB_H_INCLUDED
68#define CONF_USB_H_INCLUDED
79
1921#endif
2022
2123#ifndef USB_DEVICE_PRODUCT_NAME
22- # define USB_DEVICE_PRODUCT_NAME "Metro M0 with Flash (Experimental) "
24+ # define USB_DEVICE_PRODUCT_NAME "Metro M0 Express "
2325#endif
2426// #define USB_DEVICE_SERIAL_NAME "12...EF"
2527#define USB_DEVICE_GET_SERIAL_NAME_POINTER serial_number
@@ -55,7 +57,8 @@ extern void mp_cdc_disable(uint8_t port);
5557
5658#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
5759void usb_rx_notify (void );
58- #define UDI_CDC_SET_CODING_EXT (port ,cfg )
60+ #define UDI_CDC_SET_CODING_EXT (port ,cfg ) usb_coding_notify(port, cfg)
61+ void usb_coding_notify (uint8_t port , usb_cdc_line_coding_t * coding );
5962#define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
6063void usb_dtr_notify (uint8_t port , bool set );
6164#define UDI_CDC_SET_RTS_EXT (port ,set ) usb_rts_notify(port, set)
Original file line number Diff line number Diff line change 22#include <stdbool.h>
33#include <stdint.h>
44
5+ #include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6+
57#ifndef CONF_USB_H_INCLUDED
68#define CONF_USB_H_INCLUDED
79
@@ -55,7 +57,9 @@ extern void mp_cdc_disable(uint8_t port);
5557
5658#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
5759void usb_rx_notify (void );
58- #define UDI_CDC_SET_CODING_EXT (port ,cfg )
60+
61+ #define UDI_CDC_SET_CODING_EXT (port ,cfg ) usb_coding_notify(port, cfg)
62+ void usb_coding_notify (uint8_t port , usb_cdc_line_coding_t * coding );
5963#define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
6064void usb_dtr_notify (uint8_t port , bool set );
6165#define UDI_CDC_SET_RTS_EXT (port ,set ) usb_rts_notify(port, set)
Original file line number Diff line number Diff line change @@ -39,38 +39,42 @@ extern struct usart_module usart_instance;
3939
4040// Read by main to know when USB is connected.
4141volatile bool mp_msc_enabled = false;
42- bool mp_msc_enable ()
43- {
44- mp_msc_enabled = true;
45- return true;
42+ bool mp_msc_enable () {
43+ mp_msc_enabled = true;
44+ return true;
4645}
4746
48- void mp_msc_disable ()
49- {
50- mp_msc_enabled = false;
47+ void mp_msc_disable () {
48+ mp_msc_enabled = false;
5149}
5250
53- bool mp_cdc_enable (uint8_t port )
54- {
55- mp_cdc_enabled = false;
56- return true;
51+ bool mp_cdc_enable (uint8_t port ) {
52+ mp_cdc_enabled = false;
53+ return true;
5754}
5855
59- void mp_cdc_disable (uint8_t port )
60- {
61- mp_cdc_enabled = false;
56+ void mp_cdc_disable (uint8_t port ) {
57+ mp_cdc_enabled = false;
6258}
6359
60+ volatile bool reset_on_disconnect = false;
61+
6462void usb_dtr_notify (uint8_t port , bool set ) {
65- mp_cdc_enabled = set ;
63+ mp_cdc_enabled = set ;
64+ if (!set && reset_on_disconnect ) {
65+ reset_to_bootloader ();
66+ }
6667}
6768
6869void usb_rts_notify (uint8_t port , bool set ) {
6970 return ;
7071}
7172
72- void usb_rx_notify (void )
73- {
73+ void usb_coding_notify (uint8_t port , usb_cdc_line_coding_t * coding ) {
74+ reset_on_disconnect = coding -> dwDTERate == 1200 ;
75+ }
76+
77+ void usb_rx_notify (void ) {
7478 irqflags_t flags ;
7579 if (mp_cdc_enabled ) {
7680 while (udi_cdc_is_rx_ready ()) {
You can’t perform that action at this time.
0 commit comments