You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

78 lines
1.3 KiB

#include "gatectrl.h"
#define BIT(n) (1u << (n))
// 공통핀 매핑
// ALL : P47 -> Port4 bit7
// ZACWIRE : P157 -> Port15 bit7
#define ALL_PM PM4
#define ALL_MASK (uint8_t)BIT(7)
#define ZAC_PM PM15
#define ZAC_MASK (uint8_t)BIT(7)
static uint8_t s_ch = 1;
static void write_port(volatile uint8_t *port, uint8_t mask, uint8_t on)
{
if (on) *port |= mask;
else *port &= (uint8_t)~mask;
}
void GateCtrl_Init(void)
{
// 공통핀 출력 설정
ALL_PM &= (uint8_t)~ALL_MASK;
ZAC_PM &= (uint8_t)~ZAC_MASK;
// 기본 OFF
GateCtrl_SetAll(0);
GateCtrl_SetZacwire(0);
// 채널 관련 모듈 init
hash_init();
check_pin_init();
// ANAOUT_Init()는 main에서 한다면 여기서 중복 호출 X
}
void GateCtrl_SetAll(uint8_t on)
{
write_port(&P4, ALL_MASK, on);
}
void GateCtrl_SetZacwire(uint8_t on)
{
write_port(&P15, ZAC_MASK, on);
}
void GateCtrl_ClearChannelPins(void)
{
hash_all_off();
check_all_off();
anaout_all_off();
}
void GateCtrl_SelectChannel(uint8_t ch)
{
if (ch < 1 || ch > 20) return;
s_ch = ch;
GateCtrl_ClearChannelPins();
}
void GateCtrl_Anaout(uint8_t on)
{
anaout_pin(s_ch, on);
}
void GateCtrl_Hash(uint8_t on)
{
hash_pin(s_ch, on);
}
void GateCtrl_Check(uint8_t on)
{
check_pin(s_ch, on);
}