Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Macro for accessing a hardware register (32 bit)
- #define HWREG(x) (*((volatile unsigned int *)(x)))
- volatile register unsigned int __R31;
- int finish = 0;
- int main(int argc, const char *argv[]){
- volatile unsigned int* gpio1_dataout;
- // Enable OCP so we can access the whole memory map for the
- // device from the PRU. Clear bit 4 of SYSCFG register
- HWREG(0x26004) &= 0xFFFFFFEF;
- // GPIO1[21] as an output
- HWREG(0x44e10854) = 0x0f;
- // GPIO1[15] as an output
- HWREG(0x44e1083c) = 0x0f;
- // GPIO1[14] as an output;
- HWREG(0x44e10838) = 0x0f;
- gpio1_dataout = (unsigned int*)(0x4804c000+0x13c);
- while(!finish){
- int i;
- for (i=0; i<2000000; i++);
- *gpio1_dataout |= 1<<21;
- *gpio1_dataout |= 1<<15;
- *gpio1_dataout |= 1<<14;
- for (i=0; i<2000000; i++);
- *gpio1_dataout &= ~(1<<21);
- *gpio1_dataout &= ~(1<<15);
- *gpio1_dataout &= ~(1<<14);
- __R31 = 35;
- }
- // stop pru processing
- __halt();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement