CS4101 嵌入式系統概論 Device Drivers

Slides:



Advertisements
Similar presentations
CT213 – Computing system Organization
Advertisements

Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
LAB 9: Environment Setup for Tower System Chung-Ta King National Tsing Hua University CS 4101 Introduction to Embedded Systems.
CS4101 嵌入式系統概論 Program Organization Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan ( Materials from MSP430 Microcontroller.
CS4101 嵌入式系統概論 Design and Development 金仲達教授 國立清華大學資訊工程學系 Slides from Computers as Components: Principles of Embedded Computing System Design, Wayne Wolf,
1 Homework Reading –Review previous material on “interrupts” Machine Projects –MP4 Due today –Starting on MP5 (Due at start of Class 28) Labs –Continue.
Operating Systems Review. User Computer, including HW and SW.
Guide To UNIX Using Linux Third Edition
Operating System Organization
MSP432™ MCUs Training Part 9: Porting between MSP430 and MSP432
CS4101 嵌入式系統概論 RTOS and MQX Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan ( Materials from Freescale; Prof.
CS4101 嵌入式系統概論 Freescale Tower System Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan ( Materials from
TM Freescale, the Freescale logo, AltiVec, C-5, CodeTest, CodeWarrior, ColdFire, C-Ware, mobileGT, PowerQUICC, StarCore, and Symphony are trademarks of.
Part 1 Using the ARM board And start working with C Tutorial 5 and 6
Outline Introduction to MQX Initializing and starting MQX
LAB 11: Task Synchronization Chung-Ta King National Tsing Hua University CS 4101 Introduction to Embedded Systems.
Real-time Systems Lab, Computer Science and Engineering, ASU Linux Input Systems (ESP – Fall 2014) Computer Science & Engineering Department Arizona State.
COMP 3438 – Part I - Lecture 4 Introduction to Device Drivers Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
OS provide a user-friendly environment and manage resources of the computer system. Operating systems manage: –Processes –Memory –Storage –I/O subsystem.
1 Operating System Overview. 2 Today’s Objectives Explain the main purpose of operating systems and describe milestones of OS evolution Explain fundamental.
Computing Fundamenatls CMSC 201 Computer Science I Penny Rheingans University of Maryland Baltimore County (with inspiration from previous 201 instructors.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. C How To Program - 4th edition Deitels Class 05 University.
Chapter 13 Programming in the Large Dr. Jiung-yao Huang Dept. Comm. Eng. Nat. Chung Cheng Univ. TA: 鄭筱親 陳昱豪.
LAB 12: Timer and Interrupt Chung-Ta King National Tsing Hua University CS 4101 Introduction to Embedded Systems.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 5 - Functions Outline 5.1Introduction 5.2Program.
LAB 13: IO Driver Chung-Ta King National Tsing Hua University CS 4101 Introduction to Embedded Systems.
SOC Consortium Course Material Standard IO National Taiwan University Adopted from National Taiwan University SoC Design Laboratory.
Lab 12 Department of Computer Science and Information Engineering National Taiwan University Lab12 – Driver 2014/12/16 1 /21.
Implementation of Embedded OS Lab3 Porting μC/OS-II.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the basic properties and characteristics of external files ❏ To.
File System Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki CS 314.
Chapter 4. CONCEPT OF THE OPERATING SYSTEM MANAGING ESSENTIAL FILE OPERATIONS.
Some Network Commands n Some useful network commands –ping –finger –nslookup –tracert –ipconfig.
Introduction In this lab , we will learn
MQX GPIO.
Homework Reading Machine Projects
Operating System Overview
Outline Installing Gem5 SPEC2006 for Gem5 Configuring Gem5.
Outline Introduction to NuMaker TRIO Programming environment setup
Introduction In this lab , we will learn
Introduction to comp. and prog. CS 101 G 964
Outline Introduction to task synchronization MQX events MQX mutexs
Operating & Configuring a Cisco IOS Device
CS4101 Introduction to Embedded Systems Lab 8: Tower System
Chapter 7 Text Input/Output Objectives
Chapter 7 Text Input/Output Objectives
Cypress CY3663 Development Kit
CS4101 Introduction to Embedded Systems Lab 1: General Purpose IO
CS4101 Introduction to Embedded Systems Lab 13: Task Synchronization
Chapter 7 Text Input/Output Objectives
CS4101 Introduction to Embedded Systems Lab 9: NuMaker ADC and LCD
Homework Reading Machine Projects Labs
CS4101 Introduction to Embedded Systems Design and Implementation
Deitel- C:How to Program (5ed)
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 2: Timer and Clock Prof. Chung-Ta King Department of Computer Science National.
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 3: Interrupt Prof. Chung-Ta King Department of Computer Science National Tsing.
Larger Projects, Object Files, Prototyping, Header Files, Make Files
Chapter 3: Windows7 Part 4.
Future Designs, Inc. Your Development Partner
Chapter 5 - Functions Outline 5.1 Introduction
Functions Declarations CSCI 230
NetSilicon & Digi Confidential
CS4101 嵌入式系統概論 I/O Drivers Prof. Chung-Ta King
Rapid Prototyping Solutions
CS703 - Advanced Operating Systems
CS4101 嵌入式系統概論 RTOS Prof. Chung-Ta King Department of Computer Science
Operating Systems Tasks 17/02/2019.
CS4101 Introduction to Embedded Systems Lab 2: Basic IO and Timer
Outline Operating System Organization Operating System Examples
ECE 3567 Microcontrollers Lab
Presentation transcript:

CS4101 嵌入式系統概論 Device Drivers Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan (Materials from How to Develop I/O Drivers for MQX, Freescale MQX I/O Drivers Users Guide)

Outline Basics of MQX device drivers Null driver

MQX Drivers What is a device driver? A software layer that interacts with and handle the HW Dynamically installed software packages that provide a direct interface to hardware MQX provides several device drivers that can be use by applications: I2C, UART, SPI, RTC, Flash, GPIO, … These drivers are included on the Board Support Package (BSP) BSP is a software layer with all the initialization code, drivers, configuration needed to bring up a MCU/MPU

MQX I/O Subsystem Uniform method to communicate with I/O device drivers Hide specific driver functions

I/O Subsystem API POSIX standard I/O

MQX Driver API MQX device drive is installed by: Device names _io_device_install() The installation function calls _io_dev_install() to register the device with MQX To install a new device driver, the init_bsp.c needs to be modified and the BSP rebuilt Device names Device name must end with ‘:’, e.g., _io_mfs_install("mfs1:" ...) Characters following ‘:’ are information passed to device driver by fopen() call, e.g., fopen("mfs1:bob.txt")

MQX Driver API MQX device drive should contain following services: _io_device_open(): required create a communication channel to the driver _io_device_close(): required shut down the driver _io_device_read(): optional _io_device_write(): optional _io_device_ioctl(): optional ask specific functionality to the driver Note that “device” should be replaced with the name of the device family such as: _io_null_xxx(), _io_ttya_xxx()

Common I/O Control Commands

Outline Basics of MQX device drivers Null driver

Null Driver #include "mqx.h" // Structures & constants used by MQX #include "fio.h" // standard formatted I/O library #include "io.h" // I/O subsystem interface #include "my_null_io.h" // header for this driver /* function prototyping _mqx_int _io_my_null_open(FILE_PTR, char_ptr, char_ptr); _mqx_int _io_my_null_close(FILE_PTR); _mqx_int _io_my_null_read (FILE_PTR, char_ptr, _mqx_int); _mqx_int _io_my_null_write(FILE_PTR, _mqx_int _io_my_null_ioctl(FILE_PTR, _mqx_uint, pointer); 9 9 9

Null Driver _mqx_uint _io_my_null_install(char_ptr identifier) { /* “idetifier” identifies the device for fopen */ _mqx_uint result; result = _io_dev_install(identifier, _io_my_null_open, _io_my_null_close, _io_my_null_read, _io_my_null_write, _io_my_null_ioctl, NULL); return result; } /* This function is called from fopen() to prepare driver for subsequent read, write, ioctl operations */ _mqx_int _io_my_null_open(FILE_PTR fd_ptr, char_ptr open_name_ptr, char_ptr flags) { /* Nothing to do */ return(MQX_OK); 10 10 10

Null Driver _mqx_int _io_my_null_read(FILE_PTR fd_ptr, char_ptr data_ptr, _mqx_int num) { /* Body */ return(0); } /* Endbody */ _mqx_int _io_my_null_ioctl(FILE_PTR fd_ptr, _mqx_uint cmd, pointer param_ptr) return IO_ERROR_INVALID_IOCTL_CMD; ... 11 11 11

Driver Code Installation in BSP Create a folder inside the BSP to contain my_null device driver and save my_null program inside Create a new text file to be used as the header file for the driver Drag-and-drop the whole my_null_io folder to Codewarrior project inside the IO Drivers folder and add the files to all target boards (Details next week)

Using Null Driver #include <my_null_io.h> #define MY_TASK 5 extern void my_task(uint_32); TASK_TEMPLATE_STRUCT MQX_template_list[] = { {MY_TASK, my_task, 1500, 9, "null_test", MQX_AUTO_START_TASK, 0, 0}, {0} }; void my_task(uint_32 initial_data) { FILE_PTR null_file; uint_8 data[10]; if (IO_OK != _io_my_null_install("null:")) { printf("Error opening Null\n"); } 13 13 13

Using Null Driver if (NULL == (null_file = fopen("null:", NULL ))) { printf("Opening NULL device driver failed.\n"); _mqx_exit(-1); } if (write(null_file, data, 4 ) != 4) { printf("Writing to NULL driver failed.\n"); fclose(null_file); printf ("NULL driver working\n"); _mqx_exit(0); 14 14 14