untitled

Similar documents
Microsoft PowerPoint - lab14.pptx

KEY 디바이스 드라이버

PowerPoint 프레젠테이션

교육지원 IT시스템 선진화

Microsoft PowerPoint - lab15.pptx

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

untitled

PowerPoint 프레젠테이션

슬라이드 1

PowerPoint 프레젠테이션

Embeddedsystem(8).PDF

Chap 7

PowerPoint 프레젠테이션

Chapter #01 Subject

PowerPoint 프레젠테이션

슬라이드 1

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

6주차.key

04디바이스드라이버

ECE30076 Embedded System Programming - LED Device Driver

K&R2 Reference Manual 번역본

Microsoft Word doc

교육지원 IT시스템 선진화

(Microsoft PowerPoint - Device Driver [\310\243\310\257 \270\360\265\345])

PowerPoint 프레젠테이션

(Microsoft PowerPoint - Device Driver [\310\243\310\257 \270\360\265\345])

본 강의에 들어가기 전

Adding a New Dev file

망고100 보드로 놀아보자 -13

/chroot/lib/ /chroot/etc/

chap7.key

vi 사용법

RaspberryPi 커널컴파일및커널모듈 1 제 13 강 커널컴파일및커널모듈 커널컴파일가상주소 (mmap() 함수 ) 에의한디바이스제어커널모듈및커널모듈테스트커널모듈에의한입출력디바이스제어 (LED, BTN) 커널모듈을커널에포함하기

PowerPoint 프레젠테이션

제1장 Unix란 무엇인가?

제12장 파일 입출력

Microsoft Word - MPC850 SPI Driver.doc

06Àå


untitled

제1장 Unix란 무엇인가?

<4D F736F F F696E74202D205BBAB0C3B75D20B8AEB4AABDBA20B5F0B9D9C0CCBDBA20B5E5B6F3C0CCB9F620B8F0B5A82E >

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 \

03장.스택.key

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

13주-14주proc.PDF

歯9장.PDF

<C0CCBCBCBFB52DC1A4B4EBBFF82DBCAEBBE7B3EDB9AE2D D382E687770>

Linux 의대표적인방화벽모듈로는 iptables 가있다. 2. Netfilter Netfilter 는표준 Berkeley socket interface 의외부에존재하는 packet mangling 에대한 framework 로, 크게네부분으로구성된다. 먼저각각의프로토콜

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

°ø°³¼ÒÇÁÆ®-8È£

10.

Microsoft Word doc

chap10.PDF

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

C++-¿Ïº®Çؼ³10Àå

Microsoft Word - KPMC-400,401 SW 사용 설명서

11장 포인터

untitled

MPLAB C18 C

PowerPoint 프레젠테이션

Microsoft PowerPoint APUE(File InO)

1장. 유닉스 시스템 프로그래밍 개요


1217 WebTrafMon II

chap8.PDF

이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다. 2

MAX+plus II Getting Started - 무작정따라하기

Microsoft PowerPoint - IOControl [호환 모드]


Sena Technologies, Inc. HelloDevice Super 1.1.0

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D>

Microsoft PowerPoint APUE(File InO).ppt

¼ÒÇÁÆ®-12È£-ÃÖÁ¾¿Ï¼º

Microsoft PowerPoint - polling.pptx

, ( ),, ( ), 3, int kor[5]; int eng[5]; int Microsoft Windows 4 (ANSI C2 ) int kor[5] 20 # define #define SIZE 20 int a[10]; char c[10]; float

Chapter 4. LISTS

Microsoft PowerPoint - ch09_파이프 [호환 모드]

2009년 상반기 사업계획

Chap 6 모듈프로그래밍및 디바이스드라이버구현

ABC 11장

untitled

Microsoft PowerPoint APUE(File InO).pptx

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

Microsoft PowerPoint - chap2

5.스택(강의자료).key

untitled

리눅스커널-06

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

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

Motor

2. GCC Assembler와 AVR Assembler의차이 A. GCC Assembler 를사용하는경우 i. Assembly Language Program은.S Extension 을갖는다. ii. C Language Program은.c Extension 을갖는다.

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

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070>

중간고사

PowerPoint 프레젠테이션

untitled

Transcription:

Step Motor Device Driver Embedded System Lab. II

Step Motor Step Motor Step Motor source Embedded System Lab. II 2

open loop, : : Pulse, 1 Pulse,, -, 1 +5%, step Step Motor (2),, Embedded System Lab. II 3

Step Motor Step Motor (1), 2~6 Embedded System Lab. II 4

STEP MOTOR Step Motor,,, Embedded System Lab. II 5

PXA255-Pro Step Motor Embedded System Lab. II 6

Step Motor Data bit 8bit PXA255 FPGA 1 Bit 7 6 5 4 3 2 1 Step Motor nb B na step2 A nb B na step1 A Embedded System Lab. II 7

Half Step Operation 1-2-1-2 1/2, Sequence A na Input B nb Output 1 1(H) (L) (L) (L) A 2 1 B 3 1 na 4 1 nb Embedded System Lab. II 8

(2) Full Step Operation 4 2. (Torque) 1Cm 1m () (1) 1Cm 1m ( : gfcm Kgfcm ) Sequence A na Input B nb Output 1 1(H) (L) 1(H) (L) AB 2 1 1 nab 3 1 1 nanb 4 1 1 AnB Embedded System Lab. II 9

Device driver source code #include <linux/module.h> #include <asm/hardware.h> #include <asm/uaccess.h> #include <linux/kernel.h> #include <linux/fs.h> #include <linux/errno.h> #include <linux/types.h> #include <asm/ioctl.h> #include <linux/ioport.h> #include <linux/delay.h> #include <asm/io.h> #include <linux/init.h> #include <linux/version.h> // ex)mod_inc_usr_count //copy_from_user() //udelay() //GPIO controller //init_module() cleanup_module() #define IOM_STEP_MAJOR 247 //define major number #define IOM_STEP_NAME "STEP" //define device name #define IOM_STEP_ADDRESS xcc Embedded System Lab. II 1

Device driver source code (2) #define A #define AB #define B #define _AB #define _A #define _A_B #define _B #define A_B (unsigned short)(x1) (unsigned short)(x5) (unsigned short)(x4) (unsigned short)(x6) (unsigned short)(x2) (unsigned short)(xa) (unsigned short)(x8) (unsigned short)(x9) #define iom_step_init init_module int iom_step_open(struct inode *, struct file *); int iom_step_release(struct inode *, struct file *); ssize_t iom_step_write(struct file *, const char *, size_t, loff_t *); int init iom_step_init(void); void cleanup_module(void); Embedded System Lab. II 11

Device driver source code (3) //Global variable static int step_usage = ; static int step_major = ; static char mode; static int check = ; static unsigned short *iom_step_addr; //file operation structure static struct file_operations iom_step_fops = { open: iom_step_open, write: iom_step_write, release: iom_step_release, }; Embedded System Lab. II 12

Device driver source code (4) into iom_step_open(struct inode *minode, struct file *mfile) { if(step_usage!= ) return -EBUSY; } MOD_INC_USE_COUNT; step_usage = 1; check = ; return ; int iom_step_release(struct inode *minode, struct file *mfile) { MOD_DEC_USE_COUNT; step_usage = ; outw(,iom_step_addr); return ; } Embedded System Lab. II 13

Device driver source code (5) size iom_step_write(struct file *inode, const char *gdata, size_t length, loff_t *off_what) { if(check == ) {// check const char *temp = gdata; copy_from_user(&mode, temp, 1); check = 1; } else if(check ==1) {// Step Motor const char *tmp = gdata; unsigned short speed; #if copy_from_user(&speed, tmp, 2); //Full Step Operation outw(ab,iom_step_addr); udelay(speed); Embedded System Lab. II 14

Device driver source code (6) #else outw(_ab,iom_step_addr); udelay(speed); outw(_a_b,iom_step_addr); udelay(speed); outw(a_b,iom_step_addr); udelay(speed); //Half Step Operation if(mode == 'a'){// outw(a,iom_step_addr); udelay(speed); outw(b,iom_step_addr); udelay(speed); outw(_a,iom_step_addr); udelay(speed); outw(_b,iom_step_addr); udelay(speed); } Embedded System Lab. II 15

Device driver source code (7) else if(mode == 'b'){// outw(_b,iom_step_addr); udelay(speed); outw(_a,iom_step_addr); udelay(speed); outw(b,iom_step_addr); udelay(speed); outw(a,iom_step_addr); udelay(speed); } #endif } return length; } Embedded System Lab. II 16

Device driver source code (8) into init iom_step_init(void) { int result; result = register_chrdev(iom_step_major,iom_step_name,&iom_step_fops); if(result < ) { printk(kern_warning"can't get any major\n"); return result; } step_major = IOM_STEP_MAJOR; iom_step_addr = ioremap(iom_step_address,x2); printk("init module, %s major number : %d\n",iom_step_name,step_major); return ; } void cleanup_module(void) { iounmap(iom_step_addr); if(unregister_chrdev(step_major,iom_step_name)) printk(kern_warning"%s DRIVER CLEANUP FALLED\n",IOM_STEP_NAME); } Embedded System Lab. II 17

Application source code #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/ioctl.h> #include <signal.h> static char mode; into main(void) { int fd; unsigned short c = xffff; printf("a. spin\n");//menu printf("b. back spin\n"); printf("select->"); scanf("%c", &mode); printf("\n"); Embedded System Lab. II 18

Application source code (2) } while(1){ fd = open("/dev/step",o_wronly);//divice open if (fd < ){ printf("device Open Error\n"); exit(1);} write(fd, &mode, 1);//write mode for(;;){ if(c < x1){ c = x1;// } else c -=x1;//increase speed write(fd,&c,2);//write speed } close(fd); } Embedded System Lab. II 19

Makefile INCLUDEDIR := /home/max233/linux-2.4.19-cd/include CFLAGS := -D KERNEL -I$(INCLUDEDIR) -Wall -O2 -DMODULE CROSS_COMPILE := arm-linux- CC=$(CROSS_COMPILE)gcc LD=$(CROSS_COMPILE)ld all: step_driver test_step step_driver: $(CC) $(CFLAGS) -c step_driver.c -o step_driver.o test_step: $(CC) -I$(INCLUDEDIR) -o test_step test_step.c clean: rm -f *.o rm -f test_step Embedded System Lab. II 2

Driver Step Motor Device Driver device driver file interface (node ) Device driver major number : int register_chrdev(unsigned int major, const char *name, struct file_operations *fops) Major : major number. Name : device Fops : device file : int unregister_chrdev(unsigned int major, const char *name) Embedded System Lab. II 21

Driver (2) kernel user program open close read write system call device driver file operations device_open device_close device_read device_write device Embedded System Lab. II 22

Driver (3) Major number minor number Major number : Minor number : major number register_chrdev() major number major number Major minor inode i_rdev 16bit. 8bit major, 8bit minor. Embedded System Lab. II 23

Driver (4) mknod mknod [device file name] [type] [major] [minor] Ex] %mknod /dev/step c 247 mdev_t : major, minor number MAJOR() : kdev_t major number Ex] MAJOR(inode->i_rdev); MINOR() : kdev_t minor number cat /proc/devices Embedded System Lab. II 24

Driver (5) insmod module (install) rmmod modules (unload) lsmod Load module depmod modprobe Module symbol Makefile dependency file depmod dependency module module load modinfo Embedded System Lab. II 25

Driver (6) Device Driver Embedded System Lab. II 26

Driver (7) step_driver.c, test application test_step.c, makefile Makefile make 2 files % make step_driver.o test_step target. minicom nfs. nfs Embedded System Lab. II 27

Driver (8) Step Motor Embedded System Lab. II 28