summaryrefslogtreecommitdiff
path: root/src/arch/msp430fr5994lp
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/msp430fr5994lp')
-rw-r--r--src/arch/msp430fr5994lp/driver/spi_b.cc56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/arch/msp430fr5994lp/driver/spi_b.cc b/src/arch/msp430fr5994lp/driver/spi_b.cc
index 0fa71da..8624a40 100644
--- a/src/arch/msp430fr5994lp/driver/spi_b.cc
+++ b/src/arch/msp430fr5994lp/driver/spi_b.cc
@@ -7,33 +7,33 @@
void SPI::setup()
{
- UCB0CTLW0 |= UCSWRST;
+ UCB1CTLW0 |= UCSWRST;
- /* UCB0CLK Pin 2.2 */
- P2SEL0 &= ~BIT2;
- P2SEL1 |= BIT2;
- P2DIR |= BIT2;
+ /* UCB1CLK Pin 5.2 */
+ P5SEL1 &= ~BIT2;
+ P5SEL0 |= BIT2;
+ P5DIR |= BIT2;
- /* UCB0SIMO Pin 1.6 */
- P1SEL0 &= ~BIT6;
- P1SEL1 |= BIT6;
- P1DIR |= BIT6;
+ /* UCB1SIMO Pin 5.0 */
+ P5SEL1 &= ~BIT0;
+ P5SEL0 |= BIT0;
+ P5DIR |= BIT0;
- /* UCB0SOMI Pin 1.7 */
- P1SEL0 &= ~BIT7;
- P1SEL1 |= BIT7;
- P1DIR &= ~BIT7;
+ /* UCB1SOMI Pin 5.1 */
+ P5SEL1 &= ~BIT1;
+ P5SEL0 |= BIT1;
+ P5DIR &= ~BIT1;
//P1REN |= BIT6;
- UCB0CTLW0 = UCCKPH | UCMSB | UCMST | UCSYNC | UCMODE_0 | UCSSEL__SMCLK | UCSWRST;
- UCB0BRW = (F_CPU/F_I2C)-1; // /16 -> 1MHz
- // UCB0BRW = (F_CPU / F_I2C) - 1
- UCB0CTLW0 &= ~UCSWRST;
+ UCB1CTLW0 = UCCKPH | UCMSB | UCMST | UCSYNC | UCMODE_0 | UCSSEL__SMCLK | UCSWRST;
+ UCB1BRW = (F_CPU/F_I2C)-1; // /16 -> 1MHz
+ // UCB1BRW = (F_CPU / F_I2C) - 1
+ UCB1CTLW0 &= ~UCSWRST;
}
static inline unsigned char clean_rxbuf()
{
- return UCB0RXBUF;
+ return UCB1RXBUF;
}
signed char SPI::xmit(unsigned char tx_len, unsigned char *tx_buf,
@@ -43,32 +43,32 @@ signed char SPI::xmit(unsigned char tx_len, unsigned char *tx_buf,
return -1;
}
- while (UCB0STATW & UCBUSY) ;
+ while (UCB1STATW & UCBUSY) ;
- if (!(UCB0IFG & UCTXIFG)) {
+ if (!(UCB1IFG & UCTXIFG)) {
return -1;
}
- UCB0IFG &= ~UCRXIFG;
- UCB0TXBUF = tx_buf[0];
+ UCB1IFG &= ~UCRXIFG;
+ UCB1TXBUF = tx_buf[0];
unsigned char tx_pos = 1;
unsigned char rx_pos = 0;
while (tx_pos < tx_len || rx_pos < rx_len) {
- if ((tx_pos < tx_len) && (UCB0IFG & UCTXIFG)) {
- UCB0TXBUF = tx_buf[tx_pos++];
+ if ((tx_pos < tx_len) && (UCB1IFG & UCTXIFG)) {
+ UCB1TXBUF = tx_buf[tx_pos++];
}
- if (UCB0IFG & UCRXIFG) {
+ if (UCB1IFG & UCRXIFG) {
if (rx_pos < rx_len) {
- rx_buf[rx_pos] = UCB0RXBUF;
+ rx_buf[rx_pos] = UCB1RXBUF;
} else {
- UCB0IFG &= ~UCRXIFG;
+ UCB1IFG &= ~UCRXIFG;
}
rx_pos++;
}
}
- while (UCB0STATW & UCBUSY) ;
+ while (UCB1STATW & UCBUSY) ;
return 0;
}