18 #ifndef MBED_UARTSERIAL_H 19 #define MBED_UARTSERIAL_H 21 #include "platform/platform.h" 23 #if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) 25 #include "platform/FileHandle.h" 26 #include "drivers/SerialBase.h" 27 #include "drivers/InterruptIn.h" 28 #include "platform/PlatformMutex.h" 29 #include "platform/CircularBuffer.h" 30 #include "platform/NonCopyable.h" 32 #ifndef MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE 33 #define MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE 256 36 #ifndef MBED_CONF_DRIVERS_UART_SERIAL_TXBUF_SIZE 37 #define MBED_CONF_DRIVERS_UART_SERIAL_TXBUF_SIZE 256 60 UARTSerial(PinName tx, PinName rx,
int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
93 virtual ssize_t
write(
const void *buffer,
size_t length);
107 virtual ssize_t
read(
void *buffer,
size_t length);
135 virtual off_t
seek(off_t offset,
int whence);
150 _blocking = blocking;
229 using SerialBase::Parity;
231 using SerialBase::None;
232 using SerialBase::Odd;
233 using SerialBase::Even;
234 using SerialBase::Forced1;
235 using SerialBase::Forced0;
243 void set_format(
int bits = 8, Parity parity = UARTSerial::None,
int stop_bits = 1);
248 using SerialBase::Flow;
250 using SerialBase::Disabled;
251 using SerialBase::RTS;
252 using SerialBase::CTS;
253 using SerialBase::RTSCTS;
267 virtual void lock(
void);
270 virtual void unlock(
void);
273 virtual void api_lock(
void);
276 virtual void api_unlock(
void);
279 ssize_t write_unbuffered(
const char *buf_ptr,
size_t length);
281 void enable_rx_irq();
282 void disable_rx_irq();
283 void enable_tx_irq();
284 void disable_tx_irq();
297 bool _tx_irq_enabled;
298 bool _rx_irq_enabled;
328 #endif //(DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) 329 #endif //MBED_UARTSERIAL_H virtual int sync()
Flush any buffers associated with the file.
void baud(int baudrate)
Set the baud rate of the serial port.
virtual int enable_input(bool enabled)
Enable or disable input.
bool readable() const
Definition depends on the subclass implementing FileHandle.
Templated Circular buffer class.
virtual bool is_blocking() const
Check current blocking or non-blocking mode for file operations.
virtual int enable_output(bool enabled)
Enable or disable output.
virtual ssize_t read(void *buffer, size_t length)
Read the contents of a file into a buffer.
void set_format(int bits=8, Parity parity=UARTSerial::None, int stop_bits=1)
Set the transmission format used by the serial port.
Class providing buffered UART communication functionality using separate circular buffer for send and...
Prevents generation of copy constructor and copy assignment operator in derived classes.
void set_data_carrier_detect(PinName dcd_pin, bool active_high=false)
Setup interrupt handler for DCD line.
virtual void sigio(Callback< void()> func)
Register a callback on state change of the file.
virtual off_t seek(off_t offset, int whence)
Move the file position to a given offset from from a given location.
virtual int set_blocking(bool blocking)
Set blocking or non-blocking mode The default is blocking.
A base class for serial port implementations Can't be instantiated directly (use Serial or RawSerial)...
void set_baud(int baud)
Set the baud rate.
A digital interrupt input, used to call a function on a rising or falling edge.
virtual int isatty()
Check if the file in an interactive terminal device.
UARTSerial(PinName tx, PinName rx, int baud=MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)
Create a UARTSerial port, connected to the specified transmit and receive pins, with a particular bau...
virtual short poll(short events) const
Equivalent to POSIX poll().
bool writable() const
Definition depends on the subclass implementing FileHandle.
virtual int close()
Close a file.
virtual ssize_t write(const void *buffer, size_t length)
Write the contents of a buffer to a file.
Callback class based on template specialization.
void set_flow_control(Flow type, PinName flow1=NC, PinName flow2=NC)
Set the flow control type on the serial port.