mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-07-03 12:07:52 +00:00
NRF_CE
This commit is contained in:
parent
2c3b64cde8
commit
0acde4294e
@ -159,19 +159,19 @@ void NRF24L01_SetPower()
|
|||||||
void NRF24L01_SetTxRxMode(enum TXRX_State mode)
|
void NRF24L01_SetTxRxMode(enum TXRX_State mode)
|
||||||
{
|
{
|
||||||
if(mode == TX_EN) {
|
if(mode == TX_EN) {
|
||||||
NRF_CSN_off;
|
NRF_CE_off;
|
||||||
NRF24L01_WriteReg(NRF24L01_07_STATUS, (1 << NRF24L01_07_RX_DR) //reset the flag(s)
|
NRF24L01_WriteReg(NRF24L01_07_STATUS, (1 << NRF24L01_07_RX_DR) //reset the flag(s)
|
||||||
| (1 << NRF24L01_07_TX_DS)
|
| (1 << NRF24L01_07_TX_DS)
|
||||||
| (1 << NRF24L01_07_MAX_RT));
|
| (1 << NRF24L01_07_MAX_RT));
|
||||||
NRF24L01_WriteReg(NRF24L01_00_CONFIG, (1 << NRF24L01_00_EN_CRC) // switch to TX mode
|
NRF24L01_WriteReg(NRF24L01_00_CONFIG, (1 << NRF24L01_00_EN_CRC) // switch to TX mode
|
||||||
| (1 << NRF24L01_00_CRCO)
|
| (1 << NRF24L01_00_CRCO)
|
||||||
| (1 << NRF24L01_00_PWR_UP));
|
| (1 << NRF24L01_00_PWR_UP));
|
||||||
_delay_us(130);
|
delayMicroseconds(130);
|
||||||
NRF_CSN_on;
|
NRF_CSN_on;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (mode == RX_EN) {
|
if (mode == RX_EN) {
|
||||||
NRF_CSN_off;
|
NRF_CE_off;
|
||||||
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); // reset the flag(s)
|
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); // reset the flag(s)
|
||||||
NRF24L01_WriteReg(NRF24L01_00_CONFIG, 0x0F); // switch to RX mode
|
NRF24L01_WriteReg(NRF24L01_00_CONFIG, 0x0F); // switch to RX mode
|
||||||
NRF24L01_WriteReg(NRF24L01_07_STATUS, (1 << NRF24L01_07_RX_DR) //reset the flag(s)
|
NRF24L01_WriteReg(NRF24L01_07_STATUS, (1 << NRF24L01_07_RX_DR) //reset the flag(s)
|
||||||
@ -181,13 +181,13 @@ void NRF24L01_SetTxRxMode(enum TXRX_State mode)
|
|||||||
| (1 << NRF24L01_00_CRCO)
|
| (1 << NRF24L01_00_CRCO)
|
||||||
| (1 << NRF24L01_00_PWR_UP)
|
| (1 << NRF24L01_00_PWR_UP)
|
||||||
| (1 << NRF24L01_00_PRIM_RX));
|
| (1 << NRF24L01_00_PRIM_RX));
|
||||||
_delay_us(130);
|
delayMicroseconds(130);
|
||||||
NRF_CSN_on;
|
NRF_CE_on;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NRF24L01_WriteReg(NRF24L01_00_CONFIG, (1 << NRF24L01_00_EN_CRC)); //PowerDown
|
NRF24L01_WriteReg(NRF24L01_00_CONFIG, (1 << NRF24L01_00_EN_CRC)); //PowerDown
|
||||||
NRF_CSN_off;
|
NRF_CE_off;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ void NRF24L01_Reset()
|
|||||||
NRF24L01_FlushTx();
|
NRF24L01_FlushTx();
|
||||||
NRF24L01_FlushRx();
|
NRF24L01_FlushRx();
|
||||||
NRF24L01_Strobe(0xff); // NOP
|
NRF24L01_Strobe(0xff); // NOP
|
||||||
NRF24L01_ReadReg(0x07);
|
NRF24L01_ReadReg(NRF24L01_07_STATUS);
|
||||||
NRF24L01_SetTxRxMode(TXRX_OFF);
|
NRF24L01_SetTxRxMode(TXRX_OFF);
|
||||||
_delay_us(100);
|
_delay_us(100);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user