Giter VIP home page Giter VIP logo

nrf24_component's Introduction

nRF24 Component for PSoC4, PSoC5LP and PSoC6

The nRF24 component is developed as a personal project, it surely can be improved, pull request are always welcome!.

What do you need to use this component?

You need:

  • SPI Master Full duplex.

  • Digital output (software driven) for the /SS (Chip Select).

  • Digital output (software driven) for the CE signal.

  • OPTIONAL: Digital input for the IRQ signal.

The SPI Master component, SS, CE and IRQ (IRQ is optional) pins must be provided by the user on the project schematic. See the image below for an example.

nRF24_sch_example

Example projects

See nRF24 Example Projects for basic example projects using this component!.

How to use this component on your PSoC project?

You can directly clone this repo inside your project directory and update it as you want. After that you have to include it into your project dependencies.

If you want you can also include this repo as a git submodule.

API

The functions provided by this component try to be as clear as possible, so the user should not need to check the component documentation to know what a function does.

All the functions on the NRF_FUNCS files are intended to be used directly by the user, so no need to use the functions on the NRF_LL_SPI and NRF_COMMANDS files.

The following code style where used on the NRF_REGS file to ease finding the available registers and bitfields:

  • NRF_REG_x means this is a register, where x is the register name as documented on the nRF24 datasheet.

  • NRF_x_BIT_y means this is a bit field on a register, where x is the register name and y is the name of the bitfield as documented on the nRF24 datasheet.

Current version: 3.0

The current component symbol is shown below:

Component

The customizer or configuration window is where the PSoC Creator "magic" happens, the custom customizers are ugly so i'm also trying to write a customizer in C# and add it to the component (Work in Progress), this is not really well documented and i'm pretty bad at desining GUI's so if you know C# and UI you can help me out.

The component configuration is separated in two tabs:

  • nRF Configuration

In this tab all the configurable nRF24 registers are layed out, at the right of the window is a small description on each register field, it's better if you have a copy of the nRF24 datasheet at hand.

nRF_Configuration

  • Hardware Interface

In this tab the user need to provide the names of the SPI Master component used for communication with the nRF24 radio, the name of the pin used to control the SS (slave select) and the pin used to control the CE pin.

nRF_SPI

nRF24 Component configuration.

Note: All the functions assumes your component is named nRF24 on your schematic.

Set Rx pipes and Tx pipe address.

To set the Tx address of the radio you should use the nRF24_set_tx_address(addr, size) function where addr will be set as the Tx address of the radio and size should be up to the configured address width configured on the radio. Example of use:

const uint8_t my_addr[] = {0xBA, 0xAD, 0xC0, 0xFF, 0xEE};

nRF24_set_tx_address(my_addr, sizeof my_addr);

Remember the addresses of the nRF24 radio starts with the LSB so the real Tx address of the radio will be: 0xEEFFC0ADBA.

Coding style

The code style in the v2.0 will be similar to the Linux kernel coding style, for this the tool clang-format is used, the repo contains the .clang-format file.

nrf24_component's People

Contributors

c47d avatar manuelvegamtx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nrf24_component's Issues

getIRQ and clearIRQ functions.

When using the getIRQ and clearIRQ functions inside the IRQ interrupt handler doesn't work as expected, when reading the status register it's read as 0x00 and not the correct value (0x1E which is the MAX_RT_IRQ flag for example).
There must be a way to improve both of those functions.

nRF24_get_irq_flag should return all the IRQ flags

The current nRF24_get_irq_flag() implementation doesn't work with 2 or 3 asserted IRQ flags on the STATUS register, @Boland1776 suggested changing the implementation of the nRF24_get_irq_flag() from:

nrf_irq nRF24_get_irq_flag(void)
{
    nrf_irq irq = NRF_NONE_IRQ;

    // Get the STATUS register
    uint8_t sts = nRF24_cmd_nop();

    // We only care if bits 4, 5 or 6 are set, so we mask the STATUS with 0x0111_0000
    switch (sts & NRF_ALL_IRQ_MASK) {
    case NRF_STATUS_RX_DR_MASK:
        irq = NRF_RX_DR_IRQ;
        break;
    case NRF_STATUS_TX_DS_MASK:
        irq = NRF_TX_DS_IRQ;
        break;
    case NRF_STATUS_MAX_RT_MASK:
        irq = NRF_MAX_RT_IRQ;
        break;
    default:
        irq = NRF_ALL_IRQ_MASK;
        break;
    }

    return irq;
}

to

uint8_t nRF24_get_irq_flag(void)
{
    return NRF_ALL_IRQ_MASK & nRF24_cmd_nop();
}

So the user will get all the IRQ flags and check which one is asserted like so:

int main(void)
{
   ....
   uint8_t irqs = nRF24_get_irq_flag();
   process_IRQs(irqs);
   ....
}

void process_IRQs(uint8_t irqs) {
    if (0u == irqs) {
        return;
    }

    if (irqs & NRF_TX_DS_IRQ) {
        // do something
        nRF24_clear_irq_flag(NRF_TX_DS_IRQ);
    }
    if (irqs & NRF_MAX_RT_IRQ) {
        // do something else
       nRF24_clear_irq_flag(NRF_MAX_RT_IRQ);
    }
    if (irqs & NRF_RX_DR_IRQ) {
        // do something else
       nRF24_clear_irq_flag(NRF_RX_DR_IRQ);
    }
    .....
}

Rx Overrun in write_long_register function.

Current data transfer implementation triggers an RX OVERRUN interrupt (when enabled) due the data in the RX FIFO isn't being read and it does overflow when using the nRF24_write_long_register function.

Error running Basic Tx example

I tried running 00_Basic_Tx example on CY8C4245AXI-48344. The function nRF24_get_irq_flag(), always returns NRF_MAX_RT_IRQ.
Status from nRF24_get_status() is 0x0F or 0x0E.

Any debugging steps or error description regarding this will be very helpful.

Can't seem to get it to work on CY8CKIT-043

My setup:
-1 board for TX
-1 board for RX
-Channel 63
-TX and RX address both 0x0123456789
-Arduino for debugging purposes.

According to the arduino_scanner output, the PSOC_TX is transmitting strongly at channel 63.
However, the PSOC_RX is not receiving anything.

Any tips?

Update:
I just got it to run, apparently, I need to enable the auto-ack for it to work.

SCB version send "garbage" data on nRF_Start function.

The component based on SCB blocks send "garbage" data when calling the nRF_Start funtion, it may be caused by a TX-FIFO problem because the bytes to send arrive late and the /SS line goes high between data transfers.
Below is a capture with data beign sent with the component based on SCB.
nrf_scb

Below is the same data beign sent using the component based on UDB.
nrf_udb

When fixed they must be the same.

Radio power up

If someone uses this component and had not changed "nRF24 Power" to "Power Up" (in the configurator) it must be done in main.c. Users should be careful NOT to call;
nRF24_set_bit(NRF_REG_CONFIG, NRF_CONFIG_PWR_UP), but use
nRF24_set_bit(NRF_REG_CONFIG, NRF_CONFIG_BIT_PWR_UP) instead.
If the user takes the latter, they must also include a delay of approx 5ms to allow the radio to stabilize.

I have three suggestions;

  1. Have the default setting in the configurator be "Power On". One could assume if they are including this device they will want it powered on.
  2. Add a function in FUNCS.c, such as...
    void nRF24_set_power_up_mode(void) {
    nRF24_set_bit(NRF_REG_CONFIG, NRF_CONFIG_BIT_PWR_UP);
    CyDelay(5u);
    }
  3. nRF24_wakeup() is very close to being a "power up" function but needs a delay.

There are a few other function calls in FUNC.c that need to use the NRF_CONFIG_BIT_PWR_UP (instead of NRF_CONFIG_PWR_UP).

Other than those nits, great job!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.