#include "config.h"
Include dependency graph for nRF_API.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Defines | |
#define | NRF_select() (NRF_CS_PORT &= ~(1<<NRF_CS_PIN)) |
#define | NRF_unselect() (NRF_CS_PORT |= (1<<NRF_CS_PIN)) |
#define | NRF_disable() (NRF_CE_PORT &= ~(1<<NRF_CE_PIN)) |
#define | NRF_enable() (NRF_CE_PORT |= (1<<NRF_CE_PIN)) |
#define | IDLE 0x00 |
#define | MAX_RT 0x10 |
#define | TX_DS 0x20 |
#define | RX_DR 0x40 |
#define | SPI_CFG 0x40 |
#define | SPI_CTR 0x01 |
#define | SPI_CLK 0x00 |
#define | SPI0E 0x02 |
#define | READ_REG 0x00 |
#define | WRITE_REG 0x20 |
#define | RD_RX_PLOAD 0x61 |
#define | WR_TX_PLOAD 0xA0 |
#define | FLUSH_TX 0xE1 |
#define | FLUSH_RX 0xE2 |
#define | REUSE_TX_PL 0xE3 |
#define | NOP 0xFF |
#define | CONFIG 0x00 |
#define | EN_AA 0x01 |
#define | EN_RXADDR 0x02 |
#define | SETUP_AW 0x03 |
#define | SETUP_RETR 0x04 |
#define | RF_CH 0x05 |
#define | RF_SETUP 0x06 |
#define | STATUS 0x07 |
#define | OBSERVE_TX 0x08 |
#define | CD 0x09 |
#define | RX_ADDR_P0 0x0A |
#define | RX_ADDR_P1 0x0B |
#define | RX_ADDR_P2 0x0C |
#define | RX_ADDR_P3 0x0D |
#define | RX_ADDR_P4 0x0E |
#define | RX_ADDR_P5 0x0F |
#define | TX_ADDR 0x10 |
#define | RX_PW_P0 0x11 |
#define | RX_PW_P1 0x12 |
#define | RX_PW_P2 0x13 |
#define | RX_PW_P3 0x14 |
#define | RX_PW_P4 0x15 |
#define | RX_PW_P5 0x16 |
#define | FIFO_STATUS 0x17 |
#define | NRF_RX_DR 6 |
#define | NRF_TX_DR 5 |
#define | NRF_MAX_RT 4 |
#define | NFR_read_reg(reg) (NRF_Read(reg|READ_REG)) |
#define | NFR_write_reg(reg, val) (NRF_RW_Reg(reg|WRITE_REG,val)) |
#define | NRF_init_tx() (NRF_disable(),NFR_write_reg(CONFIG,0x0A)) |
#define | NRF_init_rx() (NRF_disable(),NFR_write_reg(CONFIG,0x0B),NRF_enable()) |
#define | Is_not_NRF_IRQ() ((NRF_IRQ_PORT & (1<<NRF_IRQ_PIN))? TRUE : FALSE) |
#define | Is_NRF_IRQ() ((NRF_IRQ_PORT & (1<<NRF_IRQ_PIN))? FALSE : TRUE) |
#define | NRF_tx_buffer(buf, n) (NRF_write_buf(WR_TX_PLOAD,buf,n)) |
#define | NRF_rx_buffer(buf, n) (NRF_read_buf(RD_RX_PLOAD,buf,n)) |
#define | NRF_set_payload(pipe, n) (NFR_write_reg(RX_PW_P##pipe,n)) |
#define | NRF_set_channel(n) (NFR_write_reg(RF_CH,n)) |
#define | NRF_set_byte_addr(n) (NFR_write_reg(SETUP_AW,n-2)) |
#define | NRF_ack_RX_DR() (NFR_write_reg(STATUS,(1<<NRF_RX_DR))) |
#define | NRF_ack_TX_DR() (NFR_write_reg(STATUS,(1<<NRF_TX_DR))) |
#define | NRF_ack_MAX_RT() (NFR_write_reg(STATUS,(1<<NRF_MAX_RT))) |
#define | NRF_ack_received() (NRF_ack_RX_DR()) |
#define | NRF_ack_transmit() (NRF_ack_TX_DR()) |
#define | NRF_ack_timeout() (NRF_ack_MAX_RT()) |
#define | NRF_flush_rx() (NFR_write_reg(FLUSH_RX,0)) |
#define | Is_NRF_RX_DR() (NFR_read_reg(STATUS)&(1<<NRF_RX_DR) ? TRUE : FALSE) |
#define | Is_NRF_TX_DR() (NFR_read_reg(STATUS)&(1<<NRF_TX_DR) ? TRUE : FALSE) |
#define | Is_NRF_MAX_RT() (NFR_read_reg(STATUS)&(1<<NRF_MAX_RT) ? TRUE : FALSE) |
#define | Is_NRF_received() (Is_NRF_RX_DR()) |
#define | Is_NRF_transmit() (Is_NRF_TX_DR()) |
#define | Is_NRF_timeout() (Is_NRF_MAX_RT()) |
#define | NRF_Write_addr(reg, buf, n) NRF_write_buf(reg+0x20,buf, n) |
Functions | |
U8 | SPI_RW (U8 byte) |
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_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. | |
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. |
Original author: Runar Kjellhaug from Nordic RefDesign with Dallas MCU
Definition in file nRF_API.h.
#define NRF_select | ( | ) | (NRF_CS_PORT &= ~(1<<NRF_CS_PIN)) |
Definition at line 77 of file nRF_API.h.
Referenced by NRF_Read(), NRF_read_buf(), NRF_RW_Reg(), and NRF_write_buf().
#define NRF_unselect | ( | ) | (NRF_CS_PORT |= (1<<NRF_CS_PIN)) |
Definition at line 78 of file nRF_API.h.
Referenced by NRF_Read(), NRF_read_buf(), NRF_RW_Reg(), and NRF_write_buf().
#define NRF_disable | ( | ) | (NRF_CE_PORT &= ~(1<<NRF_CE_PIN)) |
#define NRF_enable | ( | ) | (NRF_CE_PORT |= (1<<NRF_CE_PIN)) |
#define NFR_write_reg | ( | reg, | |||
val | ) | (NRF_RW_Reg(reg|WRITE_REG,val)) |
#define NRF_init_tx | ( | ) | (NRF_disable(),NFR_write_reg(CONFIG,0x0A)) |
#define NRF_init_rx | ( | ) | (NRF_disable(),NFR_write_reg(CONFIG,0x0B),NRF_enable()) |
#define Is_not_NRF_IRQ | ( | ) | ((NRF_IRQ_PORT & (1<<NRF_IRQ_PIN))? TRUE : FALSE) |
#define Is_NRF_IRQ | ( | ) | ((NRF_IRQ_PORT & (1<<NRF_IRQ_PIN))? FALSE : TRUE) |
#define NRF_tx_buffer | ( | buf, | |||
n | ) | (NRF_write_buf(WR_TX_PLOAD,buf,n)) |
#define NRF_rx_buffer | ( | buf, | |||
n | ) | (NRF_read_buf(RD_RX_PLOAD,buf,n)) |
#define NRF_set_payload | ( | pipe, | |||
n | ) | (NFR_write_reg(RX_PW_P##pipe,n)) |
#define NRF_set_byte_addr | ( | n | ) | (NFR_write_reg(SETUP_AW,n-2)) |
#define NRF_ack_RX_DR | ( | ) | (NFR_write_reg(STATUS,(1<<NRF_RX_DR))) |
#define NRF_ack_TX_DR | ( | ) | (NFR_write_reg(STATUS,(1<<NRF_TX_DR))) |
#define NRF_ack_MAX_RT | ( | ) | (NFR_write_reg(STATUS,(1<<NRF_MAX_RT))) |
#define NRF_ack_received | ( | ) | (NRF_ack_RX_DR()) |
#define NRF_ack_transmit | ( | ) | (NRF_ack_TX_DR()) |
#define NRF_ack_timeout | ( | ) | (NRF_ack_MAX_RT()) |
#define Is_NRF_RX_DR | ( | ) | (NFR_read_reg(STATUS)&(1<<NRF_RX_DR) ? TRUE : FALSE) |
#define Is_NRF_TX_DR | ( | ) | (NFR_read_reg(STATUS)&(1<<NRF_TX_DR) ? TRUE : FALSE) |
#define Is_NRF_MAX_RT | ( | ) | (NFR_read_reg(STATUS)&(1<<NRF_MAX_RT) ? TRUE : FALSE) |
#define Is_NRF_received | ( | ) | (Is_NRF_RX_DR()) |
#define Is_NRF_transmit | ( | ) | (Is_NRF_TX_DR()) |
#define Is_NRF_timeout | ( | ) | (Is_NRF_MAX_RT()) |
#define NRF_Write_addr | ( | reg, | |||
buf, | |||||
n | ) | NRF_write_buf(reg+0x20,buf, n) |
NRF_ReadRead one byte from nRF24L01 register, 'reg'.
reg,register | to read |
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:
NRF_RW_RegWrites value 'value' to register 'reg'.
'reg' | register to write value 'value' to |
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:
NRF_read_bufReads 'bytes' of bytes from register 'reg', typically used to read RX payload, Rx/Tx address.
'register | 'reg' to read, | |
buffer | '*pBuf*' contains data to be stored | |
bytes,: | number of data byte to write |
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:
NRF_write_bufWrites contents of buffer '*pBuf' to nRF24L01, typically used to write TX payload, Rx/Tx address.
'register | 'reg' to write, | |
buffer | '*pBuf*' contains data to be written | |
bytes,: | number of data byte to write |
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: