This commit is contained in:
stark1898y 2024-12-11 14:31:10 +08:00
parent 840a11e70e
commit 97e2abd085
5 changed files with 27 additions and 7 deletions

View File

@ -3,6 +3,8 @@
"bsp_adc.h": "c", "bsp_adc.h": "c",
"bsp_beep.h": "c", "bsp_beep.h": "c",
"bsp_key.h": "c", "bsp_key.h": "c",
"bsp_beep_led_emv.h": "c" "bsp_beep_led_emv.h": "c",
"peripheral.h": "c",
"gattprofile.h": "c"
} }
} }

View File

@ -40,7 +40,7 @@
#define SBP_PHY_UPDATE_DELAY 2400 #define SBP_PHY_UPDATE_DELAY 2400
// What is the advertising interval when device is discoverable (units of 625us, 80=50ms) // What is the advertising interval when device is discoverable (units of 625us, 80=50ms)
#define DEFAULT_ADVERTISING_INTERVAL (160 * 1) #define DEFAULT_ADVERTISING_INTERVAL (160 * 10)
// Limited discoverable mode advertises for 30.72s, and then stops // Limited discoverable mode advertises for 30.72s, and then stops
// General discoverable mode advertises indefinitely // General discoverable mode advertises indefinitely
@ -274,8 +274,11 @@ void Peripheral_Init()
// Setup the GAP Peripheral Role Profile // Setup the GAP Peripheral Role Profile
{ {
//开启广播使能
uint8_t initial_advertising_enable = TRUE; uint8_t initial_advertising_enable = TRUE;
//最小连接间隔
uint16_t desired_min_interval = DEFAULT_DESIRED_MIN_CONN_INTERVAL; uint16_t desired_min_interval = DEFAULT_DESIRED_MIN_CONN_INTERVAL;
//最大连接间隔
uint16_t desired_max_interval = DEFAULT_DESIRED_MAX_CONN_INTERVAL; uint16_t desired_max_interval = DEFAULT_DESIRED_MAX_CONN_INTERVAL;
// Set the GAP Role Parameters // Set the GAP Role Parameters

View File

@ -77,8 +77,6 @@ __attribute__((noinline)) void Main_Circulation()
DelayMs(1000); DelayMs(1000);
PRINT("LED_ALL_OFF_DEINIT\n"); PRINT("LED_ALL_OFF_DEINIT\n");
// LED_Y // LED_Y
LED_Y_ON; LED_Y_ON;
DelayMs(1000); DelayMs(1000);
@ -89,7 +87,6 @@ __attribute__((noinline)) void Main_Circulation()
PRINT("LED_ALL_OFF_DEINIT\n"); PRINT("LED_ALL_OFF_DEINIT\n");
PRINT("Delay 6s\n"); PRINT("Delay 6s\n");
// EMV_CHARGE // EMV_CHARGE

View File

@ -61,11 +61,17 @@ void BSP_ADC_Init(void)
printf("AverageCountBat = %d\n", CountBat); printf("AverageCountBat = %d\n", CountBat);
#endif #endif
// 默认情况下ADC 引脚和所在 GPIO 引脚的数字功能是同时存在的
// ,在进行 ADC 测量时候,需要吧 GPIO 设置为高阻输入
// ,当 ADC 的电平处于中间态的时候,这时候往往会导致数字部分漏电
// ,这时候我们可以通过寄存器 R16_PIN_ANALOG_IE 来禁用相关的 AIN 通道所在的数字功能:
R32_PIN_CONFIG2 |= (1U << 13); R32_PIN_CONFIG2 |= (1U << 13);
/* 单通道采样选择adc通道3做采样对应 PA13引脚 带数据校准功能 */ /* 单通道采样选择adc通道3做采样对应 PA13引脚 带数据校准功能 */
GPIOA_ModeCfg(GPIO_Pin_13, GPIO_ModeIN_Floating); GPIOA_ModeCfg(GPIO_Pin_13, GPIO_ModeIN_Floating);
// 6dB(2倍) (ADC/4096+0.5)*Vref 1.5*Vref 0.525V1.575V 0.6V1.5V // -6dB (1/2 倍) (ADC/1024-1)*Vref 3*Vref -0.2V 3.15V 1.9V 3V
// 0db (1 倍) (ADC/2048)*Vref 2*Vref 0V 2.1V 0V 2V
// 6db (2 倍) (ADC/4096+0.5)*Vref 1.5*Vref 0.525V 1.575V 0.6V 1.5V
ADC_ExtSingleChSampInit(SampleFreq_3_2, ADC_PGA_0); ADC_ExtSingleChSampInit(SampleFreq_3_2, ADC_PGA_0);
RoughCalib_Value = ADC_DataCalib_Rough(); // 用于计算ADC内部偏差记录到全局变量 RoughCalib_Value中 RoughCalib_Value = ADC_DataCalib_Rough(); // 用于计算ADC内部偏差记录到全局变量 RoughCalib_Value中
@ -102,6 +108,18 @@ void BSP_ADC_Init(void)
printf("min=%d, max=%d, diff=%d\n", min_number, max_number, (max_number - min_number)); printf("min=%d, max=%d, diff=%d\n", min_number, max_number, (max_number - min_number));
countadc = (countadc - min_number - max_number) / 18; // 删除最小与最大值 countadc = (countadc - min_number - max_number) / 18; // 删除最小与最大值
printf("countaveradc = %d\n", countadc); printf("countaveradc = %d\n", countadc);
/*
int16_t adc_raw;
adc_raw = ADC_ExcutSingleConver() + RoughCalib_Value;
//PGA=-12db
voltage_mv = adc_raw*1050/512 - (3*1050);
//PGA=-6db
voltage_mv = adc_raw*1050/1024 - (1*1050);
//PGA=0db
voltage_mv = adc_raw*1050/2048;
//PGA=6db
voltage_mv = adc_raw*1050/4096 + (1050/2);
*/
voltage = (double)(countadc) / 2048 * 1.05; voltage = (double)(countadc) / 2048 * 1.05;
printf("voltage=%1.3lf V\n", voltage); printf("voltage=%1.3lf V\n", voltage);
PRINT("VIN: %1.3lf V\n", voltage * 2); PRINT("VIN: %1.3lf V\n", voltage * 2);

View File

@ -6,7 +6,7 @@
* Description : * Description :
********************************************************************************* *********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. * 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. * microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/ *******************************************************************************/