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);
86 virtual ssize_t
write(
const void *buffer,
size_t length);
100 virtual ssize_t
read(
void *buffer,
size_t length);
128 virtual off_t
seek(off_t offset,
int whence);
143 _blocking = blocking;
222 using SerialBase::Parity;
224 using SerialBase::None;
225 using SerialBase::Odd;
226 using SerialBase::Even;
227 using SerialBase::Forced1;
228 using SerialBase::Forced0;
236 void set_format(
int bits = 8, Parity parity = UARTSerial::None,
int stop_bits = 1);
241 using SerialBase::Flow;
243 using SerialBase::Disabled;
244 using SerialBase::RTS;
245 using SerialBase::CTS;
246 using SerialBase::RTSCTS;
260 virtual void lock(
void);
263 virtual void unlock(
void);
266 virtual void api_lock(
void);
269 virtual void api_unlock(
void);
272 ssize_t write_unbuffered(
const char *buf_ptr,
size_t length);
274 void enable_rx_irq();
275 void disable_rx_irq();
276 void enable_tx_irq();
277 void disable_tx_irq();
290 bool _tx_irq_enabled;
291 bool _rx_irq_enabled;
321 #endif //(DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) 322 #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.