EasyManuals Logo

Texas Instruments MSP430 User Manual

Texas Instruments MSP430
413 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #227 background imageLoading...
Page #227 background image
227
HW_SPI.c
#include "HW_SPI.h"
void HW_SPI_init(void)
{
UCA0CTL1 |= UCSWRST;
UCA0CTL0 = UCCKPH | UCMSB | UCMST | UCMODE_1 | UCSYNC;
UCA0CTL1 = UCSSEL_2 | UCSWRST;
UCA0BR0 = 8;
UCA0CTL1 &= ~UCSWRST;
}
void SPI_write(unsigned char tx_data)
{
while(!(IFG2 & UCA0TXIFG));
UCA0TXBUF = tx_data;
while(UCA0STAT & UCBUSY);
}
unsigned char SPI_read(void)
{
unsigned char rx_data = 0;
while(!(IFG2 & UCA0RXIFG));
rx_data = UCA0RXBUF;
while(UCA0STAT & UCBUSY);
return rx_data;
}
unsigned char SPI_transfer(unsigned char tx_data)
{
unsigned char rx_data = 0;
while(!(IFG2 & UCA0TXIFG));
UCA0TXBUF = tx_data;
while(UCA0STAT & UCBUSY);
while(!(IFG2 & UCA0RXIFG));
rx_data = UCA0RXBUF;
while(UCA0STAT & UCBUSY);
return rx_data;
}
MPL115A1.h
#include <msp430.h>
#include "delay.h"
#include "HW_SPI.h"

Table of Contents

Other manuals for Texas Instruments MSP430

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments MSP430 and is the answer not in the manual?

Texas Instruments MSP430 Specifications

General IconGeneral
BrandTexas Instruments
ModelMSP430
CategoryMicrocontrollers
LanguageEnglish

Related product manuals