- Main Page
- Data Structures
- Files
- Directories

- Search for |

- File List
- Globals

# pit.c

Go to the documentation of this file.

    00001 /*****************************************************************************************
    00002  Copyright (c) 2002-2004 The UbixOS Project
    00003  All rights reserved.
    00004
    00005  Redistribution and use in source and binary forms, with or without modification, are
    00006  permitted provided that the following conditions are met:
    00007
    00008  Redistributions of source code must retain the above copyright notice, this list of
    00009  conditions, the following disclaimer and the list of authors.  Redistributions in binary
    00010  form must reproduce the above copyright notice, this list of conditions, the following
    00011  disclaimer and the list of authors in the documentation and/or other materials provided
    00012  with the distribution. Neither the name of the UbixOS Project nor the names of its
    00013  contributors may be used to endorse or promote products derived from this software
    00014  without specific prior written permission.
    00015
    00016  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
    00017  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    00018  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
    00019  THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    00020  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
    00021  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    00022  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
    00023  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    00024  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00025
    00026  $Id: pit_8c-source.html 88 2016-01-12 00:11:29Z reddawg $
    00027
    00028 *****************************************************************************************/
    00029
    00030 #include <isa/pit.h>
    00031 #include <sys/io.h>
    00032 #include <lib/kprintf.h>
    00033
    00034 /*****************************************************************************************
    00035
    00036  Function: int pitInit()
    00037
    00038  Description: This Function Will Initialize The Programmable Timer
    00039
    00040  Notes:
    00041
    00042  0040   r/w     PIT  counter 0, counter divisor       (XT, AT, PS/2)
    00043  0041   r/w     PIT  counter 1, RAM refresh counter   (XT, AT)
    00044  0042   r/w     PIT  counter 2, cassette & speaker    (XT, AT, PS/2)
    00045  0043   r/w     PIT  mode port, control word register for counters 0-2
    00046
    00047                  bit 7-6 = 00  counter 0 select
    00048                          = 01  counter 1 select   (not PS/2)
    00049                          = 10  counter 2 select
    00050                  bit 5-4 = 00  counter latch command
    00051                          = 01  read/write counter bits 0-7 only
    00052                          = 10  read/write counter bits 8-15 only
    00053                          = 11  read/write counter bits 0-7 first, then 8-15
    00054                  bit 3-1 = 000 mode 0 select
    00055                          = 001 mode 1 select - programmable one shot
    00056                          = x10 mode 2 select - rate generator
    00057                          = x11 mode 3 select - square wave generator
    00058                          = 100 mode 4 select - software triggered strobe
    00059                          = 101 mode 5 select - hardware triggered strobe
    00060                  bit 0   = 0   binary counter 16 bits
    00061                          = 1   BCD counter
    00062
    00063 *****************************************************************************************/
    00064 int pit_init() {
    00065   outportByteP(0x43,0x36);
    00066   outportByteP(0x40,((1193180/PIT_TIMER) & 0xFF));
    00067   outportByte(0x40,(((1193180/PIT_TIMER) >> 8) & 0xFF));
    00068
    00069   /* Print out information on the PIT */
    00070   kprintf("pit0 - Port [0x%X], Timer Hz: [%iHz]\n",0x43,PIT_TIMER);
    00071
    00072   /* Return so we know everything went well */
    00073   return(0x0);
    00074   }
    00075
    00076 /***
    00077  $Log: pit_8c-source.html,v $
    00077  Revision 1.7  2006/12/15 17:47:06  reddawg
    00077  Updates
    00077
    00078  Revision 1.1.1.1  2006/06/01 12:46:12  reddawg
    00079  ubix2
    00080
    00081  Revision 1.2  2005/10/12 00:13:37  reddawg
    00082  Removed
    00083
    00084  Revision 1.1.1.1  2005/09/26 17:24:03  reddawg
    00085  no message
    00086
    00087  Revision 1.7  2004/07/16 04:06:32  reddawg
    00088  Tune ups this stuff should of been taken care of months ago
    00089
    00090  Revision 1.6  2004/07/16 01:08:58  reddawg
    00091  Whew we work once again
    00092
    00093  Revision 1.5  2004/07/09 13:29:15  reddawg
    00094  pit: pitInit to pit_init
    00095  Adjusted initialization routines
    00096
    00097  Revision 1.4  2004/05/21 12:48:22  reddawg
    00098  Cleaned up
    00099
    00100  Revision 1.3  2004/05/20 22:51:09  reddawg
    00101  Cleaned Up Warnings
    00102
    00103  Revision 1.2  2004/05/10 02:23:24  reddawg
    00104  Minor Changes To Source Code To Prepare It For Open Source Release
    00105
    00106  END
    00107  ***/
    00108