Specialized interface code for the nRF24L01P wireless transceiver.
Dependents: WalkingRobot PcRadioBridge FzeroXcontroller WalkingRobot ... more
Radio.h@4:7953b5fa8aae, 2013-01-17 (annotated)
- Committer:
- pclary
- Date:
- Thu Jan 17 18:33:18 2013 +0000
- Revision:
- 4:7953b5fa8aae
- Parent:
- 3:245faa365852
Removed unnecessary 1ms pause in receive interrupt.
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 | 3:245faa365852 | 26 | void clear(); |
pclary | 0:fb0cf6209cd3 | 27 | |
pclary | 0:fb0cf6209cd3 | 28 | SPI _spi; |
pclary | 0:fb0cf6209cd3 | 29 | DigitalOut _csn; |
pclary | 0:fb0cf6209cd3 | 30 | DigitalOut _ce; |
pclary | 0:fb0cf6209cd3 | 31 | InterruptIn _irq; |
pclary | 3:245faa365852 | 32 | Timeout clearTimeout; |
pclary | 0:fb0cf6209cd3 | 33 | unsigned rx_robot_pos; |
pclary | 0:fb0cf6209cd3 | 34 | }; |
pclary | 0:fb0cf6209cd3 | 35 | |
pclary | 0:fb0cf6209cd3 | 36 | |
pclary | 0:fb0cf6209cd3 | 37 | |
pclary | 1:32635715529f | 38 | class RadioController |
pclary | 1:32635715529f | 39 | { |
pclary | 1:32635715529f | 40 | public: |
pclary | 1:32635715529f | 41 | RadioController(PinName mosi, PinName miso, PinName sck, PinName csn, PinName ce); |
pclary | 1:32635715529f | 42 | void reset(); |
pclary | 1:32635715529f | 43 | void transmit(uint32_t data); |
pclary | 1:32635715529f | 44 | |
pclary | 1:32635715529f | 45 | int controller; |
pclary | 1:32635715529f | 46 | |
pclary | 1:32635715529f | 47 | private: |
pclary | 1:32635715529f | 48 | void setRegister(int address, int data); |
pclary | 1:32635715529f | 49 | |
pclary | 1:32635715529f | 50 | SPI _spi; |
pclary | 1:32635715529f | 51 | DigitalOut _csn; |
pclary | 1:32635715529f | 52 | DigitalOut _ce; |
pclary | 1:32635715529f | 53 | }; |
pclary | 1:32635715529f | 54 | |
pclary | 1:32635715529f | 55 | |
pclary | 1:32635715529f | 56 | |
pclary | 0:fb0cf6209cd3 | 57 | #endif // _RADIO_H |