forked from jadonk/cloud9-examples
-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathinputR31.pru1_1.c
37 lines (32 loc) · 1023 Bytes
/
inputR31.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
////////////////////////////////////////
// inputR31.c
// Reads input in P8_19 via the R31 register and blinks the USR3 LED
// Wiring: Wire a switch between P8_19 and 3.3V (P9_3 or P9_4)
// Setup: None
// See: prugpio.h to see which pins attach to R31
// 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) {
uint32_t *gpio3 = (uint32_t *)GPIO3;
/* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */
CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;
while(1) {
if(__R31 & P8_19) {
gpio3[GPIO_SETDATAOUT] = USR3; // Turn off LED
} else
gpio3[GPIO_CLEARDATAOUT] = USR3; // Turn on LED
}
__halt();
}
// Turns off triggers
#pragma DATA_SECTION(init_pins, ".init_pins")
#pragma RETAIN(init_pins)
const char init_pins[] =
"/sys/class/leds/beaglebone:green:usr3/trigger\0none\0" \
"\0\0";