📄 io.h
字号:
/* * File: io.h * * This is an interface to a utility which performs basic IO operations or * the parallel and serial ports of the device. * * See Also * io.c -- An implementation exposing a io.h interface. * * Copyright (C) 2002 RidgeRun, Inc. * Author: RidgeRun, Inc <skranz@ridgerun.com> * - Support for DSC25 added, 9-6-02, Gregory Nutt * - Support for DM270 added, 2-19-03, Gregory Nutt * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. * * Please report all bugs/problems to the author or <support@dsplinux.net> * * key: RRGPLCR (do not remove) * */#ifndef IO_H#define IO_H#define SER 0#define PAR 1#define USB 2#define __swap_16(x) \ ((((x) & 0xff00) >> 8) | \ (((x) & 0x00ff) << 8))#define __swap_32(x) \ ((((x) & 0xff000000) >> 24) | \ (((x) & 0x00ff0000) >> 8) | \ (((x) & 0x0000ff00) << 8) | \ (((x) & 0x000000ff) << 24))extern void io_putchar(unsigned char c); // --io_putchar-- // Writes a char to the console. For more // information see `man putchar`.extern unsigned char io_getchar_con(void); extern unsigned char io_getchar_ser(void);extern unsigned char io_getchar_par(void); //see below. // --io_getchar_con-- // --io_getchar_ser-- // --io_getchar_par-- // // These three routines are used to access the // h/w and retrieve a single incoming byte. // Each will block until a byte becomes // available. While similiar in nature they // differ slightly as described below: // // 1. io_getchar_con() -- use this when you simply // want a byte from the "console", whatever // that might be. Other areas of the system // have already either assigned the console // to the serial port, or the parallel port, // or whatever -- you don't care, you just // want a byte from whatever piece of h/w the // console is attached to; in other words "stdin". // // 2. io_getchar_ser() -- use this to *specifically* // acquire a byte from the serial port. Which // serial port? The *default* one -- as defined by // other areas of the system. // // 3. io_getchar_par() -- use this to *specifically* // acquire a byte from the *default* parrallel port.extern unsigned char io_getc(int timeout_msec); // --io_getc-- // Similiar to io_getchar_con() but instead of waiting indefinitely // for a character it will accept a timeout that controls the // longest this routine will try before returning to the caller. // // timeout_sec // -1 -- wait indefinitely for a key press. // 0 -- don't wait at all, if a key value // is present now return it, otherwise // return '\0'. // t -- wait up to this long for a key press // to return, otherwise give up and return // '\0'.extern int io_getbootmode(void); // --io_getbootmode-- // Get the hardware dip switch setting that has been set // aside to reflect how the user wants to boot; either // in "rrlo" or "rrload" mode for returned values 0 and 1 // respectively.extern void display_board_digit(unsigned char val); // --display_board_digit-- // Display the supplied val as a digit on the board's // led digit display. Typically this is used to give the // user feedback that something is running until it // otherwise becomes obvious.extern void io_delay(int milliseconds); // --io_delay-- // Waits this many milliseconds and then returns to caller. // This provides an easy way for the caller to simply stall // for the requested number of milliseconds. The implementation // of this routine is h/w dependent and is why the io_xxx.c // files implement it.#ifdef C5471 /* *revisit-skranz* */extern void io_StartTimeElapse(int milliseconds); // --io_StartTimeElapse-- // Start a time elapse that can be periodically // tested for expiration using the call below. // NOTE: *revisit-skranz* For now this routine // is hardcoded to always setup a time interval // of 0.5 second. This can be extended to match // the interface definition later. Temporary.extern int io_TimeElapseHasExpired(void); // --io_TimeElapseHasExpired-- // Returns 1 if a previously started time elapse // has finally expired. Continues to return true // unless some new time elapse has been started // in which case returns 0 for duration of time // that elapse.#endifextern int io_AddressIsInFlashSpace(unsigned int addr); // --io_AddressIsInFlashSpace-- // If the passed in address is from the on-board // flash area of the board's memory map then returns // 1, otherwise returns 0.extern void io_init(void); // --io_init-- // Called once at bootloader boot to initialize the underlying // implementation.extern void io_change_con(int new_con); // --io_change_con-- // Change the console port. // // new_con // SER -- serial port // PAR -- parallel port // USB -- usb port#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -