]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/msp430/usci/Msp430Usci.h
More USCI work.
[tinyos-2.x.git] / tos / chips / msp430 / usci / Msp430Usci.h
index d8a5893807993f7b898b602f0172c127c5ec5364..4d0a2cd713cf5f8db76ed56986d2e0c2b6a0fb9a 100644 (file)
  * @author R. Steve McKown <smckown@gmail.com>
  */
  
-#ifndef MSP430USCI_h
-#define MSP430USCI_h
+#ifndef MSP430_USCI_h
+#define MSP430_USCI_h
 
-#define MSP430_HPLUSCIA0_RESOURCE "Msp430UsciA0.Resource"
-#define MSP430_HPLUSCIB0_RESOURCE "Msp430UsciB0.Resource"
-#define MSP430_HPLUSCIA1_RESOURCE "Msp430UsciA0.Resource"
-#define MSP430_HPLUSCIB1_RESOURCE "Msp430UsciB0.Resource"
+#define MSP430_USCIA0_RESOURCE "Msp430UsciA0.Resource"
+#define MSP430_USCIB0_RESOURCE "Msp430UsciB0.Resource"
+#define MSP430_USCIA1_RESOURCE "Msp430UsciA1.Resource"
+#define MSP430_USCIB1_RESOURCE "Msp430UsciB1.Resource"
 
 /* Values of UCAxCTL0 only looking at the UCMODEx bits */
 typedef enum
@@ -58,6 +58,7 @@ typedef enum
   USCI_I2C
 } msp430_usci_mode_t;
 
+#if 0
 /* FIXME
  * There are different meanings to these fields based upon the mode
  * (uart/spi/etc) and the device (USCI_x0 or USCI_x1).
@@ -73,7 +74,7 @@ typedef struct {
   unsigned int ucmsb: 1;       /* MSB first select.  0=LSB(it) first, 1=MSB(it) first */
   unsigned int ucpar: 1;       /* Parity select. 0=odd parity, 1=even parity */
   unsigned int ucpen: 1;       /* Parity enable.  0=parity disabled, 1=parity enabled */
-} __attribute__ ((packed)) msp430_ucaxctl0_t ;
+} __attribute__ ((packed)) msp430_usci_uart_ctl0_t ;
 
 typedef struct {
   unsigned int ucswrst: 1;     // Software resent enable. 0=disabled (operational), 1=enabled (reset) */
@@ -82,8 +83,8 @@ typedef struct {
   unsigned int ucdorm: 1;      // Dormant; USCI in sleep.  0=!dormant, 1=dormant */
   unsigned int ucbrkie: 1;     // Receive break sets UCAxRXIFG interrupt.  0=no, 1=yes */
   unsigned int ucrxeie: 1;     // Receive erroneous char sets UCAxRXIFG interrupt.  0=no, 1=yes */
-  unsigned int ucucsselx: 2;   // USCI clock source (BRCLK). 00=UCLK, 01=ACLK, 10=SMCLK, 11=SMCLK */
-} __attribute__ ((packed)) msp430_ucaxctl1_t;
+  unsigned int uccsselx: 2;    // USCI clock source (BRCLK). 00=UCLK, 01=ACLK, 10=SMCLK, 11=SMCLK */
+} __attribute__ ((packed)) msp430_usci_uart_ctl1_t;
 
 typedef struct {
   unsigned int ucbusy:1;       /* USCI busy; tx or rx in process.  0=no, 1=yes */
@@ -95,19 +96,19 @@ typedef struct {
   unsigned int ucoe:1;         /* Overrun error flag.  0=no, 1=yes */
   unsigned int ucfe:1;         /* Framing error flag.  0=no, 1=yes */
   unsigned int uclisten:1;     /* Listen enable (loopback).  0=disabled, 1=enabled */
-} __attribute__ ((packed)) msp430_ucaxstat_t;
+} __attribute__ ((packed)) msp430_usci_uart_stat_t;
 
 typdef struct {
   unsigned int uciren:1;       /* IrDA decoder.  0=disabled, 1=enabled */
-  unsigned int unirtxclk:1;    /* IrDA transmit pulse clock select.  0=BRCLK, 1=BRCLK16 if ucos16=1 else BRCLK */
+  unsigned int ucirtxclk:1;    /* IrDA transmit pulse clock select.  0=BRCLK, 1=BRCLK16 if ucos16=1 else BRCLK */
   unsigned ucirtxplx:6;                /* Pulse length.  t(pulse) = (ucirtxplx + 1)/(2 * f(irtxclk)) */
-} __attribute__ ((packed)) msp430_ucaxirtctl_t;
+} __attribute__ ((packed)) msp430_usci_uart_irtctl_t;
 
 typedef struct {
   unsigned int ucirrxfe:1;     /* IrDA recv filter.  0=disabled, 1=enabled */
   unsigned int ucirrxpl:1;     /* IrDA recv input ucaxrxd polarity.  0=high w/light pulse, 1=low */
   unsigned int ucirrxflx:6;    /* IrDA recv filter len.  t(min) = (ucirrxflx + 4)/(2 * f(irtxclk)) */
-} __attribute__ ((packed)) msp430_ucaxirtctl_t;
+} __attribute__ ((packed)) msp430_usci_uart_irrctl_t;
 
 typdef struct {
   unsigned int ucabden:1;      /* Auto baud rate detect enable. 0=no, 1=yes (baud calc from break/sync) */
@@ -116,8 +117,42 @@ typdef struct {
   unsigned int ucstoe:1;       /* Synch field timeout error.  0=no, 1=yes: sync len > measurable time */
   unsigned int ucdelimx:1;     /* Break/synch delimiter length in bit times.  00=1, 01=2, 10=3, 11=4 */
   unsigned int reserved2:2;    /* Reserved */
-} __attribute__ ((packed)) msp430_ucaxabctl_t;
+} __attribute__ ((packed)) msp430_usci_uart_abctl_t;
+#endif
+
+#if 0 /* We aren't using individual fields, but rather leveraging the defs
+       * provided by the compiler.  Hence, bit fields aren't all that useful.
+       */
+typdef struct {
+  msp430_usci_uart_ctl0_t ctl0;
+  msp430_usci_uart_ctl0_t ctl1;
+  msp430_usci_uart_stat_t stat;
+  msp430_usci_uart_irtctl_t irtctl;
+  msp430_usci_uart_irrctl_t irrctl;
+  msp430_usci_uart_abctl_t abctl;
+} __attribute__ ((packed)) msp430_usci_uart_t;
+#else
+typedef struct {
+  uint8_t ctl0;
+  uint8_t ctl1;
+  uint16_t brx;
+  uint8_t mctl;
+  uint8_t irtctl;
+  uint8_t irrctl;
+  uint8_t abctl;
+  /* FIXME: add support for configuring internal pull-up or pull-down on RXD pin */
+} __attribute__ ((packed)) msp430_usci_uart_t;
+#endif
+
+/* Baud rates for UART mode */
+typedef enum {
+  /* UCOS16=0.  UMCTL = UCBRFx << 4 + UCBRSx << 1 + UCOS16. */
+  UBRX_1MHZ_9600=109, UMCTL_1MHZ_9600=(0 << 4) + (2 << 1) + 0,
+  UBRX_1MHZ_115200=9, UMCTL_1MHZ_115200=(0 << 4) + (1 << 1) + 0,
+} msp430_usci_uart_rate_t;
 
-/* FIXME: provide baud rate and configuration stuff */
+typedef union {
+  msp430_usci_uart_t uart;
+} __attribute__ ((packed)) msp430_usci_config_t;
 
 #endif