[Tinyos-devel] Proposed UART Changes
Philip Levis
pal at cs.stanford.edu
Fri Jun 26 11:09:12 PDT 2009
Here's a first cut at a UartControl interface. I've also attached a
full source file. Hopefully the comments give a sense of the
semantics. Note that this interface causes state changes in other
(receive/transmit) interfaces. We generally try to avoid this when
possible, but there are times when the benefits outweigh the costs.
I.e. tying them together would require unifying event handlers and
configuration.
2 major changes: async operations and comments.
Comments/feedback welcome.
interface UartControl {
/**
* Enables the UART receive path, such that
* the system will issue interrupts when it
* receives data.
*/
async command error_t enableRx();
/**
* Disables the UART receive path. After
* this call returns, there will be no further
* receive interrupts until enableRx is called.
*/
async command error_t disableRx();
/**
* Returns whether UART reception is enabled.
*
*/
async command bool rxEnabled();
/**
* Enables the UART transmit path, such that
* the system is able to send bytes.
*/
async command error_t enableTx();
/**
* Disables the UART transmit path. After
* this command returns, attempts to send
* bytes will return EOFF.
*/
async command error_t disableTx();
/**
* Returns whether UART transmission is
* enabled.
*/
async command bool txEnabled();
// TOS_UART_2400, TOS_UART_57600, etc.
/**
* Set the UART speed for both reception
* and transmission. This command should only
* be called when both reception and transmission
* are disabled. The speed should be an constant
* of the form TOS_UART_XX, where XX is the speed,
* such as TOS_UART_57600. Different platforms
* support different speeds.
*/
async command error_t setSpeed(uart_speed_t spd);
/**
* Return the current UART speed.
*/
async command uart_speed_t speed();
/**
* Set whether UART bytes have even parity bits,
* odd parity bits, or no parity bits. This command
* should only be called with both the receive
* and transmit paths are disabled.
*/
// TOS_PARITY_NONE, TOS_PARITY_EVEN, TOS_PARITY_ODD, etc.
async command error_t setParity(uart_parity_t par);
/**
* Return the current parity setting.
*/
async command uart_parity_t parity();
/**
* Enable stop bits. This command should only be called
* when both the receive and transmit paths are disabled.
*/
async command error_t setStop();
/**
* Disable stop bits. This command should only be called
* when both the receive and transmit paths are disabled.
*/
async command error_t setNoStop();
/**
* Returns whether stop bits are enabled.
*/
async command bool stopBits();
}
Phil
-------------- next part --------------
A non-text attachment was scrubbed...
Name: UartControl.nc
Type: application/octet-stream
Size: 4168 bytes
Desc: not available
Url : https://www.millennium.berkeley.edu/pipermail/tinyos-devel/attachments/20090626/c5a3c324/attachment-0001.obj
-------------- next part --------------
More information about the Tinyos-devel
mailing list