SZS ez430-RF2480 1.0

ZigBee Sensor Network with synchronized time and time-stamped measurements.
spi.c File Reference

SPI implementation. More...

#include <msp430.h>
#include "spi.h"
#include "cc2480ai.h"
#include "uart.h"
#include "im.h"
+ Include dependency graph for spi.c:

Go to the source code of this file.

Macros

#define SPI_SRDYBIT   BIT6
 SRDY bit.
 
#define SPI_SETSRDYDETECTUP   P2IES &= ~SPI_SRDYBIT
 Trigger interrupt when SRDY goes up.
 
#define SPI_SETSRDYDETECTDOWN   P2IES |= SPI_SRDYBIT
 Trigger interrupt when SRDY goes down.
 
#define SPI_SSBIT   0x01
 SS bit mask.
 
#define SPI_MRDYBIT   BIT6
 MRDY bit mask.
 
#define SPI_CLRMRDY   P3OUT &= ~(SPI_MRDYBIT | SPI_SSBIT)
 Clear SS and MRDY bits.
 
#define SPI_SETMRDY   P3OUT |= SPI_MRDYBIT | SPI_SSBIT
 Set SS and MRDY bits.
 
#define SPI_FRAMEHDRSIZE   3
 Size of Header of a frame: Length, cmd0 and cmd1.
 

Typedefs

typedef enum spi_state spi_state
 States for SPI.
 

Enumerations

enum  spi_state {
  SPI_INIT, SPI_IDLE, SPI_AREQ_START, SPI_AREQ_SENDING,
  SPI_AREQ_SENT, SPI_SREQ_START, SPI_SREQ_SENDING, SPI_SREQ_SENT,
  SPI_SREQ_RECEIVING_START, SPI_SREQ_RECEIVING, SPI_SREQ_RECEIVING_OVER, SPI_SREQ_RECEIVED,
  SPI_POLL_START, SPI_POLL_RECEIVING_START, SPI_POLL_RECEIVING, SPI_POLL_RECEIVING_OVER,
  SPI_POOL_RECEIVED
}
 States for SPI.
 

Functions

void spi_snd ()
 SPI send. More...
 
void spi_setPollCmd ()
 Set poll command. More...
 
void spi_process_message ()
 Process SPI message. More...
 
void spi_init ()
 SPI initialization. More...
 
UInt16 spi_proccess ()
 SPI proccess. More...
 
UInt8 spi_reqBegin (UInt8 len, UInt8 cmd0, UInt8 cmd1)
 Request begin. More...
 
UInt8 spi_reqData (UInt8 len, void *pBuf)
 Request data. More...
 
void spi_reqEnd (UInt8 forwardToSerial)
 Request end. More...
 
UInt8 spi_busy ()
 SPI busy. More...
 
void SPI_SRDYISR ()
 ISR SRDY. More...
 
void SPI_USCIB0RX_ISR ()
 USCIB0 RX. More...
 

Variables

char spi_buf [SPI_BUFSIZE]
 SPI buffer, used to send and receive data.
 
spi_state spi_currentState
 Current state of SPI. More...
 
char * spi_pBuf
 Pointer to the position being transfered of buffer.
 
UInt16 spi_bytesLeft
 Amount of data queued to TX/RX.
 
UInt8 spi_receiveOverFlow
 Data to receive that exceeds SPI_BUFSIZE.
 
UInt8 spi_currentFreeBytes
 Free bytes on current packet.
 
UInt8 spi_freezeDetect
 

Detailed Description

SPI implementation.

Definition in file spi.c.

Function Documentation

void spi_process_message ( )

Process SPI message.

This function calls the external function to process incoming data

Definition at line 273 of file spi.c.

References ccai_process_message(), spi_buf, and uart_forwardCmd().

Referenced by spi_snd().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void spi_setPollCmd ( )

Set poll command.

This function setups a Poll command on the buffer start and points to it.

Definition at line 554 of file spi.c.

References spi_buf, spi_bytesLeft, SPI_FRAMEHDRSIZE, and spi_pBuf.

Referenced by SPI_SRDYISR().

+ Here is the caller graph for this function:

void spi_snd ( )

SPI send.

This function sends and receives a byte, if there is no bytes to send or receive, chooses next action.

Definition at line 455 of file spi.c.

References spi_buf, SPI_BUFSIZE, spi_bytesLeft, spi_currentState, SPI_FRAMEHDRSIZE, spi_pBuf, spi_process_message(), spi_receiveOverFlow, and SPI_SETMRDY.

Referenced by SPI_SRDYISR(), and SPI_USCIB0RX_ISR().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

spi_state spi_currentState

Current state of SPI.

Definition at line 228 of file spi.c.

Referenced by spi_busy(), spi_init(), spi_proccess(), spi_reqBegin(), spi_reqEnd(), spi_snd(), SPI_SRDYISR(), and SPI_USCIB0RX_ISR().