Loading files
/**
* __ ____
* / /__ _ __ / __/ __
* / //_/(_)/ /_ / / ___ ____ ___ __ __ / /_
* / ,< / // __/_\ \ / _ \ / __// _ \/ // // __/
* /_/|_|/_/ \__//___// .__//_/ \___/\_,_/ \__/
* /_/ github.com/KitSprout
*
* @file stm32f4xx_bsp.c
* @author KitSprout
* @date 16-Mar-2017
* @brief
*
*/
/* Includes --------------------------------------------------------------------------------*/
#include "drivers\stm32f4_system.h"
#include "modules\serial.h"
#include "modules\nrf24l01.h"
#include "stm32f4xx_bsp.h"
/** @addtogroup STM32_Program
* @{
*/
/* Private typedef -------------------------------------------------------------------------*/
/* Private define --------------------------------------------------------------------------*/
/* Private macro ---------------------------------------------------------------------------*/
/* Private variables -----------------------------------------------------------------------*/
/* Private function prototypes -------------------------------------------------------------*/
/* Private functions -----------------------------------------------------------------------*/
void BSP_GPIO_Config( void )
{
GPIO_InitTypeDef GPIO_InitStruct;
/* Enable all GPIO Clk *******************************************************/
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
/* GPIO all analog input *****************************************************/
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_All & (~(GPIO_PIN_13 | GPIO_PIN_14));
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* GPIO Pin ******************************************************************/
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Pin = LED_R_PIN;
HAL_GPIO_Init(LED_R_GPIO_PORT, &GPIO_InitStruct);
GPIO_InitStruct.Pin = LED_G_PIN;
HAL_GPIO_Init(LED_G_GPIO_PORT, &GPIO_InitStruct);
GPIO_InitStruct.Pin = LED_B_PIN;
HAL_GPIO_Init(LED_B_GPIO_PORT, &GPIO_InitStruct);
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Pin = KEY_PIN;
HAL_GPIO_Init(KEY_GPIO_PORT, &GPIO_InitStruct);
LED_R_Set();
LED_G_Set();
LED_B_Set();
}
void BSP_UART_SERIAL_Config( pFunc rxEvent )
{
hSerial.rxEventCallback = rxEvent;
Serial_Config();
printf("\r\nHello World!\r\n\r\n");
}
NRF_ConfigTypeDef NRF24;
void BSP_SPI_NRF24_Config( void )
{
uint8_t addr[5] = { 0x34, 0x43, 0x10, 0x10, 0x01 };
NRF24_Config();
delay_ms(50);
NRF24.TxAddr = addr;
NRF24.RxP0Addr = addr;
NRF24.NRF_DynamicPayload = ENABLE;
NRF24.NRF_Channel = 60;
NRF24.NRF_TxPower = NRF_TxPower_0dBm;
NRF24.NRF_DataRate = NRF_DataRate_250Kbps;
NRF24.NRF_AutoReTxDelay = NRF_ARD_4000us;
NRF24.NRF_AutoReTxCount = NRF_ARC_UpTo15;
printf("NRF24 Init ... ");
if (NRF24_Init(&NRF24) != SUCCESS) {
printf("ERROR\r\n");
while (1) {
LED_R_Toggle();
delay_ms(100);
}
}
printf("SUCCESS\r\n\r\n");
delay_ms(50);
}
/*************************************** END OF FILE ****************************************/
64aae1ebeThis file is pinned to the selected release. Download the original to open it in your design tool.