Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #include <stdint.h>
  2. #include <stddef.h>
  3. #include "register_def.h"
  4.  
  5. #include "inc\hw_memmap.h"
  6. #include "inc\hw_gpio.h"
  7. #include "inc\hw_apps_rcm.h"
  8. #include "inc\hw_ocp_shared.h"
  9.  
  10. void delay_1sec(void)
  11. {
  12. __asm(" PUSH {r4-r12,lr}");
  13.  
  14. __asm(" LDR r4, [pc, #12]");
  15.  
  16. __asm(" MOV r5, pc");
  17. __asm(" NOP");
  18.  
  19. __asm(" SUBS r4, #1"); /* 1 instruction cycle */
  20. __asm(" ITE NEQ"); /* 1 instruction cycle */
  21.  
  22. __asm(" MOV pc, r5"); /* 1 + P instructions (where P is between 1 and 3 depending on pipeline refill) */
  23.  
  24.  
  25. __asm(" POP {r4-r12,pc}");
  26. __asm(" .word 5000000");
  27. }
  28.  
  29. int main(void)
  30. {
  31.  
  32. HWREG(ARCM_BASE + APPS_RCM_O_GPIO_A_CLK_GATING) = 0x01;
  33.  
  34. HWREG(OCP_SHARED_BASE + OCP_SHARED_O_GPIO_PAD_CONFIG_9) = 0x60;
  35. HWREG(OCP_SHARED_BASE + OCP_SHARED_O_GPIO_PAD_CONFIG_10) = 0x60;
  36. HWREG(OCP_SHARED_BASE + OCP_SHARED_O_GPIO_PAD_CONFIG_11) = 0x60;
  37.  
  38. HWREG(GPIOA1_BASE + GPIO_O_GPIO_DIR) = 0x0E;
  39. HWREG(GPIOA1_BASE + GPIO_O_GPIO_DATA + (0x0E << 2)) = 0x00;
  40.  
  41. int index = 0;
  42.  
  43. while(1)
  44. {
  45. HWREG(GPIOA1_BASE + GPIO_O_GPIO_DATA + (0x0E << 2)) = (index << 1);
  46. index = (index + 1) % 16;
  47. delay_1sec();
  48. }
  49.  
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement