/** * @brief Closes the SPI when BLE is disabled by the application * Releases allocated resources * @param None * @retval None */ void BNRG_SPI_Close(void) { #ifdef ENABLE_SPI_FIX TIMER_Delete(StartupTimerId); #endif TIMER_Delete(TxRxTimerId); return; }
/** * @brief Resets the BlueNRG. * @param None * @retval None */ void BlueNRG_RST(void) { uint8_t ubnRFResetTimerID; GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitStruct.Pin = BNRG_SPI_RESET_PIN; GPIO_InitStruct.Speed = BNRG_SPI_RESET_SPEED; TIMER_Create(eTimerModuleID_Interrupt, &ubnRFResetTimerID, eTimerMode_SingleShot, pf_nRFResetTimerCallBack); BNRG_SPI_RESET_CLK_ENABLE(); HAL_GPIO_WritePin(BNRG_SPI_RESET_PORT, BNRG_SPI_RESET_PIN, GPIO_PIN_RESET); GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(BNRG_SPI_RESET_PORT, &GPIO_InitStruct); TIMER_Start(ubnRFResetTimerID, BLUENRG_HOLD_TIME_IN_RESET); ubnRFresetTimerLock = 1; while(ubnRFresetTimerLock == 1); HAL_GPIO_WritePin(BNRG_SPI_RESET_PORT, BNRG_SPI_RESET_PIN, GPIO_PIN_SET); #if 1 /* * Limitation in HAL V1.1.0 * The HAL_GPIO_Init() is first configuring the Mode of the IO before the Pull UP configuration * To avoid glitch on the IO, the configuration shall go through an extra step OUTPUT/PULLUP * to set upfront the PULL UP configuration. */ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(BNRG_SPI_RESET_PORT, &GPIO_InitStruct); #endif GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(BNRG_SPI_RESET_PORT, &GPIO_InitStruct); TIMER_Start(ubnRFResetTimerID, BLUENRG_HOLD_TIME_AFTER_RESET); ubnRFresetTimerLock = 1; while(ubnRFresetTimerLock == 1); TIMER_Delete(ubnRFResetTimerID); return; }
/*---------------------------------------------------------------------------*/ tBleStatus Blue_NRG_HCI_Timer_Stop(uint8_t timerID) { TIMER_Delete(timerID); return (BLE_STATUS_SUCCESS); }