..

Dependencies:   mbed nRF24L01P

Fork of kl25Z_nRF_TX by Eduvance SIT2017

Committer:
ganeshgore
Date:
Mon Jun 01 05:20:18 2015 +0000
Revision:
0:19a03658bf70
Child:
1:c5c9925140b7
test

Who changed what in which revision?

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