⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpio.h

📁 56f8300E系列dsp的BOOTloader
💻 H
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************
*
* Motorola Inc.
* (c) Copyright 2002 Motorola, Inc.
* ALL RIGHTS RESERVED.
*
*******************************************************************************
*
* FILE NAME: gpio.h
*
*******************************************************************************/
#ifndef __GPIO_H
#define __GPIO_H


#include "port.h"
#include "bsp.h"
#include "io.h"


#ifdef __cplusplus
extern "C" {
#endif

/******************************************************************************
*
*                      General Interface Description
*
*  The General Purpose I/O interface manipulates external signals routed through
*  general purpose pins.  Typically, each pin may be programmed as an input, 
*  output, or level sensitive interrupt input.  However, peripherals may share
*  control of these general purpose I/O pins;  you may not use a pin for both a
*  peripheral and as a general purpose I/O pin.  Therefore, please consult the
*  appropriate technical reference to determine which pins are assigned to 
*  peripherals that you will use, and which pins may be available for general
*  purpose use. 
*  
*  The design of the general purpose I/O interface organizes pins according to
*  "ports".  Typically, each port has eight I/O pins. 
*  
******************************************************************************/

/******************************************************************************
*
*  GPIO Interfaces
* 
*     The GPIO interface can be used at three alternative levels, a low level
*     GPIO driver interface, a low level inline GPIO driver interface and the
*     common IO layer interface.  The common IO layer interface invokes the 
*     lower level GPIO driver interface. 
*
*     The low level GPIO driver provides a non-standard interface that is
*     potentially more efficient that the IO layer calls, but less portable.  
*     The IO layer calls to the GPIO interface are standard and more 
*     portable than the low level GPIO interface, but potentially less efficient.
*    
*     Your application may use either the low level GPIO driver interface or
*     the IO layer interface to the GPIO driver, depending on your specific
*     goals for efficiency and portability.
*
*     The low level GPIO driver interface defines functions as follows:
*  
*          handle_t gpioOpen  (const char *pName, int OFlags);    // open port
*          handle_t gpiopinOpen  (const char *pName, int OFlags); // open single pin
*          int gpioIoctl (handle_t FileDesc, UWord16 Cmd, gpioPin(UWord16 Pin));      
*           or
*          int gpioIoctl (handle_t FileDesc, UWord16 Cmd, gpioMask(UWord16 PinMask)); 
*          int gpioClose (handle_t FileDesc);  
*
*     The low level inline GPIO driver interface defines functions as follows:
*  
*          int gpioIoctl (int PortAddress, UWord16 Cmd, gpioPin(UWord16 Pin)); 
*           or
*          int gpioIoctl (int PortAddress, UWord16 Cmd, gpioMask(UWord16 PinMask));
*
*     The IO layer interface defines functions as follows:
*
*          handle_t     open  (const char *pName, int OFlags, ...);
*          UWord16 ioctl (handle_t FileDesc, UWord16 Cmd, unsigned long params);      
*          int     close (handle_t FileDesc);  
*
******************************************************************************/

/*****************************************************************************
*
* LOW LEVEL GPIO DRIVER INTERFACE
*
*   General Description:
*
*      The Low Level GPIO Driver is configured by the following:
*  
*         1)  The device is created and initialized by selecting it through defining the 
*             INCLUDE_GPIO variable in the appconfig.h file associated with the SDK Embedded 
*             Project created in CodeWarrior. 
*
*         2)  An "gpioOpen" call is made to open communications with the GPIO Port
*
*         3)  The GPIO port is configured via "gpioIoctl" calls.
*             See "gpioIoctl" call below.
*
*         4)  After all GPIO operations are completed, the GPIO peripheral
*             is closed via a "gpioClose" call.
*
*
*   gpioOpen
*
*      handle_t gpioOpen  (const char *pName, int OFlags);
*
*         Semantics:
*            Opens a particular port for operations. Argument pName is the 
*            particular port name. A particular port needs to be opened before
*            configuring the port with gpioIoctl calls.
*
*         Parameters:
*            pName    - device name. See bsp.h for device names specific to this 
*                       platform.  Typically, the GPIO device name is
*                          BSP_DEVICE_NAME_GPIO_A
*                          BSP_DEVICE_NAME_GPIO_B
*                          BSP_DEVICE_NAME_GPIO_C
*                          BSP_DEVICE_NAME_GPIO_D
*                          BSP_DEVICE_NAME_GPIO_E
* 
*         Return Value: 
*            Port file descriptor if open is successful.
*            -1 value if open failed.
*     
*         Example:
*
*            handle_t PortA; 
* 
*            PortA = gpioOpen(BSP_DEVICE_NAME_GPIO_A, NULL);
*
*   gpiopinOpen
*
*      handle_t gpiopinOpen (const char *pName, int OFlags);
*
*         Semantics:
*            Opens a particular pin for operations. Argument pName is the 
*            particular pin name. A particular pin needs to be opened before
*            configuring the pin with gpioIoctl calls.
*
*         Parameters:
*            pName    - device name. See bsp.h for device names specific to this 
*                       platform.  Typically, the GPIO device name is
*                       BSP_DEVICE_NAME_GPIO_A_PIN0
*                       ...
*                       BSP_DEVICE_NAME_GPIO_A_PIN7  
*                       BSP_DEVICE_NAME_GPIO_B_PIN0
*                       ...
*                       BSP_DEVICE_NAME_GPIO_B_PIN7   
*                       BSP_DEVICE_NAME_GPIO_C_PIN0
*                       ...
*                       BSP_DEVICE_NAME_GPIO_C_PIN3     
*                       BSP_DEVICE_NAME_GPIO_D_PIN0
*                       ...
*                       BSP_DEVICE_NAME_GPIO_D_PIN7  
*                       BSP_DEVICE_NAME_GPIO_E_PIN0
*                       ...
*                       BSP_DEVICE_NAME_GPIO_E_PIN7
* 
*            OFlags -   O_SETAS_INPUT
*                       O_SETAS_OUTPUT
*                       O_DISABLE_PULLUP
*                       O_ENABLE_PULLUP
*                       O_SETAS_GPIO
*                       O_SETAS_PERIPHERAL
*                       O_INTERRUPT_ASSERT_DISABLE
*                       O_INTERRUPT_ASSERT_ENABLE
*                       O_INTERRUPT_DISABLE
*                       O_INTERRUPT_ENABLE
*                       O_INTERRUPT_DETECTION_ACTIVE_HIGH
*                       O_INTERRUPT_DETECTION_ACTIVE_LOW
*
*         Return Value: 
*            Port file descriptor if open is successful.
*            -1 value if open failed.
*     
*         Example:
*
*            handle_t PinA2; 
* 
*            PinA2 = gpiopinOpen(BSP_DEVICE_NAME_GPIO_A_PIN2, O_SETAS_GPIO | O_SETAS_OUTPUT);
*
*   gpioIoctl for port configuration
*
*      UWord16 gpioIoctl(handle_t hndl, UWord16 Cmd, unsigned long params) 
*
*         Semantics:
*            Modify GPIO port configuration or set a GPIO signal.
*
*         Parameters:
*            hndl        - The file description returned by the gpioOpen call
*
*            Cmd         - command for driver ioctl command;  these commands
*                          are listed in the description of the IO Layer ioctl 
*                          interface
*
*            Params      - The Params is used to pass on a particular pin on a port in which to perform
*                          one of the above commands.  The gpioPin macro defined below is used to obtain
*                          a mask for that particular pin and port.  
*
*
*         Return Value: 
*            Integer value returned by the gpioIoctl call.  
*
*            The only gpioIoctl command which currently returns a value (0 or 1) 
*            is GPIO_READ. 
*
*         Example:
*
*            // disable peripheral as the master of bit 0 on port A
*            gpioIoctl (PortA, GPIO_SETAS_GPIO, gpioPin(0)); 
*     
*            // set bit 3 on port B as an output pin
*            gpioIoctl (PortB, GPIO_SETAS_OUTPUT, gpioPin(3));
*
*            // read the state of port D pin 5
*            state = gpioIoctl (PortD, GPIO_READ, gpioPin(5));  
*
*     
*   gpioIoctl for pin configuration
*
*      UWord16 gpioIoctl(handle_t hndl, UWord16 Cmd, unsigned long params) 
*
*         Semantics:
*            Modify pin configuration. GPIO driver supports the following commands:
*
*               GPIOPIN_SETAS_GPIO                      When peripheral disabled DDR determines 
*                                                       direction of data flow in PER register
*
*               GPIOPIN_SETAS_PERIPHERAL                A peripheral masters the gpio pin, in PER
*                                                       register
* 
*               GPIOPIN_SETAS_INPUT                     Sets a gpio pin as an input, in DDR register
*
*               GPIOPIN_SETAS_OUTPUT                    Sets a gpio pin as an output, in DDR register
*
*               GPIOPIN_INTERRUPT_DISABLE               Disables edge detection for any incoming
*                                                       interrupt, in IENR register.
*
*               GPIOPIN_INTERRUPT_ENABLE                Enables edge detection for any incoming 
*                                                       interrupt, in IENR register.
*  
*               GPIOPIN_DISABLE_PULLUP	                Disable pull-up, in PUR register
*
*               GPIOPIN_ENABLE_PULLUP                   Enable pull-up, in PUR register
*  
*               GPIOPIN_INTERRUPT_ASSERT_DISABLE        Disables an interrupt assert, in IAR register  
*
*               GPIOPIN_INTERRUPT_ASSERT_ENABLE         Enables an interrupt assert, used only
*                                                       in software testing, in IAR register
*
*               GPIOPIN_INTERRUPT_DETECTION_ACTIVE_HIGH The interrupt seen at the PAD is active high
*
*               GPIOPIN_INTERRUPT_DETECTION_ACTIVE_LOW  The interrupt seen at the PAD is active low 
*
*               GPIOPIN_CLEAR_INTERRUPT_PEND_REGISTER   By writing zeros to this register the IPR is
*                                                       cleared
*
*               GPIOPIN_SET                             Sets a GPIO signal
*
*               GPIOPIN_CLEAR                           Clears a GPIO signal
*
*               GPIOPIN_TOGGLE                          Toggles a GPIO signal 
*
*               GPIOPIN_READ                            Reads the value of an input pin;
*                                                       returns 0 or 1 for the value 
*  
*
*         Parameters:
*            hndl        - The file description returned by the gpioOpen call
*
*            Cmd         - command for driver ioctl command;  these commands
*                          are listed in the description of the IO Layer ioctl 
*                          interface
*
*            Params      - The Params is used to define callback functions only. 
*
*
*         Return Value: 
*            Integer value returned by the gpioIoctl call.  
*
*            The only gpioIoctl command which currently returns a value (0 or 1) 
*            is GPIOPIN_READ. 
*
*         Example:
*
*            // disable peripheral as the master of bit 0 on pin 2 of port A
*            gpioIoctl (PinA2, GPIOPIN_SETAS_GPIO, NULL); 
*     
*            // set bit 3 on port B as an output pin
*            gpioIoctl (PinB3, GPIO_SETAS_OUTPUT, NULL);
*
*            // read the state of port D pin 5
*            state = gpioIoctl (PinD5, GPIO_READ, NULL);  
*
*     
*   gpioClose
*
*      int gpioClose(handle_t FileDesc);  
*
*         Semantics:
*            Close GPIO device.
*  
*         Parameters:
*            FileDesc    - Port file descriptor returned by "open" call.
*
*         Example:
*
*            // Close the GPIO driver on a specific port
*            gpioClose(PortA); 
* 
*         Return Value: 
*            Zero
*     
*   gpiopinClose

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -