Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <stm32f10x.h>
  2.  
  3. #define LLG (1 << 0)
  4. #define LG (1 << 1)
  5. #define RG (1 << 2)
  6. #define RRG (1 << 3)
  7. #define LY (1 << 4)
  8. #define RY (1 << 5)
  9. #define LR (1 << 6)
  10. #define RR (1 << 7)
  11. #define OFF 8
  12.  
  13.  
  14. void Delay(u32 uiTDel)
  15. {
  16. while (uiTDel--) {}
  17. }
  18.  
  19. // ===== Function main() =================================================
  20. int main(void)
  21. { // ?????????? ???????????? ????? ? ? ????? ?
  22. // (? (??????)??????? ???? ?????? ?? ?????? ?????????? ?????? User ? ???????)
  23. RCC->APB2ENR |= RCC_APB2ENR_IOPAEN | RCC_APB2ENR_IOPCEN;
  24.  
  25. // ????????? ?????? "?????" ??? ??????????
  26. GPIOA->CRL = 0x33333333; // ????? PC8 - ??? ?????????? USER ?? Discovery
  27. char arr =
  28. {
  29. (LG|RR),
  30. (LY|RY),
  31. (LR|RG),
  32. (LY|RY),
  33. };
  34.  
  35. char pos = 0;
  36. char prev = 0;
  37. while(1)
  38. {
  39. GPIOA->BSRR ^= arr[prev] << OFF;
  40. GPIOA->BSRR ^= arr[pos];
  41. Delay(1000000);
  42. prev = pos;
  43. pos = (++pos) % arr.size();
  44. }
  45. // return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement