105 #define SPI_SRDYBIT BIT6 // On port 2
109 #define SPI_SETSRDYDETECTUP P2IES &= ~SPI_SRDYBIT
113 #define SPI_SETSRDYDETECTDOWN P2IES |= SPI_SRDYBIT
118 #define SPI_SSBIT 0x01 // bit 0 on port 3
122 #define SPI_MRDYBIT BIT6 // On port 3
126 #define SPI_CLRMRDY P3OUT &= ~(SPI_MRDYBIT | SPI_SSBIT)
130 #define SPI_SETMRDY P3OUT |= SPI_MRDYBIT | SPI_SSBIT
135 #define SPI_FRAMEHDRSIZE 3
153 SPI_SREQ_RECEIVING_START,
155 SPI_SREQ_RECEIVING_OVER,
158 SPI_POLL_RECEIVING_START,
160 SPI_POLL_RECEIVING_OVER,
253 UInt8 spi_freezeDetect;
308 UCB0CTL1 &= ~UCSWRST;
312 spi_freezeDetect = 2;
331 if (!spi_freezeDetect) {
333 spi_freezeDetect = 10;
419 if ((
spi_buf[1] & 0xE0) == 0x20) {
459 case SPI_SREQ_RECEIVING:
460 case SPI_SREQ_RECEIVING_OVER:
461 case SPI_POLL_RECEIVING:
462 case SPI_POLL_RECEIVING_OVER:
472 case SPI_AREQ_SENDING:
475 case SPI_SREQ_SENDING:
478 case SPI_SREQ_RECEIVING_START:
491 case SPI_SREQ_RECEIVING:
500 case SPI_SREQ_RECEIVING_OVER:
506 spi_freezeDetect = 2;
511 case SPI_POLL_RECEIVING_START:
524 case SPI_POLL_RECEIVING:
533 case SPI_POLL_RECEIVING_OVER:
539 spi_freezeDetect = 2;
586 case SPI_AREQ_SENDING:
591 spi_freezeDetect = 2;
598 case SPI_SREQ_SENDING:
630 case SPI_AREQ_SENDING:
631 case SPI_SREQ_SENDING:
634 case SPI_SREQ_RECEIVING_START:
635 case SPI_SREQ_RECEIVING:
637 case SPI_POLL_RECEIVING_START:
638 case SPI_POLL_RECEIVING:
void SPI_SRDYISR()
ISR SRDY.
#define SPI_MRDYBIT
MRDY bit mask.
UInt8 spi_reqBegin(UInt8 len, UInt8 cmd0, UInt8 cmd1)
Request begin.
UInt8 spi_reqData(UInt8 len, void *pBuf)
Request data.
Interruption management (enable/disable) interface.
UInt8 spi_currentFreeBytes
Free bytes on current packet.
char * spi_pBuf
Pointer to the position being transfered of buffer.
UInt8 spi_receiveOverFlow
Data to receive that exceeds SPI_BUFSIZE.
#define SPI_SRDYBIT
SRDY bit.
#define SPI_CLRMRDY
Clear SS and MRDY bits.
void SPI_USCIB0RX_ISR()
USCIB0 RX.
void im_disable_interrupt()
Disable interrupt.
void ccai_resetFull()
Full reset.
#define SPI_SETSRDYDETECTDOWN
Trigger interrupt when SRDY goes down.
UInt8 spi_busy()
SPI busy.
#define SPI_SETMRDY
Set SS and MRDY bits.
void im_enable_interrupt()
Enable interrupt.
UInt8 uart_forwardCmd(char *pBuf)
Forward command.
spi_state spi_currentState
Current state of SPI.
UInt16 spi_bytesLeft
Amount of data queued to TX/RX.
#define SPI_SSBIT
SS bit mask.
char spi_buf[SPI_BUFSIZE]
SPI buffer, used to send and receive data.
UInt16 spi_proccess()
SPI proccess.
void spi_setPollCmd()
Set poll command.
void ccai_process_message()
Proccess a received message.
#define SPI_BUFSIZE
Size of the SPI buffer.
void spi_reqEnd(UInt8 forwardToSerial)
Request end.
#define SPI_SETSRDYDETECTUP
Trigger interrupt when SRDY goes up.
void spi_init()
SPI initialization.
void spi_process_message()
Process SPI message.
#define SPI_FRAMEHDRSIZE
Size of Header of a frame: Length, cmd0 and cmd1.