From 9a760f0c11c4891b7fe54ae7960908092e68756e Mon Sep 17 00:00:00 2001 From: stark1898y <1658608470@qq.com> Date: Mon, 2 Dec 2024 17:34:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E5=8E=8B=E5=85=85=E7=94=B5=20400ms=20?= =?UTF-8?q?=E5=88=B08.4V=20=E5=8F=AF=E5=85=B3=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- APP/peripheral_main.c | 75 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 7 deletions(-) diff --git a/APP/peripheral_main.c b/APP/peripheral_main.c index 9f96617..1f30f30 100644 --- a/APP/peripheral_main.c +++ b/APP/peripheral_main.c @@ -22,7 +22,7 @@ */ __attribute__((aligned(4))) uint32_t MEM_BUF[BLE_MEMHEAP_SIZE / 4]; -#if(defined(BLE_MAC)) && (BLE_MAC == TRUE) +#if (defined(BLE_MAC)) && (BLE_MAC == TRUE) const uint8_t MacAddr[6] = {0x84, 0xC2, 0xE4, 0x03, 0x02, 0x02}; #endif @@ -34,12 +34,72 @@ const uint8_t MacAddr[6] = {0x84, 0xC2, 0xE4, 0x03, 0x02, 0x02}; * @return none */ __HIGH_CODE -__attribute__((noinline)) -void Main_Circulation() +__attribute__((noinline)) void Main_Circulation() { - while(1) + while (1) { TMOS_SystemProcess(); + if (GPIOB_ReadPortPin(GPIO_Pin_14) == 0) + { + // 12V_EN + GPIOA_SetBits(GPIO_Pin_13); + GPIOA_ModeCfg(GPIO_Pin_13, GPIO_ModeOut_PP_5mA); + PRINT("12V_EN ON\n"); + + // LED + GPIOA_SetBits(GPIO_Pin_4); + GPIOA_ModeCfg(GPIO_Pin_4, GPIO_ModeOut_PP_5mA); + DelayMs(50); + PRINT("LED ON\n"); + + GPIOA_ResetBits(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15); + GPIOA_ModeCfg(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15, GPIO_ModeIN_PD); + DelayMs(50); + PRINT("LED OFF\n"); + + GPIOA_SetBits(GPIO_Pin_5); + GPIOA_ModeCfg(GPIO_Pin_5, GPIO_ModeOut_PP_5mA); + DelayMs(50); + PRINT("LED ON\n"); + + GPIOA_ResetBits(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15); + GPIOA_ModeCfg(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15, GPIO_ModeIN_PD); + DelayMs(50); + PRINT("LED OFF\n"); + + GPIOA_SetBits(GPIO_Pin_15); + GPIOA_ModeCfg(GPIO_Pin_4, GPIO_ModeOut_PP_5mA); + DelayMs(50); + PRINT("LED ON\n"); + + GPIOA_ResetBits(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15); + GPIOA_ModeCfg(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15, GPIO_ModeIN_PD); + DelayMs(50); + PRINT("LED OFF\n"); + + DelayMs(100); + PRINT("DelayMs 700\n"); + + // 12V_EN + GPIOA_ResetBits(GPIO_Pin_13); + GPIOA_ModeCfg(GPIO_Pin_13, GPIO_ModeOut_PP_5mA); + PRINT("12V_EN OFF\n"); + + DelayMs(1000 * 5); + + + + // EMV_CTRL + GPIOB_SetBits(GPIO_Pin_13); + GPIOB_ModeCfg(GPIO_Pin_13, GPIO_ModeOut_PP_5mA); + PRINT("EMV_CTRL ON\n"); + DelayMs(100); + + // EMV_CTRL + GPIOB_ResetBits(GPIO_Pin_13); + GPIOB_ModeCfg(GPIO_Pin_13, GPIO_ModeIN_PD); + PRINT("EMV_CTRL OFF\n"); + } } } @@ -52,11 +112,11 @@ void Main_Circulation() */ int main(void) { -#if(defined(DCDC_ENABLE)) && (DCDC_ENABLE == TRUE) +#if (defined(DCDC_ENABLE)) && (DCDC_ENABLE == TRUE) PWR_DCDCCfg(ENABLE); #endif SetSysClock(CLK_SOURCE_PLL_60MHz); -#if(defined(HAL_SLEEP)) && (HAL_SLEEP == TRUE) +#if (defined(HAL_SLEEP)) && (HAL_SLEEP == TRUE) GPIOA_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PU); GPIOB_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PU); #endif @@ -75,12 +135,13 @@ int main(void) // KEY GPIOB_SetBits(GPIO_Pin_14); -// 由外部上拉电阻了 + // 由外部上拉电阻了 GPIOB_ModeCfg(GPIO_Pin_14, GPIO_ModeIN_Floating); // ADC_VBAT // GPIOAGPPCfg(ENABLE, RB_PIN_PA4_15_DIS); // R16_PIN_ANALOG_IE != RB_PIN_PA4_15_DIS; + R32_PIN_CONFIG2 |= (1U << 14); // R32_PIN_CONFIG2