Specialized interface code for the nRF24L01P wireless transceiver.

Dependents:   WalkingRobot PcRadioBridge FzeroXcontroller WalkingRobot ... more

Committer:
pclary
Date:
Sun Dec 23 04:56:14 2012 +0000
Revision:
1:32635715529f
Parent:
0:fb0cf6209cd3
Child:
3:245faa365852
Added controller class to radio library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pclary 0:fb0cf6209cd3 1 #ifndef _RADIO_H
pclary 0:fb0cf6209cd3 2 #define _RADIO_H
pclary 0:fb0cf6209cd3 3
pclary 0:fb0cf6209cd3 4 #include "mbed.h"
pclary 0:fb0cf6209cd3 5
pclary 0:fb0cf6209cd3 6 #define RX_BUFFER_SIZE 4
pclary 0:fb0cf6209cd3 7
pclary 0:fb0cf6209cd3 8
pclary 0:fb0cf6209cd3 9
pclary 0:fb0cf6209cd3 10 class Radio
pclary 0:fb0cf6209cd3 11 {
pclary 0:fb0cf6209cd3 12 public:
pclary 0:fb0cf6209cd3 13 Radio(PinName mosi, PinName miso, PinName sck, PinName csn, PinName ce, PinName irq);
pclary 0:fb0cf6209cd3 14 void reset();
pclary 0:fb0cf6209cd3 15 void transmit(uint32_t data);
pclary 0:fb0cf6209cd3 16 int getRegister(int address);
pclary 0:fb0cf6209cd3 17 int getStatus();
pclary 0:fb0cf6209cd3 18
pclary 0:fb0cf6209cd3 19 uint32_t rx_controller;
pclary 0:fb0cf6209cd3 20 uint32_t rx_robot[RX_BUFFER_SIZE];
pclary 0:fb0cf6209cd3 21 int controller;
pclary 0:fb0cf6209cd3 22
pclary 0:fb0cf6209cd3 23 private:
pclary 0:fb0cf6209cd3 24 void setRegister(int address, int data);
pclary 0:fb0cf6209cd3 25 void receive();
pclary 0:fb0cf6209cd3 26
pclary 0:fb0cf6209cd3 27 SPI _spi;
pclary 0:fb0cf6209cd3 28 DigitalOut _csn;
pclary 0:fb0cf6209cd3 29 DigitalOut _ce;
pclary 0:fb0cf6209cd3 30 InterruptIn _irq;
pclary 0:fb0cf6209cd3 31 unsigned rx_robot_pos;
pclary 0:fb0cf6209cd3 32 };
pclary 0:fb0cf6209cd3 33
pclary 0:fb0cf6209cd3 34
pclary 0:fb0cf6209cd3 35
pclary 1:32635715529f 36 class RadioController
pclary 1:32635715529f 37 {
pclary 1:32635715529f 38 public:
pclary 1:32635715529f 39 RadioController(PinName mosi, PinName miso, PinName sck, PinName csn, PinName ce);
pclary 1:32635715529f 40 void reset();
pclary 1:32635715529f 41 void transmit(uint32_t data);
pclary 1:32635715529f 42
pclary 1:32635715529f 43 int controller;
pclary 1:32635715529f 44
pclary 1:32635715529f 45 private:
pclary 1:32635715529f 46 void setRegister(int address, int data);
pclary 1:32635715529f 47
pclary 1:32635715529f 48 SPI _spi;
pclary 1:32635715529f 49 DigitalOut _csn;
pclary 1:32635715529f 50 DigitalOut _ce;
pclary 1:32635715529f 51 };
pclary 1:32635715529f 52
pclary 1:32635715529f 53
pclary 1:32635715529f 54
pclary 0:fb0cf6209cd3 55 #endif // _RADIO_H