Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-os nRF24L01P
main.cpp
- Committer:
- evedelegue
- Date:
- 2021-11-26
- Revision:
- 7:65236900b1f5
- Parent:
- 6:2be1def8ba74
- Child:
- 8:04ab02bb2262
File content as of revision 7:65236900b1f5:
/* RobotCup ENS Paris Saclay 2020-2021 Team FC Furious Code by Luc DERRIEN adapted by Eve Programme communication PC-Robot Point de vue : PC micro controleur : L475 envoi d'une chaine de caractère de taille TRANSFER_SIZE */ #include "mbed.h" #include "string.h" #include "nRF24L01P.h" #include "string.h" char text[100]; UnbufferedSerial pc_serie(USBTX,USBRX,115200); //Définition des E/S de la liaison SPI vers le module nRF24L01+ nRF24L01P my_nrf24l01p(D11, D12, D13, D9, D2, D1); // mosi, miso, sck, csn, ce, irq int main() { // Nombre de caractères transmis à chaque envoi #define TRANSFER_SIZE 20 char txData[TRANSFER_SIZE], rxData[TRANSFER_SIZE]; int txDataCnt = 0; int rxDataCnt = 0; char texte[] = "Robot PSL connecte \n\r"; pc_serie.write(texte, strlen(texte)); my_nrf24l01p.powerUp(); my_nrf24l01p.setRfFrequency(2418); // Définition de la fréquence du canal d'E/R my_nrf24l01p.setAirDataRate(NRF24L01P_DATARATE_1_MBPS); // Définition du débit de la communication RF my_nrf24l01p.setTransferSize( TRANSFER_SIZE ); my_nrf24l01p.setReceiveMode(); my_nrf24l01p.enable(); // Affichage de l'état de la configuration du nRF24L01+ sprintf(text,"_______________________\r\nCarte recepteur :\r\n_______________________\r\n"); pc_serie.write( text, strlen(text) ); sprintf(text,"nRF24L01+ Frequency : %d MHz\r\n", my_nrf24l01p.getRfFrequency() ); pc_serie.write( text, strlen(text) ); sprintf(text, "nRF24L01+ Data Rate : %d kbps\r\n", my_nrf24l01p.getAirDataRate() ); pc_serie.write( text, strlen(text) ); sprintf(text, "nRF24L01+ RX Address : 0x%010llX\r\n", my_nrf24l01p.getRxAddress() ); pc_serie.write( text, strlen(text) ); sprintf(text, "Type keys to test transfers:\r\n (transfers are grouped into %d characters)\r\n", TRANSFER_SIZE ); pc_serie.write( text, strlen(text) ); while (1) { // If we've received anything in the nRF24L01+2... if ( my_nrf24l01p.readable() ) { // ...read the data into the receive buffer rxDataCnt = my_nrf24l01p.read( NRF24L01P_PIPE_P0, rxData, sizeof( rxData ) ); pc_serie.write(rxData,TRANSFER_SIZE); } rxDataCnt = 0; } }