diff --git a/library.json b/library.json index fbbf776..27d820b 100644 --- a/library.json +++ b/library.json @@ -1,7 +1,7 @@ { "$schema": "https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/schema/library.json", "name": "USBPowerDelivery", - "version": "1.0.4", + "version": "1.0.5", "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.", "keywords": "usb,usb-pd,usb-power-delivery,protocol-analyzer,trigger-board", "homepage": "https://github.com/manuelbl/usb-pd-arduino", diff --git a/library.properties b/library.properties index 12e0fe6..63addcd 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=USBPowerDelivery -version=1.0.4 +version=1.0.5 author=Manuel Bl. maintainer=Manuel Bl. sentence=USB Power Delivery for Arduino. diff --git a/src/NucleoSNK1MK1.cpp b/src/NucleoSNK1MK1.cpp index 8b7ff8d..a929d8d 100644 --- a/src/NucleoSNK1MK1.cpp +++ b/src/NucleoSNK1MK1.cpp @@ -15,19 +15,19 @@ void SNK1MK1Controller::init() { #if defined(ARDUINO_NUCLEO_G474RE) - // Pin PB1: DB_OUT -> PIN_A9 - // Pin PC10: VCC_OUT -> 16 - pinMode(PIN_A9, OUTPUT); - digitalWrite(PIN_A9, HIGH); - pinMode(16, OUTPUT); - digitalWrite(16, HIGH); + // Pin PB1: DB_OUT + // Pin PC10: VCC_OUT + pinMode(PB1, OUTPUT); + digitalWrite(PB1, HIGH); + pinMode(PC10, OUTPUT); + digitalWrite(PC10, HIGH); #elif defined(ARDUINO_NUCLEO_G071RB) - // Pin PB6: DB_OUT -> 46 - // Pin PC10: VCC_OUT -> 16 - pinMode(46, OUTPUT); - digitalWrite(46, HIGH); - pinMode(16, OUTPUT); - digitalWrite(16, HIGH); + // Pin PB6: DB_OUT + // Pin PC10: VCC_OUT + pinMode(PB6, OUTPUT); + digitalWrite(PB6, HIGH); + pinMode(PC10, OUTPUT); + digitalWrite(PC10, HIGH); #endif } diff --git a/src/PDPhySTM32UCPD.cpp b/src/PDPhySTM32UCPD.cpp index c56ed7c..6d92cdc 100644 --- a/src/PDPhySTM32UCPD.cpp +++ b/src/PDPhySTM32UCPD.cpp @@ -21,42 +21,29 @@ // STM32G4 family: CC1 -> PB6, CC2 -> PB4 #define GPIO_CC1 GPIOB #define PIN_CC1 LL_GPIO_PIN_6 + #define ARDUINO_PIN_CC1 PB6 #define GPIO_CC2 GPIOB #define PIN_CC2 LL_GPIO_PIN_4 + #define ARDUINO_PIN_CC2 PB4 #define DMA_RX DMA1 #define DMA_CHANNEL_RX LL_DMA_CHANNEL_1 #define DMA_TX DMA1 #define DMA_CHANNEL_TX LL_DMA_CHANNEL_2 #define UCPD_IRQ UCPD1_IRQn - #if defined(ARDUINO_NUCLEO_G431KB) - #define PIN_CC1_ARDUINO D12 - #define PIN_CC2_ARDUINO D6 - #elif defined(ARDUINO_NUCLEO_G431RB) || defined(ARDUINO_NUCLEO_G474RE) || defined(ARDUINO_NUCLEO_G491RE) - #define PIN_CC1_ARDUINO D10 - #define PIN_CC2_ARDUINO D5 - #else - #endif - #elif defined(STM32G0xx) // STM32G0 family: CC1 -> PA8, CC2 -> PB15 #define GPIO_CC1 GPIOA #define PIN_CC1 LL_GPIO_PIN_8 + #define ARDUINO_PIN_CC1 PA8 #define GPIO_CC2 GPIOB #define PIN_CC2 LL_GPIO_PIN_15 + #define ARDUINO_PIN_CC2 PB15 #define DMA_RX DMA1 #define DMA_CHANNEL_RX LL_DMA_CHANNEL_1 #define DMA_TX DMA1 #define DMA_CHANNEL_TX LL_DMA_CHANNEL_2 #define UCPD_IRQ UCPD1_2_IRQn - - #if defined(ARDUINO_NUCLEO_G071RB) - #define PIN_CC1_ARDUINO D7 - #define PIN_CC2_ARDUINO D47 - #endif -#endif -#if !defined(PIN_CC1_ARDUINO) || !defined(PIN_CC2_ARDUINO) - #error "Arduiono board not yet supported - please define PIN_CC1_ARDUINO and PIN_CC2_ARDUINO" #endif @@ -85,8 +72,8 @@ void PDPhySTM32UCPD::init(bool isMonitor) { // Use Arduino function for basic pin configuration so the Arduino library is aware // if the most important settings (such as GPIO clock initialization). - pinMode(PIN_CC1_ARDUINO, INPUT_ANALOG); - pinMode(PIN_CC2_ARDUINO, INPUT_ANALOG); + pinMode(ARDUINO_PIN_CC1, INPUT_ANALOG); + pinMode(ARDUINO_PIN_CC2, INPUT_ANALOG); // initialize UCPD1 LL_UCPD_InitTypeDef ucpdInit = {};