/*******************************************************************************
|
* File Name : BSP.c
|
* Description :
|
* Created on : 2018Äê7ÔÂ23ÈÕ
|
* Author : ¶Å¼ü
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Include Files *
|
*******************************************************************************/
|
#include "BSP.h"
|
#include "stm32f4xx_hal.h"
|
#include "HIDO_Debug.h"
|
#include "Uart.h"
|
#include "Shell.h"
|
#include "DBG.h"
|
//#include "RTC.h"
|
//#include "SPI.h"
|
#ifdef __EC600S__
|
#include "EC600SDriver.h"
|
#endif
|
//#include "LED.h"
|
#include "Delay.h"
|
#include "SPIFlash.h"
|
//#include "Power.h"
|
#include "GPS.h"
|
#include "RTC.h"
|
#include "ADC_hal.h"
|
#include "global_param.h"
|
#include "dw_app.h"
|
#include "AppConfig.h"
|
/*******************************************************************************
|
* Macro *
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Type Definition *
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Global Variable *
|
*******************************************************************************/
|
|
extern SPI_HandleTypeDef hspi1;
|
extern UART_HandleTypeDef huart1;
|
extern UART_HandleTypeDef huart2;
|
extern UART_HandleTypeDef huart6;
|
extern ADC_HandleTypeDef hadc1;
|
extern DMA_HandleTypeDef hdma_usart1_rx;
|
extern DMA_HandleTypeDef hdma_usart1_tx;
|
extern DMA_HandleTypeDef hdma_usart2_rx;
|
extern DMA_HandleTypeDef hdma_usart2_tx;
|
|
/*******************************************************************************
|
* Local Variable *
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Local Function Declaration *
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Local Function *
|
*******************************************************************************/
|
/*******************************************************************************
|
* Function Name : BSP_ResourceInit
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : ¶Å¼ü
|
* Modified Date: : 2018Äê7ÔÂ23ÈÕ
|
*******************************************************************************/
|
static HIDO_INT32 BSP_ResourceInit(void)
|
{
|
/* UART */
|
#ifdef __APP_CODE__
|
ADC_Register(&hadc1);
|
#endif
|
/* SpiFlash */
|
SPI_Register(SPI_ID_FLASH, &hspi1);
|
SPIFlash_SPIRegister(SPI_FLASH_ID_0, SPI_ID_FLASH);
|
SPIFlash_PinRegister(SPI_FLASH_ID_0, SPI_FLASH_PIN_CS, GPIOB, GPIO_PIN_5);
|
SPIFlash_PinRegister(SPI_FLASH_ID_0, SPI_FLASH_PIN_SCK, GPIOA, GPIO_PIN_5);
|
SPIFlash_PinRegister(SPI_FLASH_ID_0, SPI_FLASH_PIN_MISO, GPIOA, GPIO_PIN_6);
|
SPIFlash_PinRegister(SPI_FLASH_ID_0, SPI_FLASH_PIN_MOSI, GPIOA, GPIO_PIN_7);
|
|
/* UART */
|
Uart_Register(UART_ID_DBG, &huart1);
|
Uart_Register(UART_ID_4G, &huart6);
|
Uart_Register(UART_ID_GPS, &huart2);
|
|
//TODO ADC_Register(&hadc1);
|
//Delay_TimerRegister(&htim16);
|
#ifdef _RTK_MODE_
|
/* EC600S */
|
|
|
EC600SDriver_PinRegister(EC600S_PIN_3V8_EN, GPIOB, GPIO_PIN_10);
|
//EC600SDriver_PinRegister(EC600S_PIN_3V8_EN, GPIOA, GPIO_PIN_8);
|
EC600SDriver_PinRegister(EC600S_PIN_PWRKEY, GPIOB, GPIO_PIN_0);
|
EC600SDriver_PinRegister(EC600S_PIN_RI, GPIOB, GPIO_PIN_12);
|
#ifdef __APP_CODE__
|
/* F9P */
|
GPS_PinRegister(GPS_PIN_REST, GPIOC, GPIO_PIN_6);
|
GPS_PinRegister(GPS_PIN_EN, GPIOA, GPIO_PIN_12);
|
#endif
|
#endif
|
return HIDO_OK;
|
}
|
|
/*******************************************************************************
|
* Global Function *
|
*******************************************************************************/
|
/*******************************************************************************
|
* Function Name : HAL_UART_ErrorCallback
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : ¶Å¼ü
|
* Modified Date: : 2018Äê7ÔÂ23ÈÕ
|
*******************************************************************************/
|
void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
|
{
|
Uart_RxErrorFromISR(huart);
|
}
|
|
/*******************************************************************************
|
* Function Name : HAL_UART_TxCpltCallback
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : ¶Å¼ü
|
* Modified Date: : 2018Äê7ÔÂ23ÈÕ
|
*******************************************************************************/
|
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
|
{
|
Uart_TxOverFromISR(huart);
|
}
|
|
/*******************************************************************************
|
* Function Name : HAL_UART_RxCpltCallback
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : ¶Å¼ü
|
* Modified Date: : 2018Äê7ÔÂ23ÈÕ
|
*******************************************************************************/
|
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
{
|
Uart_RxOverFromISR(huart);
|
}
|
|
/*******************************************************************************
|
* Function Name : HAL_RTC_AlarmAEventCallback
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : ¶Å¼ü
|
* Modified Date: : 2018Äê7ÔÂ23ÈÕ
|
*******************************************************************************/
|
//void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
|
//{
|
//#ifdef __APP_CODE__
|
// HIDO_Debug("HAL_RTC_AlarmAEventCallback\r\n");
|
//#endif
|
//}
|
|
/*******************************************************************************
|
* Function Name : HAL_GPIO_EXTI_Callback
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : ¶Å¼ü
|
* Modified Date: : 2018Äê7ÔÂ23ÈÕ
|
*******************************************************************************/
|
extern float nomove_count;
|
extern u8 flag_ancupd_start;
|
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
{
|
#ifdef __APP_CODE__
|
if(GPIO_Pin == GPIO_PIN_12)
|
{
|
PowerDownDetect();
|
}
|
if(GPIO_Pin == GPIO_PIN_0)
|
{
|
nomove_count = 0;
|
}
|
if(GPIO_Pin == GPIO_PIN_9&&flag_ancupd_start==0)
|
{
|
Anchor_App();
|
}
|
if(GPIO_Pin == GPIO_PIN_9&&flag_ancupd_start==1)
|
{
|
UWBYmodemT_App();
|
}
|
//HIDO_Debug("HAL_GPIO_EXTI_Callback %x\r\n", GPIO_Pin);
|
#endif
|
}
|
|
/*******************************************************************************
|
* Function Name : HAL_TIM_PeriodElapsedCallback
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : ¶Å¼ü
|
* Modified Date: : 2018Äê7ÔÂ23ÈÕ
|
*******************************************************************************/
|
extern u8 bat_percent2;
|
extern u16 basesystimer,g_Resttimer;
|
extern u8 g_start_sync_flag;
|
extern u32 sync_timer,target_time;
|
float nomove_count=0;
|
u8 uwb_timeout;
|
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
{
|
#ifdef __APP_CODE__
|
basesystimer++;
|
|
uwb_timeout++;
|
if(basesystimer>=1000)
|
{
|
basesystimer = 0;
|
// BepperTask();
|
g_Resttimer++;
|
nomove_count++;
|
g_start_sync_flag = 1;
|
if(g_Resttimer>10&&DBG_GetMode() != DBG_MODE_CHARGE)
|
{
|
NVIC_SystemReset();
|
}
|
if(g_com_map[UWBENABLE_INDEX]==0)
|
{
|
if(HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)&&DBG_GetMode() != DBG_MODE_CHARGE)
|
{
|
Set4LEDColor(uwbled,rtkled,led4g,powerled);
|
}
|
}
|
}
|
if(basesystimer==target_time)
|
{
|
g_start_send_flag = 1;
|
}
|
#endif
|
// if(synctimer%100==0)
|
// {g_start_send_flag = 1;}
|
}
|
|
|
/*******************************************************************************
|
* Function Name : BSP_Init
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : ¶Å¼ü
|
* Modified Date: : 2018Äê7ÔÂ23ÈÕ
|
*******************************************************************************/
|
HIDO_INT32 BSP_Init(void)
|
{
|
BSP_ResourceInit();
|
|
return HIDO_OK;
|
}
|