Advertisement
Guest User

Untitled

a guest
Aug 11th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. // Macro for accessing a hardware register (32 bit)
  2. #define HWREG(x) (*((volatile unsigned int *)(x)))
  3.  
  4. volatile register unsigned int __R31;
  5.  
  6. int finish = 0;
  7.  
  8. int main(int argc, const char *argv[]){
  9. volatile unsigned int* gpio1_dataout;
  10. // Enable OCP so we can access the whole memory map for the
  11. // device from the PRU. Clear bit 4 of SYSCFG register
  12. HWREG(0x26004) &= 0xFFFFFFEF;
  13.  
  14. // GPIO1[21] as an output
  15. HWREG(0x44e10854) = 0x0f;
  16.  
  17. // GPIO1[15] as an output
  18. HWREG(0x44e1083c) = 0x0f;
  19.  
  20. // GPIO1[14] as an output;
  21. HWREG(0x44e10838) = 0x0f;
  22.  
  23. gpio1_dataout = (unsigned int*)(0x4804c000+0x13c);
  24.  
  25. while(!finish){
  26. int i;
  27.  
  28. for (i=0; i<2000000; i++);
  29. *gpio1_dataout |= 1<<21;
  30. *gpio1_dataout |= 1<<15;
  31. *gpio1_dataout |= 1<<14;
  32. for (i=0; i<2000000; i++);
  33. *gpio1_dataout &= ~(1<<21);
  34. *gpio1_dataout &= ~(1<<15);
  35. *gpio1_dataout &= ~(1<<14);
  36.  
  37. __R31 = 35;
  38. }
  39.  
  40. // stop pru processing
  41. __halt();
  42.  
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement