OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [ARM7_STR71x_IAR/] [Library/] [gpio.c] - Blame information for rev 583

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 577 jeremybenn
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
2
* File Name          : gpio.c
3
* Author             : MCD Application Team
4
* Date First Issued  : 06/08/2003
5
* Description        : This file provides all the GPIO software functions
6
********************************************************************************
7
* History:
8
*  30/11/2004 : V2.0
9
*  14/07/2004 : V1.3
10
*  01/01/2004 : V1.2
11
*******************************************************************************
12
 THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
13
 CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
14
 AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
15
 OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
16
 OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
17
 CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18
*******************************************************************************/
19
 
20
#include "gpio.h"
21
 
22
/*******************************************************************************
23
* Function Name  : GPIO_Config
24
* Description    : Configure the GPIO port pins
25
* Input 1        : GPIOx (x can be 0,1 or 2) the desired port
26
* Input 2        : Port_Pins : pins placements
27
* Input 3        : Pins Mode
28
* Output         : None
29
* Return         : None
30
*******************************************************************************/
31
void GPIO_Config (GPIO_TypeDef *GPIOx, u16 Port_Pins, GpioPinMode_TypeDef GPIO_Mode)
32
{
33
  switch (GPIO_Mode)
34
  {
35
    case GPIO_HI_AIN_TRI:
36
      GPIOx->PC0&=~Port_Pins;
37
      GPIOx->PC1&=~Port_Pins;
38
      GPIOx->PC2&=~Port_Pins;
39
      break;
40
 
41
    case GPIO_IN_TRI_TTL:
42
      GPIOx->PC0|=Port_Pins;
43
      GPIOx->PC1&=~Port_Pins;
44
      GPIOx->PC2&=~Port_Pins;
45
      break;
46
 
47
    case GPIO_IN_TRI_CMOS:
48
      GPIOx->PC0&=~Port_Pins;
49
      GPIOx->PC1|=Port_Pins;
50
      GPIOx->PC2&=~Port_Pins;
51
      break;
52
 
53
    case GPIO_IPUPD_WP:
54
      GPIOx->PC0|=Port_Pins;
55
      GPIOx->PC1|=Port_Pins;
56
      GPIOx->PC2&=~Port_Pins;
57
      break;
58
 
59
    case GPIO_OUT_OD:
60
      GPIOx->PC0&=~Port_Pins;
61
      GPIOx->PC1&=~Port_Pins;
62
      GPIOx->PC2|=Port_Pins;
63
      break;
64
 
65
    case GPIO_OUT_PP:
66
      GPIOx->PC0|=Port_Pins;
67
      GPIOx->PC1&=~Port_Pins;
68
      GPIOx->PC2|=Port_Pins;
69
      break;
70
 
71
    case GPIO_AF_OD:
72
      GPIOx->PC0&=~Port_Pins;
73
      GPIOx->PC1|=Port_Pins;
74
      GPIOx->PC2|=Port_Pins;
75
      break;
76
 
77
    case GPIO_AF_PP:
78
      GPIOx->PC0|=Port_Pins;
79
      GPIOx->PC1|=Port_Pins;
80
      GPIOx->PC2|=Port_Pins;
81
      break;
82
  }
83
}
84
 
85
/*******************************************************************************
86
* Function Name  : GPIO_BitWrite
87
* Description    : Set or reset the selected port pin
88
* Input 1        : Selected GPIO port
89
* Input 2        : Pin number
90
* Input 3        : bit value
91
* Output         : None
92
* Return         : None
93
*******************************************************************************/
94
void GPIO_BitWrite(GPIO_TypeDef *GPIOx, u8 Port_Pin, u8 Port_Val)
95
{
96
  if (Port_Val&0x01) GPIOx->PD |= 1<<Port_Pin; else GPIOx->PD &= ~(1<<Port_Pin);
97
}
98
 
99
/*******************************************************************************
100
* Function Name  : GPIO_ByteWrite
101
* Description    : Write byte value to the selected PD register
102
* Input 1        : Selected GPIO port
103
* Input 2        : GPIO_MSB or GPIO_LSB
104
* Input 3        : Byte value
105
* Output         : None
106
* Return         : None
107
*******************************************************************************/
108
void GPIO_ByteWrite(GPIO_TypeDef *GPIOx, u8 Port_Byte, u8 Port_Val)
109
{
110
  GPIOx->PD = Port_Byte ? (GPIOx->PD&0x00FF) | ((u16)Port_Val<<8)
111
                        : (GPIOx->PD&0xFF00) | Port_Val;
112
}
113
 
114
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.