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 @@ -188,6 +188,7 @@ SRC_C = \
188
188
flash_api.c \
189
189
main.c \
190
190
mphalport.c \
191
+ reset.c \
191
192
samd21_pins.c \
192
193
shared_dma.c \
193
194
rgb_led_status.c \
Original file line number Diff line number Diff line change 2
2
#include <stdbool.h>
3
3
#include <stdint.h>
4
4
5
+ #include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6
+
5
7
#ifndef CONF_USB_H_INCLUDED
6
8
#define CONF_USB_H_INCLUDED
7
9
@@ -55,7 +57,8 @@ extern void mp_cdc_disable(uint8_t port);
55
57
56
58
#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
57
59
void 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 );
59
62
#define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
60
63
void usb_dtr_notify (uint8_t port , bool set );
61
64
#define UDI_CDC_SET_RTS_EXT (port ,set ) usb_rts_notify(port, set)
Original file line number Diff line number Diff line change 2
2
#include <stdbool.h>
3
3
#include <stdint.h>
4
4
5
+ #include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6
+
5
7
#ifndef CONF_USB_H_INCLUDED
6
8
#define CONF_USB_H_INCLUDED
7
9
@@ -55,7 +57,8 @@ extern void mp_cdc_disable(uint8_t port);
55
57
56
58
#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
57
59
void 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 );
59
62
#define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
60
63
void usb_dtr_notify (uint8_t port , bool set );
61
64
#define UDI_CDC_SET_RTS_EXT (port ,set ) usb_rts_notify(port, set)
Original file line number Diff line number Diff line change 2
2
#include <stdbool.h>
3
3
#include <stdint.h>
4
4
5
+ #include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6
+
5
7
#ifndef CONF_USB_H_INCLUDED
6
8
#define CONF_USB_H_INCLUDED
7
9
@@ -55,7 +57,8 @@ extern void mp_cdc_disable(uint8_t port);
55
57
56
58
#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
57
59
void 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 );
59
62
#define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
60
63
void usb_dtr_notify (uint8_t port , bool set );
61
64
#define UDI_CDC_SET_RTS_EXT (port ,set ) usb_rts_notify(port, set)
Original file line number Diff line number Diff line change 2
2
#include <stdbool.h>
3
3
#include <stdint.h>
4
4
5
+ #include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6
+
5
7
#ifndef CONF_USB_H_INCLUDED
6
8
#define CONF_USB_H_INCLUDED
7
9
@@ -55,7 +57,8 @@ extern void mp_cdc_disable(uint8_t port);
55
57
56
58
#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
57
59
void 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 );
59
62
#define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
60
63
void usb_dtr_notify (uint8_t port , bool set );
61
64
#define UDI_CDC_SET_RTS_EXT (port ,set ) usb_rts_notify(port, set)
Original file line number Diff line number Diff line change 2
2
#include <stdbool.h>
3
3
#include <stdint.h>
4
4
5
+ #include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6
+
5
7
#ifndef CONF_USB_H_INCLUDED
6
8
#define CONF_USB_H_INCLUDED
7
9
@@ -55,7 +57,8 @@ extern void mp_cdc_disable(uint8_t port);
55
57
56
58
#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
57
59
void 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 );
59
62
#define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
60
63
void usb_dtr_notify (uint8_t port , bool set );
61
64
#define UDI_CDC_SET_RTS_EXT (port ,set ) usb_rts_notify(port, set)
Original file line number Diff line number Diff line change 2
2
#include <stdbool.h>
3
3
#include <stdint.h>
4
4
5
+ #include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6
+
5
7
#ifndef CONF_USB_H_INCLUDED
6
8
#define CONF_USB_H_INCLUDED
7
9
@@ -55,7 +57,8 @@ extern void mp_cdc_disable(uint8_t port);
55
57
56
58
#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
57
59
void 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 );
59
62
#define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
60
63
void usb_dtr_notify (uint8_t port , bool set );
61
64
#define UDI_CDC_SET_RTS_EXT (port ,set ) usb_rts_notify(port, set)
Original file line number Diff line number Diff line change 2
2
#include <stdbool.h>
3
3
#include <stdint.h>
4
4
5
+ #include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6
+
5
7
#ifndef CONF_USB_H_INCLUDED
6
8
#define CONF_USB_H_INCLUDED
7
9
19
21
#endif
20
22
21
23
#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 "
23
25
#endif
24
26
// #define USB_DEVICE_SERIAL_NAME "12...EF"
25
27
#define USB_DEVICE_GET_SERIAL_NAME_POINTER serial_number
@@ -55,7 +57,8 @@ extern void mp_cdc_disable(uint8_t port);
55
57
56
58
#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
57
59
void 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 );
59
62
#define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
60
63
void usb_dtr_notify (uint8_t port , bool set );
61
64
#define UDI_CDC_SET_RTS_EXT (port ,set ) usb_rts_notify(port, set)
Original file line number Diff line number Diff line change 2
2
#include <stdbool.h>
3
3
#include <stdint.h>
4
4
5
+ #include "asf/common/services/usb/class/cdc/usb_protocol_cdc.h"
6
+
5
7
#ifndef CONF_USB_H_INCLUDED
6
8
#define CONF_USB_H_INCLUDED
7
9
@@ -55,7 +57,9 @@ extern void mp_cdc_disable(uint8_t port);
55
57
56
58
#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
57
59
void 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 );
59
63
#define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
60
64
void usb_dtr_notify (uint8_t port , bool set );
61
65
#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;
39
39
40
40
// Read by main to know when USB is connected.
41
41
volatile 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;
46
45
}
47
46
48
- void mp_msc_disable ()
49
- {
50
- mp_msc_enabled = false;
47
+ void mp_msc_disable () {
48
+ mp_msc_enabled = false;
51
49
}
52
50
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;
57
54
}
58
55
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;
62
58
}
63
59
60
+ volatile bool reset_on_disconnect = false;
61
+
64
62
void 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
+ }
66
67
}
67
68
68
69
void usb_rts_notify (uint8_t port , bool set ) {
69
70
return ;
70
71
}
71
72
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 ) {
74
78
irqflags_t flags ;
75
79
if (mp_cdc_enabled ) {
76
80
while (udi_cdc_is_rx_ready ()) {
You can’t perform that action at this time.
0 commit comments