mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-20 01:08:15 +01:00
39 lines
773 B
C++
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);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|