#12005: stdio.h:456:1: error: 'gets' undeclared here (not in a function)
-----------------------------------+----------------------------------
Reporter: danitool <dgcbueu@…> | Owner: developers
Type: defect | Status: closed
Priority: high | Milestone: Chaos Calmer (trunk)
Component: base system | Version: Trunk
Resolution: fixed | Keywords: bison m4 stdio.h
-----------------------------------+----------------------------------
Comment (by anonymous):
//===================
// 사용 CPU : ATMega 128-32M
//--------------------
// 기본헤더
#define __STDIO_FDEVOPEN_COMPAT_12
// 기본헤더
// ======AVR includes======
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
//#include <float.h>
//#include <math.h>
#include "avr/io.h"
#include "avr/interrupt.h"
#include "util/delay.h"
//Global variables
//====================
//USART 통신 관련 선언
#define RXB8 1
#define TXB8 0
#define UPE 2
#define OVR 3
#define FE 4
#define UDRE 5
#define RXC 7
#define FRAMING_ERROR (1<<FE)
#define PARITY_ERROR (1<<UPE)
#define DATA_OVERRUN (1<<OVR)
#define DATA_REGISTER_EMPTY (1<<UDRE)
#define RX_COMPLETE (1<<RXC)
// 변수 선언
char com1_rx_data,com1_rx_eflg1 = 0;
char com1_rx_eflg2, com1_rx_eflg3, com1_rx_eflg4 = 0; // COM1 통신
수신 인터럽트 관련 데이터/플레그
char com2_rx_data,com2_rx_eflg = 0;
char com1_tx_data = 0;
char com1_tx_eflg = 0; // COM2 통신 수신 인터럽트 관련 데이터/플레
그
char c1[30] = {"time "};
char c2[30] = {"q.10s"};
char c3[30] = {"w.07s"};
char c4[30] = {"e.05s"};
char c5[30] = {"r.03s"};
//--------------------------
// 함수 선언
//==========================
//MCU 초기화 function
void cpu_init(void);
//----------------------------
//===================
//USART setup function
void usart01_setup(void);
//---------------------
//====================
//external memory setup function
void Ext_memory_setup(void);
//------------------------
// ex_11_TimerCounter2_polling_modes.c
//========================
// 메모
// Timer/Counter2 setup function
void TimerCounter_02_setup(void);
void TimerCounter_00_setup(void);
void display_lenth(char val[l]);
void display(char val);
void display_enter(void);
//---------------------------
int timercount2_mode;
void display_wUSART(void);
void putchar1(char c);
void urx_string(char buff[]);
long atoh(char buff[]);
int time=0;
int count=0;
int lenth=0;
char data;
char status;
//==========메인 프로그램============
//[인수]:void
//---------------------------------
int main(void)
{
unsigned char *Ext_mem_addr;
cpu_init();
usart01_setup();
TimerCounter_02_setup();
TimerCounter_00_setup();
display_lenth(c1);
display_enter();
display_lenth(c2);
display_enter();
display_lenth(c3);
display_enter();
display_lenth(c4);
display_enter();
display_lenth(c5);
display_enter();
while(1)
{
if((status&0x80)==0x80)
{
if(com1_rx_data == 0x71) // q입력 확인.
{
time= time+1250; // 10초 충전.
com1_rx_data = 0x00;
}
else if(com1_rx_data == 0x77) // w입력 확인.
{
time= time+875;
com1_rx_data = 0x00;
}
else if(com1_rx_data == 0x65) // e입력 확인.
{
time= time+625;
com1_rx_data = 0x00;
}
else if(com1_rx_data == 0x72) // r입력 확인.
{
time= time+375;
com1_rx_data = 0x00;
}
}
else if(time == 0)
{
char c6[20] = {"DONE Light off"};
display_lenth(c6);
display_enter();
//문자열(DONE light off)출력.
}
else if(time == 2500)
{
char c7[20] = {"20 light on"};
display_lenth(c7);
display_enter();
//문자열(20/light on)출력.
}
else if(time == 2375)
{
char c8[20] = {"19 light on"};
display_lenth(c8);
display_enter();
//문자열(19/light on)출력.
}
else if(time == 2250)
{
char c9[20] = {"18 light on"};
display_lenth(c9);
display_enter();
//문자열(18/light on)출력.
}
else if(time == 2125)
{
char c10[20] = {"17 light on"};
display_lenth(c10);
display_enter();
//문자열(17/light on)출력.
}
else if(time == 2000)
{
char c11[20] = {"16 light on"};
display_lenth(c11);
display_enter();
//문자열(16/light on)출력.
}
else if(time == 1875)
{
char c12[20] = {"15 light on"};
display_lenth(c12);
display_enter();
//문자열(15/light on)출력.
}
else if(time == 1750)
{
char c13[20] = {"14 light on"};
display_lenth(c13);
display_enter();
//문자열(14/light on)출력.
}
else if(time == 1625)
{
char c14[20] = {"13 light on"};
display_lenth(c14);
display_enter();
//문자열(13/light on)출력.
}
else if(time == 1500)
{
char c15[20] = {"12 light on"};
display_lenth(c15);
display_enter();
//문자열(12/light on)출력.
}
else if(time == 1375)
{
char c16[20] = {"11 light on"};
display_lenth(c16);
display_enter();
//문자열(11/light on)출력.
}
else if(time == 1250)
{
char c17[20] = {"10 light on"};
display_lenth(c17);
display_enter();
//문자열(10/light on)출력.
}
else if(time == 1125)
{
char c18[20] = {"9 light on"};
display_lenth(c18);
display_enter();
//문자열(9/light on)출력.
}
else if(time== 1000)
{
char c19[20] = {"8 light on"};
display_lenth(c19);
display_enter();
//문자열(8/light on)출력.
}
else if(time== 875)
{
char c20[20] = {"7 light on"};
display_lenth(c20);
display_enter();
//문자열(7/light on)출력.
}
else if(time== 750)
{
char c21[20] = {"6 light on"};
display_lenth(c21);
display_enter();
//문자열(6/light on)출력.
}
else if(time == 625)
{
char c22[20] = {"5 light on"};
display_lenth(c22);
display_enter();
//문자열(5/light on)출력.
}
else if(time == 500)
{
char c23[20] = {"4 light on"};
display_lenth(c23);
display_enter();
//문자열(4/light on)출력.
}
else if(time== 375)
{
char c24[20] = {"3 light on"};
display_lenth(c24);
display_enter();
//문자열(3/light on)출력.
}
else if(time== 250)
{
char c25[20] = {"2 light on"};
display_lenth(c25);
display_enter();
//문자열(2/light on)출력.
}
else if(time == 125)
{
char c26[20] = {"1 light on"};
display_lenth(c26);
display_enter();
//문자열(1/light on)출력.
}
}
return 0;
}
//====cpu 초기화=====
//[인수] void
//----------------------
void cpu_init(void)
{
// ==============
// 모든 interrupt 신호는 발생하지 않도록 조치한다.
// 이유 : 원하지 않는 interrupt에 대한 처리 routine이 없을 경우 MCU가
이상 동작을 할 수 있다.
// 아래 코드는 그대로 사용하도록 함.
// External (외부) interrupt 0~7 발생하지 않도록 (disable) (datasheet
P. 90~92)
EICRA=0x00;
//EICRB=0x00;
EIMSK=0x00;
// EEPROM의 interrupt 발생하지 않도록 (disable) (datasheet P.22)
EECR = 0x00;
// Timer(s)/Counter(s) interrupt(s) 발생하지 않도록 disable
TIMSK=0x00;
//ETIMSK=0x00;
//USART 0,1 interrupt disable (datasheet P.190)
UCSR0B=0x00;
//UCSR1B=0x00;
//SPI interrupt disable (datasheet P.167)
SPCR = 0x00;
//TWI interrupt disable (datasheet P.206)
TWCR = 0x00;
//Analog-to-Digital converter interrupt disable (datasheet P.244)
ADCSRA = 0x00;
//Analog comparator interrupt disable datasheet P.227)
ACSR = 0x00;
// ==============
// Global interrupts enable : sei 함수가 실행되어야 각 block의
interrupt를 enable/disable 할 수 잇음
// sei 함수는 interrupt.h.에 선언되어 있음
sei();
// --------------
// ==============
// 범용 digital 1/0 pin 기본 설정: 기본적으로 입력으로 설정하고, pull-
up 저항을 사용하지
// PortA 설정
PORTA=0x00; // 포트 출력 reg
DDRA=0x00; // 포트 방향 reg(0입력, 1출력)
// PortB 설정
PORTB=0x00; // 포트 출력 reg
DDRB=0x00; // 포트 출력 reg(0입력, 1출력)
// PortC 설정
PORTC=0x00; // 포트 출력 reg
DDRC=0x00; // 포트 방향 reg(0입력, 1출력)
// PortD 설정
PORTD=0x00; // 포트 출력 reg
DDRD=0x00; // 포트 출력 reg(0입력, 1출력)
// PortE 설정
PORTE=0x00; // 포트 출력 reg
DDRE=0x00; // 포트 출력 reg(0입력, 1출력)
// PortF 설정
PORTF=0x00; // 포트 출력 reg
DDRF=0x00; // 포트 방향 reg(0입력, 1출력)
// PortG 설정
PORTG=0x00; // 포트 출력 reg
DDRG=0x00; // 포트 출력 reg(0입력, 1출력)
PORTG=0xFF; // 포트 출력 reg
DDRG=0xFF; // 포트 출력 reg(0입력, 1출력)
// ---------------
}
void usart01_setup(void)
{
// ===================
// USART port 통신 초기화
// USART0 : 19200Bps, 8Data, 1 Stop, No Parity
// 속도 및 option은 변경 가능함.
UCSR0A=0x00;
UCSR0B=0x98;
UCSR0C=0x06;
UBRR0H=0x00;
UBRR0L=0x33;
// USART0 : 19200Bps, 8 Data, 1Stop, No Parity
// 속도 및 OPTION은 변경 가능함.
UCSR1A=0x00;
UCSR1B=0x18;
UCSR1C=0x06;
UBRR1H=0x00;
UBRR1L=0x33;
//-----------------
}
SIGNAL(SIG_UART0_RECV)
{
status = UCSR0A;
data = UDR0;
if((status & (FRAMING_ERROR | PARITY_ERROR | DATA_OVERRUN))==0) //오
류 검출
{
com1_rx_data = data;
if(data == 0x71) //q 입력 확인.
{
com1_rx_eflg1 = 1;
}
if(data == 0x77) //w 입력 확인.
{
com1_rx_eflg2 = 1;
}
if(data == 0x65) //e 입력 확인.
{
com1_rx_eflg3 = 1;
}
if(data == 0x72) //r 입력 확인.
{
com1_rx_eflg4 = 1;
}
else
{
com1_rx_eflg1 = 0;
com1_rx_eflg2 = 0;
com1_rx_eflg3 = 0;
com1_rx_eflg4 = 0;
}
}
}
SIGNAL(SIG_UART0_DATA)
{
UDR0 = com1_tx_data; // 데이터를 보낸다.
UCSR0B=0x98;
}
SIGNAL(SIG_OUTPUT_COMPARE2)
{
time = time - 1;
}
SIGNAL(SIG_OUTPUT_COMPARE0)
{
count++;
}
void Ext_memory_setup(void)
{
MCUCR = 0x80;
XMCRA = 0x00;
XMCRB = 0x00;
}
void TimerCounter_02_setup(void)
{
TCCR2 = 0x00;
TIMSK = 0x82;
OCR2 = 0x80;
}
void TimerCounter_00_setup(void)
{
TCCR0 = 0x00;
OCR0 = 0x80;
}
void display(char val)
{
_delay_ms(50);
char data;
data=val;
com1_tx_data = data; // 전송 데이터
UCSR0B=0xB8;
}
void display_lenth(char val[l])
{
l = strlen(val);
for(int i=0; i<l-1; i++)
{
display(val[i]);
_delay_ms(30);
}
}
void display_enter(void)
{
display('\n');
display('\r');
}
--
Ticket URL: <https://dev.openwrt.org/ticket/12005#comment:3>
OpenWrt <http://openwrt.org>
Opensource Wireless Router Technology
_______________________________________________
openwrt-tickets mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-tickets