PowerPoint 프레젠테이션

Similar documents
PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

Microsoft PowerPoint - lab14.pptx

PowerPoint 프레젠테이션

untitled

Microsoft PowerPoint - lab15.pptx

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

Microsoft PowerPoint - lab16.pptx

KEY 디바이스 드라이버

Microsoft PowerPoint - IOControl [호환 모드]

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074>

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202839C1D6C2F7207E203135C1D6C2F >

교육지원 IT시스템 선진화

슬라이드 1

6주차.key

ECE30076 Embedded System Programming - LED Device Driver

K&R2 Reference Manual 번역본

vi 사용법

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 -

프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어

Microsoft PowerPoint - chap13-입출력라이브러리.pptx

본 강의에 들어가기 전

제1장 Unix란 무엇인가?

[8051] 강의자료.PDF

Microsoft PowerPoint - es-arduino-lecture-03

Sena Technologies, Inc. HelloDevice Super 1.1.0

untitled

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202834C1D6C2F7207E2038C1D6C2F729>

IoT FND8 7-SEGMENT api

2009년 상반기 사업계획

PowerPoint 프레젠테이션

제12장 파일 입출력

PowerPoint 프레젠테이션

Microsoft Word doc

Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3

ActFax 4.31 Local Privilege Escalation Exploit

제1장 Unix란 무엇인가?

chap7.key

<4D F736F F F696E74202D FB8DEB8F0B8AE20B8C5C7CE205BC8A3C8AF20B8F0B5E55D>

MPLAB C18 C

0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x = (12 + 6) / 2 * 3; x = 27 x = 3 * (8 / 4

歯9장.PDF

Chapter #01 Subject

KEY01 PIN_J3 KEY02 PIN_M6 KEY03 PIN_M4 KEY04 PIN_M3 KEY05 PIN_M2 KEY06 PIN_M5 KEY07 PIN_L7 KEY08 PIN_H1 KEY09 PIN_J2 KEY10 PIN_J1 KEY11 PIN_L6 KEY12 P

PowerPoint 프레젠테이션

Microsoft Word - FS_ZigBee_Manual_V1.3.docx


Microsoft Word - MPC850 SPI Driver.doc

SRC PLUS 제어기 MANUAL

/chroot/lib/ /chroot/etc/

Microsoft Word ARM_ver2_0a.docx

13주-14주proc.PDF

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D>

중간고사

歯7장.PDF

chap7.PDF

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

Microsoft PowerPoint - [2009] 02.pptx

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx

MODBUS SERVO DRIVER( FDA7000 Series ) STANDARD PROTOCOL (Ver 1.00) 1

BMP 파일 처리

<4D F736F F F696E74202D20BBB7BBB7C7D15F FBEDFB0A3B1B3C0B05FC1A638C0CFC2F72E BC8A3C8AF20B8F0B5E55D>

int main(void) int a; int b; a=3; b=a+5; printf("a : %d \n", a); printf("b : %d \n", b); a b 3 a a+5 b &a(12ff60) &b(12ff54) 3 a 8 b printf(" a : %x \

10.

Microsoft PowerPoint - chap03-변수와데이터형.pptx


Microsoft PowerPoint - chap10-함수의활용.pptx

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf("hihi\n"); } warning: conflicting types for functiona


Microsoft PowerPoint APUE(File InO)

강의10

Chap 7

Chapter_06

<4D F736F F F696E74202D20C1A63132B0AD20B5BFC0FB20B8DEB8F0B8AEC7D2B4E7>

PowerPoint Presentation

교육지원 IT시스템 선진화

C 프로그래밊 개요

슬라이드 1

컴파일러

Microsoft PowerPoint - chap2

untitled

PowerPoint 프레젠테이션

고급 프로그래밍 설계


chap8.PDF

Microsoft PowerPoint - 09-Pipe

디바이스드라이버 (Device Driver) Driver is literally a subject which drive a object. 응용프로그램에서하드웨어장치를이용해서데이터를직접읽고쓰거나제어해야하는경우에디바이스드라이버를이용 하드웨어를제어하는프로그램과애플리케이션에서

2009년 상반기 사업계획

BY-FDP-4-70.hwp


Embeddedsystem(8).PDF

Microsoft PowerPoint APUE(File InO).pptx

ABC 11장

Microsoft PowerPoint APUE(File InO).ppt

Transcription:

7-Segment Device Control - Device driver Jo, Heeseung

HBE-SM5-S4210 의 M3 Module 에는 6 자리를가지는 7-Segment 모듈이아래그림처럼실장 6 Digit 7-Segment 2

6-Digit 7-Segment LED controller 16비트로구성된 2개의레지스터에의해제어 SEG_Sel_Reg(Segment Select Register) SEG_Data_Reg(Segment Data Register) 레지스터들은 Read와 Write 모두가능하도록설계 SEG_Sel_Reg 0~5bit 에 0 또는 1 을써넣음으로써 display 될 digit 를선택 SEG_Data_Reg 0~7bit 에 0 또는 1 을써넣음으로써 display 될 segment 들을선택 3

Segment Select Register 와 Segment Data Register 각비트에대응되는 6Digit 7-Segment 의핀배치도 SEL3 SEL4 SEL2 SEL1 SEL5 SEL6 SEG_F SEG_G SEG_E SEG_D SEG_A SEG_B SEG_C SEG_H 4

SEG_Sel_Reg 비트구조 Physical Address 0x0500_0030 SEG_Sel_Reg BIT 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Reserved SEL 6 SEL 5 SEL 4 SEL 3 SEL 2 SEL 1 Reset X X X X X X X X X X 0 0 0 0 0 0 Bits Name Description 0 SEL1 Digit 1 Select Bit0 (Active Low) 1 SEL2 Digit 1 Select Bit1 (Active Low) 2 SEL3 Digit 1 Select Bit2 (Active Low) 3 SEL4 Digit 1 Select Bit3 (Active Low) 4 SEL5 Digit 1 Select Bit4 (Active Low) 5 SEL6 Digit 1 Select Bit5 (Active Low) 5

SEL1 ~ SEL6 6-Digit 7-Segment LED 중 display될 digit를선택하는 bit 1을입력할경우선택해제 0을입력할경우선택 6

SEG_Data_Reg 비트구조 Physical Address 0x0500_0032 SEG_Data_Reg BIT 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Reserved SEG_ A SEG_ B SEG_ C SEG_ D SEG_ E SEG_ F SEG_ G SEG_ H Reset X X X X X X X X 0 0 0 0 0 0 0 0 Bits Name Description 0 SEG_A Segment Display Bit0 (Active High) 1 SEG_B Segment Display Bit1 (Active High) 2 SEG_C Segment Display Bit2 (Active High) 3 SEG_D Segment Display Bit3 (Active High) 4 SEG_E Segment Display Bit4 (Active High) 5 SEG_F Segment Display Bit5 (Active High) 6 SEG_G Segment Display Bit6 (Active High) 7 SEG_H Segment Display Bit7 (Active High) 7

SEG_A ~ SEG_G 6 Digit 7-Segment 중 display 될 digit 의 segment 들을선택하는 bit 0 을입력할경우선택해제 1 을입력할경우선택 8

6 개의 7-Segment Array 에 "123456" 의숫자를표시하기위한과정과각신호라인의펄스타이밍도 지속해서신호를주어야불이켜진것처럼보임 1 2 6 3 5 4 7 1 2 3 4 5 6 10

Device driver 소스파일 7-Segment 리눅스디바이스드라이버는커널에포함 menuconfig 실행 - Device Drivers -> [*] Misc devices -> [*] Hanback Electronics M3(FPGA) Device Support -> <*>7 Segment linux-2.6.35-s4210/drivers/misc/hanback/segment.c 참조 12

EL3 linux-2.6.35-s4210/drivers/misc/hanback/segment.c SEL4 EL2 EL1 unsigned short Getsegmentcode (short x) { unsigned short code; switch (x) { case 0x0 : code = 0xfc; break; case 0x1 : code = 0x60; break; case 0x2 : code = 0xda; break; case 0x3 : code = 0xf2; break; case 0x4 : code = 0x66; break; case 0x5 : code = 0xb6; break; case 0x6 : code = 0xbe; break; case 0x7 : code = 0xe4; break; case 0x8 : code = 0xfe; break; case 0x9 : code = 0xf6; break; SEL5 SEL6 SEG_F SEG_G SEG_E SEG_D SEG_A SEG_B SEG_C SEG_H case 0xa : code = 0xfa; break; case 0xb : code = 0x3e; break; case 0xc : code = 0x1a; break; case 0xd : code = 0x7a; break; case 0xe : code = 0x9e; break; case 0xf : code = 0x8e; break; default : code = 0; break; return code; 13

ssize_t segment_write(struct file *inode, const char *gdata, size_t length, loff_t *off_what) { unsigned char data[6]; unsigned char digit[6]={0x20, 0x10, 0x08, 0x04, 0x02, 0x01; unsigned int i,num,ret; unsigned int count=0,temp1,temp2; ret=copy_from_user(&num,gdata,4); count = num; if(num!=0) { data[5]=getsegmentcode(count/100000); temp1=count%100000; data[4]=getsegmentcode(temp1/10000); temp2=temp1%10000; data[3]=getsegmentcode(temp2/1000); temp1=temp2%1000; data[2]=getsegmentcode(temp1/100); temp2=temp1%100; data[1]=getsegmentcode(temp2/10); data[0]=getsegmentcode(temp2%10); 14

switch (mode_select) { case MODE_0_TIMER_FORM: break; case MODE_1_CLOCK_FORM: // dot print data[4] += 1; data[2] += 1; break; // print for(i=0;i<6;i++) { *segment_grid = digit[i]; *segment_data = data[i]; mdelay(1); *segment_grid = ~digit[0]; *segment_data = 0; return length; 15

seg_test.c 프로그램작성 #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <time.h> int main (int argc, char *argv[]) { int fd, value = 1, i, count, clock, ch; unsigned short input, dir = 0; if (argc <= 1) { printf ("please input the parameter! ex) %s 123456\n", argv[0]); return -1; 16

if ((fd = open ("/dev/segment", O_RDWR O_SYNC)) < 0) { printf ("FND open fail\n"); exit (1); count = atoi(argv[1]); for (i = 0; i < 400; i++) { write (fd, &count, 4); usleep (1000); close (fd); return 0; 17

Makefile 작성 CC = arm-linux-gcc CFLAGS = -DNO_DEBUG EXEC = seg_test OBJS = $(EXEC).o all: $(EXEC) $(EXEC): $(OBJS) $(CC) -o $@ $^ clean: rm -f $(OBJS) $(EXEC) 18

컴파일 make clean 하면먼저컴파일된실행예제파일삭제 make 명령어로컴파일실행 root@ubuntu:/working/device_driver/seg_driver# ls Makefile seg_test.c root@ubuntu:/working/device_driver/seg_driver# make clean; make ------------------다음과같은메시지가출력된다 ----------------- rm -f seg_test.o seg_test arm-linux-gcc -c -DNO_DEBUG -o seg_test.o seg_test.c arm-linux-gcc -o seg_test seg_test.o root@ubuntu:/working/device_driver/seg_driver# ls Makefile seg_test seg_test.c seg_test.o 테스트 board 에서실행 19

7-Segment Device Control - mmap() Jo, Heeseung

7-Segment 제어 7-Segment 원하는자리에원하는부분 ( 세그먼트 ) 를켜서데이터를출력 해당데이터에따라 7-Segment에숫자나영문자를표시 그리드선택번지 : 0x05000030 세그먼트선택번지 : 0x05000032 그리드선택번지의데이터형식 0x01 SEG1을선택 0x02 SEG2를선택 0x04 SEG3을선택 0x08 SEG4를선택 0x10 SEG5를선택 0x20 SEG6을선택 23

7-Segment 제어 EL3 EL2 EL1 다음으로세그먼트데이터형식 숫자 0 : 0xfc 숫자 1 : 0x60 숫자 2 : 0xda 숫자 3 : 0xf2 숫자 4 : 0x66 숫자 5 : 0xb6 숫자 6 : 0xbe 숫자 7 : 0xe4 숫자 8 : 0xfe 숫자 9 : 0xf6 영문 a : 0xfa 영문 b : 0x3e 영문 c : 0x1a 영문 d : 0x7a 영문 e : 0x9e 영문 f : 0x8e SEL4 SEL5 SEL6 SEG_F SEG_G SEG_E SEG_D SEG_A SEG_B SEG_C SEG_H 24

7-Segment 제어 segment.c 작성 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <sys/mman.h> #include <fcntl.h> unsigned short Getsegcode(short x); #define FPGA_BASEADDRESS #define SEG_GRID_OFFSET #define SEG_DATA_OFFSET 0x05000000 0x30 0x32 int main() { int fd; volatile int i,j; unsigned int count=1,num,temp1,temp2; unsigned short data[6]; unsigned short digit[6]={0x20, 0x10, 0x08, 0x04, 0x02, 0x01; unsigned short *addr_fpga; unsigned short *addr_grid, *addr_data; 25

7-Segment 제어 if((fd=open("/dev/mem",o_rdwr O_SYNC)) < 0) { printf("mem open fail\n"); exit(1); addr_fpga= (unsigned short *)mmap(null, 4096, PROT_READ PROT_WRITE, MAP_SHARED, fd, FPGA_BASEADDRESS); if(*addr_fpga == (unsigned short)-1) { close(fd); printf("mmap error\n"); exit(1); addr_grid=addr_fpga+seg_grid_offset; addr_data=addr_fpga+seg_data_offset; printf("- 7 Segment\n"); 26

7-Segment 제어 while(count!=0) { num=0; printf("input count value: [1-999999] (0 : exit program) \n"); scanf("%d", &count); while(num<=count ) { data[5]=getsegcode(num/100000); temp1=num%100000; data[4]=getsegcode(temp1/10000); temp2=temp1%10000; data[3]=getsegcode(temp2/1000); temp1=temp2%1000; data[2]=getsegcode(temp1/100); temp2=temp1%100; data[1]=getsegcode(temp2/10); data[0]=getsegcode(temp2%10); for(j=0;j<20;j++) { for(i=0;i<6;i++) { *addr_grid = digit[i]; *addr_data = data[i]; usleep(1000); num++; *addr_grid = ~digit[0]; *addr_data = 0; 28

7-Segment 제어 munmap(addr_fpga,4096); close(fd); return 0; unsigned short Getsegcode(short x) { unsigned short code; switch (x) { case 0x0 : code = 0xfc; break; case 0x1 : code = 0x60; break; case 0x2 : code = 0xda; break; case 0x3 : code = 0xf2; break; case 0x4 : code = 0x66; break; case 0x5 : code = 0xb6; break; case 0x6 : code = 0xbe; break; case 0x7 : code = 0xe4; break; case 0x8 : code = 0xfe; break; case 0x9 : code = 0xf6; break; case 0xa : code = 0xfa; break; case 0xb : code = 0x3e; break; case 0xc : code = 0x1a; break; case 0xd : code = 0x7a; break; case 0xe : code = 0x9e; break; case 0xf : code = 0x8e; break; default : code = 0; break; return code; 29

7-Segment 제어 Makefile 작성 CC = arm-linux-gcc CFLAGS = -DNO_DEBUG EXEC = segment OBJS = $(EXEC).o all: $(EXEC) $(EXEC): $(OBJS) $(CC) -o $@ $^ clean: rm -f $(OBJS) $(EXEC) 30

7-Segment 제어 컴파일 make clean 하면먼저컴파일된실행예제파일삭제 make 명령어로컴파일실행 root@ubuntu:/working/mmap/segment# make arm-linux-gcc -c -DNO_DEBUG -o segment.o segment.c arm-linux-gcc -o segment segment.o root@ubuntu:/working/mmap/segment# ls Makefile segment segment.c segment.o 테스트 board 에서실행 31