1.. _nrf52840_papyr:
2
3Electronut Labs Papyr
4#####################
5
6Overview
7********
8
9Zephyr applications use the nrf52840_papyr board configuration
10to run on Electronut Labs Papyr hardware. It provides
11support for the Nordic Semiconductor nRF52840 ARM Cortex-M4F CPU and
12the following devices:
13
14* :abbr:`ADC (Analog to Digital Converter)`
15* CLOCK
16* FLASH
17* :abbr:`GPIO (General Purpose Input Output)`
18* :abbr:`I2C (Inter-Integrated Circuit)`
19* :abbr:`MPU (Memory Protection Unit)`
20* :abbr:`NVIC (Nested Vectored Interrupt Controller)`
21* :abbr:`PWM (Pulse Width Modulation)`
22* RADIO (Bluetooth Low Energy and 802.15.4)
23* :abbr:`RTC (nRF RTC System Clock)`
24* :abbr:`SPI (Serial Peripheral Interface)`
25* :abbr:`UART (Universal asynchronous receiver-transmitter)`
26* :abbr:`USB (Universal Serial Bus)`
27* :abbr:`WDT (Watchdog Timer)`
28* COUNTER
29
30.. figure:: img/nrf52840_papyr.jpg
31     :align: center
32     :alt: Electronut Labs Papyr
33
34     Electronut Labs Papyr (Credit: Electronut Labs)
35
36More information about the board is available at https://gitlab.com/electronutlabs-public/papyr.
37
38Hardware
39********
40
41Papyr has two external oscillators. The frequency of
42the slow clock is 32.768 kHz. The frequency of the main clock
43is 32 MHz.
44
45Supported Features
46==================
47
48The nrf52840_papyr board configuration supports the following
49hardware features currently:
50
51+-----------+------------+----------------------+
52| Interface | Controller | Driver/Component     |
53+===========+============+======================+
54| ADC       | on-chip    | adc                  |
55+-----------+------------+----------------------+
56| CLOCK     | on-chip    | clock_control        |
57+-----------+------------+----------------------+
58| FLASH     | on-chip    | flash                |
59+-----------+------------+----------------------+
60| GPIO      | on-chip    | gpio                 |
61+-----------+------------+----------------------+
62| I2C(M)    | on-chip    | i2c                  |
63+-----------+------------+----------------------+
64| MPU       | on-chip    | arch/arm             |
65+-----------+------------+----------------------+
66| NVIC      | on-chip    | arch/arm             |
67+-----------+------------+----------------------+
68| PWM       | on-chip    | pwm                  |
69+-----------+------------+----------------------+
70| RADIO     | on-chip    | Bluetooth,           |
71|           |            | ieee802154           |
72+-----------+------------+----------------------+
73| RTC       | on-chip    | system clock         |
74+-----------+------------+----------------------+
75| SPI(M/S)  | on-chip    | spi                  |
76+-----------+------------+----------------------+
77| UART      | on-chip    | serial               |
78+-----------+------------+----------------------+
79| USB       | on-chip    | usb                  |
80+-----------+------------+----------------------+
81| WDT       | on-chip    | watchdog             |
82+-----------+------------+----------------------+
83
84Connections and IOs
85===================
86
87LED
88---
89
90* LED1 (green) = P0.13
91* LED2 (blue)  = P0.15
92* LED3 (red)   = P0.14
93
94Push buttons
95------------
96
97* Reset = SW0 = P0.18 (can be used as GPIO also)
98
99UART
100----
101
102* TX = P0.8
103* RX = P0.7
104
105I2C
106---
107
108I2C pins connected to onboard sensors (I2C_0):
109
110* SDA = P0.5
111* SCL = P0.6
112
113SPI
114---
115
116The e-paper display is connected to the chip via SPI on the following pins (SPI_1):
117
118* SCK  = P0.31
119* MOSI = P0.29
120* MISO = P1.1 (not used by the display)
121
122NOTE: P1.1 is pin 33 in absolute enumeration.
123
124Other pins used by the e-paper display are:
125
126* E-ink enable = P0.11 (cuts off power to the display with MOSFET)
127* CS   = P0.30
128* BUSY = P0.3
129* D/C  = P0.28
130* RES  = P0.2
131
132Programming and Debugging
133*************************
134
135Applications for the ``nrf52840_papyr`` board configuration can be
136built and flashed in the usual way (see :ref:`build_an_application`
137and :ref:`application_run` for more details); Black Magic
138Probe debugger presents itself as two USB-serial ports. On Linux,
139they may come up as ``/dev/ttyACM0`` and ``/dev/ttyACM1``. The first
140one of these (``/dev/ttyACM0`` here) is the debugger port.
141GDB can directly connect to this port without requiring a GDB server by specifying
142``target external /dev/ttyACM0``. The second port acts as a
143serial port, connected to the SoC.
144
145Flashing
146========
147
148By default, papyr is configured to be used with a blackmagicprobe compatible
149debugger (see _Bumpy).
150
151Applications are flashed and run as usual (see :ref:`build_an_application` and
152:ref:`application_run` for more details).
153
154Here is an example for the :ref:`hello_world` application.
155
156First, run your favorite terminal program to listen for output.
157
158.. code-block:: console
159
160   $ minicom -D <tty_device> -b 115200
161
162Replace :code:`<tty_device>` with the serial port of Black Magic Probe.
163For example, under Linux, :code:`/dev/ttyACM1`.
164
165Then build and flash the application in the usual way.
166
167.. zephyr-app-commands::
168   :zephyr-app: samples/hello_world
169   :board: nrf52840_papyr
170   :goals: build flash
171
172Debugging
173=========
174
175Debug and attach configurations are available using Black Magic Probe, and
176``ninja debug``, or ``ninja attach`` (or with ``make``) are available.
177
178NOTE: You may need to press the reset button once after using ``ninja flash``
179to start executing the code. (not required with ``debug`` or ``attach``)
180
181References
182**********
183
184.. target-notes::
185
186.. _Electronut Labs website: https://electronut.in
187.. _Store link: https://www.tindie.com/stores/ElectronutLabs/
188.. _Papyr website: https://docs.electronut.in/papyr/
189.. _Schematic: https://gitlab.com/electronutlabs-public/papyr/raw/master/hardware/papyr_schematic_v_0_3.pdf?inline=false
190.. _Datasheet: https://gitlab.com/electronutlabs-public/papyr/raw/master/papyr_v0.3_datasheet.pdf?inline=false
191.. _Nordic Semiconductor Infocenter: http://infocenter.nordicsemi.com/
192.. _Black Magic Probe website: https://github.com/blacksphere/blackmagic
193.. _Bumpy website: https://docs.electronut.in/bumpy/
194