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.
main.cpp
00001 /****************************************************************************/ 00002 /* Test MOD-24LR / nrf24L01 */ 00003 /****************************************************************************/ 00004 /* LEnsE / Julien VILLEMEJANE / Institut d'Optique Graduate School */ 00005 /****************************************************************************/ 00006 /* Brochage */ 00007 /* TO COMPLETE */ 00008 /****************************************************************************/ 00009 /* Test réalisé sur Nucléo-F411RE */ 00010 /****************************************************************************/ 00011 00012 #include "mbed.h" 00013 #include "MOD24_NRF.h" 00014 #define TRANSFER_SIZE 4 00015 00016 nRF24L01P my_mod(D11, D12, D13, D7, D8, D5); 00017 00018 Serial pc(USBTX, USBRX); 00019 DigitalIn my_bp(USER_BUTTON); 00020 00021 char k; 00022 char dataToSend[TRANSFER_SIZE] = {0xAA, 0x01, 0x10, 0xF0}; 00023 char dataReceived[TRANSFER_SIZE] = {0}; 00024 00025 int main() { 00026 pc.printf("Test\r\n"); 00027 my_mod.setRfFrequency(2400); 00028 wait(0.1); 00029 my_mod.powerUp(); 00030 00031 // Display the (default) setup of the nRF24L01+ chip 00032 pc.printf( "nRF24L01+ Frequency : %d MHz\r\n", my_mod.getRfFrequency() ); 00033 pc.printf( "nRF24L01+ Output power : %d dBm\r\n", my_mod.getRfOutputPower() ); 00034 pc.printf( "nRF24L01+ Data Rate : %d kbps\r\n", my_mod.getAirDataRate() ); 00035 pc.printf( "nRF24L01+ TX Address : 0x%010llX\r\n", my_mod.getTxAddress() ); 00036 pc.printf( "nRF24L01+ RX Address : 0x%010llX\r\n", my_mod.getRxAddress() ); 00037 00038 pc.printf( "Type keys to test transfers:\r\n (transfers are grouped into %d characters)\r\n", TRANSFER_SIZE ); 00039 00040 my_mod.setTransferSize( TRANSFER_SIZE ); 00041 00042 my_mod.setReceiveMode(); 00043 my_mod.enable(); 00044 00045 while(1) { 00046 if(my_bp == 1){ 00047 my_mod.setRfFrequency(2400); 00048 } 00049 else{ 00050 my_mod.setRfFrequency(2500); 00051 } 00052 my_mod.write( NRF24L01P_PIPE_P0, dataToSend, TRANSFER_SIZE ); 00053 pc.printf( "SENDED\r\n"); 00054 wait(1); 00055 } 00056 }
Generated on Tue Jul 12 2022 20:33:10 by
1.7.2