nrf24L01  1.0
nrf24L01 library
 All Files Functions Variables Typedefs Enumerations Enumerator Macros
nrf24spiXM2.h File Reference

Header file SPI driver for Nordic NRF24L01p on Xmegaboard-version2. More...

#include <avr/io.h>
#include <util/delay.h>

Go to the source code of this file.

Macros

#define F_CPU   32000000UL
 
#define NRF_SELECT   0
 Spi slave selected. More...
 
#define NRF_DESELECT   1
 Spi slave deselected. More...
 
#define NRF_ENABLE   1
 NRF chip enable. More...
 
#define NRF_DISABLE   0
 NRF chip disable. More...
 

Functions

void nrfspiInit (void)
 Initialization of SPI. More...
 
uint8_t nrfspiTransfer (uint8_t iData)
 SPI transfer. More...
 
void nrfCSn (uint8_t bSelected)
 Set chip select. More...
 
void nrfCE (uint8_t bEnabled)
 Set chip enable. More...
 

Detailed Description

Header file SPI driver for Nordic NRF24L01p on Xmegaboard-version2.

Author
Wim Dolman (w.e.dolman@hva.nl)
Date
18-02-2016
Version
1.0

This file contains the definitions and prototypes for interfacing a Nordic NRF24L01p on Xmegaboard-version2 from july 2015.

This driver uses UARTC0 as SPI-interface. The baudrate is the maximum rate. This is 8 MHz @ Fcpu 32MHz. It doesn't exceed the maximum speed 10 MHz of the NRF24L01p.

The interface exists of six signals:

Nordic NRF24L01p Xmegaboard-V2
IRQ interrupt request PF6
CE chip enable PF7
CSN SPI slave select PF5
SCK SPI clock PC1
MOSI SPI MOSI PC3
MISO SPI MOSI PC2

More information can be found in chapter 8 of the NRF24L01p datasheet.

Macro Definition Documentation

#define F_CPU   32000000UL
#define NRF_DESELECT   1

Spi slave deselected.

#define NRF_DISABLE   0

NRF chip disable.

#define NRF_ENABLE   1

NRF chip enable.

#define NRF_SELECT   0

Spi slave selected.

Function Documentation

void nrfCE ( uint8_t  bEnabled)
inline

Set chip enable.

Parameters
bEnabledNRF_ENABLE enables transmission of Nordic chip NRF_DISABLE disables transmission of Nordic chip

Level NRF_ENABLE (high) starts transmission and NRF_ENABLE (low) puts Nordic LOW in standby.

Returns
void
void nrfCSn ( uint8_t  bSelected)
inline

Set chip select.

Parameters
bSelectedNRF_SELECT selects SPI bus, NRF_DESELECT deselect SPI bus
Returns
void
void nrfspiInit ( void  )

Initialization of SPI.

This routines has no parameters. It Initializes UARTC0 as SPI and the signals IRQ and CE

Returns
void
uint8_t nrfspiTransfer ( uint8_t  iData)

SPI transfer.

Parameters
iDatadata byte send to the slave

This function send a byte IData to register to the slave, while data from the slave is received into the DATA register.

In this case, for the nrf24L01p, the value of status-register is shifted out

Returns
Data received from slave (status of the nrf24L01p)