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.
51 lines
1.3 KiB
51 lines
1.3 KiB
#include "gatectrl.h"
|
|
|
|
static uint8_t s_ch = 1;
|
|
|
|
#define PORT_BIT_SETCLR(PORT, MASK, ON) \
|
|
do { \
|
|
if (ON) { (PORT) |= (uint8_t)(MASK); } \
|
|
else { (PORT) &= (uint8_t)~(MASK); } \
|
|
} while (0)
|
|
|
|
void Gate_SetByNum(uint8_t ch, uint8_t hash_on, uint8_t anaout_on, uint8_t check_on)
|
|
{
|
|
switch (ch)
|
|
{
|
|
case 1: /* HASH P15.3, ANAOUT P6.4, CHECK P15.4 */
|
|
PORT_BIT_SETCLR(P15, 0x08, hash_on); // P15.3
|
|
PORT_BIT_SETCLR(P6, 0x10, anaout_on); // P6.4
|
|
PORT_BIT_SETCLR(P15, 0x10, check_on); // P15.4
|
|
break;
|
|
|
|
case 2: /* P15.2, P6.5, P15.5 */
|
|
PORT_BIT_SETCLR(P15, 0x04, hash_on); // P15.2
|
|
PORT_BIT_SETCLR(P6, 0x20, anaout_on); // P6.5
|
|
PORT_BIT_SETCLR(P15, 0x20, check_on); // P15.5
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void Cal_Init(void)
|
|
{
|
|
uint8_t i;
|
|
|
|
// P4.7 = 0, P15.7 = 1 (´Ù¸¥ ºñÆ® º¸Á¸!)
|
|
PORT_BIT_SETCLR(P4, 0x80, 0);
|
|
PORT_BIT_SETCLR(P15, 0x80, 1);
|
|
|
|
for (i = 1; i <= 2; i++) {
|
|
Gate_SetByNum(i, 0, 0, 1); // hash=0, anaout=0, check=1
|
|
}
|
|
}
|
|
|
|
void GateCtrl_SelectChannel(uint8_t ch)
|
|
{
|
|
if (ch < 1 || ch > 2) return;
|
|
s_ch = ch;
|
|
}
|
|
|
|
|
|
|