[Tinyos-devel] Proposed UART Changes
Philip Levis
pal at cs.stanford.edu
Thu Jun 18 15:24:54 PDT 2009
On Jun 17, 2009, at 12:56 PM, Trevor Pace wrote:
> Hey Eric,
>
> The problem I am seeing right now is that I am developing a module
> which should in theory work on any mote that supports UART. However,
> there exists no hardware abstraction interface provided by all
> platforms that would allow me to disable/enable communication. It
> does exist at the lower HPL but that is implemented per chip.
>
> So for me to shut-off my reception temporary I must wire a chip-
> specific HPL Uart module removing the possibility of compatibility
> with other chip sets. The Msp430HplUart you mentioned does support
> enabling/disabling for sure, unfortunately by the time it gets to
> the PlatformSerialC abstraction (which is available to all chipsets
> with UART) then I lose that ability.
It seems we definitely want a UartControl or UartSettings interface.
One constraint is that we want to catch bad settings at compile-time.
For example, trying to set the UART to a speed the MCU does not
support should be a compile-time error. The standard way to do this is
with enums: if you use an undefined enum you don't compile.
How about something like
interface UartControl {
command error_t enableRx();
command error_t disableRx();
command bool rxEnabled();
command error_t enableTx();
command error_t disableTx();
command bool txEnabled();
// TOS_UART_2400, TOS_UART_57600, etc.
command error_t setSpeed(uart_speed_t spd);
command uart_speed_t speed();
// TOS_PARITY_NONE, TOS_PARITY_EVEN, TOS_PARITY_ODD, etc.
command error_t setParity(uart_parity_t par);
command uart_parity_t parity();
command error_t setStop();
command error_t setNoStop();
command bool stopBits();
}
Thoughts?
Phil
More information about the Tinyos-devel
mailing list