arduino-emulator
Loading...
Searching...
No Matches
HardwareGPIO_FIR.h
1#pragma once
2/*
3 HardwareGPIO_FIR.h
4 Copyright (c) 2025 Phil Schatzmann. All right reserved.
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19*/
20#ifdef USE_FIRMATA
21// Undefine DEPRECATED macro from libftdi1 to avoid conflict with Arduino API
22#ifdef DEPRECATED
23#undef DEPRECATED
24#endif
25#include "HardwareGPIO.h"
26#include <map>
27#include <thread>
28#include <atomic>
29#include <mutex>
30#include <chrono>
31
32namespace arduino {
33
38 public:
42 HardwareGPIO_FIRMA() = default;
43
48
57 bool begin(Stream &stream);
58
62 void end();
63
69 void pinMode(pin_size_t pinNumber, PinMode pinMode) override;
70
76 void digitalWrite(pin_size_t pinNumber, PinStatus status) override;
77
83 PinStatus digitalRead(pin_size_t pinNumber) override;
84
90 int analogRead(pin_size_t pinNumber) override;
91
96 void analogReference(uint8_t mode) override;
97
103 void analogWrite(pin_size_t pinNumber, int value) override;
104
110 void analogWriteFrequency(pin_size_t pinNumber, uint32_t frequency);
111
118 void tone(uint8_t _pin, unsigned int frequency,
119 unsigned long duration = 0) override;
120
125 void noTone(uint8_t _pin) override;
126
134 unsigned long pulseIn(uint8_t pin, uint8_t state,
135 unsigned long timeout = 1000000L) override;
136
144 unsigned long pulseInLong(uint8_t pin, uint8_t state,
145 unsigned long timeout = 1000000L) override;
146
152 void analogWriteResolution(uint8_t bits) override;
153
158 operator bool() { return is_open && ftdi_context != nullptr; }
159
160
161 protected:
162 bool is_open = false;
163
164};
165
166} // namespace arduino
167
168#endif // USE_FTDI
Definition DMAPool.h:103
Definition HardwareGPIO_FIR.h:37
~HardwareGPIO_FIRMA()
Destructor for HardwareGPIO_FTDI.
void analogWriteResolution(uint8_t bits) override
Set the resolution for analogWrite() operations.
Definition HardwareGPIO_FIR.cpp:163
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout=1000000L) override
Measure pulse duration on a pin.
Definition HardwareGPIO_FIR.cpp:153
int analogRead(pin_size_t pinNumber) override
Read an analog value from a pin (not supported by FT2232HL).
Definition HardwareGPIO_FIR.cpp:102
void end()
Close the FTDI connection and cleanup resources.
Definition HardwareGPIO_FIR.cpp:36
PinStatus digitalRead(pin_size_t pinNumber) override
Read a digital value from a GPIO pin.
Definition HardwareGPIO_FIR.cpp:71
void analogWrite(pin_size_t pinNumber, int value) override
Write an analog value (PWM) to a pin using software PWM.
Definition HardwareGPIO_FIR.cpp:133
void noTone(uint8_t _pin) override
Stop tone generation on a pin (not supported by FT2232HL).
Definition HardwareGPIO_FIR.cpp:149
void digitalWrite(pin_size_t pinNumber, PinStatus status) override
Write a digital value to a GPIO pin.
Definition HardwareGPIO_FIR.cpp:54
bool begin(Stream &stream)
Initialize the GPIO hardware interface for FTDI FT2232HL.
Definition HardwareGPIO_FIR.cpp:29
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration=0) override
Generate a tone on a pin (not supported by FT2232HL).
Definition HardwareGPIO_FIR.cpp:145
HardwareGPIO_FIRMA()=default
Constructor for HardwareGPIO_FIRMATA.
void analogWriteFrequency(pin_size_t pinNumber, uint32_t frequency)
Set the PWM frequency for analogWrite() on a specific pin.
Definition HardwareGPIO_FIR.cpp:141
void analogReference(uint8_t mode) override
Set the analog reference mode (not supported by FT2232HL).
Definition HardwareGPIO_FIR.cpp:129
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout=1000000L) override
Measure long pulse duration on a pin.
Definition HardwareGPIO_FIR.cpp:158
void pinMode(pin_size_t pinNumber, PinMode pinMode) override
Set the mode of a GPIO pin (INPUT, OUTPUT, etc).
Definition HardwareGPIO_FIR.cpp:45
Abstract base class for GPIO (General Purpose Input/Output) functions.
Definition HardwareGPIO.h:51
Definition Stream.h:51
We provide the WiFi class to simulate the Arduino WIFI. In in Linux we can expect that networking is ...
Definition CanMsg.cpp:31