Files
Upsilon/ion/src/device/usb.cpp
Émilie Feral c632f7c5ee [ion] Improve suspend implementation
Change-Id: Ic43b58f34379292c53a82ab6c85674c6f7a9b381
2017-04-13 12:06:37 +02:00

39 lines
773 B
C++

#include <ion/usb.h>
#include "usb.h"
#include "regs/regs.h"
namespace Ion {
namespace USB {
bool isPlugged() {
return Device::VbusPin.group().IDR()->get(Device::VbusPin.pin());
}
}
}
namespace Ion {
namespace USB {
namespace Device {
void init() {
initGPIO();
}
void initGPIO() {
/* Configure the GPIO
* The VBUS pin is connected to the USB VBUS port. To read if the USB is
* plugged, the pin must be pulled down. */
VbusPin.group().MODER()->setMode(VbusPin.pin(), GPIO::MODER::Mode::Input);
VbusPin.group().PUPDR()->setPull(VbusPin.pin(), GPIO::PUPDR::Pull::Down);
}
void shutdown() {
VbusPin.group().MODER()->setMode(VbusPin.pin(), GPIO::MODER::Mode::Analog);
VbusPin.group().PUPDR()->setPull(VbusPin.pin(), GPIO::PUPDR::Pull::None);
}
}
}
}