How to use a library in online KeilStudio IDE. LPC1768 and nRF24L01

I want to use an LPC1768 and nRF24L01 to receive small slow data(temperature and pressure) from another nRF24L01. So I will need to implement SPI on the LPC1768. I need to decide which pins to use and then I need to refer to them in code. Here is a link to pinout LPC1768[mbed LPC1768 | Mbed]

I am using this library NRF2401P [NRF2401P - This is a work in progress for an NRF2401P | Mbed] As a complete beginner I build the code step by step so before implementing anything I import the library. ` I used the KeilStudio-“File-Add mbed library to active project” command.

#include "mbed.h"
#include "NRF2401P.h"
// main() runs in its own thread in the OS
int main()
{
    while (true) {

    }
}

The KeilStudio IDE gives the following errors and many similar. 
"In included file: unknown type name 'Serial' clang(unknown_typename)[2,10]" 
"In included file; unknown type name 'SPI' clang(unknown_typename)[2,10]" 

Unfortunately my knowledge of programming is very limited though I suspect the library is incompatible for reasons which more experienced programmers may understand. I'm coming from limited experience of old style VisualBasic/MicrosoftOffice where I almost never had to deal with this. Perhaps I could edit the NRF2401.P in some way or perhaps I should look for different library. How should I proceed? 

I would find it useful to get a better idea of how libraries are written and used in the C++ environment of KeilStudio but I dont want to take a ComputerScience course.

Hi Gregory,

Those error usually means that your program is based on Mbed OS 6 which has a Serial API deprecated. I recommend. Adding this library to Mbed OS 5 program (you can create a new Mbed OS 5 program using File->New->Mbed Project functionality).

Adding this library to Mbed OS 5 project should work correctly:

You can find more about deprecated APIs in this section: Full API list - API references and tutorials | Mbed OS 6 Documentation

Thanks,
Arek - Studio team

Thanks Arek for such a quick response.

Hello. I find that when “Connect to target hardware” in KeilStudio i have the message "Connected device is unsupported. It is an mbed LPC1768. I have downloaded an example hello_world nRF24L01 | Mbed for LPC1768 and nRF24L01 . The KeilStudio Cloud is 1.5.53. I have previously uploaded the example ms-os-example-blinky which works ok so obviously the LPC1768 is supported. Does this mean that the nRF24L01 is unsupported even though there exist several libraries for it? I am a little confused.

Hi Arek. You can see I am in need of a tutorial on using the KeilStudio and a device such as LPC1768. Can you point me to some resource where I can get some of these basic questions answered instead of bothering you?

Hello Martin,

you need separate two things. Issues connected to the tool, the Keil Studio Cloud in this case, and issues what are in context of MbedOS version and its compatibility.

Mbed’s build tools:

  • Mbed CLI - desktop console build tool
  • Mbed CLI2 - also desktop console build tool, but based on CMake
  • Online Compiler - old web based build tool, the simplest one, but it is retiring with this year.
  • Keil Studio Cloud - new web based IDE
  • Mbed Studio - “new” desktop IDE (in the future will be replaced with Keil Studio desktop)

On the main page https://os.mbed.com/ you will found section Documentation, where you will found links to documentation of MbedOS, MbedStudio or Keil Studio Cloud

MbedStudio and KeilStudioCloud (KSC ) are able to build, deploy and debug, but deploy and debug may not be available for all targets now. Unfortunately the LPC1768 is in the group of these targets, but the time is coming New beta firmware for LPC1768 - Keil Studio - Arm Mbed OS support forum
So, until this is resolved, you will have to upload the binary with drag & drop method with binary what will be generated and downloaded via KSC and your browser.

Issues like you wrote above about Serial API are connected to Mbed OS version compatibility.
Mbed’s versions:

  • Mbed2 - oldes one without RTOS, unmaintained, obsolete, but most of libraries are for this version
  • MbedOS 5 - old one with RTOS, but most of libraries are able to work with this version
  • MbedOS 6 - the latest one and not all libraries are compatible with this version

I hope I made an answer for your questions, but do not be hesitate to ask for more.

BR, Jan

1 Like

Hi Jan and thanks for rapid reply. So after following instructions to upgrade to beta firmware I have a virtual comm port which I can now access using an external program(though I cant access in mbed Studio). I can see the output of my program successfully there. Here is the program

#include "mbed.h"
#include "RF24.h"
 
const uint64_t  ADDRESS = 0xF0F0F0F0F0F0F0F0L;
 
DigitalOut      led(LED1);
uint8_t         dataReceived;
RF24            radio(p5, p6, p7, p8, p9); // mosi, miso, sck, ce, csn
 
int main()
{
    printf("Starting ...\r\n");
    radio.begin();
    radio.setPALevel(RF24_PA_LOW);
    radio.setRetries(5, 15);
    radio.setPayloadSize(1);
    radio.setAutoAck(true);
    radio.openReadingPipe(0, ADDRESS);  // use pipe 0 of this slave to receive messsages and send back auto acknowledgement
    while (true)
    {
        if (radio.available())
        {
            radio.read(&dataReceived, 1);
            printf("A radio message received.\r\n");
            led = dataReceived;
        }
    }
}

Following on this success I wanted to import this other program [https://os.mbed.com/users/Owen/code/nRF24L01P_Hello_World/]
However the instructions at the top of that page suggest that I import the program "using mbed CLI" but I dont know how to do this. Where do I find the CLI, as my terminal defaults to "...system32/cmd.exe" ? Do I need to cd to another directory? The mbed documentation "https://os.mbed.com/docs/mbed-os/v6.15/build-tools/use.html" does not say how to invoke the CLI environment in order to issue a command such as "mbed-tools --help"
Your help is much appreciated.
1 Like

Apologies. I found a link in documentation how to install the CLI

First, be so kind and use these 3 symbols ``` before and after your code for good format and the look of. Because how you can see the text after your code has bad format and is easy to miss

I can not verified and test the binary, but I tried in KeilStudioCloud.

  • File → Clone… Place your URL → Add project
  • select LPC1768 in target selector, do not care if the USB were recognized or not
  • hit hammer icon w8 until finished
  • your browser will inform you about new downloaded file and that is the bin file for your board
  • drag&drop the .bin file to LPC’s drive via Windows file manager
  • tadáááá, you will see

And to be honest if you have problems with KeilStudio, then I am not sure you will able to do that with CLI.

BR, Jan