-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathProgrammableDIOClass.h
71 lines (60 loc) · 2.56 KB
/
ProgrammableDIOClass.h
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* @file ProgrammableDIOClass.h
* @author Leonardo Cavagnis
* @brief Header file for the Programmable Digital IO connector of the Portenta Machine Control library.
*
* This library allows interfacing with the IO Expander and configuring the thermal shutdown mode of the high-side switches.
*/
#ifndef __PROGRAMMABLE_DIO_CLASS_H
#define __PROGRAMMABLE_DIO_CLASS_H
/* Includes -------------------------------------------------------------------*/
#include "utility/ioexpander/ArduinoIOExpander.h"
#include <Arduino.h>
#include <mbed.h>
#include "pins_mc.h"
/* Class ----------------------------------------------------------------------*/
/**
* @class ProgrammableDIOClass
* @brief Class for the Programmable Digital IO connector of the Portenta Machine Control.
*
* This class extends the ArduinoIOExpanderClass to interface with the IO Expander and provides methods to configure thermal shutdown modes.
*/
class ProgrammableDIOClass : public ArduinoIOExpanderClass {
public:
/**
* @brief Construct a ProgrammableDIOClass object.
*
* This constructor initializes a ProgrammableDIOClass object with the specified pin assignment for the latch pin.
*
* @param latch_pin The pin number for the latch mode control.
*/
ProgrammableDIOClass(PinName latch_pin = MC_PDIO_LATCH_PIN);
/**
* @brief Destruct the ProgrammableDIOClass object.
*
* This destructor releases any resources used by the ProgrammableDIOClass object.
*/
~ProgrammableDIOClass();
/**
* @brief Initialize the ProgrammableDIO module with the specified latch mode.
*
* @param latch_mode The latch mode for thermal shutdown. If true, thermal shutdown operates in the latch mode. Otherwise, it operates in the auto-retry mode.
* @return true If the ProgrammableDIO module is successfully initialized, false otherwise.
*/
bool begin(bool latch_mode = true);
private:
PinName _latch; // Latch control pin
/**
* @brief Configures the thermal shutdown of the high-side switches (TPS4H160) to operate in latch mode.
* The output latches off when thermal shutdown occurs.
*/
void _setLatchMode();
/**
* @brief Configures the thermal shutdown of the high-side switches (TPS4H160) to operate in auto-retry mode.
* The output automatically recovers when TJ < T(SD) – T(hys), but the current is limited to ICL(TSD)
* to avoid repetitive thermal shutdown.
*/
void _setAutoRetryMode();
};
extern ProgrammableDIOClass MachineControl_DigitalProgrammables;
#endif /* __PROGRAMMABLE_DIO_CLASS_H */