Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 7 months ago.
Callback is not a template "Callback<void()> _ irq[IrqCnt];
- ifndef MBED_SERIALBASE_H
- define MBED_SERIALBASE_H
- include "platform/platform.h"
- if DEVICE_SERIAL
- include "Stream.h"
- include "Callback.h"
- include "serial_api.h"
- include "toolchain.h"
- if DEVICE_SERIAL_ASYNCH
- include "CThunk.h"
- include "dma_api.h"
- endif
namespace mbed { class SerialBase {
public: void baud(int baudrate);
enum Parity { None = 0, Odd, Even, Forced1, Forced0 };
enum IrqType { RxIrq = 0, TxIrq,
IrqCnt };
enum Flow { Disabled = 0, RTS, CTS, RTSCTS };
void format(int bits=8, Parity parity=SerialBase::None, int stop_bits=1);
int readable();
int writeable();
void attach(Callback<void()> func, IrqType type=RxIrq);
template<typename T> MBED_DEPRECATED_SINCE("mbed-os-5.1", "The attach function does not support cv-qualifiers. Replaced by " "attach(callback(obj, method), type).") void attach(T *obj, void (T::*method)(), IrqType type=RxIrq) { attach(callback(obj, method), type); }
template<typename T> MBED_DEPRECATED_SINCE("mbed-os-5.1", "The attach function does not support cv-qualifiers. Replaced by " "attach(callback(obj, method), type).") void attach(T *obj, void (*method)(T*), IrqType type=RxIrq) { attach(callback(obj, method), type); }
protected:
virtual void unlock(void);
public:
- if DEVICE_SERIAL_FC void set_flow_control(Flow type, PinName flow1=NC, PinName flow2=NC);
- endif
static void _irq_handler(uint32_t id, SerialIrq irq_type);
- if DEVICE_SERIAL_ASYNCH
int write(const uint8_t *buffer, int length, const event_callback_t& callback, int event = SERIAL_EVENT_TX_COMPLETE);
int write(const uint16_t *buffer, int length, const event_callback_t& callback, int event = SERIAL_EVENT_TX_COMPLETE);
int read(uint8_t *buffer, int length, const event_callback_t& callback, int event = SERIAL_EVENT_RX_COMPLETE, unsigned char char_match = SERIAL_RESERVED_CHAR_MATCH);
int read(uint16_t *buffer, int length, const event_callback_t& callback, int event = SERIAL_EVENT_RX_COMPLETE, unsigned char char_match = SERIAL_RESERVED_CHAR_MATCH);
void abort_read();
int set_dma_usage_tx(DMAUsage usage);
int set_dma_usage_rx(DMAUsage usage);
protected: void start_read(void *buffer, int buffer_size, char buffer_width, const event_callback_t& callback, int event, unsigned char char_match); void start_write(const void *buffer, int buffer_size, char buffer_width, const event_callback_t& callback, int event); void interrupt_handler_asynch(void);
- endif
protected: SerialBase(PinName tx, PinName rx, int baud); virtual SerialBase() { }
int _base_getc(); int _base_putc(int c);
- if DEVICE_SERIAL_ASYNCH CThunk<SerialBase> _thunk_irq; event_callback_t _tx_callback; event_callback_t _rx_callback; DMAUsage _tx_usage; DMAUsage _rx_usage;
- endif
serial_t _serial; Callback<void()> _irq[IrqCnt]; int _baud;
};
} namespace mbed
- endif
- endif