Library for the (decidedly not as good as the 24L01+) Nordic 2401A radio.
Diff: Nrf2401A.h
- Revision:
- 1:049f6cb8b160
- Parent:
- 0:db163b6f1592
--- a/Nrf2401A.h Fri Sep 20 20:55:24 2013 +0000 +++ b/Nrf2401A.h Fri Sep 20 21:47:44 2013 +0000 @@ -46,7 +46,7 @@ // methods - Nrf2401(PinName n_DR1, PinName n_CE, PinName n_SC, PinName n_CLK, PinName n_DAT); + Nrf2401(PinName n_DR1, PinName n_CE, PinName n_CS, PinName n_CLK, PinName n_DAT); void rxMode(unsigned char messageSize=0); void txMode(unsigned char messageSize=0); void write(unsigned char dataByte); @@ -61,6 +61,46 @@ void configure(void); void loadConfiguration(bool modeSwitchOnly=false); void loadByte(unsigned char byte); + inline void select_chip(void) { + _cs = 1; + } + + inline void deselect_chip(void) { + _cs = 0; + } + + inline void enable_chip(void) { + _ce = 1; + } + + inline void disable_chip(void) { + _ce = 0; + } + + inline void cycle_clock(void) { + _clk = 1; + wait_us(1); + _clk = 0; + } + + inline void tx_data_lo(void) { + _dat.output(); + _dat = 1; + } + + inline void tx_data_hi(void) { + _dat.output(); + _dat = 1; + } + + inline int rx_data_hi(void) { + _dat.input(); + return _dat; + } + + inline int data_ready(void) { + return _dr1; + } DigitalOut _ce, _cs, _clk; DigitalIn _dr1;