forked from jadonk/cloud9-examples
-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathblinkExternalLED.pru1_1.c
42 lines (36 loc) · 1.27 KB
/
blinkExternalLED.pru1_1.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
////////////////////////////////////////
// blinkExternalLED.c
// Blinks one LED wired to P9_25 by writing to memory using the PRU
// Wiring: P9_25 connects to the plus lead of an LED. The negative lead of the
// LED goes to a 220 Ohm resistor. The other lead of the resistor goes
// to ground.
// Setup: Set the direction to out on P9_25
// See: prugpio.h to see to which ports the P8 and P9 pins are attached
// PRU: pru1_1
////////////////////////////////////////
#include <stdint.h>
#include <pru_cfg.h>
#include "resource_table_empty.h"
#include "prugpio.h"
volatile register unsigned int __R30;
volatile register unsigned int __R31;
void main(void) {
// Points to the GPIO port that is used
uint32_t *gpio6 = (uint32_t *)GPIO6;
/* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */
CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;
while(1) {
gpio6[GPIO_SETDATAOUT] = P9_25; // Turn the USR1 LED on
__delay_cycles(500000000/5); // Wait 1/2 second
gpio6[GPIO_CLEARDATAOUT] = P9_25; // Off
__delay_cycles(500000000/5);
}
__halt();
}
// Set direction of P9_25 (which is port 6 pin 17)
#pragma DATA_SECTION(init_pins, ".init_pins")
#pragma RETAIN(init_pins)
const char init_pins[] =
"/sys/class/gpio/export\0 177\0" \
"/sys/class/gpio/gpio177/direction\0out\0" \
"\0\0";