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 "SerialBase.h" 27 #include "InterruptIn.h" 28 #include "platform/PlatformMutex.h" 29 #include "hal/serial_api.h" 30 #include "platform/CircularBuffer.h" 31 #include "platform/NonCopyable.h" 33 #ifndef MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE 34 #define MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE 256 37 #ifndef MBED_CONF_DRIVERS_UART_SERIAL_TXBUF_SIZE 38 #define MBED_CONF_DRIVERS_UART_SERIAL_TXBUF_SIZE 256 59 UARTSerial(PinName tx, PinName rx,
int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
85 virtual ssize_t
write(
const void *buffer,
size_t length);
99 virtual ssize_t
read(
void *buffer,
size_t length);
127 virtual off_t
seek(off_t offset,
int whence);
142 _blocking = blocking;
221 using SerialBase::Parity;
223 using SerialBase::None;
224 using SerialBase::Odd;
225 using SerialBase::Even;
226 using SerialBase::Forced1;
227 using SerialBase::Forced0;
235 void set_format(
int bits = 8, Parity parity = UARTSerial::None,
int stop_bits = 1);
240 using SerialBase::Flow;
242 using SerialBase::Disabled;
243 using SerialBase::RTS;
244 using SerialBase::CTS;
245 using SerialBase::RTSCTS;
258 void wait_ms(uint32_t millisec);
261 virtual void lock(
void);
264 virtual void unlock(
void);
267 virtual void api_lock(
void);
270 virtual void api_unlock(
void);
273 ssize_t write_unbuffered(
const char *buf_ptr,
size_t length);
275 void enable_rx_irq();
276 void disable_rx_irq();
277 void enable_tx_irq();
278 void disable_tx_irq();
291 bool _tx_irq_enabled;
292 bool _rx_irq_enabled;
319 #endif //(DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) 320 #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.