This project demonstrates how to interface an Atmel XMEGA microcontroller with the nRF24L01+ 2.4 GHz RF transceiver using SPI communication.
It also includes utility code for USART, I²C (TWI), PWM, GPIO control, and SPI drivers.
-
nrf24l01_.h- Low-level driver for the nRF24L01+ transceiver
- Provides functions to:
- Initialize as receiver or transmitter
- Read/write registers
- Load TX buffer and read RX buffer
- Control CE/CSN pins for SPI transactions
-
myFirstXmega.c- Main application code running on the XMEGA
- Initializes 32 MHz clock, USART, SPI, GPIO
- Provides helper functions for:
- LED and button testing
- USART TX/RX with interrupts
- I²C routines for external sensors (e.g., MPU6050)
- PWM generation (example at 38 kHz)
- Demonstrates RF data transmit/receive via nRF24L01+
-
MY_SPI.cpp- Hardware abstraction layer for SPI communication
- Functions include:
spi_init(...)→ Configure SPIspi_write(...)→ Write a bytespi(...)→ Full-duplex transferspi_read(...)→ Read received byte
- SPI communication with nRF24L01+
- Dual role: transmitter and receiver
- Interrupt-based UART communication
- Software I²C routines
- PWM generation example
- LED/button testing utilities
- Microcontroller: Atmel XMEGA (tested on
ATxmega128A1) - RF Module: nRF24L01+ (2.4 GHz)
- Connections:
- SPI: MOSI, MISO, SCK, CSN, CE
- GPIO: LEDs, buttons
- USART: Serial debugging
- I²C: External sensors
git clone https://github.com/yourusername/xmega-nrf24l01.git