a502322188
손상된 .git 히스토리(missing tree)로 재초기화 후 작업트리 전체 커밋. .claude/ 만 제외(로컬 에이전트 설정). 구 저장소 백업(.git_corrupt_backup/) 포함. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
190 lines
4.4 KiB
C
190 lines
4.4 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 uint16_t Process_1000ms , Process_333ms, Process_100ms, Process_10ms, Process_5ms;
|
|
extern volatile uint8_t Err_Code;
|
|
|
|
|
|
|
|
extern volatile uint8_t Tx_Mode_Event, Tx_Fan_Event, Tx_Reserve_Event;
|
|
extern volatile uint8_t Reserve_hour;
|
|
|
|
extern volatile uint8_t Roomcon_connect_mode;
|
|
|
|
uint32_t Reset_src_value = 0;
|
|
|
|
// HERV~~~MAIN
|
|
void main(void)
|
|
{
|
|
/*
|
|
// === 부팅 검증 코드 — 다른 모든 init 보다 먼저 ===
|
|
{
|
|
// 1. SYS 보호 레지스터 unlock — BSP 함수 사용
|
|
SYS_UnlockReg();
|
|
|
|
// 2. GPIO AHB 클럭 강제 활성화 (Nano100: CLK->AHBCLK bit 0 = GPIO_EN)
|
|
CLK->AHBCLK |= CLK_AHBCLK_GPIO_EN_Msk;
|
|
|
|
// 3. PA10 을 push-pull OUTPUT 으로 강제 설정 (PMD[21:20] = 01)
|
|
PA->PMD &= ~(0x3UL << 20);
|
|
PA->PMD |= (0x1UL << 20);
|
|
|
|
// 4. LED 무조건 토글 — 이게 깜박이면 부팅 자체는 정상
|
|
while(1) {
|
|
PA->DOUT ^= (1UL << 10);
|
|
for(volatile uint32_t i = 0; i < 200000; i++);
|
|
}
|
|
}
|
|
*/
|
|
|
|
uint8_t Indicate_Error = 0;
|
|
|
|
|
|
|
|
__disable_irq(); // NuEclipse(GCC) 포팅: __disable_interrupt() → __disable_irq() (CMSIS 표준)
|
|
|
|
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();
|
|
|
|
UART0_Init(); // INT1 Hood
|
|
UART1_Init(); // to EX1 - homnet
|
|
SC0_Init(); // to RJ roomcon
|
|
SC1_Init(); // to EX2 --> BUNBAGI
|
|
|
|
Init_EEPROM(eep_data_size, eep_page_amount);
|
|
Search_Valid_Page();
|
|
|
|
__enable_irq(); // NuEclipse(GCC) 포팅: __enable_interrupt() → __enable_irq() (CMSIS 표준)
|
|
|
|
Reset_src_value = SYS_GetResetSrc();
|
|
init_process();
|
|
SYS_ClearResetSrc(Reset_src_value);
|
|
|
|
__wdt_setting();
|
|
|
|
while(1)
|
|
{
|
|
Hood_RS485_process(); // Hood connect - uart0
|
|
//com_display_process(); // display
|
|
com_roomcon_process(); // roomcon
|
|
InCom_process(); // Bunbaegi
|
|
Homenet_Process(); // HOMENET(ErvDashboard) 수신 명령 처리 + REQ_STATUS 응답
|
|
|
|
if(Process_5ms == 0)
|
|
{
|
|
Process_5ms = 5;
|
|
}
|
|
|
|
if(Process_10ms == 0)
|
|
{
|
|
Process_10ms = 3000;
|
|
}
|
|
|
|
if(Process_100ms == 0)
|
|
{
|
|
Process_100ms = 100;
|
|
Fan_Speed_process();
|
|
Fan_Error_Check();
|
|
Tx_display_flag = 1;
|
|
}
|
|
if(Process_333ms == 0)
|
|
{
|
|
Process_333ms = 200;
|
|
Hood_process();
|
|
__wdt_reset();
|
|
}
|
|
|
|
Indicate_Error = Err_Code;
|
|
Indicate_Error &= ~(ERROR_SOMETIME|ERROR_PROTECT|ERROR_FILTER_CHANGE|ERROR_FILTER_CLEAN|ERROR_SOJA_CHANGE);
|
|
|
|
if((Indicate_Error))
|
|
{
|
|
if(Process_1000ms < 600)ST_LED = 0;
|
|
else ST_LED = 1;
|
|
}
|
|
else
|
|
{
|
|
if(Process_1000ms < 2)ST_LED = 0;
|
|
else ST_LED = 1;
|
|
}
|
|
|
|
|
|
if(Process_1000ms == 0)
|
|
{
|
|
Process_1000ms = 999;
|
|
|
|
/* (꺼짐)예약 카운트다운 : 0 도달 시 전원 OFF (대시보드 CTRL_RESERVE) */
|
|
if(Reserve_Remain_Sec > 0)
|
|
{
|
|
Reserve_Remain_Sec--;
|
|
if(Reserve_Remain_Sec == 0)
|
|
{
|
|
Power_On = 0;
|
|
Set_Run_Mode = 0;
|
|
Set_Fan_Mode = 0;
|
|
Command_request_type |= (TYPE_MODE | TYPE_FAN_SPEED);
|
|
}
|
|
}
|
|
|
|
Bldc_check();
|
|
ADC_Sensing();
|
|
|
|
Filter_process();
|
|
|
|
Air_Quality_color_process();
|
|
Total_Air_Volume = Air_Quality_damper_process(); // 260520 사양 자동 동작로직(집중/분산) - 1s 주기
|
|
Homenet_Send_Status(); // HOMENET(ErvDashboard) STATUS(0x81) 1s 주기 송신
|
|
|
|
RJ_Com_Err_Check();
|
|
#if((SPEC_MODE_INFO&0x20) == 0x20) // UV 옵션
|
|
UV_process(); // 1sec
|
|
#endif
|
|
|
|
}
|
|
|
|
if(EEP_Save_Flag == 1)
|
|
{
|
|
EEP_Save_Flag = 0;
|
|
EEP_Save_process();
|
|
}
|
|
}
|
|
}
|