tp

Dependencies:   mbed nRF24L01P

Committer:
monish
Date:
Sat Jun 25 02:40:02 2016 +0000
Revision:
1:e899a2cb1ffc
Parent:
0:2f050d0ea947
m; ;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
monish 0:2f050d0ea947 1 #include "mbed.h"
monish 0:2f050d0ea947 2 #include "nRF24L01P.h"
monish 0:2f050d0ea947 3
monish 0:2f050d0ea947 4 Serial pc(USBTX, USBRX); // tx, rx
monish 0:2f050d0ea947 5
monish 0:2f050d0ea947 6 nRF24L01P my_nrf24l01p(PTD2, PTD3, PTD1, PTD0, PTD5, PTD4); // mosi, miso, sck, csn, ce, irq
monish 0:2f050d0ea947 7 DigitalOut RedLED(LED1);
monish 0:2f050d0ea947 8
monish 0:2f050d0ea947 9 int main()
monish 0:2f050d0ea947 10 {
monish 0:2f050d0ea947 11 RedLED = 1;
monish 0:2f050d0ea947 12 char count[2];
monish 0:2f050d0ea947 13 char TxDataCnt;
monish 0:2f050d0ea947 14 char temp;
monish 0:2f050d0ea947 15 int x=0;
monish 0:2f050d0ea947 16
monish 0:2f050d0ea947 17
monish 0:2f050d0ea947 18 my_nrf24l01p.powerUp();
monish 0:2f050d0ea947 19 my_nrf24l01p.setRfFrequency(2435);
monish 0:2f050d0ea947 20
monish 0:2f050d0ea947 21 // Display the (default) setup of the nRF24L01+ chip
monish 0:2f050d0ea947 22 pc.printf( "nRF24L01+ Frequency : %d MHz\r\n", my_nrf24l01p.getRfFrequency() );
monish 0:2f050d0ea947 23 pc.printf( "nRF24L01+ Output power : %d dBm\r\n", my_nrf24l01p.getRfOutputPower() );
monish 0:2f050d0ea947 24 pc.printf( "nRF24L01+ Data Rate : %d kbps\r\n", my_nrf24l01p.getAirDataRate() );
monish 0:2f050d0ea947 25 pc.printf( "nRF24L01+ TX Address : 0x%010llX\r\n", my_nrf24l01p.getTxAddress() );
monish 0:2f050d0ea947 26 pc.printf( "nRF24L01+ RX Address : 0x%010llX\r\n", my_nrf24l01p.getRxAddress() );
monish 0:2f050d0ea947 27
monish 0:2f050d0ea947 28 pc.printf( "Simple Transmitter (0 - 9 Counter) \r\n");
monish 0:2f050d0ea947 29
monish 0:2f050d0ea947 30 TxDataCnt = 2;
monish 0:2f050d0ea947 31 my_nrf24l01p.setTransferSize(TxDataCnt);
monish 0:2f050d0ea947 32
monish 0:2f050d0ea947 33 my_nrf24l01p.enable();
monish 0:2f050d0ea947 34
monish 0:2f050d0ea947 35 count[0] = 0x01;
monish 1:e899a2cb1ffc 36 count[1] = 0x01; //monish
monish 0:2f050d0ea947 37
monish 0:2f050d0ea947 38 while (1) {
monish 0:2f050d0ea947 39
monish 0:2f050d0ea947 40 // Send the Transmit buffer via the nRF24L01+
monish 0:2f050d0ea947 41 temp = my_nrf24l01p.write( NRF24L01P_PIPE_P0,count, TxDataCnt );
monish 0:2f050d0ea947 42
monish 0:2f050d0ea947 43 pc.printf( "Sending %d - %d %d\r\n",temp,count[0],count[1]);
monish 0:2f050d0ea947 44
monish 0:2f050d0ea947 45 // Toggle LED1 (to help debug Host -> nRF24L01+ communication)
monish 0:2f050d0ea947 46
monish 0:2f050d0ea947 47 RedLED = count[1]%2;
monish 0:2f050d0ea947 48
monish 0:2f050d0ea947 49 count[1]=count[1]+10;
monish 0:2f050d0ea947 50
monish 0:2f050d0ea947 51 wait(1);
monish 0:2f050d0ea947 52 }
monish 0:2f050d0ea947 53 }