Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.05 KB | None | 0 0
  1. void config_input(){
  2.     GPIO_InitTypeDef GPIO_InitInput;
  3.  
  4.     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
  5.  
  6.     GPIO_InitInput.GPIO_Pin = GPIO_Pin_0 |GPIO_Pin_1|GPIO_Pin_2;
  7.     GPIO_InitInput.GPIO_Mode = GPIO_Mode_IN;
  8.     GPIO_InitInput.GPIO_PuPd = GPIO_NOPULL;
  9.  
  10.     GPIO_Init(GPIOD, &GPIO_Initinput);  
  11. }
  12.  
  13. void config_output(){
  14.     GPIO_InitTypeDef GPIO_InitOutput;
  15.  
  16.     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
  17.  
  18.     GPIO_InitPuertoD.GPIO_Pin = GPIO_Pin_All;
  19.     GPIO_InitPuertoD.GPIO_Mode = GPIO_Mode_OUT;
  20.     GPIO_InitPuertoD.GPIO_OType = GPIO_OType_OD;
  21.     GPIO_InitPuertoD.GPIO_Speed = GPIO_Speed_100MHz;
  22.     GPIO_InitPuertoD.GPIO_PuPd = GPIO_NOPULL;
  23.  
  24.     GPIO_Init(GPIOA, &GPIO_InitOutput);  
  25. }
  26.  
  27. int main(){
  28.     config_input();
  29.     config_output();
  30.  
  31.     while(1){
  32.         if(GPIO_ReadInputDataBit(GPIOD,GPIO_Pin_0) && GPIO_ReadInputDataBit(GPIOD,GPIO_Pin_1) && GPIO_ReadInputDataBit(GPIOD,GPIO_Pin_2) ==1){
  33.     GPIO_SetBits(GPIOA,GPIO_Pin_All);
  34.     }
  35.     else{
  36.     GPIO_ResetBits(GPIOA,GPIO_Pin_All);
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement