Skip to content

Commit 6a78463

Browse files
Use std::function instead of raw function pointer
Since lambdas with captures can no longer be converted to function pointers
1 parent c9b9e4f commit 6a78463

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/CH375.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ bool CH375::test() {
4848
return ((uint8_t) receive()) == ((uint8_t) ~b);
4949
}
5050

51-
bool CH375::setBaudRate(uint32_t baudRate, void (*setLocalBaudRate)(void)) {
51+
bool CH375::setBaudRate(uint32_t baudRate, std::function<void(void)> setLocalBaudRate) {
5252
sendCommand(CH375_CMD_SET_BAUDRATE);
5353
sendData(0x03);
5454
sendData((uint8_t) (256 - 6000000/baudRate)); //TODO: may be architecture-dependend, check on AVR

src/CH375.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#pragma once
2+
#include <functional>
23
#include "Arduino.h"
34

45
#define CH375_CMD_GET_IC_VER 0x01
@@ -105,7 +106,7 @@ class CH375 {
105106
CH375(Stream& _stream, int _interruptPin);
106107
bool init();
107108
bool test();
108-
bool setBaudRate(uint32_t baudRate, void (*setLocalBaudRate)(void));
109+
bool setBaudRate(uint32_t baudRate, std::function<void(void)> setLocalBaudRate);
109110
uint8_t getChipVersion();
110111
void rd_usb_data(uint8_t* buf, uint8_t maxLen);
111112
void wr_usb_data(uint8_t* buf, uint8_t len);

0 commit comments

Comments
 (0)