nrf24L01  1.0
nrf24L01 library
 All Files Functions Variables Typedefs Enumerations Enumerator Macros
nrf24_test_send.c File Reference

Test program for sending data with a Nordic NRF24L01p and a Xmega. More...

#include <avr/io.h>
#include <util/delay.h>
#include "nrf24/nrf24spiXM2.h"
#include "nrf24/nrf24L01.h"

Macros

#define F_CPU   2000000UL
 

Functions

void init_nrf (void)
 Initializes nrf24L01+. More...
 
void init_adc (void)
 Initializes ADC. More...
 
int16_t read_adc (void)
 read ADC More...
 
int main (void)
 main routine for sender More...
 

Variables

uint8_t pipe [5] = {0x48, 0x76, 0x41, 0x30, 0x31}
 pipe address "HvA01" More...
 

Detailed Description

Test program for sending data with a Nordic NRF24L01p and a Xmega.

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

The hardware configuration consists of a sender and a receiver. This file contains the program for the sender. The receiver is in file nrf24_test_receiver.c. The sender is a HvA-Xmegaboard with a external potmeter.

xmega3u_nrf_ptx_prx.png
The sender measures the analog value on input PA0. The measured value, which is in the range from 0 to 2047, is send with the nrf24l01+. The least significant byte of the 16-bits value is send first.

Note
Usage with Atmel Studio:
    • place this file in the Atmel Studio project folder
    • add this file to the project
You place the library fiels also directly in the project folder or in an other folder. In that case you need to change the path in the #include lines.

This test program is based on the example in paragraph E.1 from 'De taal C en de Xmega'

Macro Definition Documentation

#define F_CPU   2000000UL

Function Documentation

void init_adc ( void  )

Initializes ADC.

It initializes PA0 as channel 0 of ADCA in a signed single ended coversion.

This routine is almost (it uses PA0 in stead of PA2) equal to init_adc() of code 20.3 from 'De taal C en de Xmega' second edition, see Voorbeelden uit 'De taal C en de Xmega'

Returns
void
void init_nrf ( void  )

Initializes nrf24L01+.

This function is almost the same as the init_nrf() of the receiver. There are two pipes. One for sending the value and one for the acknowledge

This routine is code E.1 from 'De taal C en de Xmega' second edition, see Voorbeelden uit 'De taal C en de Xmega'

Returns
void
int main ( void  )

main routine for sender

It initializes the nrf24L01+ and the ADC. Every 20 ms the program measures the input value and send the value with the nrf24L01+. The least significant byte is send first.

This routine is code E.2 from 'De taal C en de Xmega' second edition, see Voorbeelden uit 'De taal C en de Xmega'

Returns
int
int16_t read_adc ( void  )

read ADC

This function reads a value from channel 0 of ADCA.

This routine is equal to read_adc() of code 20.3 from 'De taal C en de Xmega' second edition, see Voorbeelden uit 'De taal C en de Xmega'

Returns
void

Variable Documentation

uint8_t pipe[5] = {0x48, 0x76, 0x41, 0x30, 0x31}

pipe address "HvA01"