From 97e2abd0858e19614a98df7ddc66782a4c9d5f17 Mon Sep 17 00:00:00 2001 From: stark1898y <1658608470@qq.com> Date: Wed, 11 Dec 2024 14:31:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 4 +++- APP/peripheral.c | 5 ++++- APP/peripheral_main.c | 3 --- BSP/src/bsp_adc.c | 20 +++++++++++++++++++- Profile/gattprofile.c | 2 +- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index af9c1da..96ca4aa 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,6 +3,8 @@ "bsp_adc.h": "c", "bsp_beep.h": "c", "bsp_key.h": "c", - "bsp_beep_led_emv.h": "c" + "bsp_beep_led_emv.h": "c", + "peripheral.h": "c", + "gattprofile.h": "c" } } diff --git a/APP/peripheral.c b/APP/peripheral.c index 953afd9..53a8130 100644 --- a/APP/peripheral.c +++ b/APP/peripheral.c @@ -40,7 +40,7 @@ #define SBP_PHY_UPDATE_DELAY 2400 // 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 // General discoverable mode advertises indefinitely @@ -274,8 +274,11 @@ void Peripheral_Init() // Setup the GAP Peripheral Role Profile { + //开启广播使能 uint8_t initial_advertising_enable = TRUE; + //最小连接间隔 uint16_t desired_min_interval = DEFAULT_DESIRED_MIN_CONN_INTERVAL; + //最大连接间隔 uint16_t desired_max_interval = DEFAULT_DESIRED_MAX_CONN_INTERVAL; // Set the GAP Role Parameters diff --git a/APP/peripheral_main.c b/APP/peripheral_main.c index 14309ac..e66c7b2 100644 --- a/APP/peripheral_main.c +++ b/APP/peripheral_main.c @@ -77,8 +77,6 @@ __attribute__((noinline)) void Main_Circulation() DelayMs(1000); PRINT("LED_ALL_OFF_DEINIT\n"); - - // LED_Y LED_Y_ON; DelayMs(1000); @@ -89,7 +87,6 @@ __attribute__((noinline)) void Main_Circulation() PRINT("LED_ALL_OFF_DEINIT\n"); - PRINT("Delay 6s\n"); // EMV_CHARGE diff --git a/BSP/src/bsp_adc.c b/BSP/src/bsp_adc.c index 943f1d2..ed11f37 100644 --- a/BSP/src/bsp_adc.c +++ b/BSP/src/bsp_adc.c @@ -61,11 +61,17 @@ void BSP_ADC_Init(void) printf("AverageCountBat = %d\n", CountBat); #endif + // 榛樿鎯呭喌涓嬶紝ADC 寮曡剼鍜屾墍鍦 GPIO 寮曡剼鐨勬暟瀛楀姛鑳芥槸鍚屾椂瀛樺湪鐨 + // 锛屽湪杩涜 ADC 娴嬮噺鏃跺欙紝闇瑕佸惂 GPIO 璁剧疆涓洪珮闃昏緭鍏 + // 锛屽綋 ADC 鐨勭數骞冲浜庝腑闂存佺殑鏃跺欙紝杩欐椂鍊欏線寰浼氬鑷存暟瀛楅儴鍒嗘紡鐢 + // 锛岃繖鏃跺欐垜浠彲浠ラ氳繃瀵勫瓨鍣 R16_PIN_ANALOG_IE 鏉ョ鐢ㄧ浉鍏崇殑 AIN 閫氶亾鎵鍦ㄧ殑鏁板瓧鍔熻兘: R32_PIN_CONFIG2 |= (1U << 13); /* 鍗曢氶亾閲囨牱锛氶夋嫨adc閫氶亾3鍋氶噰鏍凤紝瀵瑰簲 PA13寮曡剼锛 甯︽暟鎹牎鍑嗗姛鑳 */ GPIOA_ModeCfg(GPIO_Pin_13, GPIO_ModeIN_Floating); - // 6dB(2鍊) (ADC/4096+0.5)*Vref 1.5*Vref 0.525V锝1.575V 0.6V锝1.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); 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)); countadc = (countadc - min_number - max_number) / 18; // 鍒犻櫎鏈灏忎笌鏈澶у 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; printf("voltage=%1.3lf V\n", voltage); PRINT("VIN: %1.3lf V\n", voltage * 2); diff --git a/Profile/gattprofile.c b/Profile/gattprofile.c index 488567c..786ef27 100644 --- a/Profile/gattprofile.c +++ b/Profile/gattprofile.c @@ -6,7 +6,7 @@ * Description : 自定义包含五种不同属性的服务,包含可读、可写、通知、可读可写、安全可读 ********************************************************************************* * 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. *******************************************************************************/