mbedos senza corrente
UARTSerial_half Class Reference
[Drivers]
Class providing buffered UART communication functionality using separate circular buffer for send and receive channels. More...
#include <UARTSerial_half.h>
Public Member Functions | |
UARTSerial_half (PinName tx, PinName rx, PinName dir, int UARTbaud=MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE) | |
Create a UARTSerial_half port, connected to the specified transmit and receive pins, with a particular baud rate. | |
virtual short | poll (short events) const |
Equivalent to POSIX poll(). | |
virtual ssize_t | write (const void *buffer, size_t length) |
Write the contents of a buffer to a file. | |
virtual ssize_t | read (void *buffer, size_t length) |
Read the contents of a file into a buffer. | |
virtual int | close () |
Close a file. | |
virtual int | isatty () |
Check if the file in an interactive terminal device. | |
virtual off_t | seek (off_t offset, int whence) |
Move the file position to a given offset from from a given location. | |
virtual int | sync () |
Flush any buffers associated with the file. | |
virtual int | flush () |
Set blocking or non-blocking mode The default is blocking. | |
virtual int | set_blocking (bool blocking) |
Set blocking or non-blocking mode The default is blocking. | |
virtual bool | is_blocking () const |
Check current blocking or non-blocking mode for file operations. | |
virtual int | enable_input (bool enabled) |
Enable or disable input. | |
virtual int | enable_output (bool enabled) |
Enable or disable output. | |
virtual void | sigio (Callback< void()> func) |
Register a callback on state change of the file. | |
void | set_data_carrier_detect (PinName dcd_pin, bool active_high=false) |
Setup interrupt handler for DCD line. | |
void | set_baud (int UARTbaud) |
Set the baud rate. | |
void | set_format (int bits=8, Parity parity=UARTSerial_half::None, int stop_bits=1) |
Set the transmission format used by the serial port. | |
void | set_flow_control (Flow type, PinName flow1=NC, PinName flow2=NC) |
Set the flow control type on the serial port. |
Detailed Description
Class providing buffered UART communication functionality using separate circular buffer for send and receive channels.
Definition at line 36 of file UARTSerial_half.h.
Constructor & Destructor Documentation
UARTSerial_half | ( | PinName | tx, |
PinName | rx, | ||
PinName | dir, | ||
int | UARTbaud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE |
||
) |
Create a UARTSerial_half port, connected to the specified transmit and receive pins, with a particular baud rate.
- Parameters:
-
tx Transmit pin rx Receive pin baud The baud rate of the serial port (optional, defaults to MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)
Definition at line 15 of file UARTSerial_half.cpp.
Member Function Documentation
int close | ( | ) | [virtual] |
Close a file.
- Returns:
- 0 on success, negative error code on failure
Definition at line 62 of file UARTSerial_half.cpp.
int enable_input | ( | bool | enabled ) | [virtual] |
Enable or disable input.
Control enabling of device for input. This is primarily intended for temporary power-saving; the overall ability of the device to operate for input and/or output may be fixed at creation time, but this call can allow input to be temporarily disabled to permit power saving without losing device state.
- Parameters:
-
enabled true to enable input, false to disable.
- Returns:
- 0 on success
- Negative error code on failure
Definition at line 414 of file UARTSerial_half.cpp.
int enable_output | ( | bool | enabled ) | [virtual] |
Enable or disable output.
Control enabling of device for output. This is primarily intended for temporary power-saving; the overall ability of the device to operate for input and/or output may be fixed at creation time, but this call can allow output to be temporarily disabled to permit power saving without losing device state.
- Parameters:
-
enabled true to enable output, false to disable.
- Returns:
- 0 on success
- Negative error code on failure
Definition at line 433 of file UARTSerial_half.cpp.
int flush | ( | ) | [virtual] |
Set blocking or non-blocking mode The default is blocking.
- Parameters:
-
blocking true for blocking mode, false for non-blocking mode.
Definition at line 89 of file UARTSerial_half.cpp.
virtual bool is_blocking | ( | ) | const [virtual] |
Check current blocking or non-blocking mode for file operations.
- Returns:
- true for blocking mode, false for non-blocking mode.
Definition at line 148 of file UARTSerial_half.h.
int isatty | ( | ) | [virtual] |
Check if the file in an interactive terminal device.
- Returns:
- True if the file is a terminal
- False if the file is not a terminal
- Negative error code on failure
Definition at line 64 of file UARTSerial_half.cpp.
short poll | ( | short | events ) | const [virtual] |
Equivalent to POSIX poll().
Derived from FileHandle. Provides a mechanism to multiplex input/output over a set of file handles.
Definition at line 300 of file UARTSerial_half.cpp.
ssize_t read | ( | void * | buffer, |
size_t | length | ||
) | [virtual] |
Read the contents of a file into a buffer.
Follows POSIX semantics:
* if no data is available, and non-blocking set return -EAGAIN * if no data is available, and blocking set, wait until data is available * If any data is available, call returns immediately
- Parameters:
-
buffer The buffer to read in to length The number of bytes to read
- Returns:
- The number of bytes read, 0 at end of file, negative error on failure
Definition at line 194 of file UARTSerial_half.cpp.
off_t seek | ( | off_t | offset, |
int | whence | ||
) | [virtual] |
Move the file position to a given offset from from a given location.
Not valid for a device type FileHandle like UARTSerial_half. In case of UARTSerial_half, returns ESPIPE
- Parameters:
-
offset The offset from whence to move to whence The start of where to seek SEEK_SET to start from beginning of file, SEEK_CUR to start from current position in file, SEEK_END to start from end of file
- Returns:
- The new offset of the file, negative error code on failure
Definition at line 67 of file UARTSerial_half.cpp.
void set_baud | ( | int | UARTbaud ) |
virtual int set_blocking | ( | bool | blocking ) | [virtual] |
Set blocking or non-blocking mode The default is blocking.
- Parameters:
-
blocking true for blocking mode, false for non-blocking mode.
Definition at line 137 of file UARTSerial_half.h.
void set_data_carrier_detect | ( | PinName | dcd_pin, |
bool | active_high = false |
||
) |
Setup interrupt handler for DCD line.
If DCD line is connected, an IRQ handler will be setup. Does nothing if DCD is NC, i.e., not connected.
- Parameters:
-
dcd_pin Pin-name for DCD active_high a boolean set to true if DCD polarity is active low
void set_flow_control | ( | Flow | type, |
PinName | flow1 = NC , |
||
PinName | flow2 = NC |
||
) |
Set the flow control type on the serial port.
- Parameters:
-
type the flow control type (Disabled, RTS, CTS, RTSCTS) flow1 the first flow control pin (RTS for RTS or RTSCTS, CTS for CTS) flow2 the second flow control pin (CTS for RTSCTS)
Definition at line 54 of file UARTSerial_half.cpp.
void set_format | ( | int | bits = 8 , |
Parity | parity = UARTSerial_half::None , |
||
int | stop_bits = 1 |
||
) |
Set the transmission format used by the serial port.
- Parameters:
-
bits The number of bits in a word (5-8; default = 8) parity The parity used (None, Odd, Even, Forced1, Forced0; default = None) stop_bits The number of stop bits (1 or 2; default = 1)
Definition at line 46 of file UARTSerial_half.cpp.
void sigio | ( | Callback< void()> | func ) | [virtual] |
Register a callback on state change of the file.
The specified callback will be called on state changes such as when the file can be written to or read from.
The callback may be called in an interrupt context and should not perform expensive operations.
Note! This is not intended as an attach-like asynchronous api, but rather as a building block for constructing such functionality.
The exact timing of when the registered function is called is not guaranteed and susceptible to change. It should be used as a cue to make read/write/poll calls to find the current state.
- Parameters:
-
func Function to call on state change
Definition at line 107 of file UARTSerial_half.cpp.
int sync | ( | ) | [virtual] |
Flush any buffers associated with the file.
- Returns:
- 0 on success, negative error code on failure
Definition at line 74 of file UARTSerial_half.cpp.
ssize_t write | ( | const void * | buffer, |
size_t | length | ||
) | [virtual] |
Write the contents of a buffer to a file.
Follows POSIX semantics:
* if blocking, block until all data is written * if no data can be written, and non-blocking set, return -EAGAIN * if some data can be written, and non-blocking set, write partial
- Parameters:
-
buffer The buffer to write from length The number of bytes to write
- Returns:
- The number of bytes written, negative error on failure
Definition at line 136 of file UARTSerial_half.cpp.
Generated on Mon Jul 18 2022 22:37:29 by 1.7.2