BASIC4MCU | 질문게시판 | 헤더파일 디버깅하는데 자꾸 에러가 나네요..
페이지 정보
작성자 남민기 작성일2018-12-12 17:50 조회9,369회 댓글2건본문
#define KEY_DN 1;
#define EV_DN 2;
#define EV_UP 4;
#define EV_LONGDN 8;
#define EV_DBCLICK 16;
typedef struct key_tag_type{
volatile char *INPORT;
char pin;
volatile int8_t key;
volatile int8_t tmr;
} key_tag;
void hook_key(key_tag *k);
int8_t getEV(key_tag *k);
void init_key(key_tag *k, volatile char *PORTX, int8_t pin_num, uint8_t term);
-------------------------------------------------------------------------------------------------------------
expected ')' before ';' token
해당 에러가 뜨는데
스트럭트 쪽에서 에러가 나는 것 같더라고요. 문법은 맞는 것 같은데 이유가 있을까요..
댓글 2
조회수 9,369master님의 댓글
master 작성일전체 소스파일 첨부해야지 컴파일 해볼 수 있습니다.
남민기님의 댓글
남민기
#define F_CPU 16000000
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "LCD.h"
#include "key.h"
#define MIN_TERM 8
#define MAX_TERM 60
#define _DEBOUNCEC 60
#define _LONG_HOLD 1000
#define _DC_GAP 250
static int8_t _debounce_ticks;
static int8_t _long_hold_ticks;
static int8_t _dc_gap_ticks;
//모스부호 ,/ 0 = null / 1= . / 2 = ㅡ /
int A[4] = { 1,2,0,0 },
B[4] = { 2,1,1,1 },
C[4] = { 2,1,2,1 },
D[4] = { 2,1,1,0 },
E[4] = { 1,0,0,0 },
F[4] = { 1,1,2,1 },
G[4] = { 2,2,1,0 },
H[4] = { 1,1,1,1 },
I[4] = { 1,1,0,0 },
J[4] = { 1,2,2,2 },
K[4] = { 2,1,2,0 },
L[4] = { 1,2,1,1 },
M[4] = { 2,2,0,0 },
N[4] = { 2,1,0,0 },
O[4] = { 2,2,2,0 },
P[4] = { 1,2,2,1 },
Q[4] = { 2,2,1,2 },
R[4] = { 1,2,1,0 },
S[4] = { 1,1,1,0 },
T[4] = { 2,0,0,0 },
U[4] = { 1,1,2,0 },
V[4] = { 1,1,1,2 },
W[4] = { 1,2,2,0 },
X[4] = { 2,1,1,2 },
Y[4] = { 2,1,2,2 },
Z[4] = { 2,2,1,1 };
//function declaration
int curr = 0; int num = 1;
int index = 1;
int LoadBuffer = 0;
void Port_init();
char key_scan(void);
char Character(int[]);
void LoadBufferReset(void);
char GetBN(void);
int morse[4];
int chanel=0;
int main(void)
{
char sceneNo = '0', sceneNo0 = '0';
int ciper = 0; //자릿수
Port_init();
_delay_ms(50); //cache
LCD_initialize();
int cnt_arr = 0;
LCD_clear();
_delay_ms(10);
//main stage
LCD_string(0x80, "1.ENG to MORSE");
LCD_string(0xc0, "2.MORto ENG Ini2");
while(chanel == 0){
//get a button main
sceneNo = GetBN();
if(sceneNo == sceneNo0) continue;
switch(sceneNo)
{
case '1':
LCD_string(0x80,"--ch0ch0");
break;
case '2':
LCD_string(0x80,"ch0ch0ch0");
break;
case '3':
LCD_clear();
EGtoMS();
break;
case '6' :
LCD_clear();
LCD_string(0x80, "1.ENG to MORSE");
LCD_string(0xc0, "2.MORto ENG Home");
break;
}
}//while
return 0;
}//main
void Port_Init(void)
{
DDRE = 0x00; //BUTTON
PORTE = 0x00;
DDRF = 0xff;
PORTF = 0x00;
DDRB = 0xff; //LCD
PORTB = 0x00;
DDRD = 0xff;
PORTD = 0x00;
DDRF = 0xff;
PORTF = 0x00;
DDRE = 0xff;
}
char GetBN(void)
{
unsigned char p = 0x00;
if((PINE & 0x01) == 0){
return '1';
_delay_ms(100); while(PINE & 0x01); _delay_ms(100); //채터링방지용
}
if((PINE & 0x02) == 0){
return '2';
_delay_ms(100); while(PINE & 0x02); _delay_ms(100); //채터링방지용
}
if((PINE & 0x04) == 0){
_delay_ms(100);
return '3';
_delay_ms(100); while(PINE & 0x04); _delay_ms(100); //채터링방지용
}
if((PINE & 0x08) == 0){
return '4';
_delay_ms(100); while(PINE & 0x08); _delay_ms(100); //채터링방지용
}
if((PINE & 0x10) == 0){
return '5';
_delay_ms(100); while(PINE & 0x10); _delay_ms(100); //채터링방지용
}
if((PINE & 0x20) == 0){
return '6';
_delay_ms(100); while(PINE & 0x20); _delay_ms(100); //채터링방지용
}
return '0';
}
void EGtoMS(void){_delay_ms(500);
chanel = 1;
LCD_clear();
// LCD_command(0x0e);
Eng();
}
void Eng(void){
LCD_clear();
LCD_string(0x80, "Enter Message");LCD_string(0x8f,"?");
char spell[] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
int i = 0;
char Strings[20];
int j = 0;
int force = 0;
while(chanel==1){
//스펠링이 들어갈 곳.
char btn=GetBN();
//force = 0;
switch(btn){
case '1':
if(i==0){
i=26;
}
i--;
spelling(i);
if(force<3){
_delay_ms(500);
force++;}
else {_delay_ms(200);}
break;
case '2':
if(i==25){
i=-1;
}
i++;
spelling(i);
if(force<3){
_delay_ms(500);
force++;}
else {_delay_ms(200);}
break;
case '3':
Strings[j] = spell[i];
j++;
LCD_string(0xc0,Strings);
_delay_ms(1000);
break;
case '5':
for (int k = 0; k <26; k++) { //string 초기화
Strings[k] = ' ';
}
j=0;
LCD_string(0xc0,Strings);
break;
case '6':
chanel = 0;
break;
}//switch
}//while
}
void spelling(char arr){
char arr1 = arr+65;
switch(arr1){
case'A':
LCD_string(0x8f,"A");
break;
case'B':
LCD_string(0x8f,"B");
break;
case'C':
LCD_string(0x8f,"C");
break;
case'D':
LCD_string(0x8f,"D");
break;
case'E':
LCD_string(0x8f,"E");
break;
case'F':
LCD_string(0x8f,"F");
break;
case'G':
LCD_string(0x8f,"G");
break;
case'H':
LCD_string(0x8f,"H");
break;
case'I':
LCD_string(0x8f,"I");
break;
case'J':
LCD_string(0x8f,"J");
break;
case'K':
LCD_string(0x8f,"K");
break;
case'L':
LCD_string(0x8f,"L");
break;
case'M':
LCD_string(0x8f,"M");
break;
case'N':
LCD_string(0x8f,"N");
break;
case'O':
LCD_string(0x8f,"O");
break;
case'P':
LCD_string(0x8f,"P");
break;
case'Q':
LCD_string(0x8f,"Q");
break;
case'R':
LCD_string(0x8f,"R");
break;
case'S':
LCD_string(0x8f,"S");
break;
case'T':
LCD_string(0x8f,"T");
break;
case'U':
LCD_string(0x8f,"U");
break;
case'V':
LCD_string(0x8f,"V");
break;
case'W':
LCD_string(0x8f,"W");
break;
case'X':
LCD_string(0x8f,"X");
break;
case'Y':
LCD_string(0x8f,"Y");
break;
case'Z':
LCD_string(0x8f,"Z");
break;
}
}
void test(void){
char test = 'A';
switch(test){
case 'A':
LCD_string(0x8f,"A");
break;
}
}
void hook_key(key_tag *k){
if(k->tmr>0){
if (k->tmr < _debounce_ticks) k->tmr++;
else {
if ( (*(k->INPORT) & k->pin) != 0 ) {
k->key &= ~KEY_DN;
k->key |= EV_UP;
k->tmr = -1;
} else {
if (k->tmr < _long_hold_ticks){
k->tmr++;
if ( k->tmr == _long_hold_ticks)
k->key |= EV_LONGDN;
}
}
}
} else if( k->tmr < 0){
if(-k->tmr < _debounce_ticks) k->tmr--;
else {
if ( (*k->INPORT) & (k->pin) == 0) {
if (-k->tmr < _dc_gap_ticks)
k->key |= EV_DBCLICK;
k->key |= (KEY_DN | EV_DN);
k->tmr = 1;
} else {
if ( k->tmr < _dc_gap_ticks )
k->tmr--;
}
}
} else {
if( (*(k->INPORT) & k->pin) != 0){
k->key = 0;
k->tmr = -_dc_gap_ticks;
} else {
k->key = KEY_DN;
k->tmr = 1;
}
}
}
int8_t getEV(key_tag *k){
int8_t c;
cli();
c=k->key;
k->key &= KEY_DN;
sei();
return c;
}
void init_key(key_tag *k, volatile char *PORTE, int8_t pin_num, uint8_t term)
{
*((volatile char*) (PORTE-1)) &= ~_BV(pin_num);
k->INPORT = (volatile char *) (PORTE-2);
k->pin = _BV(pin_num);
if(term < MIN_TERM) term = MIN_TERM;
else if(term > MAX_TERM) term = MAX_TERM;
_debounce_ticks = (_DEBOUNCE / term);
_long_hold_ticks = (_LONG_HOLD / term);