Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. /* Includes */
  2. #include <stddef.h>
  3. #include "stm32f10x.h"
  4.  
  5. GPIO_InitTypeDef GPIO_InitStructure;
  6.  
  7.  
  8. void delayLoop() {
  9. volatile uint32_t delayCount = 1000000;
  10.  
  11. while (delayCount > 0) {
  12. delayCount--;
  13. }
  14. }
  15.  
  16. int main(void)
  17. {
  18.  
  19. SystemInit();
  20.  
  21.  
  22. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
  23.  
  24. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
  25. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  26. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  27. GPIO_Init(GPIOA, &GPIO_InitStructure);
  28.  
  29. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
  30. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  31. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  32. GPIO_Init(GPIOA, &GPIO_InitStructure);
  33.  
  34. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
  35. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  36. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  37. GPIO_Init(GPIOA, &GPIO_InitStructure);
  38.  
  39. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
  40. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  41. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  42. GPIO_Init(GPIOA, &GPIO_InitStructure);
  43.  
  44. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
  45. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  46. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  47. GPIO_Init(GPIOA, &GPIO_InitStructure);
  48.  
  49. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
  50. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  51. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  52. GPIO_Init(GPIOA, &GPIO_InitStructure);
  53.  
  54. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
  55. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  56. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  57. GPIO_Init(GPIOA, &GPIO_InitStructure);
  58.  
  59. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
  60. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  61. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  62. GPIO_Init(GPIOA, &GPIO_InitStructure);
  63.  
  64. while(1) {
  65. GPIOA->BSRR = GPIO_Pin_0;
  66. GPIOA->BSRR = GPIO_Pin_1;
  67. GPIOA->BSRR = GPIO_Pin_2;
  68. GPIOA->BSRR = GPIO_Pin_3;
  69. GPIOA->BSRR = GPIO_Pin_10;
  70. GPIOA->BSRR = GPIO_Pin_11;
  71. GPIOA->BSRR = GPIO_Pin_12;
  72. GPIOA->BSRR = GPIO_Pin_15;// LED On
  73. delayLoop();
  74.  
  75. GPIOA->BRR = GPIO_Pin_0;
  76. GPIOA->BRR = GPIO_Pin_1;
  77. GPIOA->BRR = GPIO_Pin_2;
  78. GPIOA->BRR = GPIO_Pin_3;
  79. GPIOA->BRR = GPIO_Pin_10;
  80. GPIOA->BRR = GPIO_Pin_11;
  81. GPIOA->BRR = GPIO_Pin_12;
  82. GPIOA->BRR = GPIO_Pin_15; // LED Off
  83. delayLoop();
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement