Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. void GPIO_Config(void)
  2. {
  3. //konfigurowanie portow GPIO
  4. GPIO_InitTypeDef GPIO_InitStructure;
  5.  
  6. // disable JTAG
  7. GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
  8.  
  9. /*Tu nalezy umiescic kod zwiazany z konfiguracja poszczegolnych portow GPIO potrzebnych w programie*/
  10.  
  11. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;;
  12. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  13. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //wyjscie push-pull
  14. GPIO_Init(GPIOB, &GPIO_InitStructure);
  15. }
  16.  
  17. void NVIC_Config(void)
  18. {
  19. //Konfigurowanie kontrolera przerwan NVIC
  20.  
  21. NVIC_InitTypeDef NVIC_InitStructure;
  22. NVIC_InitTypeDef NVIC_InitStructure2;
  23.  
  24. #ifdef VECT_TAB_RAM
  25. // Jezeli tablica wektorow w RAM, to ustaw jej adres na 0x20000000
  26. NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
  27. #else // VECT_TAB_FLASH
  28. // W przeciwnym wypadku ustaw na 0x08000000
  29. NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
  30. #endif
  31.  
  32. //Konfiguracja NVIC - ustawienia priorytetow przerwania EXTI0
  33. NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); //Wybor modelu grupowania przerwan
  34.  
  35. NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn; //Wybor konfigurowanego IRQ
  36. NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; //Priorytet grupowy
  37. NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //Podpriorytet
  38. NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //Wlaczenie obslugi IRQ
  39. NVIC_Init(&NVIC_InitStructure);
  40.  
  41. NVIC_InitStructure2.NVIC_IRQChannel = EXTI1_IRQn; //Wybor konfigurowanego IRQ
  42. NVIC_InitStructure2.NVIC_IRQChannelPreemptionPriority = 1; //Priorytet grupowy
  43. NVIC_InitStructure2.NVIC_IRQChannelSubPriority = 0; //Podpriorytet
  44. NVIC_InitStructure2.NVIC_IRQChannelCmd = ENABLE; //Wlaczenie obslugi IRQ
  45. NVIC_Init(&NVIC_InitStructure2);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement