UniMAP 1 Interfacing Peripherals. UniMAP 2 Interfacing devices on Embedded Linux In general, to interface to a device connected to an embedded Linux platform.

Slides:



Advertisements
Similar presentations
Computer System Laboratory
Advertisements

CIMCO Integration Software Products
Lab 12 : Liquid Crystal Displays: Slide 2 Slide 3 Slide 4 Slide 5 Slide 6 Slide 7 DMD Basics : Slide 8 Slide 9 Slide 10 Slide 11 Slide 12 Data Write the.
Programming In C++ Spring Semester 2013 Lecture 8 Programming In C++, Lecture 8 By Umer Rana.
Programmable Interval Timer
Programmable Keyboard/ Display Interface: 8279
The ATA/IDE Interface Can we write a character-mode device driver for the hard disk?
Operating Systems High Level View Chapter 1,2. Who is the User? End Users Application Programmers System Programmers Administrators.
CSS 372 Lecture 1 Course Overview: CSS 372 Web page Syllabus Lab Ettiquette Lab Report Format Review of CSS 371: Simple Computer Architecture Traps Interrupts.
Other I/O LCD display Flash ROM Keyboard (PS/2) UART connectors.
Embedded Systems 7763B Mt Druitt College of TAFE Electrical Engineering Lesson 2 LCD Display Interfacing.
Chapter 7 Interupts DMA Channels Context Switching.
Chapter 8 Overview Programmed I/O Introduction to Interrupt Driven I/O Project 3.
Exceptions, Interrupts & Traps
CCNA 2 v3.1 Module 2.
Process. Process Concept Process – a program in execution Textbook uses the terms job and process almost interchangeably A process includes: – program.
LCD's 1. LCD Types Many types available. Most common are:  Character Pre-programmed with a set of alphanumeric characters & symbols Size range from 8×1.
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
TextWand Programmable LED Display Carlos Vila-Virella and Andy Campanella.
1 Semester 2 Module 2 Introduction to Routers Yuda college of business James Chen
1 CSC 2405: Computer Systems II Spring 2012 Dr. Tom Way.
Digital Outputs LCD Display
1 Chapter 2 ROUTER FUNDAMENTALS By: Tassos Tassou.
Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to Embedded Systems Dr. Jerry Shiao, Silicon Valley University.
Basic Input Output System
Computer Maintenance Unit Subtitle: Basic Input/Output System (BIOS) Excerpted from 1 Copyright © Texas Education Agency, All.
DOS  In the 1980s or early 1990s, the operating system that shipped with most PCs was a version of the Disk Operating System (DOS) created by Microsoft:
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
Windows Tutorial Common Objects ACOS: 1, 4. Using the Taskbar 1. Using the taskbar, you can switch between open programs and between open documents within.
LCD Interfacing.
Interrupts By Ryan Morris. Overview ● I/O Paradigm ● Synchronization ● Polling ● Control and Status Registers ● Interrupt Driven I/O ● Importance of Interrupts.
Device Drivers CPU I/O Interface Device Driver DEVICECONTROL OPERATIONSDATA TRANSFER OPERATIONS Disk Seek to Sector, Track, Cyl. Seek Home Position.
PHY 201 (Blum)1 Microcode Source: Digital Computer Electronics (Malvino and Brown)
Video systems. Lesson plan Review the code for the previous exercise Video systems Review for midterm exam.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
Chapter Three The UNIX Editors.
Chapter 10 Glass Bliss Using the Parallel Master Port to communicate with Alphanumeric LCD displays.
CSC414 “Introduction to UNIX/ Linux” Lecture 2. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
1 CCNA Semester 2 Introduction to Routers Unit 2 Review JEOPARDY.
Department of Electronic & Electrical Engineering LCD character display (parallel interface). How to interface a LCD character display to a PIC.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Sem 2v2 Chapter 5 Router Startup and Setup. A router initializes by loading the bootstrap, the operating system, and a configuration file. If the router.
Computer Maintenance I
1 Basic Processor Architecture. 2 Building Blocks of Processor Systems CPU.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Introduction Purpose  This training course demonstrates the Project Generator function.
Project Assignment Snake Game/Car Acceleration Meter Min 10 Pages 10 min Presentation Max 5 group members Submitting Date: lab 2:Dec 27, 2014 Lab 3: Dec.
Vishwakarma government engineering college Prepare by. Hardik Jolapara( ) LCD Interfacing with ATmega16.
A.D.Patel institute of technology Sub : LCD and Keyboard interfacing with AVR. prepared by, chokshi abhi p ( ) Guided by, Prof. Asif Thakor.
CEng3361 CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT Spring 2011 Recitation 06.
WORKING OF SCHEDULER IN OS
Input/Output (I/O) Important OS function – control I/O
Peripherals – Keypad The Keypad provides a simple means of numerical data or control input. The keys can be attributed whatever data or control values.
CCNA 2 v3 JEOPARDY Module 2 CCNA2 v3 Module 2 K. Martin.
Linux Kernel Module Programming
LCD and Keyboard Interfacing
Computer Maintenance Unit Subtitle: Basic Input/Output System (BIOS)
Router Startup and Setup
Protection of System Resources
EET 2261 Unit 11 Controlling LCD and Keypad
LCD and Keyboard Interfacing
EET 2261 Unit 11 Controlling LCD and Keypad
LCD and Keyboard Interfacing
Operating Systems Chapter 5: Input/Output Management
LCD and Keyboard Interfacing
LCD and Keyboard Sepehr Naimi
Computer Architecture and Assembly Language
LCD and Keyboard Interfacing
Router Startup and Setup
Computer System Laboratory
Presentation transcript:

UniMAP 1 Interfacing Peripherals

UniMAP 2 Interfacing devices on Embedded Linux In general, to interface to a device connected to an embedded Linux platform requires a device driver, which of course has to be written by the programmer. However, in this class we are not gonna write device driver…simply because Device driver programming is a.. woops actually more course by itself.

UniMAP 3 What is device driver programming What u need to know –Indepth knowledge about the respective hardware. –Indepth knowledge about the OS that u want to write the device driver for. An error could leads to system crash Well enough of the threatening news….after all thousands of people had successfully written them… so it can be learned.

UniMAP 4 The LCD we are using

UniMAP 5 LCD Interface A 14-pin LCD connector is provided on the TS-5500 for interfacing with standard alphanumeric LCD displays. These displays use a common controller, the Hitachi HD44780 or equivalent. While software written for the HD44780 will work with all displays using the controller, the cable needed is dependent on the display used. For most displays, a straight-through type ribbon cable can be used. The connector on the LCD display is typically mounted on the backside of the display. Warning – using an incorrect cable or mounting the LCD connector on the front-side can result in a reverse power polarity and can damage the LCD display. Please refer to your LCD data sheets for in-depth information.

UniMAP 6 The LCD Header signals table is not the standard pin-outs given for LCD displays. But this pin-out allows a standard ribbon cable to be used when the ribbon cable is attached to the backside of the LCD.

UniMAP 7 Writing to LCD using C Using the LCD HD44780 Device Driver distributed under GNU Public License –lcdconf.h Header file defining some configuration values including various register values for control and data for the lcd –lcd.h Various functions that one may use to write to the LCD –lcd.c lcd.h implementation file

UniMAP 8 The lcdconf.h #ifndef LCDCONF_H #define LCDCONF_H #define LCD_MEMORY_INTERFACE #ifdef LCD_MEMORY_INTERFACE #ifndef LCD_CTRL_ADDR // CPU memory address of the LCD control register #define LCD_CTRL_ADDR 0x72 #endif #ifndef LCD_DATA_ADDR // CPU memory address of the LCD data register #define LCD_DATA_ADDR 0x73 #endif #ifndef LCD_DIR_PORT // CPU memory address of the LCD enable register #define LCD_DIR_PORT 0x7D #endif #ifndef LCD_ENABLE_PIN

UniMAP 9 Lcdconf.h… cont // CPU memory address of the LCD enable register #define LCD_ENABLE_PIN 4 #endif // LCD display geometry // change these definitions to adapt settings #define LCD_LINES 2 // visible lines #define LCD_LINE_LENGTH 24 // line length (in characters) // cursor position to DDRAM mapping #define LCD_LINE0_DDRAMADDR 0x00 #define LCD_LINE1_DDRAMADDR 0x40 #define LCD_LINE2_DDRAMADDR 0x14 #define LCD_LINE3_DDRAMADDR 0x54 #endif

UniMAP 10 The lcd.h #ifndef LCD_H #define LCD_H #include // include project-dependent configurations #include "lcdconf.h" typedef unsigned char u08; typedef unsigned short u16; #define sbi(port,bit) outb(inb(port) | 1<<bit, port) #define cbi(port,bit) outb(inb(port) & ~(1<<bit), port) // HD44780 LCD controller command set (do not modify these)

UniMAP 11 lcd.h… cont // writing: #define LCD_CLR 0 // DB0: clear display #define LCD_HOME 1 // DB1: return to home position #define LCD_ENTRY_MODE 2 // DB2: set entry mode #define LCD_ENTRY_INC 1 // DB1: increment #define LCD_ENTRY_SHIFT 0 // DB2: shift #define LCD_ON_CTRL 3 // DB3: turn lcd/cursor on #define LCD_ON_DISPLAY 2 // DB2: turn display on #define LCD_ON_CURSOR 1 // DB1: turn cursor on #define LCD_ON_BLINK 0 // DB0: blinking cursor #define LCD_MOVE 4 // DB4: move cursor/display #define LCD_MOVE_DISP 3 // DB3: move display (0-> move cursor) #define LCD_MOVE_RIGHT 2 // DB2: move right (0-> left) #define LCD_FUNCTION 5 // DB5: function set #define LCD_FUNCTION_8BIT 4 // DB4: set 8BIT mode (0->4BIT mode) #define LCD_FUNCTION_2LINES 3 // DB3: two lines (0->one line) #define LCD_FUNCTION_10DOTS 2 // DB2: 5x10 font (0->5x7 font) #define LCD_CGRAM 6 // DB6: set CG RAM address #define LCD_DDRAM 7 // DB7: set DD RAM address

UniMAP 12 lcd.h // reading: #define LCD_BUSY 7 // DB7: LCD is busy // Default LCD setup // this default setup is loaded on LCD initialization #ifdef LCD_DATA_4BIT #define LCD_FDEF_1 (0<<LCD_FUNCTION_8BIT) #else #define LCD_FDEF_1 (1<<LCD_FUNCTION_8BIT) #endif #define LCD_FDEF_2 (1<<LCD_FUNCTION_2LINES) #define LCD_FUNCTION_DEFAULT ((1<<LCD_FUNCTION) | LCD_FDEF_1 | LCD_FDEF_2) #define LCD_MODE_DEFAULT ((1<<LCD_ENTRY_MODE) | (1<<LCD_ENTRY_INC))

UniMAP 13 // custom LCD characters #define LCDCHAR_PROGRESS05 0 // 0/5 full progress block #define LCDCHAR_PROGRESS15 1 // 1/5 full progress block #define LCDCHAR_PROGRESS25 2 // 2/5 full progress block #define LCDCHAR_PROGRESS35 3 // 3/5 full progress block #define LCDCHAR_PROGRESS45 4 // 4/5 full progress block #define LCDCHAR_PROGRESS55 5 // 5/5 full progress block #define LCDCHAR_REWINDARROW 6 // rewind arrow #define LCDCHAR_STOPBLOCK 7 // stop block #define LCDCHAR_PAUSEBARS 8 // pause bars #define LCDCHAR_FORWARDARROW 9 // fast-forward arrow #define LCDCHAR_SCROLLUPARROW 10 // scroll up arrow #define LCDCHAR_SCROLLDNARROW 11 // scroll down arrow #define LCDCHAR_BLANK 12 // scroll down arrow #define LCDCHAR_ANIPLAYICON0 13 // animated play icon frame 0 #define LCDCHAR_ANIPLAYICON1 14 // animated play icon frame 1 #define LCDCHAR_ANIPLAYICON2 15 // animated play icon frame 2 #define LCDCHAR_ANIPLAYICON3 16 // animated play icon frame 3

UniMAP 14 // progress bar defines #define PROGRESSPIXELS_PER_CHAR 6 // initializes I/O pins connected to LCD void lcdInitHW(void); // waits until LCD is not busy void lcdBusyWait(void); // writes a control command to the LCD void lcdControlWrite(u08 data); // read the control status from the LCD u08 lcdControlRead(void); // writes a data byte to the LCD screen at the current position void lcdDataWrite(u08 data); // reads the data byte on the LCD screen at the current position u08 lcdDataRead(void); // initializes the LCD display (gets it ready for use) void lcdInit(void); // moves the cursor/position to Home (upper left corner) void lcdHome(void); // clears the LCD display void lcdClear(void); // moves the cursor/position to the row,col requested void lcdGotoXY(u08 row, u08 col);

UniMAP 15 // loads a special user-defined character into the LCD // is a pointer to a ROM array containing custom characters // is the index of the character to load from lcdCustomCharArray // is the RAM location in the LCD (legal value: 0-7) void lcdLoadCustomChar(u08* lcdCustomCharArray, u08 romCharNum, u08 lcdCharNum); // prints a series of bytes/characters to the display void lcdPrintData(char* data, u08 nBytes); // clears the screen then prints a series of bytes/characters to the display going to the // next line on a '\n' or when the end of the line is reached void lcdPrintScreen(char* data); // prints a string of bytes/characters to the display but does not wrap lines void lcdPrintString(char* data); // displays a horizontal progress bar at the current cursor location // is the value the bargraph should indicate // is the value at the end of the bargraph // is the number of LCD characters that the bargraph should cover void lcdProgressBar(u16 progress, u16 maxprogress, u08 length); #endif

UniMAP 16 Sample Code for u int main (void) { buf[0] = 0; //initialize LCD Hardware lcdInit(); lcdPrintScreen("Assalamualaikum\n"); sleep(2); lcdClear(); lcdPrintScreen("Press Enter to End This\nStage"); sleep(2); lcdClear(); while (buf[0] != 'D') { rtrn = read (fc, &buf, sizeof(char)); if (rtrn < 0 ) printf ("Errno: %s \n", strerror(errno)); else if (!rtrn) { buf[0] = '\0'; continue; } lcdPrintString(buf); } lcdPrintScreen("Goodbye!"); return 0; }

UniMAP 17 Keypad Interface The DIO2 port, signals DIO2_0 through DIO2_7, may be configured to support a 4 x 4 matrix keypad. When enabled, BIOS firmware performs all the work, making the matrix keypad appear as a simple 16- key keyboard to software. This allows the use of standard keyboard access routines. The default set of keys translated by the BIOS consists of 0 – 9, A – D, *, and #. The # key is returned as an ASCII Carriage Return character (Hex 0D). Because the user is writing the software, this set of keys is usually sufficient. However, a custom translation table can be loaded, allowing the use of function keys, arrowkeys, or any other key on the keyboard.

UniMAP 18 Installing Matrix Keypad Under kernel ts, there is module for matrix keypad which is ts_keypad.o locates at –/lib/ ts/kernel/drivers/char/. That module is not included under kernel ts.leucosia. Copy entire source code sample from Linux Develop's Manual at Matrix Keypad section as readkeypad.c and compile it. ( i used to compile this file under RedHat 8.0) –gcc -o readkeypad readkeypad.c Copy that executable file onto SBC at /usr/bin.

UniMAP 19 …continue At SBC, to enable the keypad, firstly load the module for keypad. –#modprobe ts_keypad.o OR –#insmod ts_keypad.o Technologic System Matrix KeyPad Driver V To check that the ts_keypad module has been probed or enabled, type lsmod. –#lsmod ModuleSize Used by Tainted: P ts_keypad (unsed) Right now, you can run the executable readkeypad by typing –#./readkeypad Starting Technologic Systems Matrix Keypad Example Program Testing continous read of device Press “#’ to end of this stage

UniMAP 20 So what have u learn What is device driver What it takes to develop device driver Application… simply use existing device driver… of course we have to leave with the limitation build inside the device driver