void NRF24L01_SetContCarrier(rt_bool_t contCarrier) { radioConf.contCarrier = contCarrier?1:0; RADIO_DIS_CE(); NRF24L01_UpdateRfSetup(); if(contCarrier) RADIO_EN_CE(); }
void nrfSetEnable(bool enable) { if (enable==TRUE) { RADIO_EN_CE(); } else { RADIO_DIS_CE(); } }
void radioSetContCarrier(bool contCarrier) { radioConf.contCarrier = contCarrier?1:0; RADIO_DIS_CE(); radioUpdateRfSetup(); if(contCarrier) RADIO_EN_CE(); }
//Set the radio channel. void NRF24L01_SetChannel(char channel) { //Test the input if(channel<0 || channel>125) return; //Change the channel RADIO_DIS_CE(); NRF24L01_WriteReg(REG_RF_CH, channel); //CE is continously activated if in continous carrier mode if(radioConf.contCarrier) RADIO_EN_CE(); }
void rt_hw_nrf24l01_init(void) { SPI_InitTypeDef SPI_InitStructure; EXTI_InitTypeDef EXTI_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; //if (isInit==TRUE) // return; /* Enable the EXTI interrupt router */ // extiInit(); /* Enable SPI and GPIO clocks */ RCC_APB2PeriphClockCmd(RADIO_SPI_CLK | RADIO_GPIO_SPI_CLK | RADIO_GPIO_CS_PERIF | RADIO_GPIO_CE_PERIF | RADIO_GPIO_IRQ_PERIF, ENABLE); /* Disable JTAG */ GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE); /* Remap SPI1 */ GPIO_PinRemapConfig(GPIO_Remap_SPI1 , ENABLE); /* Configure SPI pins: SCK, MISO and MOSI */ GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_SPI_SCK | RADIO_GPIO_SPI_MOSI | RADIO_GPIO_SPI_MISO; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(RADIO_GPIO_SPI_PORT, &GPIO_InitStructure); /* Configure MISO */ // GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_SPI_MISO; // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; // GPIO_Init(RADIO_GPIO_SPI_PORT, &GPIO_InitStructure); /* Configure I/O for the Chip select */ GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_CS; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(RADIO_GPIO_CS_PORT, &GPIO_InitStructure); /* Configure the interruption (EXTI Source) */ GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_IRQ; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(RADIO_GPIO_IRQ_PORT, &GPIO_InitStructure); GPIO_EXTILineConfig(RADIO_GPIO_IRQ_SRC_PORT, RADIO_GPIO_IRQ_SRC); EXTI_InitStructure.EXTI_Line = RADIO_GPIO_IRQ_LINE; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); /* disable the chip select */ RADIO_DIS_CS(); /* Configure I/O for the Chip Enable */ GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_CE; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(RADIO_GPIO_CE_PORT, &GPIO_InitStructure); /* disable the chip enable */ RADIO_DIS_CE(); /* SPI configuration */ SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; SPI_InitStructure.SPI_Mode = SPI_Mode_Master; SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7; SPI_Init(RADIO_SPI, &SPI_InitStructure); /* Enable the SPI */ SPI_Cmd(RADIO_SPI, ENABLE); //isInit = TRUE; }