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
Diff: main.cpp
- Revision:
- 13:f8a0252d346e
- Parent:
- 12:155a1ce7c92b
--- a/main.cpp Fri Feb 11 08:19:10 2022 +0000
+++ b/main.cpp Fri Mar 18 10:03:55 2022 +0000
@@ -14,40 +14,43 @@
#include "nRF24L01P.h"
/* 115200 bit/s */
-BufferedSerial pc(USBTX, USBRX,115200); // tx, rx
+BufferedSerial pc(USBTX, USBRX,115200); // tx, rx
//Définition des E/S de la liaison SPI vers le module nRF24L01+
nRF24L01P my_nrf24l01p(D11, D12, D13, A3, D9, A0); // mosi, miso, sck, csn, ce, irq
int main()
-{
+{
#define TRANSFER_SIZE 12
- char c;
+ char c[50];
my_nrf24l01p.powerUp();
- my_nrf24l01p.setRfFrequency(2418);
- my_nrf24l01p.setAirDataRate(1000);
+ my_nrf24l01p.setRfFrequency(2406);
+ my_nrf24l01p.setAirDataRate(1000);
my_nrf24l01p.setRfOutputPower(-6);
my_nrf24l01p.setTransferSize( TRANSFER_SIZE );
my_nrf24l01p.setTransmitMode();
my_nrf24l01p.setCrcWidth(0);
my_nrf24l01p.setTxAddress();
my_nrf24l01p.enable();
+ DigitalOut led1(D4);
+ DigitalOut led2(D5);
while (1) {
- if (pc.readable())
- {
- for (int i=0; i< TRANSFER_SIZE ; i++){
- pc.read(&c+i,1);
- }
- my_nrf24l01p.write( NRF24L01P_PIPE_P0, &c ,TRANSFER_SIZE);
- pc.write(&c,TRANSFER_SIZE);
+ for (int i=0; i< TRANSFER_SIZE ; i++) {
+ while(!pc.readable());
+ led1 = !led1;
+ pc.read(c+i,1);
+ }
+ led2 = !led2;
+ my_nrf24l01p.write( NRF24L01P_PIPE_P0, c,TRANSFER_SIZE);
+ //pc.write(c,TRANSFER_SIZE);
+ }
}
- }
-
-
-}
+
+
+