Skip to content

Commit

Permalink
Use std::function instead of raw function pointer
Browse files Browse the repository at this point in the history
Since lambdas with captures can no longer be converted to function
pointers
  • Loading branch information
gianluca-nitti committed Aug 13, 2020
1 parent c9b9e4f commit 6a78463
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/CH375.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bool CH375::test() {
return ((uint8_t) receive()) == ((uint8_t) ~b);
}

bool CH375::setBaudRate(uint32_t baudRate, void (*setLocalBaudRate)(void)) {
bool CH375::setBaudRate(uint32_t baudRate, std::function<void(void)> setLocalBaudRate) {
sendCommand(CH375_CMD_SET_BAUDRATE);
sendData(0x03);
sendData((uint8_t) (256 - 6000000/baudRate)); //TODO: may be architecture-dependend, check on AVR
Expand Down
3 changes: 2 additions & 1 deletion src/CH375.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <functional>
#include "Arduino.h"

#define CH375_CMD_GET_IC_VER 0x01
Expand Down Expand Up @@ -105,7 +106,7 @@ class CH375 {
CH375(Stream& _stream, int _interruptPin);
bool init();
bool test();
bool setBaudRate(uint32_t baudRate, void (*setLocalBaudRate)(void));
bool setBaudRate(uint32_t baudRate, std::function<void(void)> setLocalBaudRate);
uint8_t getChipVersion();
void rd_usb_data(uint8_t* buf, uint8_t maxLen);
void wr_usb_data(uint8_t* buf, uint8_t len);
Expand Down

0 comments on commit 6a78463

Please sign in to comment.