fertiges programm

Dependencies:   mbed nRF24L01P

Fork of testuC by scooter

Committer:
thorb3n
Date:
Tue Jan 12 17:02:25 2016 +0000
Revision:
3:62a65ac86473
Parent:
2:0b023bf05e0d
fertig, pins angepasst,reihenfolge angepasst

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Owen 0:a51a6e7da590 1 #include "mbed.h"
Owen 0:a51a6e7da590 2 #include "nRF24L01P.h"
thorb3n 2:0b023bf05e0d 3 #define IWDG_START 0x0000CCCC
thorb3n 2:0b023bf05e0d 4 #define IWDG_WRITE_ACCESS 0x00005555
thorb3n 2:0b023bf05e0d 5 #define IWDG_PR_PR_0 7
thorb3n 3:62a65ac86473 6 #define IWDG_RELOAD 200000
thorb3n 2:0b023bf05e0d 7 #define IWDG_REFRESH 0xAAAA
thorb3n 3:62a65ac86473 8 DigitalOut vcc_funk(PB_8); // Pin vcc funk modul
thorb3n 3:62a65ac86473 9 #define TRANSFER_SIZE 2
Owen 0:a51a6e7da590 10
thorb3n 2:0b023bf05e0d 11
Owen 0:a51a6e7da590 12
thorb3n 2:0b023bf05e0d 13 int main()
thorb3n 3:62a65ac86473 14 {
thorb3n 2:0b023bf05e0d 15 // pLATHALTER FÜR ANSHCALTEN ÜBER GPIO
thorb3n 2:0b023bf05e0d 16 //
thorb3n 3:62a65ac86473 17 vcc_funk = 1;
thorb3n 3:62a65ac86473 18 wait_us(30);
thorb3n 3:62a65ac86473 19 nRF24L01P my_nrf24l01p(PB_5,PB_4,PB_3,PB_7,PD_2,PB_6); // mosi, miso, sck, csn, ce, irq
Owen 0:a51a6e7da590 20
thorb3n 3:62a65ac86473 21 char txData[TRANSFER_SIZE];
Owen 0:a51a6e7da590 22 int txDataCnt = 0;
Owen 0:a51a6e7da590 23
Owen 0:a51a6e7da590 24 my_nrf24l01p.powerUp();
thorb3n 2:0b023bf05e0d 25 my_nrf24l01p.setAirDataRate(250);
thorb3n 2:0b023bf05e0d 26 my_nrf24l01p.setTxAddress(0xE7E7E7E7E1,5);
thorb3n 2:0b023bf05e0d 27 my_nrf24l01p.setRxAddress(0xE7E7E7E7E7,5,0);
thorb3n 3:62a65ac86473 28
Owen 0:a51a6e7da590 29
Owen 0:a51a6e7da590 30 my_nrf24l01p.setTransferSize( TRANSFER_SIZE );
Owen 0:a51a6e7da590 31
thorb3n 2:0b023bf05e0d 32 my_nrf24l01p.setTransmitMode();
Owen 0:a51a6e7da590 33 my_nrf24l01p.enable();
thorb3n 2:0b023bf05e0d 34 txData[1] = 2;
thorb3n 2:0b023bf05e0d 35 txData[0] = 23;
thorb3n 2:0b023bf05e0d 36 txDataCnt =1;
thorb3n 2:0b023bf05e0d 37 IWDG->KR=IWDG_START;
thorb3n 2:0b023bf05e0d 38 IWDG->KR=IWDG_WRITE_ACCESS;
thorb3n 2:0b023bf05e0d 39 IWDG->PR=IWDG_PR_PR_0;
thorb3n 2:0b023bf05e0d 40 IWDG->RLR=IWDG_RELOAD;
thorb3n 2:0b023bf05e0d 41 while(IWDG->SR) {
thorb3n 3:62a65ac86473 42 wait_ms(1);
thorb3n 2:0b023bf05e0d 43 }
thorb3n 2:0b023bf05e0d 44 my_nrf24l01p.write( NRF24L01P_PIPE_P0, txData, txDataCnt );
thorb3n 2:0b023bf05e0d 45 IWDG->KR=IWDG_REFRESH; /* (6) */
thorb3n 2:0b023bf05e0d 46 deepsleep();
Owen 0:a51a6e7da590 47 while (1) {
Owen 0:a51a6e7da590 48 }
Owen 0:a51a6e7da590 49 }