Advertisement
PomozMi

ptm??

Jan 17th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.75 KB | None | 0 0
  1. #include "stm32f4xx_conf.h"
  2. #include "stm32f4xx_gpio.h"
  3. #include "stm32f4xx_rcc.h"
  4.  
  5.  
  6. int main(void)
  7. {
  8.     //
  9.     /*skonfigurowanie i włączenie generatora sygnału zegarowego,*/
  10.  
  11.     SystemInit();// skonfigurowanie wszystkich sygnałów zegarowych (zegar systemowy, HCLK, PCLK2, PCLK1)
  12.     SystemCoreClockUpdate(); // calculates the current core clock
  13.  
  14.     /* GPIOD Periph clock enable */
  15.     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
  16.     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);
  17.     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
  18.     //
  19.     while (1)
  20.     {
  21.         ///
  22.         // Diody LED
  23.         /* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */ // DIODY LED
  24.         GPIO_InitTypeDef  GPIO_InitStructure;
  25.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
  26.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  27.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  28.         GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  29.         GPIO_Init(GPIOD, &GPIO_InitStructure);
  30.         ///
  31.         //
  32.         unsigned int tmp = 0;
  33.         if (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0) == 1){
  34.             switch (tmp){
  35.             case 0:
  36.                 GPIO_ResetBits(GPIOD, GPIO_Pin_15 | GPIO_Pin_14 | GPIO_Pin_13);
  37.                 GPIO_SetBits(GPIOD, GPIO_Pin_12);
  38.                 tmp++;
  39.                 break;
  40.             case 1:
  41.                 GPIO_SetBits(GPIOD, GPIO_Pin_13);
  42.                 tmp++;
  43.                 break;
  44.             case 2:
  45.                 GPIO_ResetBits(GPIOD, GPIO_Pin_12);
  46.                 tmp++;
  47.                 break;
  48.             case 3:
  49.                 GPIO_SetBits(GPIOD, GPIO_Pin_14);
  50.                 tmp++;
  51.                 break;
  52.             case 4:
  53.                 GPIO_ResetBits(GPIOD, GPIO_Pin_13);
  54.                 tmp++;
  55.                 break;
  56.             case 5:
  57.                 GPIO_SetBits(GPIOD, GPIO_Pin_15);
  58.                 tmp++;
  59.                 break;
  60.             case 6:
  61.                 GPIO_ResetBits(GPIOD, GPIO_Pin_14);
  62.                 tmp++;
  63.                 break;
  64.             case 7:
  65.                 tmp = 0;
  66.                 break;
  67.             }
  68.             for (;;);
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement