096111e983
.claude/ 제외(.gitignore 추가). 기존 초기커밋(5a96a69) 위에 신규·수정·이동분 커밋.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
155 lines
3.0 KiB
C
155 lines
3.0 KiB
C
/**************************************************************************//**
|
|
* @file main.c
|
|
* @version V1.00
|
|
* $Revision: 4 $
|
|
* $Date: 14/09/11 5:23p $
|
|
* @brief Show how to pixel on and off on LCD panel.
|
|
*
|
|
* @note
|
|
* Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved.
|
|
*****************************************************************************/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdint.h>
|
|
#include "Nano100Series.h"
|
|
#include "adc.h"
|
|
#include "gpio.h"
|
|
#include "pwm.h"
|
|
#include "timer.h"
|
|
#include "uart.h"
|
|
#include "sys.h"
|
|
#include "clk.h"
|
|
#include "EEPROM_Emulate.h"
|
|
|
|
|
|
#include "My_define.h"
|
|
|
|
#define __wdt_setting() SYS_UnlockReg(); WDT_Open(WDT_TIMEOUT_2POW14, 0, TRUE, FALSE); SYS_LockReg();
|
|
#define __wdt_reset() SYS_UnlockReg(); WDT_RESET_COUNTER(); SYS_LockReg();
|
|
|
|
extern volatile uint8_t Run_Timer;
|
|
extern volatile uint16_t mSec_Timer;
|
|
extern volatile uint16_t Blink_Timer;
|
|
extern volatile uint8_t Tx_Reservation_Hour, Rx_Reservation_Hour;
|
|
extern volatile uint8_t Reservation_Min;
|
|
|
|
extern volatile uint8_t Rx_Main_complete;
|
|
extern volatile uint8_t Tx_Data_Mode;
|
|
extern volatile uint8_t Tx_Main_Event_Flag;
|
|
|
|
extern uint16_t Main_Err_Code;
|
|
|
|
uint8_t Sec_Timer = 0;
|
|
uint8_t Blink_Toggle = 0;
|
|
uint8_t Blinking_Count = 0;
|
|
uint8_t In_Com_Error_Count = 0;
|
|
uint8_t Out_Com_Error_Count = 0;
|
|
uint8_t Sensor_Error_Count = 0;
|
|
|
|
extern volatile uint8_t IR_Event_Flag;
|
|
extern volatile uint8_t Rx_wifi_complete;
|
|
extern volatile uint16_t FastBlink_Timer;
|
|
uint8_t FastBlink_Toggle;
|
|
uint32_t Reset_src_value = 0;
|
|
|
|
|
|
void main(void)
|
|
{
|
|
|
|
__disable_interrupt();
|
|
SYS_Init();
|
|
|
|
SYS_EnableBOD(SYS_BODCTL_BOD25_RST_EN_Msk, SYS_BODCTL_BOD25_EN_Msk);
|
|
|
|
// ADC_Init();
|
|
|
|
GPIO_Init();
|
|
PWM_Init();
|
|
Timer0_Init();
|
|
Timer1_Init();
|
|
Timer2_Init();
|
|
|
|
// UART0_Init(); //
|
|
UART1_Init(); // to rs485 - internal
|
|
SC0_Init(); // to external
|
|
//SC1_Init(); // to wifi
|
|
|
|
Init_EEPROM(eep_data_size, eep_page_amount);
|
|
Search_Valid_Page();
|
|
|
|
__enable_interrupt();
|
|
|
|
Reset_src_value = SYS_GetResetSrc();
|
|
if((Reset_src_value & 0x00000037) != 0x00000004) // WDT reset
|
|
{
|
|
Processor_Init();
|
|
}
|
|
SYS_ClearResetSrc(Reset_src_value);
|
|
|
|
__wdt_setting();
|
|
|
|
Tx_Data_Mode = TX_DATA_MODE_REQUEST1;
|
|
|
|
while(1)
|
|
{
|
|
Touch_process();
|
|
com_rs485_process();
|
|
|
|
if(IR_Event_Flag == 1)
|
|
{
|
|
IR_Event_Flag = 0;
|
|
IR_Remocon_process();
|
|
}
|
|
|
|
|
|
if(Run_Timer == 0)
|
|
{
|
|
Run_Timer = 25;
|
|
Display_update();
|
|
Display_process();
|
|
}
|
|
|
|
|
|
if(mSec_Timer == 0)
|
|
{
|
|
mSec_Timer = 999;
|
|
|
|
if(In_Com_Error_Count++ >= 10){In_Com_Error_Count = 10;Main_Err_Code |= ERROR_IN_COM;}
|
|
if(Sensor_Error_Count++ >= 10){Sensor_Error_Count = 10;Main_Err_Code |= ERROR_CO2|ERROR_DUST;}
|
|
|
|
Air_Quality_process();
|
|
|
|
}
|
|
|
|
if(FastBlink_Timer == 0)
|
|
{
|
|
FastBlink_Timer = 249;
|
|
FastBlink_Toggle ^= 1;
|
|
}
|
|
|
|
if(Blink_Timer == 0)
|
|
{
|
|
Blink_Timer = 499;
|
|
|
|
if(Blink_Toggle == 0)
|
|
{
|
|
Blink_Toggle = 1;
|
|
}
|
|
else
|
|
{
|
|
Blink_Toggle = 0;
|
|
if(Blinking_Count)
|
|
{
|
|
Blinking_Count--;
|
|
}
|
|
}
|
|
__wdt_reset();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|