/*
///////////////////////////////////////////////////////////////////////////////
ATMEGA 128, 2561 RELAY 4 Library V.1.0
1st v.1.0 : 2011년 9월 23일
제작자 : (주)이지플로우
///////////////////////////////////////////////////////////////////////////////
*/
#ifdef EF_RELAY4
#define RELAY4_DATA_0123
//#define RELAY4_DATA_4567
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// RELAY 스위치 포트를 정의합니다.
// RELAY data Output:Bit 0,1,2,3 OR
// 4,5,6,7
#define RELAY4_DATA (PORTD)
#define RELAY4_DATA_DIR (DDRD)
//4비트 0123을 사용합니다.
#if defined(RELAY4_DATA_0123)
#define RELAY4_BIT_DATA ( (1<<0)|(1<<1)|(1<<2)|(1<<3) )
#define RELAY4_ON0 SETBIT (RELAY4_DATA, 0)
#define RELAY4_ON1 SETBIT (RELAY4_DATA, 1)
#define RELAY4_ON2 SETBIT (RELAY4_DATA, 2)
#define RELAY4_ON3 SETBIT (RELAY4_DATA, 3)
#define RELAY4_OFF0 CLEARBIT (RELAY4_DATA, 0)
#define RELAY4_OFF1 CLEARBIT (RELAY4_DATA, 1)
#define RELAY4_OFF2 CLEARBIT (RELAY4_DATA, 2)
#define RELAY4_OFF3 CLEARBIT (RELAY4_DATA, 3)
#else
#define RELAY4_BIT_DATA ( (1<<4)|(1<<5)|(1<<6)|(1<<7) )
#define RELAY4_ON0 SETBIT (RELAY4_DATA, 4)
#define RELAY4_ON1 SETBIT (RELAY4_DATA, 5)
#define RELAY4_ON2 SETBIT (RELAY4_DATA, 6)
#define RELAY4_ON3 SETBIT (RELAY4_DATA, 7)
#define RELAY4_OFF0 CLEARBIT (RELAY4_DATA, 4)
#define RELAY4_OFF1 CLEARBIT (RELAY4_DATA, 5)
#define RELAY4_OFF2 CLEARBIT (RELAY4_DATA, 6)
#define RELAY4_OFF3 CLEARBIT (RELAY4_DATA, 7)
#endif
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// clear RELAY Module
// RELAY Module 화면을 지웁니다.
void RELAY4_clear(void)
{
RELAY4_DATA = 0xFF - RELAY4_BIT_DATA;
}
// clear RELAY Module
// RELAY Module 을 모두 오프합니다.
void RELAY4_Init(void)
{
RELAY4_DATA = 0xFF - RELAY4_BIT_DATA;
RELAY4_DATA_DIR |= RELAY4_BIT_DATA;
}
// clear RELAY Module
// RELAY Module 을 모두 ON 합니다.
void RELAY4_OnBitOne(unsigned char i)
{
switch (i)
{
case 1: RELAY4_ON0; break;
case 2: RELAY4_ON1; break;
case 3: RELAY4_ON2; break;
case 4: RELAY4_ON3; break;
default: RELAY4_clear();
}
}
// clear RELAY Module
// RELAY Module 을 모두 OFF 합니다.
void RELAY4_OffBitOne(unsigned char i)
{
switch (i)
{
case 1: RELAY4_OFF0; break;
case 2: RELAY4_OFF1; break;
case 3: RELAY4_OFF2; break;
case 4: RELAY4_OFF3; break;
default: RELAY4_clear();
}
}
///////////////////////////////////////////////////////////////////////////////
#endif
|