1 /******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
3 * Author : MCD Application Team
4 * Date First Issued : 06/08/2003
5 * Description : This file provides all the GPIO software functions
6 ********************************************************************************
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 *******************************************************************************/
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
30 *******************************************************************************/
31 void GPIO_Config (GPIO_TypeDef *GPIOx, u16 Port_Pins, GpioPinMode_TypeDef GPIO_Mode)
36 GPIOx->PC0&=~Port_Pins;
37 GPIOx->PC1&=~Port_Pins;
38 GPIOx->PC2&=~Port_Pins;
42 GPIOx->PC0|=Port_Pins;
43 GPIOx->PC1&=~Port_Pins;
44 GPIOx->PC2&=~Port_Pins;
47 case GPIO_IN_TRI_CMOS:
48 GPIOx->PC0&=~Port_Pins;
49 GPIOx->PC1|=Port_Pins;
50 GPIOx->PC2&=~Port_Pins;
54 GPIOx->PC0|=Port_Pins;
55 GPIOx->PC1|=Port_Pins;
56 GPIOx->PC2&=~Port_Pins;
60 GPIOx->PC0&=~Port_Pins;
61 GPIOx->PC1&=~Port_Pins;
62 GPIOx->PC2|=Port_Pins;
66 GPIOx->PC0|=Port_Pins;
67 GPIOx->PC1&=~Port_Pins;
68 GPIOx->PC2|=Port_Pins;
72 GPIOx->PC0&=~Port_Pins;
73 GPIOx->PC1|=Port_Pins;
74 GPIOx->PC2|=Port_Pins;
78 GPIOx->PC0|=Port_Pins;
79 GPIOx->PC1|=Port_Pins;
80 GPIOx->PC2|=Port_Pins;
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
93 *******************************************************************************/
94 void GPIO_BitWrite(GPIO_TypeDef *GPIOx, u8 Port_Pin, u8 Port_Val)
96 if (Port_Val&0x01) GPIOx->PD |= 1<<Port_Pin; else GPIOx->PD &= ~(1<<Port_Pin);
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
107 *******************************************************************************/
108 void GPIO_ByteWrite(GPIO_TypeDef *GPIOx, u8 Port_Byte, u8 Port_Val)
110 GPIOx->PD = Port_Byte ? (GPIOx->PD&0x00FF) | ((u16)Port_Val<<8)
111 : (GPIOx->PD&0xFF00) | Port_Val;
114 /******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/