-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathUSBClass.cpp
53 lines (40 loc) · 1.07 KB
/
USBClass.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* @file USBClass.cpp
* @author Leonardo Cavagnis
* @brief Source file for the USB Controller of the Portenta Machine Control.
*/
/* Includes -----------------------------------------------------------------*/
#include "USBClass.h"
/* Functions -----------------------------------------------------------------*/
USBClass::USBClass(PinName power_pin, PinName usbflag_pin)
: _power{power_pin}, _usbflag{usbflag_pin}
{ }
USBClass::~USBClass()
{ }
bool USBClass::begin() {
pinMode(_power, OUTPUT);
pinMode(_usbflag, INPUT);
_enable();
return true;
}
void USBClass::end() {
_disable();
}
bool USBClass::getFaultStatus() {
bool res = false;
if (digitalRead(_usbflag) == LOW) {
/* Active−low, asserted during overcurrent, overtemperature, or reverse−voltage conditions. */
res = true;
} else {
res = false;
}
return res;
}
void USBClass::_enable() {
digitalWrite(_power, LOW);
}
void USBClass::_disable() {
digitalWrite(_power, HIGH);
}
USBClass MachineControl_USBController;
/**** END OF FILE ****/