Advertisement
voik3

Untitled

Jul 2nd, 2019
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. C:
  2. #include "main_base.h"
  3.  
  4. unsigned short int dioda();
  5.  
  6. int main(void) {
  7.     // to jest jednorazowa konfiguracja
  8.         RCC->AHB1ENR |= RCC_AHB1Periph_GPIOG;
  9.         GPIOG->MODER |= GPIO_Mode_OUT << (14*2);// 1 - output
  10.         GPIOG->OTYPER|= GPIO_OType_PP << 14;//0 - push-pull (def.)
  11.         GPIOG->PUPDR |= GPIO_PuPd_NOPULL << (14*2);//0 - (default)
  12.         RCC->AHB1ENR |= RCC_AHB1Periph_GPIOG;
  13.         GPIOG->MODER |= GPIO_Mode_OUT << (13*2);// 1 - output
  14.         GPIOG->OTYPER|= GPIO_OType_PP << 13;//0 - push-pull (def.)
  15.         GPIOG->PUPDR |= GPIO_PuPd_NOPULL << (13*2);//0 - (default)
  16.         RCC->AHB1ENR |= RCC_AHB1Periph_GPIOA;
  17.         GPIOA->MODER |= GPIO_Mode_IN; // 0 - input (default)
  18.         GPIOA->PUPDR |= GPIO_PuPd_NOPULL ; // 0 - (default)
  19.     while (1) {
  20.         GPIOG->BSRR = 0x80004000;   // dodany początek 0x8000 gaszący diodę PG14
  21.         if(GPIOA->IDR&1)
  22.             dioda();
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement