Skip to content

Commit 91e5a65

Browse files
committed
Opta: provide USB VID/PID in bootloader
When the various combination have been decided we need to change boards.txt (with particular attention to dfu-utils commandline)
1 parent 6723757 commit 91e5a65

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

variants/OPTA/pins_arduino.h

+23-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,29 @@ static const uint8_t SCK = PIN_SPI_SCK;
139139

140140
#define SERIAL_CDC 1
141141
#define HAS_UNIQUE_ISERIAL_DESCRIPTOR
142-
#define BOARD_VENDORID 0x2341
143-
#define BOARD_PRODUCTID 0x0264
142+
143+
// Use these only if bootloader data is not available / valid
144+
#define _BOARD_VENDORID 0x2341
145+
#define _BOARD_PRODUCTID 0x0264
146+
147+
static uint8_t* bootloader_data = (uint8_t*)(0x801F000);
148+
static inline bool _isBootloaderDataValid() {
149+
return bootloader_data[0] == 0xA0;
150+
}
151+
static inline uint16_t _getVid_() {
152+
if (_isBootloaderDataValid()) {
153+
return bootloader_data[1] | ((uint16_t)bootloader_data[2] << 8);
154+
} else {
155+
return _BOARD_VENDORID;
156+
}
157+
}
158+
static inline uint16_t _getPid_() {
159+
if (_isBootloaderDataValid()) {
160+
return bootloader_data[3] | ((uint16_t)bootloader_data[4] << 8);
161+
} else {
162+
return _BOARD_PRODUCTID;
163+
}
164+
}
144165
#define BOARD_NAME "Arduino Opta"
145166

146167
#define DFU_MAGIC_SERIAL_ONLY_RESET 0xb0

0 commit comments

Comments
 (0)