I’m using the online compiler
Hi, I’m just trying to communicate two blue pill’s with two nRF24L01P’s with maybe just a button to turn a resistor.
My question is that what is the correct syntax to powerup/powerdown the board.
This is my nRF24L01P.h file
/**
* Power up the nRF24L01+ into Standby mode
*/
void powerUp(void);
/**
* Power down the nRF24L01+ into Power Down mode
*/
void powerDown(void);
This is my nRF24L01P.cpp file
void nRF24L01P::powerUp(void) {
int config = getRegister(_NRF24L01P_REG_CONFIG);
config |= _NRF24L01P_CONFIG_PWR_UP;
setRegister(_NRF24L01P_REG_CONFIG, config);
// Wait until the nRF24L01+ powers up
wait_us( _NRF24L01P_TIMING_Tpd2stby_us );
mode = _NRF24L01P_MODE_STANDBY;
}
void nRF24L01P::powerDown(void) {
int config = getRegister(_NRF24L01P_REG_CONFIG);
config &= ~_NRF24L01P_CONFIG_PWR_UP;
setRegister(_NRF24L01P_REG_CONFIG, config);
// Wait until the nRF24L01+ powers down
wait_us( _NRF24L01P_TIMING_Tpd2stby_us ); // This *may* not be necessary (no timing is shown in the Datasheet), but just to be safe
mode = _NRF24L01P_MODE_POWER_DOWN;
}
I’m trying to implement this in my main.cpp file
My code is
DigitalOut myled(LED1);
int main()
{
while(1) {
nRF24L01P::powerUp;
myled = 0; // LED ON
wait(5.0); // 5 second
nRF24L01P::powerDown;
myled = 1; // LED ON
wait(5.0); // 5 second
}
}