interface SpiPacket;
interface ArbiterInfo; /* ??? */
}
- uses interface AsyncConfigure<const msp430_usci_config_t*> as
- Msp430UsciConfigure;
+ uses interface AsyncConfigure<const msp430_usci_spi_t*> as Configure;
}
implementation {
enum {
components new Msp430SpiP() as SpiP;
SpiByte = SpiP;
SpiPacket = SpiP;
- Msp430UsciConfigure = SpiP;
+ Configure = SpiP;
components Msp430UsciA0C as UsciC;
Resource = UsciC.Resource[CLIENT_ID];
interface HplMsp430GeneralIO as SIMO;
interface HplMsp430GeneralIO as SOMI;
interface HplMsp430GeneralIO as SCL;
- interface AsyncConfigure<const msp430_usci_config_t*> as
- Msp430UsciConfigure;
+ interface AsyncConfigure<const msp430_usci_spi_t*> as Configure;
interface Counter<T32khz,uint16_6>
interface ArbiterInfo;
}
async command void ResourceConfigure.configure()
{
atomic {
- const msp430_usci_config_t* config = call Msp430UsciConfigure.get();
+ const msp430_usci_spi_t* config = call Configure.get();
call Registers.setCtl1(UCSWRST);
/* Configure USCI registers */
- call Registers.assignCtl0(config->spi.ctl0);
- call Registers.assignCtl1(config->spi.ctl1|UCSWRST);
- call Registers.assignBr0(config->spi.brx & 0xff);
- call Registers.assignBr1(config->spi.brx >> 8);
- call Registers.assignMctl(config->spi.mctl);
- call Registers.assignIrtctl(config->spi.irtctl);
- call Registers.assignIrrctl(config->spi.irrctl);
- call Registers.assignAbctl(config->spi.abctl);
+ call Registers.assignCtl0(config->ctl0);
+ call Registers.assignCtl1(config->ctl1|UCSWRST);
+ call Registers.assignBr0(config->brx & 0xff);
+ call Registers.assignBr1(config->brx >> 8);
+ call Registers.assignMctl(config->mctl);
+ call Registers.assignIrtctl(config->irtctl);
+ call Registers.assignIrrctl(config->irrctl);
+ call Registers.assignAbctl(config->abctl);
call Registers.clrStat(UCLISTEN);
/* Save pin IO states */
/* Configure RX pin for UART use */
call RXD.makeInput();
- if (config->spi.ren & USCI_REN_RX) {
- if (config->spi.ren & USCI_REN_RX_PULLUP)
+ if (config->ren & USCI_REN_RX) {
+ if (config->ren & USCI_REN_RX_PULLUP)
call RXD.set();
else
call RXD.clr();
*/
/* Configure TX pin for UART use */
- if (config->spi.ren & USCI_REN_TX) {
- if (config->spi.ren & USCI_REN_TX_PULLUP)
+ if (config->ren & USCI_REN_TX) {
+ if (config->ren & USCI_REN_TX_PULLUP)
call TXD.set();
else
call TXD.clr();
signal UartStream.receivedByte(byte);
}
- default async command const msp430_usci_config_t* Msp430UsciConfigure.get()
+ default async command const msp430_usci_spi_t* Configure.get()
{
- const static msp430_usci_config_t def = {
- spi: {
- ctl0: UCMODE_0, /* async, lsb first, 8N1 */
- ctl1: UCSWRST|UCSSEL_1, /* clock spi from SMCLK */
- brx: UBRX_32768HZ_9600,
- mctl: UMCTL_32768HZ_9600,
- irtctl: 0,
- irrctl: 0,
- abctl: 0,
- ren: USCI_REN_NONE
- }
+ const static msp430_usci_spi_t def = {
+ ctl0: UCMODE_0, /* async, lsb first, 8N1 */
+ ctl1: UCSWRST|UCSSEL_1, /* clock spi from SMCLK */
+ brx: UBRX_32768HZ_9600,
+ mctl: UMCTL_32768HZ_9600, /* ??? */
+ ren: USCI_REN_NONE
};
return &def;
interface UartByte;
interface ArbiterInfo; /* ??? */
}
- uses interface AsyncConfigure<const msp430_usci_config_t*> as
- Msp430UsciConfigure;
+ uses interface AsyncConfigure<const msp430_usci_uart_t*> as Configure;
}
implementation {
enum {
components new Msp430UartP() as UartP;
UartStream = UartP;
UartByte = UartP;
- Msp430UsciConfigure = UartP;
+ Configure = UartP;
components Msp430UsciA0C as UsciC;
Resource = UsciC.Resource[CLIENT_ID];
interface UartByte;
interface ArbiterInfo; /* ??? */
}
- uses interface AsyncConfigure<const msp430_usci_config_t*> as
- Msp430UsciConfigure;
+ uses interface AsyncConfigure<const msp430_usci_uart_t*> as Configure;
}
implementation {
enum {
components new Msp430UartP() as UartP;
UartStream = UartP;
UartByte = UartP;
- Msp430UsciConfigure = UartP;
+ Configure = UartP;
components Msp430UsciA1C as UsciC;
Resource = UsciC.Resource[CLIENT_ID];
interface HplMsp430UsciInt as Interrupts;
interface HplMsp430GeneralIO as RXD;
interface HplMsp430GeneralIO as TXD;
- interface AsyncConfigure<const msp430_usci_config_t*> as
- Msp430UsciConfigure;
+ interface AsyncConfigure<const msp430_usci_uart_t*> as Configure;
interface Counter<T32khz,uint16_t>;
interface ArbiterInfo;
}
async command void ResourceConfigure.configure()
{
atomic {
- const msp430_usci_config_t* config = call Msp430UsciConfigure.get();
+ const msp430_usci_uart_t* config = call Configure.get();
call Registers.setCtl1(UCSWRST);
/* Configure USCI registers */
- call Registers.assignCtl0(config->uart.ctl0);
- call Registers.assignCtl1(config->uart.ctl1|UCSWRST);
- call Registers.assignBr0(config->uart.brx & 0xff);
- call Registers.assignBr1(config->uart.brx >> 8);
- call Registers.assignMctl(config->uart.mctl);
- call Registers.assignIrtctl(config->uart.irtctl);
- call Registers.assignIrrctl(config->uart.irrctl);
- call Registers.assignAbctl(config->uart.abctl);
+ call Registers.assignCtl0(config->ctl0);
+ call Registers.assignCtl1(config->ctl1|UCSWRST);
+ call Registers.assignBr0(config->brx & 0xff);
+ call Registers.assignBr1(config->brx >> 8);
+ call Registers.assignMctl(config->mctl);
+ call Registers.assignIrtctl(config->irtctl);
+ call Registers.assignIrrctl(config->irrctl);
+ call Registers.assignAbctl(config->abctl);
call Registers.clrStat(UCLISTEN);
/* Save pin IO states */
/* Configure RX pin for UART use */
call RXD.makeInput();
- if (config->uart.ren & USCI_REN_RX) {
- if (config->uart.ren & USCI_REN_RX_PULLUP)
+ if (config->ren & USCI_REN_RX) {
+ if (config->ren & USCI_REN_RX_PULLUP)
call RXD.set();
else
call RXD.clr();
*/
/* Configure TX pin for UART use */
- if (config->uart.ren & USCI_REN_TX) {
- if (config->uart.ren & USCI_REN_TX_PULLUP)
+ if (config->ren & USCI_REN_TX) {
+ if (config->ren & USCI_REN_TX_PULLUP)
call TXD.set();
else
call TXD.clr();
signal UartStream.receivedByte(byte);
}
- default async command const msp430_usci_config_t* Msp430UsciConfigure.get()
+ default async command const msp430_usci_uart_t* Configure.get()
{
- const static msp430_usci_config_t def = {
- uart: {
- ctl0: UCMODE_0, /* async, lsb first, 8N1 */
- ctl1: UCSWRST|UCSSEL_1, /* clock uart from SMCLK */
- brx: UBRX_32768HZ_9600,
- mctl: UMCTL_32768HZ_9600,
- irtctl: 0,
- irrctl: 0,
- abctl: 0,
- ren: USCI_REN_NONE
- }
+ const static msp430_usci_uart_t def = {
+ ctl0: UCMODE_0, /* async, lsb first, 8N1 */
+ ctl1: UCSWRST|UCSSEL_1, /* clock uart from SMCLK */
+ brx: UBRX_32768HZ_9600,
+ mctl: UMCTL_32768HZ_9600,
+ irtctl: 0,
+ irrctl: 0,
+ abctl: 0,
+ ren: USCI_REN_NONE
};
return &def;
USCI_REN_TX_PULLDOWN = USCI_REN_TX + 0x20
} msp430_ren_t;
+/* Baud rates for UART mode. Only 32KHz modes work right now. */
+typedef enum {
+ /* UCOS16=0. UMCTL = UCBRFx << 4 + UCBRSx << 1 + UCOS16.
+ * 1MHZ = 1,048576HZ, 1E6MHZ = 1,000,000HZ.
+ */
+ UBRX_32768HZ_9600=3, UMCTL_32768HZ_9600=(0 << 4) + (3 << 1) + 0,
+ UBRX_1MHZ_9600=109, UMCTL_1MHZ_9600=(0 << 4) + (2 << 1) + 0,
+ UBRX_1MHZ_115200=9, UMCTL_1MHZ_115200=(0 << 4) + (1 << 1) + 0,
+ UBRX_1E6MHZ_9600=104, UMCTL_1E6MHZ_9600=(0 << 4) + (1 << 1) + 0,
+ UBRX_1E6MHZ_115200=8, UMCTL_1E6MHZ_115200=(0 << 4) + (6 << 1) + 0,
+} msp430_usci_uart_rate_t;
+
typedef struct {
uint8_t ctl0;
uint8_t ctl1;
msp430_ren_t ren;
} __attribute__ ((packed)) msp430_usci_spi_t;
-/* Baud rates for UART mode. Only 32KHz modes work right now. */
-typedef enum {
- /* UCOS16=0. UMCTL = UCBRFx << 4 + UCBRSx << 1 + UCOS16.
- * 1MHZ = 1,048576HZ, 1E6MHZ = 1,000,000HZ.
- */
- UBRX_32768HZ_9600=3, UMCTL_32768HZ_9600=(0 << 4) + (3 << 1) + 0,
- UBRX_1MHZ_9600=109, UMCTL_1MHZ_9600=(0 << 4) + (2 << 1) + 0,
- UBRX_1MHZ_115200=9, UMCTL_1MHZ_115200=(0 << 4) + (1 << 1) + 0,
- UBRX_1E6MHZ_9600=104, UMCTL_1E6MHZ_9600=(0 << 4) + (1 << 1) + 0,
- UBRX_1E6MHZ_115200=8, UMCTL_1E6MHZ_115200=(0 << 4) + (6 << 1) + 0,
-} msp430_usci_uart_rate_t;
-
-typedef union {
- msp430_usci_uart_t uart;
- msp430_usci_spi_t spi;
-} __attribute__ ((packed)) msp430_usci_config_t;
+typedef struct {
+ uint8_t ctl0;
+ uint8_t ctl1;
+ uint16_t brx;
+ uint8_t i2cie;
+ uint8_t i2coa;
+ uint8_t i2csa;
+ msp430_ren_t ren;
+} __attribute__ ((packed)) msp430_usci_i2c_t;
#endif