| 1 | # ATXMEGA |
| 2 | |
| 3 | @tableofcontents |
| 4 | |
| 5 | The RF24 driver can be build as a static library with Atmel Studio 7 in order to be included as any other library in another program for the XMEGA family. |
| 6 | |
| 7 | Currently only the [ATXMEGA D3](https://www.microchip.com/wwwproducts/en/ATxmega64d3) family is implemented. |
| 8 | |
| 9 | ## Preparation |
| 10 | |
| 11 | Create an empty GCC Static Library project in Atmel Studio 7. |
| 12 | |
| 13 | As not all files are required, copy the following directory structure in the project: |
| 14 | |
| 15 | ```text |
| 16 | utility\ |
| 17 | ATXMegaD3\ |
| 18 | compatibility.c |
| 19 | compatibility.h |
| 20 | gpio.cpp |
| 21 | gpio.h |
| 22 | gpio_helper.c |
| 23 | gpio_helper.h |
| 24 | includes.h |
| 25 | RF24_arch_config.h |
| 26 | spi.cpp |
| 27 | spi.h |
| 28 | nRF24L01.h |
| 29 | printf.h |
| 30 | RF24.cpp |
| 31 | RF24.h |
| 32 | RF24_config.h |
| 33 | ``` |
| 34 | |
| 35 | ## Usage |
| 36 | |
| 37 | Add the library to your project! |
| 38 | |
| 39 | In the file where the `main()` is put the following in order to update the millisecond functionality: |
| 40 | |
| 41 | ```cpp |
| 42 | ISR(TCE0_OVF_vect) |
| 43 | { |
| 44 | update_milisec(); |
| 45 | } |
| 46 | ``` |
| 47 | |
| 48 | Declare the rf24 radio with `RF24 radio(XMEGA_PORTC_PIN3, XMEGA_SPI_PORT_C);` |
| 49 | |
| 50 | 1. First parameter is the CE pin which can be any available pin on the microcontroller. |
| 51 | 2. Second parameter is the CS which can be on port C (**XMEGA_SPI_PORT_C**) or on port D (**XMEGA_SPI_PORT_D**). |
| 52 | |
| 53 | Call the `__start_timer()` to start the millisecond timer. |
| 54 | |
| 55 | @note The millisecond functionality is based on the TCE0 so don't use these pins as IO. |
| 56 | |
| 57 | @note The operating frequency of the uC is 32MHz. If you have a different frequency, change the TCE0 registers appropriately in function `__start_timer()` in **compatibility.c** file for your frequency. |