Specialized interface code for the nRF24L01P wireless transceiver.
Dependents: WalkingRobot PcRadioBridge FzeroXcontroller WalkingRobot ... more
Radio.h@0:fb0cf6209cd3, 2012-12-23 (annotated)
- Committer:
- pclary
- Date:
- Sun Dec 23 04:48:16 2012 +0000
- Revision:
- 0:fb0cf6209cd3
- Child:
- 1:32635715529f
Working robot-to-robot communication along with a test program
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:fb0cf6209cd3 | 36 | #endif // _RADIO_H |