Skip to content

Commit a9765e7

Browse files
committed
Simplify G0/G4 pin configuration
1 parent 41c3b5f commit a9765e7

File tree

4 files changed

+20
-33
lines changed

4 files changed

+20
-33
lines changed

library.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/schema/library.json",
33
"name": "USBPowerDelivery",
4-
"version": "1.0.4",
4+
"version": "1.0.5",
55
"description": "USB Power Delivery for Arduino. Create a USB PD protocol analyzer, trigger board or power sink for no or only few additional components. Supports several STM32 boards.",
66
"keywords": "usb,usb-pd,usb-power-delivery,protocol-analyzer,trigger-board",
77
"homepage": "https://github.com/manuelbl/usb-pd-arduino",

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=USBPowerDelivery
2-
version=1.0.4
2+
version=1.0.5
33
author=Manuel Bl. <manuel.bleichenbacher@gmail.com>
44
maintainer=Manuel Bl. <manuel.bleichenbacher@gmail.com>
55
sentence=USB Power Delivery for Arduino.

src/NucleoSNK1MK1.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515
void SNK1MK1Controller::init() {
1616

1717
#if defined(ARDUINO_NUCLEO_G474RE)
18-
// Pin PB1: DB_OUT -> PIN_A9
19-
// Pin PC10: VCC_OUT -> 16
20-
pinMode(PIN_A9, OUTPUT);
21-
digitalWrite(PIN_A9, HIGH);
22-
pinMode(16, OUTPUT);
23-
digitalWrite(16, HIGH);
18+
// Pin PB1: DB_OUT
19+
// Pin PC10: VCC_OUT
20+
pinMode(PB1, OUTPUT);
21+
digitalWrite(PB1, HIGH);
22+
pinMode(PC10, OUTPUT);
23+
digitalWrite(PC10, HIGH);
2424
#elif defined(ARDUINO_NUCLEO_G071RB)
25-
// Pin PB6: DB_OUT -> 46
26-
// Pin PC10: VCC_OUT -> 16
27-
pinMode(46, OUTPUT);
28-
digitalWrite(46, HIGH);
29-
pinMode(16, OUTPUT);
30-
digitalWrite(16, HIGH);
25+
// Pin PB6: DB_OUT
26+
// Pin PC10: VCC_OUT
27+
pinMode(PB6, OUTPUT);
28+
digitalWrite(PB6, HIGH);
29+
pinMode(PC10, OUTPUT);
30+
digitalWrite(PC10, HIGH);
3131
#endif
3232
}
3333

src/PDPhySTM32UCPD.cpp

+6-19
Original file line numberDiff line numberDiff line change
@@ -21,42 +21,29 @@
2121
// STM32G4 family: CC1 -> PB6, CC2 -> PB4
2222
#define GPIO_CC1 GPIOB
2323
#define PIN_CC1 LL_GPIO_PIN_6
24+
#define ARDUINO_PIN_CC1 PB6
2425
#define GPIO_CC2 GPIOB
2526
#define PIN_CC2 LL_GPIO_PIN_4
27+
#define ARDUINO_PIN_CC2 PB4
2628
#define DMA_RX DMA1
2729
#define DMA_CHANNEL_RX LL_DMA_CHANNEL_1
2830
#define DMA_TX DMA1
2931
#define DMA_CHANNEL_TX LL_DMA_CHANNEL_2
3032
#define UCPD_IRQ UCPD1_IRQn
3133

32-
#if defined(ARDUINO_NUCLEO_G431KB)
33-
#define PIN_CC1_ARDUINO D12
34-
#define PIN_CC2_ARDUINO D6
35-
#elif defined(ARDUINO_NUCLEO_G431RB) || defined(ARDUINO_NUCLEO_G474RE) || defined(ARDUINO_NUCLEO_G491RE)
36-
#define PIN_CC1_ARDUINO D10
37-
#define PIN_CC2_ARDUINO D5
38-
#else
39-
#endif
40-
4134
#elif defined(STM32G0xx)
4235
// STM32G0 family: CC1 -> PA8, CC2 -> PB15
4336
#define GPIO_CC1 GPIOA
4437
#define PIN_CC1 LL_GPIO_PIN_8
38+
#define ARDUINO_PIN_CC1 PA8
4539
#define GPIO_CC2 GPIOB
4640
#define PIN_CC2 LL_GPIO_PIN_15
41+
#define ARDUINO_PIN_CC2 PB15
4742
#define DMA_RX DMA1
4843
#define DMA_CHANNEL_RX LL_DMA_CHANNEL_1
4944
#define DMA_TX DMA1
5045
#define DMA_CHANNEL_TX LL_DMA_CHANNEL_2
5146
#define UCPD_IRQ UCPD1_2_IRQn
52-
53-
#if defined(ARDUINO_NUCLEO_G071RB)
54-
#define PIN_CC1_ARDUINO D7
55-
#define PIN_CC2_ARDUINO D47
56-
#endif
57-
#endif
58-
#if !defined(PIN_CC1_ARDUINO) || !defined(PIN_CC2_ARDUINO)
59-
#error "Arduiono board not yet supported - please define PIN_CC1_ARDUINO and PIN_CC2_ARDUINO"
6047
#endif
6148

6249

@@ -85,8 +72,8 @@ void PDPhySTM32UCPD::init(bool isMonitor) {
8572

8673
// Use Arduino function for basic pin configuration so the Arduino library is aware
8774
// if the most important settings (such as GPIO clock initialization).
88-
pinMode(PIN_CC1_ARDUINO, INPUT_ANALOG);
89-
pinMode(PIN_CC2_ARDUINO, INPUT_ANALOG);
75+
pinMode(ARDUINO_PIN_CC1, INPUT_ANALOG);
76+
pinMode(ARDUINO_PIN_CC2, INPUT_ANALOG);
9077

9178
// initialize UCPD1
9279
LL_UCPD_InitTypeDef ucpdInit = {};

0 commit comments

Comments
 (0)