Skip to content

Commit 251a378

Browse files
committed
Configurable debug pin
1 parent d9ff5d9 commit 251a378

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# USB Power Delivery for Arduino
22

3-
Implement a USB PD protocol analyzer, a USB PD trigger board or a more
4-
sophisticated power sink using with a few additional components and simple
5-
Arduino code. Supports several STM32 microcontrollers.
3+
Implement a USB PD protocol analyzer, a USB PD trigger board or a more sophisticated power sink using a few additional components and simple Arduino code. Supports several STM32 microcontrollers.
64

7-
Dependning on the microcontroller, a comparator and a few resistors are needed, or only resistors or no additional component at all. See below for more details. For 5 USD in parts, you can build a USB PD protocol analyzer.
5+
Depending on the microcontroller, a comparator and a few resistors are needed, or just the resistors or no additional component at all. See below for more details. For 5 USD in parts, you can build a USB PD protocol analyzer.
86

97

108

@@ -59,8 +57,7 @@ See the Wiki for details regarding the required components and wiring.
5957

6058
### Trigger Board
6159

62-
The trigger boards communicates with a USB power supply and requests a different voltage than
63-
the initial 5V.
60+
The trigger boards communicates with a USB power supply and requests a different voltage than the initial 5V.
6461

6562
```c++
6663
#include "PowerDelivery.h"
@@ -77,3 +74,11 @@ void loop() {
7774
```
7875

7976
See the Wiki for details regarding the required components and wiring.
77+
78+
79+
## Restrictions
80+
81+
- This library uses several peripherals exclusively (e.g. one or two timers and the ADC in many cases). The peripheral can no longer be used by your own code as it would interfer with the operation of this library. Please read to restrictions that apply to your board.
82+
83+
- The USB PD protocol is very timing sensitive. In order to be robust even in the presence of blocking code (e.g. `Serial.println()`), most of the USB PD processing is done in interrupt handlers. While receiving a USB PD message, interrupt handlers can consume up to 40% of the CPU time.
84+

src/PDPhySTM32F1.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ static int txBitStreamLength;
6363
// PB3 can be configured as debug output pin. It indicates certain activities such as
6464
// ADC conversion complete, EXTI interrupt, processing of received data.
6565

66+
#if USBPD_DEBUG_PIN
6667
static constexpr bool useDebugOut = true;
68+
#else
69+
static constexpr bool useDebugOut = false;
70+
#endif
6771
static inline void debugOutOn() { if (useDebugOut) gpioSetOutputHigh(GPIOB, 3); }
6872
static inline void debugOutOff() { if (useDebugOut) gpioSetOutputLow(GPIOB, 3); }
6973

src/PDPhySTM32F4.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ static int txBitStreamLength;
5959
// PB3 can be configured as debug output pin. It indicates certain activities such as
6060
// ADC conversion complete, EXTI interrupt, processing of received data.
6161

62+
#if USBPD_DEBUG_PIN
6263
static constexpr bool useDebugOut = true;
64+
#else
65+
static constexpr bool useDebugOut = false;
66+
#endif
6367
static inline void debugOutOn() { if (useDebugOut) gpioSetOutputHigh(GPIOB, 3); }
6468
static inline void debugOutOff() { if (useDebugOut) gpioSetOutputLow(GPIOB, 3); }
6569

src/PDPhySTM32L4.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ static int txBitStreamLength;
6060
// PA8 can be configured as debug output pin. It indicates certain activities such as
6161
// ADC conversion complete, comparator interrupt, processing of received data.
6262

63+
#if USBPD_DEBUG_PIN
6364
static constexpr bool useDebugOut = true;
65+
#else
66+
static constexpr bool useDebugOut = false;
67+
#endif
6468
static inline void debugOutOn() { if (useDebugOut) gpioSetOutputHigh(GPIOA, 8); }
6569
static inline void debugOutOff() { if (useDebugOut) gpioSetOutputLow(GPIOA, 8); }
6670

0 commit comments

Comments
 (0)