Skip to content

Commit b09b4ac

Browse files
committed
Make certain DigitalOut methods virtual
1 parent a6207ca commit b09b4ac

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/DigitalOut.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,17 @@ class DigitalOut {
7070
gpio_init_out_ex(&gpio, pin, value);
7171
}
7272

73+
virtual ~DigitalOut()
74+
{
75+
gpio_free(&gpio);
76+
}
77+
7378
/** Set the output, specified as 0 or 1 (int)
7479
*
7580
* @param value An integer specifying the pin output value,
7681
* 0 for logical 0, 1 (or any other non-zero value) for logical 1
7782
*/
78-
void write(int value)
83+
virtual void write(int value)
7984
{
8085
// Thread safe / atomic HAL call
8186
gpio_write(&gpio, value);
@@ -87,7 +92,7 @@ class DigitalOut {
8792
* an integer representing the output setting of the pin,
8893
* 0 for logical 0, 1 for logical 1
8994
*/
90-
int read()
95+
virtual int read()
9196
{
9297
// Thread safe / atomic HAL call
9398
return gpio_read(&gpio);
@@ -99,7 +104,7 @@ class DigitalOut {
99104
* Non zero value if pin is connected to uc GPIO
100105
* 0 if gpio object was initialized with NC
101106
*/
102-
int is_connected()
107+
virtual int is_connected()
103108
{
104109
// Thread safe / atomic HAL call
105110
return gpio_is_connected(&gpio);

0 commit comments

Comments
 (0)