|
int main(void)
{
init();
uint8_t btn0_nstate; // Store new (current) state of button 0
uint8_t btn1_nstate; // Store new (current) state of button 1
uint8_t btn0_ostate = nrf_gpio_pin_read(BUTTON0); // Store old (previous) state of button 0
uint8_t btn1_ostate = nrf_gpio_pin_read(BUTTON1); // Store old (previous) state of button 1
while(true)
{
uint8_t btns = 0;
btn0_nstate = nrf_gpio_pin_read(BUTTON0);
btn1_nstate = nrf_gpio_pin_read(BUTTON1);
if ((btn0_ostate == 1) && (btn0_nstate == 0))
{
btns |= 1;
}
if ((btn1_ostate == 1) && (btn1_nstate == 0))
{
btns |= 2;
}
btn0_ostate = btn0_nstate;
btn1_ostate = btn1_nstate;
// Place the read buttons in the payload, enable the radio and
// send the packet:
// packet[0] = 1;
NRF_RADIO->EVENTS_READY = 0U;
NRF_RADIO->TASKS_TXEN = 1U;
while (NRF_RADIO->EVENTS_READY == 0U)
{
}
NRF_RADIO->TASKS_START = 1U;
NRF_RADIO->EVENTS_END = 0U;
while(NRF_RADIO->EVENTS_END == 0U)
{
}
NRF_RADIO->EVENTS_DISABLED = 0U;
// Disable radio
NRF_RADIO->TASKS_DISABLE = 1U;
while(NRF_RADIO->EVENTS_DISABLED == 0U)
{
}
}
}
/**
*@}
**/
此代码为nrf51822 demo代码,代码不能将TASKS_TXEN寄存器赋值? |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|