[Tinyos-devel] Re: [Tinyos-help] HplAtm128UartP Baudrate
configuration
Mark Kranz
mkranz at gmail.com
Tue Jul 10 00:56:16 PDT 2007
Phil,
Here's the patch. I left the PLATFORM_BAUDRATE enum intact on each of
the four atm128 platforms (mica2, mica2dot, micaz, btnode3), since it
was needed for some timing calibration in Atm128UartP (a generic
interface to higher level serial components - which has no knowledge of
whether it is wired to UART0 or UART1).
A possibly better way to do it would be to include the baudrate as a
parameter to the Atm128UartP generic (currently wired in Atm128Uart0C) -
but this doesn't really bother me at the moment.
Now each platform can just change the UART0_BAUDRATE or UART1_BAUDRATE
in their hardware.h. Those 4 platforms compile okay, and I don't imagine
that I've broken anything.
Good luck with testing the next release!
cheers
-Mark
Philip Levis wrote:
> On Jul 8, 2007, at 8:00 PM, Mark Kranz wrote:
>
>> Hi all,
>>
>> The way that UART baudrates is configured on atm128 chips makes it
>> impossible to use different baud-rates on different UARTs (eg UART0
>> and UART1).
>>
>> ubrr0 = call Atm128Calibrate.baudrateRegister(PLATFORM_BAUDRATE);
>> ...
>> ubrr1 = call Atm128Calibrate.baudrateRegister(PLATFORM_BAUDRATE);
>>
>> At the moment, the only way to override this is to shadow
>> HplAtm128UartP in our platform's implementation, change the function
>> arguments UART0_BAUDRATE and UART1_BAUDRATE, then #define them in the
>> platform's hardware header or makefile settings.
>>
>> Can anyone think of a better way to do this? Does anyone else have a
>> genuine need for different baud-rates on different UARTs?
>
> A better solution would be to have separate UART0 and UART1 values
> defined in platform.h. I suspect the only reason they have the same
> value is that not many people use UART1 so it wasn't needed.
>
> Right now we're testing 2.0.2, but if you send a patch to -devel I can
> apply it after the release. If you do, be sure to test that it doesn't
> break existing platforms.
>
> Until then, shadowing a component seems like a perfectly reasonable
> way to handle the issue.
>
> Phil
>
-------------- next part --------------
Index: tinyos-2.x/tos/chips/atm128/HplAtm128UartP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/atm128/HplAtm128UartP.nc,v
retrieving revision 1.5
diff -u -8 -p -r1.5 HplAtm128UartP.nc
--- tinyos-2.x/tos/chips/atm128/HplAtm128UartP.nc 12 Dec 2006 18:23:03 -0000 1.5
+++ tinyos-2.x/tos/chips/atm128/HplAtm128UartP.nc 10 Jul 2007 07:42:52 -0000
@@ -89,17 +89,17 @@ implementation {
Atm128UartStatus_t stts;
Atm128UartControl_t ctrl;
uint16_t ubrr0;
ctrl.bits = (struct Atm128_UCSRB_t) {rxcie:0, txcie:0, rxen:0, txen:0};
stts.bits = (struct Atm128_UCSRA_t) {u2x:1};
mode.bits = (struct Atm128_UCSRC_t) {ucsz:ATM128_UART_DATA_SIZE_8_BITS};
- ubrr0 = call Atm128Calibrate.baudrateRegister(PLATFORM_BAUDRATE);
+ ubrr0 = call Atm128Calibrate.baudrateRegister(UART0_BAUDRATE);
UBRR0L = ubrr0;
UBRR0H = ubrr0 >> 8;
UCSR0A = stts.flat;
UCSR0C = mode.flat;
UCSR0B = ctrl.flat;
return SUCCESS;
}
@@ -186,17 +186,17 @@ implementation {
Atm128UartStatus_t stts;
Atm128UartControl_t ctrl;
uint16_t ubrr1;
ctrl.bits = (struct Atm128_UCSRB_t) {rxcie:0, txcie:0, rxen:0, txen:0};
stts.bits = (struct Atm128_UCSRA_t) {u2x:1};
mode.bits = (struct Atm128_UCSRC_t) {ucsz:ATM128_UART_DATA_SIZE_8_BITS};
- ubrr1 = call Atm128Calibrate.baudrateRegister(PLATFORM_BAUDRATE);
+ ubrr1 = call Atm128Calibrate.baudrateRegister(UART1_BAUDRATE);
UBRR1L = ubrr1;
UBRR1H = ubrr1 >> 8;
UCSR1A = stts.flat;
UCSR1C = mode.flat;
UCSR1B = ctrl.flat;
return SUCCESS;
}
Index: tinyos-2.x/tos/platforms/mica2dot/hardware.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/platforms/mica2dot/hardware.h,v
retrieving revision 1.5
diff -u -8 -p -r1.5 hardware.h
--- tinyos-2.x/tos/platforms/mica2dot/hardware.h 12 Dec 2006 18:23:43 -0000 1.5
+++ tinyos-2.x/tos/platforms/mica2dot/hardware.h 10 Jul 2007 07:42:54 -0000
@@ -53,12 +53,14 @@
// A/D channels
enum {
CHANNEL_RSSI = ATM128_ADC_SNGL_ADC0,
CHANNEL_BATTERY_THERMISTOR = ATM128_ADC_SNGL_ADC1
};
enum {
- PLATFORM_BAUDRATE = 19200L
+ UART0_BAUDRATE = 19200L,
+ UART1_BAUDRATE = 19200L,
+ PLATFORM_BAUDRATE = UART0_BAUDRATE
};
#endif //HARDWARE_H
Index: tinyos-2.x/tos/platforms/mica2/hardware.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/platforms/mica2/hardware.h,v
retrieving revision 1.5
diff -u -8 -p -r1.5 hardware.h
--- tinyos-2.x/tos/platforms/mica2/hardware.h 12 Dec 2006 18:23:43 -0000 1.5
+++ tinyos-2.x/tos/platforms/mica2/hardware.h 10 Jul 2007 07:42:54 -0000
@@ -54,12 +54,14 @@
// A/D channels
enum {
CHANNEL_RSSI = ATM128_ADC_SNGL_ADC0,
CHANNEL_THERMISTOR = ATM128_ADC_SNGL_ADC1, // normally unpopulated
CHANNEL_BATTERY = ATM128_ADC_SNGL_ADC7,
};
enum {
- PLATFORM_BAUDRATE = 57600L
+ UART0_BAUDRATE = 57600L,
+ UART1_BAUDRATE = 57600L,
+ PLATFORM_BAUDRATE = UART0_BAUDRATE
};
#endif //HARDWARE_H
Index: tinyos-2.x/tos/platforms/micaz/hardware.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/platforms/micaz/hardware.h,v
retrieving revision 1.5
diff -u -8 -p -r1.5 hardware.h
--- tinyos-2.x/tos/platforms/micaz/hardware.h 12 Dec 2006 18:23:43 -0000 1.5
+++ tinyos-2.x/tos/platforms/micaz/hardware.h 10 Jul 2007 07:42:57 -0000
@@ -52,12 +52,14 @@
#include <MicaTimer.h>
// A/D channels
enum {
CHANNEL_THERMISTOR = ATM128_ADC_SNGL_ADC1 // normally unpopulated
};
enum {
- PLATFORM_BAUDRATE = 57600L
+ UART0_BAUDRATE = 57600L,
+ UART1_BAUDRATE = 57600L,
+ PLATFORM_BAUDRATE = UART0_BAUDRATE
};
#endif //HARDWARE_H
Index: tinyos-2.x/tos/platforms/btnode3/hardware.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/platforms/btnode3/hardware.h,v
retrieving revision 1.5
diff -u -8 -p -r1.5 hardware.h
--- tinyos-2.x/tos/platforms/btnode3/hardware.h 21 Jun 2007 21:44:16 -0000 1.5
+++ tinyos-2.x/tos/platforms/btnode3/hardware.h 10 Jul 2007 07:42:58 -0000
@@ -55,12 +55,14 @@
// A/D constants (channels, etc)
enum {
CHANNEL_RSSI = ATM128_ADC_SNGL_ADC2,
CHANNEL_THERMISTOR = ATM128_ADC_SNGL_ADC1, // not available on BTnode3
CHANNEL_BATTERY = ATM128_ADC_SNGL_ADC3,
};
enum {
- PLATFORM_BAUDRATE = 57600L
+ UART0_BAUDRATE = 57600L,
+ UART1_BAUDRATE = 57600L,
+ PLATFORM_BAUDRATE = UART0_BAUDRATE
};
#endif //HARDWARE_H
More information about the Tinyos-devel
mailing list