forked from deepakkarki/pruspeak
-
Notifications
You must be signed in to change notification settings - Fork 1
/
blinkled.c
58 lines (52 loc) · 2.35 KB
/
blinkled.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/********************************************************************************
* Name: blinkled.c *
* Created By: Siddharth Bharat Purohit *
* PRU C Compiler Version: 2.0.0B1 *
* Description: This example is presented to illustrate the usage of Starterwar *
* library originaly developed for main processor can be utilised for accessing *
* main core's peripheral by PRU. *
*********************************************************************************/
#include <gpio_v2.h>
#include <soc_AM335x.h>
#define PRU0_ARM_INTERRUPT 19
#define GPIO1 (*(volatile unsigned long *)(0x4804c000)) // The address of the GPIO1
#define GPIO_INSTANCE_ADDRESS (SOC_GPIO_1_REGS)
#define SYSCFG (*(&C4+0x01))
int C4 __attribute__((cregister("MEM",near),peripheral)); //only compatible with v1.1.0B1 +
//add following lines to MEMORY{} in lnk.cmd
//PAGE 2:
// MEM : o = 0x00026000 l = 0x00002000 CREGISTER=4
volatile register unsigned int __R31;
void main()
{
/*Intialise OCP Master port for accessing external memories*/
SYSCFG&=0xFFFFFFEF;
/*Start Main Code*/
int i;
while(1) {//remove if an infinite loop is not needed
GPIOPinWrite(GPIO_INSTANCE_ADDRESS, 60, GPIO_PIN_LOW);
GPIOPinWrite(GPIO_INSTANCE_ADDRESS, 31, GPIO_PIN_LOW);
GPIOPinWrite(GPIO_INSTANCE_ADDRESS, 50, GPIO_PIN_LOW);
GPIOPinWrite(GPIO_INSTANCE_ADDRESS, 48, GPIO_PIN_LOW);
for(i=0;i<0x00a00000;i++);
GPIOPinWrite(GPIO_INSTANCE_ADDRESS, 60, GPIO_PIN_HIGH);
GPIOPinWrite(GPIO_INSTANCE_ADDRESS, 31, GPIO_PIN_HIGH);
GPIOPinWrite(GPIO_INSTANCE_ADDRESS, 50, GPIO_PIN_HIGH);
GPIOPinWrite(GPIO_INSTANCE_ADDRESS, 48, GPIO_PIN_HIGH);
for(i=0;i<0x00a00000;i++);
GPIOPinWrite(GPIO_INSTANCE_ADDRESS, 60, GPIO_PIN_LOW);
GPIOPinWrite(GPIO_INSTANCE_ADDRESS, 31, GPIO_PIN_LOW);
GPIOPinWrite(GPIO_INSTANCE_ADDRESS, 50, GPIO_PIN_LOW);
GPIOPinWrite(GPIO_INSTANCE_ADDRESS, 48, GPIO_PIN_LOW);
for(i=0;i<0x00a00000;i++);
GPIOPinWrite(GPIO_INSTANCE_ADDRESS, 60, GPIO_PIN_HIGH);
GPIOPinWrite(GPIO_INSTANCE_ADDRESS, 31, GPIO_PIN_HIGH);
GPIOPinWrite(GPIO_INSTANCE_ADDRESS, 50, GPIO_PIN_HIGH);
GPIOPinWrite(GPIO_INSTANCE_ADDRESS, 48, GPIO_PIN_HIGH);
for(i=0;i<0x00a00000;i++);
}
/*Exiting procedure*/
__R31 = 35; // Send notification to Host for program completion
__halt(); //only compatible with v2.0.0B1 + for lower verions of Compiler use
//asm(" HALT");
}