19 #ifndef _SIGNALGENERATOR_ESP32_H_ 20 #define _SIGNALGENERATOR_ESP32_H_ 23 #include <driver/timer.h> 28 #define MAX_BYTES_IN_PACKET 10 31 uint8_t buffer[MAX_BYTES_IN_PACKET];
33 uint8_t numberOfRepeats;
37 struct SignalGenerator {
38 template<
int timerIndex>
39 void configureSignal(String, uint8_t, uint16_t);
41 bool IRAM_ATTR getNextBitToSend();
42 void loadPacket(std::vector<uint8_t>,
int);
43 void waitForQueueEmpty();
46 hw_timer_t *_fullCycleTimer;
47 hw_timer_t *_pulseTimer;
49 uint8_t _directionPin;
50 int _currentMonitorPin;
51 std::queue<Packet *> _toSend;
52 std::queue<Packet *> _availablePackets;
53 Packet *_currentPacket;
55 Packet _idlePacket = {
56 { 0xFF, 0xFF, 0xFD, 0xFE, 0x00, 0x7F, 0x80, 0x00, 0x00, 0x00 },
63 extern SignalGenerator dccSignalGenerators[2];
64 void startDCCSignalGenerators();
66 int16_t readCV(
const uint16_t);
67 bool writeProgCVByte(
const uint16_t,
const uint8_t);
68 bool writeProgCVBit(
const uint16_t,
const uint8_t,
const bool);
69 void writeOpsCVByte(
const uint16_t,
const uint16_t,
const uint8_t);
70 void writeOpsCVBit(
const uint16_t,
const uint16_t,
const uint8_t,
const bool);
72 #define SIGNAL_GENERATOR_MAIN 0 73 #define SIGNAL_GENERATOR_PROG 1