193,16 → 193,13 |
|
void halSPISetup(void) |
{ |
UCB0CTL0 = UCCKPL+UCMSB+UCMST+UCMODE_0; // 3-pin, 8-bit SPI master |
UCB0CTL0 = UCMSB+UCMST+UCMODE_0; // 3-pin, 8-bit SPI master |
halSPISetPolarityPhase(0, 0); |
UCB0CTL1 = UCSSEL_2+UCSWRST; // SMCLK |
halSPISetSpeedLow(); |
//UCB0MCTL = 0; |
SPI_PxSEL |= SPI_UCLK+SPI_SOMI+SPI_SIMO; |
SPI_PxSEL2 |= SPI_UCLK+SPI_SOMI+SPI_SIMO; |
SPI_PxOUT |= SPI_SIMO + SPI_SOMI + SPI_UCLK; |
// SPI_PxOUT &= ~SPI_UCLK; |
SPI_PxDIR |= SPI_SIMO + SPI_UCLK; |
SPI_PxDIR &= ~SPI_SOMI; |
SPI_PxSEL2 |= SPI_UCLK+SPI_SOMI+SPI_SIMO; |
UCB0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** |
} |
|
216,6 → 213,21 |
UCB0BR1 = 0; |
} |
|
void halSPISetPolarityPhase(char polarity, char phase) { |
// Polarity 0 = inactive low, Polarity 1 = inactive high |
// Phase 0 = Capture on first edge, change on following edge |
// Phase 1 = Change on first edge, capture on following edge |
// Note: Phase is inverted on MSP430! |
UCB0CTL0 &= ~(UCCKPH + UCCKPL); |
if (polarity == 0 && phase == 0) { |
UCB0CTL0 |= UCCKPH; |
} else if (polarity == 1 && phase == 0) { |
UCB0CTL0 |= UCCKPH + UCCKPL; |
} else if (polarity == 1 && phase == 1) { |
UCB0CTL0 |= UCCKPL; |
} |
} |
|
#elif SPI_SER_INTF == SER_INTF_USCIB1 |
|
void halSPISetup(void) |