Altium Designer畫的額溫槍原理圖和PCB圖如下:(51hei附件中可下載工程文件)
51hei.png (22.24 KB, 下載次數: 100)
下載附件
2021-3-7 18:21 上傳
51hei.png (83.54 KB, 下載次數: 98)
下載附件
2021-3-7 18:22 上傳
51hei.png (10.98 KB, 下載次數: 101)
下載附件
2021-3-7 18:22 上傳
單片機源程序如下:
- /******************************************************************************/
- /** \file main.c
- **
- ** A detailed description is available at
- ** @link Sample Group Some description @endlink
- **
- ** - 2017-05-28 LiuHL First Version
- **
- ******************************************************************************/
- /******************************************************************************
- * Include files
- ******************************************************************************/
- #include "adc.h"
- #include "gpio.h"
- #include "bgr.h"
- #include "lcd.h"
- #include "lvd.h"
- #include "app_lcd.h"
- #include "app_gpio.h"
- #include "app_adc.h"
- #include "app.h"
- /******************************************************************************
- * Local pre-processor symbols/macros ('#define')
- ******************************************************************************/
- #define USERKEYTRUE (0xFFFFFFFFu)
- #define USERKEYFALSE (0x00000000u)
- #define LCDCHAR__ (0xFFFFu)
- #define CHARGEEMPTY (0x00000000u)
- #define CHARGEFULL (0xFFFFFFFFu)
- /******************************************************************************
- * Global variable definitions (declared in header file with 'extern')
- ******************************************************************************/
- volatile uint32_t gu32AdcRestult = 0;
- volatile uint32_t gu32UserKeyFlag[4] = {USERKEYFALSE, USERKEYFALSE, USERKEYFALSE, USERKEYFALSE};
- volatile stc_lcd_display_cfg_t gstcLcdDisplayCfg = {0};
- volatile uint32_t gVolFlag = CHARGEFULL;
- /******************************************************************************
- * Local type definitions ('typedef')
- ******************************************************************************/
- typedef enum enMState
- {
- InitialMode = 0u,
- TempMeasureMode = 1u,
- TempShowMode = 2u,
- PowerOffMode = 3u,
- MemoryMode = 4u,
-
- }enMState_t;
- /******************************************************************************
- * Local function prototypes ('static')
- ******************************************************************************/
- /******************************************************************************
- * Local variable definitions ('static') *
- ******************************************************************************/
- /*****************************************************************************
- * Function implementation - global ('extern') and local ('static')
- ******************************************************************************/
- /**
- ******************************************************************************
- ** \brief Main function of project
- **
- ** \return uint32_t return value, if needed
- **
- ** This sample
- **
- ******************************************************************************/
- int32_t main(void)
- {
- volatile enMState_t enMState = InitialMode;
- uint32_t u32AdcResultTmp, u32NtcIndex;
-
- ///< GPIO 初始化
- AppMGpioInit();
-
- ///< ADC 模塊初始化
- AppMAdcInit();
-
- ///< LCD 模塊初始化
- AppLcdInit();
-
- ///< 電量監測模塊初始化
- AppVolMonitorInit();
-
-
- // 初次上電開機LCD全屏顯示閃爍兩次
- {
- AppLcdShowAll();
- delay1ms(400);
- AppLcdClearAll();
- delay1ms(400);
- AppLcdShowAll();
- delay1ms(400);
- AppLcdClearAll();
- delay1ms(400);
- AppLcdShowAll();
- }
-
- while(1)
- {
- switch(enMState)
- {
- case InitialMode:
- {
- // LCD 初始狀態顯示
- gstcLcdDisplayCfg.bM6En = FALSE;
- gstcLcdDisplayCfg.bM5En = TRUE;
- gstcLcdDisplayCfg.bM2En = FALSE;
- gstcLcdDisplayCfg.bM7En = TRUE;
- gstcLcdDisplayCfg.bM8En = TRUE;
- gstcLcdDisplayCfg.bM9En = FALSE;
- gstcLcdDisplayCfg.bM10En = FALSE;
- gstcLcdDisplayCfg.bM11En = TRUE;
- gstcLcdDisplayCfg.bM3En = FALSE;
- gstcLcdDisplayCfg.enTmpMode = Char__;
- gstcLcdDisplayCfg.u16Num = LCDCHAR__;
- }
-
- {
- if(USERKEYTRUE == gu32UserKeyFlag[2])
- {
- //……
- //(進入溫度測量)
- gu32UserKeyFlag[0] = USERKEYFALSE;
- gu32UserKeyFlag[1] = USERKEYFALSE;
- gu32UserKeyFlag[2] = USERKEYFALSE;
- gu32UserKeyFlag[3] = USERKEYFALSE;
-
- }
- else if (USERKEYTRUE == gu32UserKeyFlag[2])
- {
- //……
- gu32UserKeyFlag[0] = USERKEYFALSE;
- gu32UserKeyFlag[1] = USERKEYFALSE;
- gu32UserKeyFlag[2] = USERKEYFALSE;
- gu32UserKeyFlag[3] = USERKEYFALSE;
-
- enMState = TempMeasureMode;
- }
- }
-
- // ……
- break;
-
- case TempMeasureMode:
- // ……
- break;
-
- case TempShowMode:
- // ……
- break;
-
- case PowerOffMode:
- // ……
- break;
-
- case MemoryMode:
- // ……
- break;
-
- default:
- // ……
- break;
-
- }
-
- ///< 溫度采集及數據處理
- if(USERKEYTRUE == gu32UserKeyFlag[3])
- {
- gu32UserKeyFlag[3] = USERKEYFALSE;
-
- AppAdcNtcAvgCodeGet(&u32AdcResultTmp);
- u32NtcIndex = App_TempNtcFind(u32AdcResultTmp);
- AppLcdStkLcdShow((u32NtcIndex + 10)*10);
- delay1ms(1000);
-
-
- AppAdcVirAvgCodeGet(&u32AdcResultTmp);
- AppLcdStkLcdShow(App_TempVirFind(u32NtcIndex, u32AdcResultTmp));
- delay1ms(3000);
-
- }
-
- ///< LCD顯示更新
- {
- //AppLcdDisplayUpdate((stc_lcd_display_cfg_t*)(&gstcLcdDisplayCfg));
- }
- }
- }
- ///< LVD 中斷服務函數
- void Lvd_IRQHandler(void)
- {
- Lvd_ClearIrq();
- // 電量顯示更新標識
- gVolFlag = CHARGEEMPTY;
-
- }
- ///< GPIO 中斷服務程序 ———— 測溫及選擇功能鍵
- void PortC_IRQHandler(void)
- {
- delay1ms(20);
- if (TRUE == Gpio_GetIrqStatus(M_KEY_USER0_PORT, M_KEY_USER0_PIN))
- {
- Gpio_ClearIrq(M_KEY_USER0_PORT, M_KEY_USER0_PIN);
- if(FALSE == Gpio_GetInputIO(M_KEY_USER0_PORT, M_KEY_USER0_PIN))
- {
- //標定按鍵按下
- //……
- }
- return;
- }
-
- if (TRUE == Gpio_GetIrqStatus(M_KEY_USER1_PORT, M_KEY_USER1_PIN))
- {
- Gpio_ClearIrq(M_KEY_USER1_PORT, M_KEY_USER1_PIN);
- if(FALSE == Gpio_GetInputIO(M_KEY_USER1_PORT, M_KEY_USER1_PIN))
- {
- //標定按鍵按下
- //……
- }
- return;
- }
-
- if (TRUE == Gpio_GetIrqStatus(M_KEY_USER2_PORT, M_KEY_USER2_PIN))
- {
- Gpio_ClearIrq(M_KEY_USER2_PORT, M_KEY_USER2_PIN);
- if(FALSE == Gpio_GetInputIO(M_KEY_USER2_PORT, M_KEY_USER2_PIN))
- {
- //標定按鍵按下
- //……
- }
- return;
- }
- }
- ///< GPIO 中斷服務程序 ———— 模式功能鍵
- void PortD_IRQHandler(void)
- {
- delay1ms(100);
- if (TRUE == Gpio_GetIrqStatus(M_KEY_USER3_PORT, M_KEY_USER3_PIN))
- {
- Gpio_ClearIrq(M_KEY_USER3_PORT, M_KEY_USER3_PIN);
- if(FALSE == Gpio_GetInputIO(M_KEY_USER3_PORT, M_KEY_USER3_PIN))
- {
- //標定按鍵按下
- gu32UserKeyFlag[3] = USERKEYTRUE;
- //……
- }
- return;
- }
- }
- /******************************************************************************
- * EOF (not truncated)
- ******************************************************************************/
復制代碼
所有資料51hei提供下載:
HC32L136額溫槍方案.zip
(7.54 MB, 下載次數: 84)
2021-3-7 17:26 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|