Skip to content

Commit 389c05b

Browse files
committed
Add support for Electronut Labs Papyr
Signed-off-by: Tavish Naruka <[email protected]>
1 parent 9d7de45 commit 389c05b

File tree

4 files changed

+131
-20
lines changed

4 files changed

+131
-20
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This is a CDC/DFU/UF2 bootloader for nRF52 boards.
1010
- Particle Boron
1111
- Particle Xenon
1212
- MakerDiary MDK nRF52840 USB Dongle
13+
- [Electronut Labs Papyr](https://docs.electronut.in/papyr/)
1314

1415
UF2 is an easy-to-use bootloader that appears as a flash drive. You can just copy `.uf2`-format
1516
application images to the flash drive to load new firmware.

src/boards/electronut_labs_papyr.h

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/**************************************************************************/
2+
/*!
3+
@file elelctronutlabs_papyr.h
4+
@author Tavish Naruka <[email protected]>
5+
6+
@section LICENSE
7+
8+
Software License Agreement (BSD License)
9+
10+
Copyright (c) 2017, Adafruit Industries (adafruit.com)
11+
All rights reserved.
12+
13+
Redistribution and use in source and binary forms, with or without
14+
modification, are permitted provided that the following conditions are met:
15+
1. Redistributions of source code must retain the above copyright
16+
notice, this list of conditions and the following disclaimer.
17+
2. Redistributions in binary form must reproduce the above copyright
18+
notice, this list of conditions and the following disclaimer in the
19+
documentation and/or other materials provided with the distribution.
20+
3. Neither the name of the copyright holders nor the
21+
names of its contributors may be used to endorse or promote products
22+
derived from this software without specific prior written permission.
23+
24+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
25+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
28+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34+
*/
35+
/**************************************************************************/
36+
37+
#ifndef PAPYR_H
38+
#define PAPYR_H
39+
40+
/*------------------------------------------------------------------*/
41+
/* LED
42+
*------------------------------------------------------------------*/
43+
#define LEDS_NUMBER 2
44+
#define LED_PRIMARY_PIN 13
45+
#define LED_SECONDARY_PIN 14
46+
#define LED_STATE_ON 0
47+
48+
/*------------------------------------------------------------------*/
49+
/* BUTTON
50+
*------------------------------------------------------------------*/
51+
// NOTE: USB UF2 bootloader can be triggered by double pressing RESET
52+
// App can trigger OTA bootloader by writing DFU_MAGIC_OTA_APPJUM to
53+
// GPREGRET register if softdevice is not initialized; or by
54+
// writing DFU_MAGIC_OTA_RESET in case softdevice is initialized.
55+
#define BUTTONS_NUMBER 2
56+
#define BUTTON_1 18 // RESET also by default
57+
#define BUTTON_2 1 // P0.1 not exposed anywhere, FRST n/a
58+
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
59+
60+
/*------------------------------------------------------------------*/
61+
/* UART
62+
*------------------------------------------------------------------*/
63+
#define RX_PIN_NUMBER 7
64+
#define TX_PIN_NUMBER 8
65+
#define CTS_PIN_NUMBER 0
66+
#define RTS_PIN_NUMBER 0
67+
#define HWFC false
68+
69+
// Used as model string in OTA mode
70+
#define DIS_MANUFACTURER "Electronut Labs"
71+
#define DIS_MODEL "Papyr"
72+
73+
#define BOARD_ID "Electronut Labs Papyr"
74+
#define INDEX_URL "https://docs.electronut.in/papyr"
75+
76+
#define USB_DESC_VID 0x239A
77+
#define USB_DESC_UF2_PID 0x003B
78+
79+
#define USB_STRING_DESCRIPTORS { \
80+
/* 0: is supported language = English */ \
81+
TUD_DESC_STRCONV(0x0409), \
82+
\
83+
/* 1: Manufacturer */ \
84+
TUD_DESC_STRCONV('E','l','e','c','t','r','o','n','u','t',' ','L','a','b','s'), \
85+
\
86+
/* 2: Product */ \
87+
TUD_DESC_STRCONV('P','a','p','y','r', ' ', 'D','F','U'), \
88+
\
89+
/* 3: Serials TODO use chip ID */ \
90+
usb_desc_str_serial, \
91+
\
92+
/* 4: CDC Interface */ \
93+
TUD_DESC_STRCONV('P','a','p','y','r',' ','S','e','r','i','a','l'), \
94+
\
95+
/* 5: MSC Interface */ \
96+
TUD_DESC_STRCONV('P','a','p','y','r',' ','U','F','2'), \
97+
}
98+
99+
#endif // PPAPYR_H

src/usb/usb_desc.c

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -79,30 +79,33 @@ enum {
7979
// STRING DESCRIPTORS
8080
//--------------------------------------------------------------------+
8181

82+
#ifndef USB_STRING_DESCRIPTORS
83+
#define USB_STRING_DESCRIPTORS { \
84+
/* 0: is supported language = English */ \
85+
TUD_DESC_STRCONV(0x0409), \
86+
\
87+
/* 1: Manufacturer */ \
88+
TUD_DESC_STRCONV('A','d','a','f','r','u','i','t',' ','I','n','d','u','s','t','r','i','e','s'), \
89+
\
90+
/* 2: Product */ \
91+
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','n','R','F','5','2','8','4','0', ' ', 'D','F','U'), \
92+
\
93+
/* 3: Serials TODO use chip ID */ \
94+
usb_desc_str_serial, \
95+
\
96+
/* 4: CDC Interface */ \
97+
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','S','e','r','i','a','l'), \
98+
\
99+
/* 5: MSC Interface */ \
100+
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','U','F','2'), \
101+
}
102+
#endif
103+
82104
// Serial is 64-bit DeviceID -> 16 chars len
83105
uint16_t usb_desc_str_serial[1+16] = { TUD_DESC_STR_HEADER(16) };
84106

85107
// array of pointer to string descriptors
86-
uint16_t const * const string_desc_arr [] =
87-
{
88-
// 0: is supported language = English
89-
TUD_DESC_STRCONV(0x0409),
90-
91-
// 1: Manufacturer
92-
TUD_DESC_STRCONV('A','d','a','f','r','u','i','t',' ','I','n','d','u','s','t','r','i','e','s'),
93-
94-
// 2: Product
95-
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','n','R','F','5','2','8','4','0', ' ', 'D','F','U'),
96-
97-
// 3: Serials TODO use chip ID
98-
usb_desc_str_serial,
99-
100-
// 4: CDC Interface
101-
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','S','e','r','i','a','l'),
102-
103-
// 5: MSC Interface
104-
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','U','F','2'),
105-
};
108+
uint16_t const * const string_desc_arr [] = USB_STRING_DESCRIPTORS;
106109

107110
//--------------------------------------------------------------------+
108111
// Device Descriptor

src/usb/usb_desc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,23 @@
4040
#define USB_DESC_H_
4141

4242
#include "tusb.h"
43+
#include "boards.h"
4344

4445
#ifdef __cplusplus
4546
extern "C" {
4647
#endif
4748

49+
#ifndef USB_DESC_VID
4850
#define USB_DESC_VID 0x239A
51+
#endif
4952

53+
#ifndef USB_DESC_UF2_PID
5054
#define USB_DESC_UF2_PID 0x0029
55+
#endif
56+
57+
#ifndef USB_DESC_SERIAL_ONLY_PID
5158
#define USB_DESC_SERIAL_ONLY_PID 0x002A
59+
#endif
5260

5361

5462
/*------------- Configuration Descriptor -------------*/

0 commit comments

Comments
 (0)