mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[ion/device/n0110/usb] Consolidate configs of Vbus pin
Even though the configuration of the Vbus pin depends on the hardware running Epsilon, we do not actually need one VbusPin object for each configuration. Indeed, an AFGPIOPin object can be used to configure the pin as a standard GPIO, provided one does not call its init() method.
This commit is contained in:
@@ -9,10 +9,6 @@ void initVbus() {
|
||||
Config::VbusPin.init();
|
||||
}
|
||||
|
||||
void shutdownVbus() {
|
||||
Config::VbusPin.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,13 @@ namespace Config {
|
||||
|
||||
using namespace Regs;
|
||||
|
||||
constexpr static GPIOPin VbusPin = GPIOPin(GPIOA, 9);
|
||||
constexpr static AFGPIOPin VbusAFPin = AFGPIOPin(GPIOA, 9, GPIO::AFR::AlternateFunction::AF10, GPIO::PUPDR::Pull::None, GPIO::OSPEEDR::OutputSpeed::Fast);
|
||||
/* On the STM32F730, PA9 does not actually support alternate function 10.
|
||||
* However, because of the wiring of the USB connector on the N0110, detection
|
||||
* of when the device is plugged requires the use of this undocumented setting.
|
||||
* After the revision of the USB connector and ESD protection, can can now
|
||||
* follow the specification and configure the Vbus pin as a floating-input GPIO.
|
||||
*/
|
||||
constexpr static AFGPIOPin VbusPin = AFGPIOPin(GPIOA, 9, GPIO::AFR::AlternateFunction::AF10, GPIO::PUPDR::Pull::None, GPIO::OSPEEDR::OutputSpeed::Fast);
|
||||
|
||||
constexpr static AFGPIOPin DmPin = AFGPIOPin(GPIOA, 11, GPIO::AFR::AlternateFunction::AF10, GPIO::PUPDR::Pull::None, GPIO::OSPEEDR::OutputSpeed::Fast);
|
||||
constexpr static AFGPIOPin DpPin = AFGPIOPin(GPIOA, 12, GPIO::AFR::AlternateFunction::AF10, GPIO::PUPDR::Pull::None, GPIO::OSPEEDR::OutputSpeed::Fast);
|
||||
|
||||
@@ -15,21 +15,13 @@ bool useAlternateFunctionVbus() {
|
||||
|
||||
void initVbus() {
|
||||
if (useAlternateFunctionVbus()) {
|
||||
Config::VbusAFPin.init();
|
||||
Config::VbusPin.init();
|
||||
} else {
|
||||
Config::VbusPin.group().MODER()->setMode(Config::VbusPin.pin(), GPIO::MODER::Mode::Input);
|
||||
Config::VbusPin.group().PUPDR()->setPull(Config::VbusPin.pin(), GPIO::PUPDR::Pull::None);
|
||||
}
|
||||
}
|
||||
|
||||
void shutdownVbus() {
|
||||
if (useAlternateFunctionVbus()) {
|
||||
Config::VbusAFPin.shutdown();
|
||||
} else {
|
||||
Config::VbusPin.group().MODER()->setMode(Config::VbusPin.pin(), GPIO::MODER::Mode::Analog);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,9 +75,10 @@ void initGPIO() {
|
||||
}
|
||||
|
||||
void shutdownGPIO() {
|
||||
Config::DpPin.shutdown();
|
||||
Config::DmPin.shutdown();
|
||||
shutdownVbus();
|
||||
constexpr static AFGPIOPin Pins[] = { Config::DpPin, Config::DmPin, Config::VbusPin };
|
||||
for (const AFGPIOPin & p : Pins) {
|
||||
p.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
void initOTG() {
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace USB {
|
||||
void init();
|
||||
void shutdown();
|
||||
void initVbus();
|
||||
void shutdownVbus();
|
||||
void initGPIO();
|
||||
void shutdownGPIO();
|
||||
void initOTG();
|
||||
|
||||
Reference in New Issue
Block a user