summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-07-16 14:52:32 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2019-07-16 14:52:32 +0200
commitb47295e3b04413cc5d278df2ea8fe2c168beefd2 (patch)
treeebf340f74ad5fcbd1db4d0e3bee091356c9bc3de
parenta426c8d552d4b477758f90d6bb08619fb1ff3edd (diff)
more radio tests
-rw-r--r--include/driver/nrf24l01.h22
-rw-r--r--src/app/nrf24l01test/main.cc9
-rw-r--r--src/driver/nrf24l01.cc12
3 files changed, 28 insertions, 15 deletions
diff --git a/include/driver/nrf24l01.h b/include/driver/nrf24l01.h
index e753604..ecf4bc2 100644
--- a/include/driver/nrf24l01.h
+++ b/include/driver/nrf24l01.h
@@ -60,7 +60,7 @@ private:
*/
uint8_t writePayload(const void *buf, uint8_t data_len, const uint8_t writeType);
- /**
+ /**
* Read the receive payload
*
* The size of data read is the fixed payload size, see getPayloadSize()
@@ -69,7 +69,7 @@ private:
* @param len Maximum number of bytes to read
* @return Current value of status register
*/
- uint8_t readPayload(void* buf, uint8_t len);
+ uint8_t readPayload(void *buf, uint8_t len);
inline void csnHigh()
{
@@ -81,6 +81,16 @@ private:
gpio.write(NRF24L01_CS_PIN, 0);
arch.delay_us(5);
}
+ inline void ceHigh()
+ {
+ gpio.write(NRF24L01_EN_PIN, 1);
+ arch.delay_us(5);
+ }
+ inline void ceLow()
+ {
+ gpio.write(NRF24L01_EN_PIN, 0);
+ arch.delay_us(5);
+ }
inline void beginTransaction()
{
csnLow();
@@ -515,7 +525,7 @@ s *
void openWritingPipe(const uint8_t *address);
- /**
+ /**
* Test whether there was a carrier on the line for the
* previous listening period.
*
@@ -523,9 +533,9 @@ s *
*
* @return true if was carrier, false if not
*/
- bool testCarrier(void);
+ bool testCarrier(void);
- /**
+ /**
* Test whether a signal (carrier or otherwise) greater than
* or equal to -64dBm is present on the channel. Valid only
* on nRF24L01P (+) hardware. On nRF24L01, use testCarrier().
@@ -542,7 +552,7 @@ s *
* @endcode
* @return true if signal => -64dBm, false if not
*/
- bool testRPD(void);
+ bool testRPD(void);
uint8_t getStatus();
};
diff --git a/src/app/nrf24l01test/main.cc b/src/app/nrf24l01test/main.cc
index d0961d4..2ddcee3 100644
--- a/src/app/nrf24l01test/main.cc
+++ b/src/app/nrf24l01test/main.cc
@@ -33,6 +33,9 @@ void loop(void)
if (status & 0x01) {
kout << " TX_FULL";
}
+ if ((status & 0x0e) < 0x0d) {
+ kout << " @" << (status & 0x0e)/2;
+ }
kout << endl;
#ifdef MULTIPASS_ARCH_msp430fr5969lp
@@ -65,11 +68,11 @@ int main(void)
kout << "nrf24l01 configure ...";
unsigned char addr[5] = {0, 'D', 'E', 'R', 'F'};
- //nrf24l01.setAutoAck(1);
+ nrf24l01.setAutoAck(1);
//nrf24l01.enableAckPayload();
- nrf24l01.setDynamicPayloads(true);
+ nrf24l01.setDynamicPayloads(false);
nrf24l01.setPALevel(Nrf24l01::RF24_PA_MAX);
- nrf24l01.setChannel(25);
+ nrf24l01.setChannel(110);
nrf24l01.setDataRate(Nrf24l01::RF24_2MBPS);
#ifdef MULTIPASS_ARCH_msp430fr5994lp
nrf24l01.openReadingPipe(1, addr);
diff --git a/src/driver/nrf24l01.cc b/src/driver/nrf24l01.cc
index abd42ea..937831b 100644
--- a/src/driver/nrf24l01.cc
+++ b/src/driver/nrf24l01.cc
@@ -131,7 +131,7 @@ void Nrf24l01::powerUp(void)
void Nrf24l01::powerDown(void)
{
- gpio.write(NRF24L01_EN_PIN, 0);
+ ceLow();
writeRegister(NRF_CONFIG, readRegister(NRF_CONFIG) & ~(1 << PWR_UP));
}
@@ -234,18 +234,18 @@ uint8_t Nrf24l01::write(const void *buf, uint8_t len, bool await_ack, bool block
{
writePayload(buf, len, await_ack ? W_TX_PAYLOAD : W_TX_PAYLOAD_NO_ACK);
- gpio.write(NRF24L01_EN_PIN, 1);
+ ceHigh();
if (!blocking)
{
arch.delay_us(10);
- gpio.write(NRF24L01_EN_PIN, 0);
+ ceLow();
return 0;
}
while (!(getStatus() & ((1 << TX_DS) | (1 << MAX_RT))))
;
- gpio.write(NRF24L01_EN_PIN, 1);
+ ceLow();
uint8_t status = writeRegister(NRF_STATUS, ((1 << TX_DS) | (1 << MAX_RT)));
if (status & (1 << MAX_RT))
@@ -260,7 +260,7 @@ void Nrf24l01::startListening(void)
{
writeRegister(NRF_CONFIG, readRegister(NRF_CONFIG) | (1 << PRIM_RX));
writeRegister(NRF_STATUS, (1 << RX_DR) | (1 << TX_DS) | (1 << MAX_RT));
- gpio.write(NRF24L01_EN_PIN, 1);
+ ceHigh();
// Restore the pipe0 adddress, if exists
if (pipe0_reading_address[0] > 0)
@@ -280,7 +280,7 @@ void Nrf24l01::startListening(void)
void Nrf24l01::stopListening(void)
{
- gpio.write(NRF24L01_EN_PIN, 0);
+ ceLow();
arch.delay_us(txRxDelay);