Advertisement
voik3

Untitled

Jun 17th, 2019
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1.  
  2. #include "main_base.h"
  3.  
  4. int f = 0;
  5. void mryganie_diody(unsigned int);
  6.  
  7.  
  8.  
  9. int main(void) {
  10.  
  11. RCC->AHB1ENR |= RCC_AHB1Periph_GPIOG;
  12. GPIOG->MODER |= GPIO_Mode_OUT << (14*2);// 1 - output
  13. GPIOG->OTYPER|= GPIO_OType_PP << 14;//0 - push-pull (def.)
  14. GPIOG->PUPDR |= GPIO_PuPd_NOPULL << (14*2);//0 - (default)
  15.  
  16.  
  17.  
  18. GPIOG->MODER |= GPIO_Mode_OUT << (13*2);// 1 - output
  19. GPIOG->OTYPER|= GPIO_OType_PP << 13;//0 - push-pull (def.)
  20. GPIOG->PUPDR |= GPIO_PuPd_NOPULL << (13*2);//0 - (default)
  21.  
  22. RCC->AHB1ENR |= RCC_AHB1Periph_GPIOA;
  23. GPIOA->MODER |= GPIO_Mode_IN; // 0 - input (default)
  24. GPIOA->PUPDR |= GPIO_PuPd_NOPULL ; // 0 - (default)
  25.  
  26. GPIOG->BSRR = 0x4000;
  27.  
  28. while (1) {
  29.  
  30.  
  31. while((GPIOA->IDR&1) ){
  32. f=0;
  33. mryganie_diody(f);
  34.  
  35. for(int g = 0;g<2000000;g++){}
  36. f=1;
  37. while(!(GPIOA->IDR&1) ){}
  38. mryganie_diody(f);
  39.  
  40. for(int K = 0;K<2000000;K++){}
  41.  
  42. }
  43.  
  44. }
  45. // GPIOG->BSRR = GPIO_Pin_14<<16; //0x40000000
  46. //GPIOG->BSRR = GPIO_Pin_13; //0x4000
  47.  
  48.  
  49. }
  50.  
  51.  
  52.  
  53.  
  54.  
  55. --------------------------------------------------------------------------------------------------------------
  56.  
  57.  
  58. .syntax unified
  59. .set PRESCALER_MAX,50
  60. .set PERIPH_BASE,0x40000000
  61. .set AHB1PERIPH_OFFSET, 0x00020000
  62. .set GPIOG_BASE,PERIPH_BASE+AHB1PERIPH_OFFSET+0x1800
  63. .set BSRR_OFFSET,0x18
  64.  
  65.  
  66.  
  67.  
  68.  
  69. .global mryganie_diody
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. .section .text
  79.  
  80.  
  81.  
  82. mryganie_diody:
  83. ldr r3,=GPIOG_BASE+BSRR_OFFSET
  84. mov r1,#0x20000000
  85. mov r4,#0x40000000
  86. mov r2,#0x2000
  87. lsl r2,r2,r0
  88. str r4,[r3]
  89. str r1,[r3]
  90. str r2,[r3]
  91. mov pc,lr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement