Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

want UART methods to be virtual methods. #928

Open
tokiedokie opened this issue Jul 22, 2024 · 0 comments
Open

want UART methods to be virtual methods. #928

tokiedokie opened this issue Jul 22, 2024 · 0 comments

Comments

@tokiedokie
Copy link
Contributor

tokiedokie commented Jul 22, 2024

MbedSPI and MbedI2C methods are declared as virtual methods.
However the UART methods are not.

Since we want to create our own driver by inheriting from UART, it would be nice if the UART methods were also declared as virtual methods.

class MbedI2C : public HardwareI2C
{
public:
MbedI2C(int sda, int scl);
MbedI2C(PinName sda, PinName scl);
virtual void begin();
#ifndef DEVICE_I2CSLAVE
virtual void __attribute__ ((error("I2C Slave mode is not supported"))) begin(uint8_t address);
#else
virtual void begin(uint8_t address);
#endif
virtual void end();
virtual void setClock(uint32_t freq);
virtual void beginTransmission(uint8_t address);
virtual uint8_t endTransmission(bool stopBit);
virtual uint8_t endTransmission(void);
virtual size_t requestFrom(uint8_t address, size_t len, bool stopBit);
virtual size_t requestFrom(uint8_t address, size_t len);
virtual void onReceive(void(*)(int));
virtual void onRequest(void(*)(void));
virtual size_t write(uint8_t data);
virtual size_t write(int data) {
return write ((uint8_t)data);
};
virtual size_t write(const uint8_t* data, int len);
using Print::write;
virtual int read();
virtual int peek();
virtual void flush();
virtual int available();

class MbedSPI : public SPIClass
{
public:
MbedSPI(int miso, int mosi, int sck);
MbedSPI(PinName miso, PinName mosi, PinName sck);
virtual uint8_t transfer(uint8_t data);
virtual uint16_t transfer16(uint16_t data);
virtual void transfer(void *buf, size_t count);
// Transaction Functions
virtual void usingInterrupt(int interruptNumber);
virtual void notUsingInterrupt(int interruptNumber);
virtual void beginTransaction(SPISettings settings);
virtual void endTransaction(void);
// SPI Configuration methods
virtual void attachInterrupt();
virtual void detachInterrupt();
virtual void begin();
virtual void end();

class UART : public HardwareSerial {
public:
UART(int tx, int rx, int rts = -1, int cts = -1);
UART(PinName tx, PinName rx, PinName rts = NC, PinName cts = NC) : _tx(tx), _rx(rx), _rts(rts), _cts(cts) {}
UART() {
is_usb = true;
}
void begin(unsigned long);
void begin(unsigned long baudrate, uint16_t config);
void begin(unsigned long baudrate, uint16_t config, bool no_rx_pullup);
void end();
int available(void);
int peek(void);
int read(void);
void flush(void);
size_t write(uint8_t c);
size_t write(const uint8_t*, size_t);
using Print::write; // pull in write(str) and write(buf, size) from Print
operator bool();
operator mbed::FileHandle*(); // exposes the internal mbed object
#if defined(SERIAL_CDC)
uint32_t baud();
uint8_t stopbits();
uint8_t paritytype();
uint8_t numbits();
bool dtr();
bool rts();
#endif

@tokiedokie tokiedokie changed the title Make the methods of the UART class virtual. want UART methods to be virtual methods. Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant