Last active
June 30, 2019 14:55
-
-
Save pranav083/68dcbd2d59f6f07ed8a4602373e15cc2 to your computer and use it in GitHub Desktop.
INPUT AT P8_16 PIN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/dts-v1/; | |
/plugin/; | |
/ { | |
compatible = "ti,beaglebone", "ti,beaglebone-black", "ti,beaglebone-green"; | |
// identification | |
part-number = "PRU-GPIO-EXAMPLE2"; | |
version = "00A0"; | |
// resources | |
exclusive-use = | |
"P8.11", | |
"P8.12", | |
"P8.13", | |
"P8.15", | |
"P8.16", | |
// "P8.20", | |
// "P8.21", | |
// "P9.27", | |
"pru0"; | |
// "P9.12", | |
// "P9.24", | |
// "pru1"; | |
// pinmux | |
fragment@0 { | |
target = <&am33xx_pinmux>; | |
__overlay__ { | |
pinctrl_test: PRU-GPIO-EXAMPLE2-pins{ | |
pinctrl-single,pins= < | |
0x018 0x07 /* p8_6 38 gpio1_6 op pd mode7 */ | |
0x01c 0x27 /* p8_7 39 gpio1_7 in pd mode7 */ | |
0x034 0x07 /* p8_11 45 gpio1_13 in pd mode7 */ | |
0x030 0x07 /* p8_12 44 gpio1_12 op pd mode6 */ | |
0x024 0x27 /* p8_13 23 gpio0_23 op pd mode6 */ | |
0x03c 0x47 /* p8_15 47 gpio1_15 op pd mode7 */ | |
0x038 0x27 /* p8_16 46 gpio1_14 in pd mode6 */ | |
/* 0x084 0x05 /* p8_20 63 gpio1_31 in pd mode5 */ | |
/* 0x080 0x05 /* p8_21 62 gpio1_30 in pd mode5 */ | |
/* 0x078 0x0f /* p9_12 60 gpio1_13 op none mode7 */ | |
/* 0x184 0x27 /* p9_24 15 gpio1_28 in pd mode7 */ | |
/* 0x1a4 0x25 /* p9_27 115 gpio3_19 in pd mode5 */ | |
/* OUTPUT GPIO(mode7) 0x07 pulldown, 0x17 pullup, 0x?f no pullup/down */ | |
/* INPUT GPIO(mode7) 0x27 pulldown, 0x37 pullup, 0x?f no pullup/down */ | |
>; | |
}; | |
}; | |
}; | |
//----- PRU | |
fragment@1 { | |
target = <&ocp>; | |
__overlay__ { | |
test_helper: helper { | |
compatible = "bone-pinmux-helper"; | |
status = "okay"; | |
pinctrl-names = "default", "gpio"; | |
pinctrl-0 = <&pinctrl_test>; | |
}; | |
}; | |
}; | |
fragment@2 { | |
target = <&pruss>; | |
__overlay__ { | |
status = "okay"; | |
}; | |
}; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.origin 0 | |
.entrypoint START | |
#define GPIO0 0x44E07000 | |
#define GPIO1 0x4804C000 | |
#define GPIO2 0x481AC000 | |
#define GPIO3 0x481AE000 | |
#define GPIO_OE 0x134 | |
#define GPIO_DATAIN 0x138 | |
#define GPIO_CLEARDATAOUT 0x190 | |
#define GPIO_SETDATAOUT 0x194 | |
#define INS_PER_MS 200 * 1000 | |
#define ON_DURATION 250 * INS_PER_MS | |
#define OFF_DURATION 250 * INS_PER_MS | |
// set up a value that has a 1 in bit 24. We will later use this to toggle the state of LED3 | |
#define GPIO1_LED3BIT 1<<24 | |
#define BUTTON 14 /* P8_16 46 GPIO 1_14 mode 7 */ | |
#define BULB 12 /* P8_12 44 GPIO 1_12 mode 7 */ | |
#define CPRUCFG c4 | |
// this label is where the code execution starts | |
START: | |
// Enable the OCP master port, | |
lbco r0, CPRUCFG, 4, 4 // read SYSCFG | |
clr r0.t4 // clear SYSCFG[STANDBY_INIT] | |
sbco r0, CPRUCFG, 4, 4 // enable OCP master port; | |
//set OUT pin to ouput | |
MOV r3, GPIO1 | GPIO_OE | |
LBBO r2, r3, 0, 4 | |
CLR r2, r2, 12 // setting as a output pin | |
SBBO r2, r3, 0, 4 | |
//set OUT pin to ouput | |
MOV r3, GPIO1 | GPIO_OE | |
LBBO r2, r3, 0, 4 | |
SET r2, r2, 14 // setting as a output pin | |
SBBO r2, r3, 0, 4 | |
//set IN pin to INPUT | |
MOV r3, GPIO1 | GPIO_DATAIN | |
LBBO r2, r3, 0, 4 | |
//setting the register for data high and low for GPIO0 | |
MOV r5, GPIO1 | GPIO_SETDATAOUT | |
MOV r4, GPIO1 | GPIO_CLEARDATAOUT | |
L1: | |
//set IN pin to INPUT | |
MOV r3, GPIO1 | GPIO_DATAIN | |
LBBO r2, r3, 0, 4 | |
// Now monitor the state of R31 bit 14, this corresponds to header 8 pin 16 | |
QBBS LED_HIGH, r2.t14 // if the bit is high, jump to LED_HIGH | |
QBBC LED_LOW, r2.t14 // if the bit is low, jump to LED_LOW | |
JMP L1 // we should never get here unless the bit | |
// changes between tests | |
LED_HIGH: | |
//Setting the value for the out pin | |
MOV r2, 1 << 12 //move out pin to | |
SBBO r2, r4, 0, 4 // the p8_12 pin is low | |
JMP L1 // test again | |
LED_LOW: | |
//Setting the value for the out pin | |
MOV r2, 1 << 12 //move out pin to | |
SBBO r2, r5, 0, 4 // the p8_12 pin is HIGH | |
JMP L1 // test again | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment