# znp_interface_spi.c File Reference

Interface to the Zigbee Network Processor (e.g. CC2530ZNP) over the Serial Peripheral Interface (SPI) port. More...

`#include "../HAL/hal.h"`
`#include "znp_interface_spi.h"`

## Functions
signed int | sendSreq ()
signed int | spiPoll ()
signed int | sendMessage ()
## Variables
unsigned char | znpBuf [100]

## Detailed Description

Interface to the Zigbee Network Processor (e.g. CC2530ZNP) over the Serial Peripheral Interface (SPI) port.

Note:
  To output SPI transmit information, define ZNP_INTERFACE_SPI_VERBOSE. It is recommended to define this on a per-project basis. In IAR, this can be done in Project Options : C/C++ compiler : Preprocessor In the defined symbols box, add: ZNP_INTERFACE_SPI_VERBOSE

See also:
  http://processors.wiki.ti.com/index.php/Tutorial_on_the_Examples and http://e2e.ti.com/support/low_power_rf/default.aspx

Rev
  590

Author
  dsmith

Date
  2010-06-11 17:04:51 -0700 (Fri, 11 Jun 2010)

YOU ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.

## Function Documentation

signed int sendMessage | ( |  | ) |

Public method to send messages to the ZNP. This will send one message and then receive the Synchronous Response (SRSP) message from the ZNP to indicate the command was received.

Precondition:
  znpBuf contains a properly formatted message
  ZNP has been initialized

Postcondition:
  buffer znpBuf contains the response (if any) from the ZNP.

Returns:
  0 if the SRSP received was the expected SRSP, -11 if it was NOT the expected SRSP, -12 if sendSreq timeout, or -13 if too many bytes received.

signed int sendSreq | ( |  | ) |

Sends a CC2530ZNP Synchronous Request (SREQ) message and retrieves the response. A SREQ is a message to the ZNP that is immediately followed by a Synchronous Response (SRSP) message from the ZNP. As opposed to an Asynchronous Request (AREQ) message, which does not have a SRSP. This is a private method that gets wrapped by sendMessage().

Precondition:
  CC2530ZNP has been initialized
  znpBuf contains a properly formatted message

Postcondition:
  received data is written to znpBuf

Returns:
  0 if success, -1 if timeout waiting for SRDY to go low after chip select; -2 if timeout waiting for SRSP. : timeout on SRDY_IS_HIGH() and SRDY_IS_LOW(), or separate this method and return control to the application

signed int spiPoll | ( |  | ) |

Polls the ZNP for data. This is used to receive data from the ZNP, for example when a message has arrived. This will be initiated by detecting SRDY going low.

Precondition:
  CC2530ZNP has been initialized.
  SRDY has gone low
  CC2530ZNP has been initialized

Postcondition:
  received data is written to znpBuf

Returns:
  result of sendSreq()

Note:
  this method not required to be implemented when using UART interface.

## Variable Documentation

unsigned char znpBuf[100]

This buffer will hold the transmitted messages and received SRSP Payload after sendMessage() was called.

All Data Structures Files Functions Variables Defines