-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathProgrammableDIOClass.cpp
41 lines (31 loc) · 1021 Bytes
/
ProgrammableDIOClass.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
/**
* @file ProgrammableDIOClass.cpp
* @author Leonardo Cavagnis
* @brief Source file for the Programmable Digital IO connector of the Portenta Machine Control library.
*/
/* Includes -----------------------------------------------------------------*/
#include "ProgrammableDIOClass.h"
/* Functions -----------------------------------------------------------------*/
ProgrammableDIOClass::ProgrammableDIOClass(PinName latch_pin)
: _latch{latch_pin}
{ }
ProgrammableDIOClass::~ProgrammableDIOClass()
{ }
bool ProgrammableDIOClass::begin(bool latch_mode) {
ArduinoIOExpanderClass::begin(IO_ADD);
pinMode(_latch, OUTPUT);
if(latch_mode) {
_setLatchMode();
} else {
_setAutoRetryMode();
}
return true;
}
void ProgrammableDIOClass::_setLatchMode() {
digitalWrite(_latch, HIGH);
}
void ProgrammableDIOClass::_setAutoRetryMode() {
digitalWrite(_latch, LOW);
}
ProgrammableDIOClass MachineControl_DigitalProgrammables;
/**** END OF FILE ****/