update 1.8
This commit is contained in:
+24
-1
@@ -16,6 +16,7 @@
|
||||
#include "string.h"
|
||||
|
||||
tmosTaskID halTaskID;
|
||||
uint32_t g_LLE_IRQLibHandlerLocation;
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn Lib_Calibration_LSI
|
||||
@@ -84,6 +85,9 @@ void WCHBLE_Init(void)
|
||||
{
|
||||
uint8_t i;
|
||||
bleConfig_t cfg;
|
||||
|
||||
g_LLE_IRQLibHandlerLocation = (uint32_t)LLE_IRQLibHandler;
|
||||
|
||||
if(!tmos_memcmp(VER_LIB, VER_FILE, strlen(VER_FILE)))
|
||||
{
|
||||
PRINT("head file error...\n");
|
||||
@@ -258,7 +262,8 @@ void HAL_Init()
|
||||
*/
|
||||
uint16_t HAL_GetInterTempValue(void)
|
||||
{
|
||||
uint32_t rcc_apb2pcenr, rcc_cfgr0, adc1_ctrl1, adc1_ctrl2, adc1_rsqr1, adc1_rsqr3, adc1_samptr1;
|
||||
uint32_t rcc_apb2pcenr, rcc_cfgr0, adc1_ctrl1, adc1_ctrl2, adc1_rsqr1, adc1_rsqr2, adc1_rsqr3, adc1_samptr1, adc1_samptr2;
|
||||
uint32_t adc1_iofr1, adc1_iofr2, adc1_iofr3, adc1_iofr4, adc1_wdhtr, adc1_wdltr, adc1_isqr;
|
||||
ADC_InitTypeDef ADC_InitStructure = {0};
|
||||
uint16_t adc_data;
|
||||
|
||||
@@ -267,8 +272,17 @@ uint16_t HAL_GetInterTempValue(void)
|
||||
adc1_ctrl1 = ADC1->CTLR1;
|
||||
adc1_ctrl2 = ADC1->CTLR2;
|
||||
adc1_rsqr1 = ADC1->RSQR1;
|
||||
adc1_rsqr2 = ADC1->RSQR2;
|
||||
adc1_rsqr3 = ADC1->RSQR3;
|
||||
adc1_samptr1 = ADC1->SAMPTR1;
|
||||
adc1_samptr2 = ADC1->SAMPTR2;
|
||||
adc1_iofr1 = ADC1->IOFR1;
|
||||
adc1_iofr2 = ADC1->IOFR2;
|
||||
adc1_iofr3 = ADC1->IOFR3;
|
||||
adc1_iofr4 = ADC1->IOFR4;
|
||||
adc1_wdhtr = ADC1->WDHTR;
|
||||
adc1_wdltr = ADC1->WDLTR;
|
||||
adc1_isqr = ADC1->ISQR;
|
||||
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
|
||||
RCC_ADCCLKConfig(RCC_PCLK2_Div8);
|
||||
@@ -295,8 +309,17 @@ uint16_t HAL_GetInterTempValue(void)
|
||||
ADC1->CTLR1 = adc1_ctrl1;
|
||||
ADC1->CTLR2 = adc1_ctrl2;
|
||||
ADC1->RSQR1 = adc1_rsqr1;
|
||||
ADC1->RSQR2 = adc1_rsqr2;
|
||||
ADC1->RSQR3 = adc1_rsqr3;
|
||||
ADC1->SAMPTR1 = adc1_samptr1;
|
||||
ADC1->SAMPTR2 = adc1_samptr2;
|
||||
ADC1->IOFR1 = adc1_iofr1;
|
||||
ADC1->IOFR2 = adc1_iofr2;
|
||||
ADC1->IOFR3 = adc1_iofr3;
|
||||
ADC1->IOFR4 = adc1_iofr4;
|
||||
ADC1->WDHTR = adc1_wdhtr;
|
||||
ADC1->WDLTR = adc1_wdltr;
|
||||
ADC1->ISQR = adc1_isqr;
|
||||
return (adc_data);
|
||||
}
|
||||
|
||||
|
||||
+13
-3
@@ -43,7 +43,6 @@ void RTC_SetTignTime(uint32_t time)
|
||||
RTCTigFlag = 0;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn HAL_Time0Init
|
||||
*
|
||||
@@ -56,6 +55,9 @@ void RTC_SetTignTime(uint32_t time)
|
||||
void HAL_TimeInit(void)
|
||||
{
|
||||
uint16_t temp=0;
|
||||
uint8_t state=0;
|
||||
bleClockConfig_t conf;
|
||||
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR|RCC_APB1Periph_BKP, ENABLE);
|
||||
PWR_BackupAccessCmd(ENABLE);
|
||||
#if( CLK_OSC32K )
|
||||
@@ -87,13 +89,21 @@ void HAL_TimeInit(void)
|
||||
#if( CLK_OSC32K )
|
||||
Lib_Calibration_LSI();
|
||||
#endif
|
||||
TMOS_TimerInit( RTC_GetCounter );
|
||||
conf.ClockAccuracy = CLK_OSC32K?1000:100;
|
||||
conf.ClockFrequency = CAB_LSIFQ/2;
|
||||
conf.ClockMaxCount = 0xFFFFFFFF;
|
||||
conf.getClockValue = RTC_GetCounter;
|
||||
state = TMOS_TimerInit( &conf );
|
||||
if(state)
|
||||
{
|
||||
PRINT("TMOS_TimerInit err %x\n",state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
__attribute__((interrupt("WCH-Interrupt-fast")))
|
||||
void RTCAlarm_IRQHandler(void)
|
||||
{
|
||||
TMOS_TimerIRQHandler();
|
||||
RTCTigFlag = 1;
|
||||
EXTI_ClearITPendingBit(EXTI_Line17);
|
||||
RTC_ClearITPendingBit(RTC_IT_ALR);
|
||||
|
||||
+16
-13
@@ -6,7 +6,7 @@
|
||||
* Description : Sleep configuration and its initialization
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
/* Header file contains */
|
||||
#include "HAL.h"
|
||||
|
||||
#define US_TO_TICK(us) (uint32_t)((us)/(1000000/((CAB_LSIFQ/2))))
|
||||
#define US_TO_TICK(us) (uint32_t)((us) / (1000000 / ((CAB_LSIFQ / 2))))
|
||||
|
||||
#define SLEEP_PERIOD_MIN_US 200
|
||||
#define SLEEP_PERIOD_MAX_TICK 0xFFD2393F
|
||||
#define SLEEP_PERIOD_MIN_TICK US_TO_TICK(SLEEP_PERIOD_MIN_US)
|
||||
#define HESREADY_TICK US_TO_TICK(WAKE_UP_MAX_TIME_US)
|
||||
#define SLEEP_PERIOD_MIN_US 200
|
||||
#define SLEEP_PERIOD_MAX_TICK 0xFFD2393F
|
||||
#define SLEEP_PERIOD_MIN_TICK US_TO_TICK(SLEEP_PERIOD_MIN_US)
|
||||
#define HESREADY_TICK US_TO_TICK(WAKE_UP_MAX_TIME_US)
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn BLE_LowPower
|
||||
@@ -43,8 +43,8 @@ uint32_t BLE_LowPower(uint32_t time)
|
||||
current_time = RTC_GetCounter();
|
||||
sleep_period = wake_time - current_time;
|
||||
|
||||
if((sleep_period < SLEEP_PERIOD_MIN_TICK)
|
||||
|| (sleep_period > SLEEP_PERIOD_MAX_TICK)) {
|
||||
if((sleep_period < SLEEP_PERIOD_MIN_TICK) || (sleep_period > SLEEP_PERIOD_MAX_TICK))
|
||||
{
|
||||
__enable_irq();
|
||||
return 2;
|
||||
}
|
||||
@@ -52,18 +52,21 @@ uint32_t BLE_LowPower(uint32_t time)
|
||||
RTC_SetTignTime(wake_time);
|
||||
__enable_irq();
|
||||
|
||||
#if(DEBUG == DEBUG_UART1) // To use other serial ports to output printing information, you need to modify this line of code
|
||||
#if(DEBUG == DEBUG_UART1) // To use other serial ports to output printing information, you need to modify this line of code
|
||||
while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET)
|
||||
{
|
||||
__NOP();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
// LOW POWER-sleep
|
||||
if(!RTCTigFlag) {
|
||||
if(!RTCTigFlag)
|
||||
{
|
||||
PWR_EnterSTOPMode_RAM_LV(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
|
||||
SystemInit();
|
||||
} else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user