nRF_API.c File Reference

This file manages the NRF24L01 RF device and provide low level driver access (based on SPI driver). More...

#include "config.h"
#include "nRF_API.h"
#include "lib_mcu/spi/spi_lib.h"

Include dependency graph for nRF_API.c:

Go to the source code of this file.

Functions

U8 NRF_Read (U8 reg)
 NRF_ReadRead one byte from nRF24L01 register, 'reg'.
U8 NRF_RW_Reg (U8 reg, U8 value)
 NRF_RW_RegWrites value 'value' to register 'reg'.
U8 NRF_write_buf (U8 reg, U8 *pBuf, U8 bytes)
 NRF_write_bufWrites contents of buffer '*pBuf' to nRF24L01, typically used to write TX payload, Rx/Tx address.
U8 NRF_read_buf (U8 reg, U8 *pBuf, U8 bytes)
 NRF_read_bufReads 'bytes' of bytes from register 'reg', typically used to read RX payload, Rx/Tx address.


Detailed Description

This file manages the NRF24L01 RF device and provide low level driver access (based on SPI driver).

Original author: Runar Kjellhaug from Nordic RefDesign with Dallas MCU

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file nRF_API.c.


Function Documentation

U8 NRF_Read ( U8  reg  ) 

NRF_ReadRead one byte from nRF24L01 register, 'reg'.

Parameters:
reg,register to read
Returns:
reg_val, register value

Definition at line 57 of file nRF_API.c.

References NRF_select, NRF_unselect, and spi_rw().

00058 {
00059    U8 reg_val;
00060 
00061    NRF_select();
00062    spi_rw(reg);                                    // Select register to read from..
00063    reg_val = spi_rw(0);                            // ..then read registervalue
00064    NRF_unselect();                                 // CSN high, terminate SPI communication
00065    return(reg_val);                                // return register value
00066 }

Here is the call graph for this function:

U8 NRF_RW_Reg ( U8  reg,
U8  value 
)

NRF_RW_RegWrites value 'value' to register 'reg'.

Parameters:
'reg' register to write value 'value' to
Returns:
status byte

Definition at line 78 of file nRF_API.c.

References NRF_select, NRF_unselect, and spi_rw().

00079 {
00080    U8 status;
00081 
00082    NRF_select();           // CSN low, init SPI transaction
00083    status = spi_rw(reg);   // select register
00084    spi_rw(value);          // ..and write value to it..
00085    NRF_unselect();         // CSN high again
00086    return(status);         // return nRF24L01 status byte
00087 }

Here is the call graph for this function:

U8 NRF_write_buf ( U8  reg,
U8 pBuf,
U8  bytes 
)

NRF_write_bufWrites contents of buffer '*pBuf' to nRF24L01, typically used to write TX payload, Rx/Tx address.

Parameters:
'register 'reg' to write,
buffer '*pBuf*' contains data to be written
bytes,: number of data byte to write
Returns:
nRF24L01 status byte

FIXE ME !!!!!! 10µs CE pulse required

Definition at line 101 of file nRF_API.c.

References FOSC, NRF_disable, NRF_enable, NRF_select, NRF_unselect, and spi_rw().

00102 {
00103    U8 status,byte_ctr;
00104    volatile U32 tempo;
00105 
00106    NRF_select();                                   // Set CSN low, init SPI tranaction
00107    status = spi_rw(reg);                           // Select register to write to and read status byte
00108    for(byte_ctr=0; byte_ctr<bytes; byte_ctr++)     // then write all byte in buffer(*pBuf)
00109    spi_rw(*pBuf++);
00110    NRF_unselect();                                 // Set CSN high again
00111    NRF_enable();
00112    for(tempo=0;tempo<FOSC/100;tempo++);     
00113    NRF_disable();
00114    return(status);                                 // return nRF24L01 status byte
00115 }

Here is the call graph for this function:

U8 NRF_read_buf ( U8  reg,
U8 pBuf,
U8  bytes 
)

NRF_read_bufReads 'bytes' of bytes from register 'reg', typically used to read RX payload, Rx/Tx address.

Parameters:
'register 'reg' to read,
buffer '*pBuf*' contains data to be stored
bytes,: number of data byte to write
Returns:
nRF24L01 status byte

Definition at line 128 of file nRF_API.c.

References NRF_select, NRF_unselect, and spi_rw().

00129 {
00130    U8 status,byte_ctr;
00131 
00132    NRF_select();                                     // Set CSN low, init SPI tranaction
00133    status = spi_rw(reg);                           // Select register to write to and read status byte
00134 
00135    for(byte_ctr=0;byte_ctr<bytes;byte_ctr++)
00136     pBuf[byte_ctr] = spi_rw(0);                   // Perform SPI_RW to read byte from nRF24L01
00137 
00138    NRF_unselect();                                     // Set CSN high again
00139 
00140    return(status);                                 // return nRF24L01 status byte
00141 }

Here is the call graph for this function:


Generated on Mon May 5 15:58:03 2008 for ATMEL by  doxygen 1.5.1-p1