Professional Documents
Culture Documents
c
//#include "def_common.h"
//#include "naame.h"
/*
void main() //p14~15 중간 , main.c 와 cpu.c 를 주고 헤더파일을 만들어봐라 약 10 개
//(굵은글씨로 표현, 대문자) ex) #deine TRUE 1, 함수 void cpu_init( );
이런식으로 #define 4 개, 함수 2 개 #include <stdio.h> 이거 첫줄에 써야 프린트에프 가능
//
{
int cnt_num = 0;
while (TRUE)
{
cpu_init();
cpu_run();
cnt_num++;
printf("%d 회 수행완료 \n\n", cnt_num);
Sleep(1000);
}
}
*/
/*void main()
{
printf("이름: %s \n", NAME);
printf("나이: %d \n", AGE);
printf("직업 : %s \n", JOB);
}
*/
/*
#define _CPU_20M //p16 이것도 중간 나올 수 있음 p17 은 안나옴
#include <stdio.h>
#include "def_common.h"
void main()
{
printf("시스템 클락 주파수 = %d MHz \n", _CPU_CLK);
printf("타이머 설정치 = %d \n", timer_value);
}
*/
/*
#include "def_common.h" //p17
void main()
{
printf("P_Gain = %d \n", P_Gain); //20
printf("I_Gain = %d \n", I_Gain); //8
printf("D_Gain = %d \n", D_Gain); //5
}
*/
/*
void main() //얜 뭐지;;
{
int cnt_num = 0;
while (TRUE)
{
cpu_init();
cpu_run();
cnt_num++;
printf("%d 회 수행완로 \n", cnt_num);
Sleep(1000);
}
}
*/
void main()
{
init();
init();
}
void init()
{
static int x; //static : 변수를 0 으로 초기화 , 값 유지
// 초기화 안하면 오류,
x = x + 1;
printf("x 값은 %d \n", x);
}
//def_common.h
#include <stdio.h>
#include <windows.h>
#define TRUE 1
#define NUM 5
void cpu_init();
void cpu_run();
#ifdef _CPU_20M
#define _CPU_CLK 20
#define timer_value 100
#else
#define _CPU_CLK 16
#define timer_value 125
#endif
#ifndef _CONST_H
#define _CONST_H
#define P_Gain 20
#define I_Gain 8
#define D_Gain 5
#endif
//cpu.c
#include <stdio.h>
#include "def_common.h"
void cpu_init()
{
printf("초기화 내용 \n");
}
void cpu_run()
{
int i;
for (i = 1;i<=NUM;i++)
printf("작업 수행중 \n");
}