Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Commit c4a51c22 authored by Jason Kridner's avatar Jason Kridner
Browse files

books/pru-cookbook: move code to submodule

parent 41ab321a
Branches
Tags
2 merge requests!40Merge BeaglePlay and latest BeagleConnect documentation,!36Jason's lateast updates
Showing
with 3 additions and 1000 deletions
[submodule "books/beaglebone-cookbook/code"]
path = books/beaglebone-cookbook/code
url = https://git.beagleboard.org/beagleboard/beaglebone-cookbook-code.git
[submodule "books/pru-cookbook/code"]
path = books/pru-cookbook/code
url = https://git.beagleboard.org/beagleboard/pru-cookbook-code
/* From: https://simppru.readthedocs.io/en/latest/examples/led_blink/ */
while : 1 == 1 {
digital_write(P1_31, true);
delay(250); /* Delay 250 ms */
digital_write(P1_31, false);
delay(250);
}
#!/usr/bin/env python3
"""A demo client for Open Pixel Control
http://github.com/zestyping/openpixelcontrol
Runs an LED around in a circle
"""
import time
import opc
ADDRESS = 'localhost:7890'
# Create a client object
client = opc.Client(ADDRESS)
# Test if it can connect
if client.can_connect():
print('connected to %s' % ADDRESS)
else:
# We could exit here, but instead let's just print a warning
# and then keep trying to send pixels in case the server
# appears later
print('WARNING: could not connect to %s' % ADDRESS)
# Send pixels forever
STR_LEN=16
for i in range(STR_LEN):
leds = [(0, 0, 0)] * STR_LEN
leds[0] = (0, 127, 0)
while True:
tmp = leds[0]
for i in range(STR_LEN-1):
leds[i] = leds[i+1]
leds[-1] = tmp
if client.put_pixels(leds, channel=0):
print('sent')
else:
print('not connected')
time.sleep(0.1)
#!/usr/bin/env python3
# Controls a NeoPixel (WS2812) string via E1.31 and FPP
# https://pypi.org/project/sacn/
# https://github.com/FalconChristmas/fpp/releases
import sacn
import time
# provide an IP-Address to bind to if you are using Windows and want to use multicast
sender = sacn.sACNsender("192.168.7.1")
sender.start() # start the sending thread
sender.activate_output(1) # start sending out data in the 1st universe
sender[1].multicast = False # set multicast to True
sender[1].destination = "192.168.7.2" # or provide unicast information.
sender.manual_flush = True # turning off the automatic sending of packets
# Keep in mind that if multicast is on, unicast is not used
LEDcount = 24
# Have green fade is as it goes
data = []
for i in range(LEDcount):
data.append(0) # Red
data.append(i) # Green
data.append(0) # Blue
sender[1].dmx_data = data
sender.flush()
time.sleep(0.5)
# Turn off all LEDs
data=[]
for i in range(3*LEDcount):
data.append(0)
sender.flush()
sender[1].dmx_data = data
time.sleep(0.5)
# Have red fade in
data = []
for i in range(LEDcount):
data.append(i)
data.append(0)
data.append(0)
sender[1].dmx_data = data
sender.flush()
time.sleep(0.25)
# Make LED circle 5 times
for j in range(15):
for i in range(LEDcount-1):
data[3*i+0] = 0
data[3*i+1] = 0
data[3*i+2] = 0
data[3*i+3] = 0
data[3*i+4] = 64
data[3*i+5] = 0
sender[1].dmx_data = data
sender.flush()
time.sleep(0.02)
# Wrap around
i = LEDcount-1
data[0] = 0
data[1] = 64
data[2] = 0
data[3*i+0] = 0
data[3*i+1] = 0
data[3*i+2] = 0
sender[1].dmx_data = data
sender.flush()
time.sleep(0.02)
time.sleep(2) # send the data for 10 seconds
sender.stop() # do not forget to stop the sender
#!/bin/bash
# Configure the pins based on which Beagle is running
machine=$(awk '{print $NF}' /proc/device-tree/model)
echo -n $machine
# Configure eQEP pins
if [ $machine = "Black" ]; then
echo " Found"
pins="P9_92 P9_27 P8_35 P8_33 P8_12 P8_11 P8_41 P8_42"
elif [ $machine = "Blue" ]; then
echo " Found"
pins=""
elif [ $machine = "PocketBeagle" ]; then
echo " Found"
pins="P1_31 P2_34 P2_10 P2_24 P2_33"
else
echo " Not Found"
pins=""
fi
for pin in $pins
do
echo $pin
config-pin $pin qep
config-pin -q $pin
done
##########################################
# Configure PRU pins
if [ $machine = "Black" ]; then
echo " Found"
pins="P8_16 P8_15"
elif [ $machine = "Blue" ]; then
echo " Found"
pins=""
elif [ $machine = "PocketBeagle" ]; then
echo " Found"
pins="P2_09 P2_18"
else
echo " Not Found"
pins=""
fi
for pin in $pins
do
echo $pin
config-pin $pin pruin
config-pin -q $pin
done
File deleted
# Instructions for installing BeagleLogic
# https://beaglelogic.readthedocs.io/en/latest/index.html
# From: https://github.com/abhishek-kakkar/BeagleLogic/wiki
# beaglelogic is installed on the 4.9 kernel, but not the 4.14, so
# if you are running 4.14, switch to 4.9
sudo /opt/scripts/tools/update_kernel.sh --lts-4_9
sudo reboot
git clone https://github.com/abhishek-kakkar/BeagleLogic
cd BeagleLogic
sudo ./install.sh
sudo reboot
# Now the kernel driver headers
sudo apt install linux-headers-`uname -r`
modinfo beaglelogic
modprobe beaglelogic
# From: https://beaglelogic.readthedocs.io/en/latest
# Here's what works from abhishek
git clone https://github.com/abhishek-kakkar/BeagleLogic
cd BeagleLogic
# 1. Get the dts file from this gist (https://gist.github.com/abhishek-kakkar/0761ef7b10822cff4b3efd194837f49c)
# 2. cd to 'BeagleLogic/kernel' directory. Put the dts file there. (edited)
# 3. Run 'make overlay'
# 4. Run 'sudo cp -v beaglelogic-00A0.dtbo /lib/firmware/' (edited)
# 5. Run 'sudo update-initramfs -u -k ``uname -r``' (edited)
# (single backticks only, apparently Slack treats single backtick as code) (edited)
# 6. Reboot
# 7. Browse to bone:4000
/*
* Source Modified by Zubeen Tolani < ZeekHuge - zeekhuge@gmail.com >
* Based on the examples distributed by TI
*
* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdint.h>
#include <pru_cfg.h>
#include "resource_table_pru1.h"
// The function is defined in pru1_asm_blinky.asm in same dir
// We just need to add a declaration here, the defination can be
// seperately linked
extern void start(void);
void main(void)
{
/* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */
CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;
start();
}
{
"outputMode": "ws281x",
"outputMapping": "original-ledscape",
"demoMode": "fade",
"ledsPerStrip": 16,
"usedStripCount": 1,
"colorChannelOrder": "BRG",
"opcTcpPort": 7890,
"opcUdpPort": 7890,
"enableInterpolation": false,
"enableDithering": false,
"enableLookupTable": true,
"lumCurvePower": 2.0000,
"whitePoint": {
"red": 0.9000,
"green": 1.0000,
"blue": 1.0000
}
}
#!/usr/bin/env python
"""Python Client library for Open Pixel Control
http://github.com/zestyping/openpixelcontrol
Sends pixel values to an Open Pixel Control server to be displayed.
http://openpixelcontrol.org/
Recommended use:
import opc
# Create a client object
client = opc.Client('localhost:7890')
# Test if it can connect (optional)
if client.can_connect():
print('connected to %s' % ADDRESS)
else:
# We could exit here, but instead let's just print a warning
# and then keep trying to send pixels in case the server
# appears later
print('WARNING: could not connect to %s' % ADDRESS)
# Send pixels forever at 30 frames per second
while True:
my_pixels = [(255, 0, 0), (0, 255, 0), (0, 0, 255)]
if client.put_pixels(my_pixels, channel=0):
print('...')
else:
print('not connected')
time.sleep(1/30.0)
"""
import socket
import struct
import sys
SET_PIXEL_COLOURS = 0 # "Set pixel colours" command (see openpixelcontrol.org)
class Client(object):
def __init__(self, server_ip_port, long_connection=True, verbose=False):
"""Create an OPC client object which sends pixels to an OPC server.
server_ip_port should be an ip:port or hostname:port as a single string.
For example: '127.0.0.1:7890' or 'localhost:7890'
There are two connection modes:
* In long connection mode, we try to maintain a single long-lived
connection to the server. If that connection is lost we will try to
create a new one whenever put_pixels is called. This mode is best
when there's high latency or very high framerates.
* In short connection mode, we open a connection when it's needed and
close it immediately after. This means creating a connection for each
call to put_pixels. Keeping the connection usually closed makes it
possible for others to also connect to the server.
A connection is not established during __init__. To check if a
connection will succeed, use can_connect().
If verbose is True, the client will print debugging info to the console.
"""
self.verbose = verbose
self._long_connection = long_connection
self._ip, self._port = server_ip_port.split(':')
self._port = int(self._port)
self._socket = None # will be None when we're not connected
def _debug(self, m):
if self.verbose:
print(' %s' % str(m))
def _ensure_connected(self):
"""Set up a connection if one doesn't already exist.
Return True on success or False on failure.
"""
if self._socket:
self._debug('_ensure_connected: already connected, doing nothing')
return True
try:
self._debug('_ensure_connected: trying to connect...')
self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._socket.settimeout(1)
self._socket.connect((self._ip, self._port))
self._debug('_ensure_connected: ...success')
return True
except socket.error:
self._debug('_ensure_connected: ...failure')
self._socket = None
return False
def disconnect(self):
"""Drop the connection to the server, if there is one."""
self._debug('disconnecting')
if self._socket:
self._socket.close()
self._socket = None
def can_connect(self):
"""Try to connect to the server.
Return True on success or False on failure.
If in long connection mode, this connection will be kept and re-used for
subsequent put_pixels calls.
"""
success = self._ensure_connected()
if not self._long_connection:
self.disconnect()
return success
def put_pixels(self, pixels, channel=0):
"""Send the list of pixel colors to the OPC server on the given channel.
channel: Which strand of lights to send the pixel colors to.
Must be an int in the range 0-255 inclusive.
0 is a special value which means "all channels".
pixels: A list of 3-tuples representing rgb colors.
Each value in the tuple should be in the range 0-255 inclusive.
For example: [(255, 255, 255), (0, 0, 0), (127, 0, 0)]
Floats will be rounded down to integers.
Values outside the legal range will be clamped.
Will establish a connection to the server as needed.
On successful transmission of pixels, return True.
On failure (bad connection), return False.
The list of pixel colors will be applied to the LED string starting
with the first LED. It's not possible to send a color just to one
LED at a time (unless it's the first one).
"""
self._debug('put_pixels: connecting')
is_connected = self._ensure_connected()
if not is_connected:
self._debug('put_pixels: not connected. ignoring these pixels.')
return False
# build OPC message
command = SET_PIXEL_COLOURS
header = struct.pack('>BBH', channel, SET_PIXEL_COLOURS, len(pixels)*3)
pieces = [struct.pack(
'BBB',
min(255, max(0, int(r))),
min(255, max(0, int(g))),
min(255, max(0, int(b)))
) for r, g, b in pixels]
if bytes is str:
message = header + ''.join(pieces)
else:
message = header + b''.join(pieces)
self._debug('put_pixels: sending pixels to server')
try:
self._socket.send(message)
except socket.error:
self._debug('put_pixels: connection lost. could not send pixels.')
self._socket = None
return False
if not self._long_connection:
self._debug('put_pixels: disconnecting')
self.disconnect()
return True
;*
;* Copyright (C) 2016 Zubeen Tolani <ZeekHuge - zeekhuge@gmail.com>
;*
;* This file is as an example to show how to develope
;* and compile inline assembly code for PRUs
;*
;* This program is free software; you can redistribute it and/or modify
;* it under the terms of the GNU General Public License version 2 as
;* published by the Free Software Foundation.
.cdecls "main_pru1.c"
DELAY .macro time, reg
LDI32 reg, time
QBEQ $E?, reg, 0
$M?: SUB reg, reg, 1
QBNE $M?, reg, 0
$E?:
.endm
.clink
.global start
start:
LDI R30, 0xFFFF
DELAY 10000000, r11
LDI R30, 0x0000
DELAY 10000000, r11
; JMP start
; HALT
; these pin definitions are specific to SD-101C Robotics Cape
.asg r30.t8, CH1BIT ; P8_27
.asg r30.t10, CH2BIT ; P8_28
.asg r30.t9, CH3BIT ; P8_29
.asg r30.t11, CH4BIT ; P8_30
.asg r30.t6, CH5BIT ; P8_39
.asg r30.t7, CH6BIT ; P8_40
.asg r30.t4, CH7BIT ; P8_41
.asg r30.t5, CH8BIT ; P8_42
.asg C4, CONST_SYSCFG
.asg C28, CONST_PRUSHAREDRAM
.asg 0x22000, PRU0_CTRL
.asg 0x24000, PRU1_CTRL ; page 19
.asg 0x28, CTPPR0 ; page 75
.asg 0x000, OWN_RAM
.asg 0x020, OTHER_RAM
.asg 0x100, SHARED_RAM ; This is so prudebug can find it.
LBCO &r0, CONST_SYSCFG, 4, 4 ; Enable OCP master port
CLR r0, r0, 4 ; Clear SYSCFG[STANDBY_INIT] to enable OCP master port
SBCO &r0, CONST_SYSCFG, 4, 4
; Configure the programmable pointer register for PRU0 by setting c28_pointer[15:0]
LDI r0, SHARED_RAM ; Set C28 to point to shared RAM
LDI32 r1, PRU1_CTRL + CTPPR0 ; Note we use beginning of shared ram unlike example which
SBBO &r0, r1, 0, 4 ; page 25
LDI r9, 0x0 ; erase r9 to use to use later
LDI r0, 0x0 ; clear internal counters
LDI r1, 0x0
LDI r2, 0x0
LDI r3, 0x0
LDI r4, 0x0
LDI r5, 0x0
LDI r6, 0x0
LDI32 r7, 0x0
LDI r30, 0x0 ; turn off GPIO outputs
; Beginning of loop, should always take 48 instructions to complete
CH1:
QBEQ CLR1, r0, 0 ; If timer is 0, jump to clear channel
SET r30, CH1BIT ; If non-zero turn on the corresponding channel
SUB r0, r0, 1 ; Subtract one from timer
CLR r9, r9.t1 ; waste a cycle for timing
SBCO &r9, CONST_PRUSHAREDRAM, 0, 4 ; write 0 to shared memory
CH2:
QBEQ CLR2, r1, 0
SET r30, CH2BIT
SUB r1, r1, 1
CLR r9, r9.t1
SBCO &r9, CONST_PRUSHAREDRAM, 4, 4
CH3:
QBEQ CLR3, r2, 0
SET r30, CH3BIT
SUB r2, r2, 1
CLR r9, r9.t1
SBCO &r9, CONST_PRUSHAREDRAM, 8, 4
CH4:
QBEQ CLR4, r3, 0
SET r30, CH4BIT
SUB r3, r3, 1
CLR r9, r9.t1
SBCO &r9, CONST_PRUSHAREDRAM, 12, 4
CH5:
QBEQ CLR5, r4, 0
SET r30, CH5BIT
SUB r4, r4, 1
CLR r9, r9.t1
SBCO &r9, CONST_PRUSHAREDRAM, 16, 4
CH6:
QBEQ CLR6, r5, 0
SET r30, CH6BIT
SUB r5, r5, 1
CLR r9, r9.t1
SBCO &r9, CONST_PRUSHAREDRAM, 20, 4
CH7:
QBEQ CLR7, r6, 0
SET r30, CH7BIT
SUB r6, r6, 1
CLR r9, r9.t1
SBCO &r9, CONST_PRUSHAREDRAM, 24, 4
CH8:
QBEQ CLR8, r7, 0
SET r30, CH8BIT
SUB r7, r7, 1
SBCO &r9, CONST_PRUSHAREDRAM, 28, 4
QBA CH1 ; return to beginning of loop
; no need to waste a cycle for timing here because of the QBA above
CLR1:
CLR r30, CH1BIT ; turn off the corresponding channel
LBCO &r0, CONST_PRUSHAREDRAM, 0, 4 ; Load new timer register
QBA CH2
CLR2:
CLR r30, CH2BIT
LBCO &r1, CONST_PRUSHAREDRAM, 4, 4
QBA CH3
CLR3:
CLR r30, CH3BIT
LBCO &r2, CONST_PRUSHAREDRAM, 8, 4
QBA CH4
CLR4:
CLR r30, CH4BIT
LBCO &r3, CONST_PRUSHAREDRAM, 12, 4
QBA CH5
CLR5:
CLR r30, CH5BIT
LBCO &r4, CONST_PRUSHAREDRAM, 16, 4
QBA CH6
CLR6:
CLR r30, CH6BIT
LBCO &r5, CONST_PRUSHAREDRAM, 20, 4
QBA CH7
CLR7:
CLR r30, CH7BIT
LBCO &r6, CONST_PRUSHAREDRAM, 24, 4
QBA CH8
CLR8:
CLR r30, CH8BIT
LBCO &r7, CONST_PRUSHAREDRAM, 28, 4
QBA CH1 ; return to beginning of loop
/*
*
* servo tester
* (c) Copyright 2016
* Mark A. Yoder, 20-July-2016
*
*/
#include <stdio.h>
#include <fcntl.h>
#include <sys/mman.h>
#include "robotics_cape_defs.h"
#define PRU_ADDR 0x4A300000 // Start of PRU memory Page 184 am335x TRM
#define PRU_LEN 0x80000 // Length of PRU memory
#define PRU_SHAREDMEM 0x10000 // Offset to shared memory
unsigned int *prusharedMem_32int_ptr; // Points to the start of the shared memory
/*******************************************************************************
* int send_servo_pulse_us(int ch, int us)
*
* Sends a single pulse of duration us (microseconds) to a single channel (ch)
*******************************************************************************/
int send_servo_pulse_us(int ch, int us) {
// Sanity Checks
if(ch<1 || ch>SERVO_CHANNELS){
printf("ERROR: Servo Channel must be between 1&%d\n", SERVO_CHANNELS);
return -1;
} if(prusharedMem_32int_ptr == NULL){
printf("ERROR: PRU servo Controller not initialized\n");
return -1;
}
// PRU runs at 200Mhz. find #loops needed
unsigned int num_loops = ((us*200.0)/PRU_SERVO_LOOP_INSTRUCTIONS);
// printf("num_loops: %d\n", num_loops);
// write to PRU shared memory
prusharedMem_32int_ptr[ch-1] = num_loops;
return 0;
}
int main(int argc, char *argv[])
{
unsigned int *pru; // Points to start of PRU memory.
int fd;
printf("Servo tester\n");
fd = open ("/dev/mem", O_RDWR | O_SYNC);
if (fd == -1) {
printf ("ERROR: could not open /dev/mem.\n\n");
return 1;
}
pru = mmap (0, PRU_LEN, PROT_READ | PROT_WRITE, MAP_SHARED, fd, PRU_ADDR);
if (pru == MAP_FAILED) {
printf ("ERROR: could not map memory.\n\n");
return 1;
}
close(fd);
printf ("Using /dev/mem.\n");
prusharedMem_32int_ptr = pru + PRU_SHAREDMEM/4; // Points to start of shared memory
// while(1) {
// printf("value to store: ");
// scanf("%d", &value);
// printf("Storing: %d in %lx\n", value, addr);
// pru[addr/4] = value;
// }
int i;
while(1) {
for(i=1; i<=SERVO_CHANNELS; i++) {
send_servo_pulse_us(i, 10*i);
}
usleep(200);
}
if(munmap(pru, PRU_LEN)) {
printf("munmap failed\n");
} else {
printf("munmap succeeded\n");
}
}
#!/bin/bash
# Configure the PRU pins based on which Beagle is running
machine=$(awk '{print $NF}' /proc/device-tree/model)
echo -n $machine
if [ $machine = "Black" ]; then
echo " Found"
pins="P8_27 P8_28 P8_29 P8_30 P8_39 P8_40 P8_41 P8_42"
elif [ $machine = "Blue" ]; then
echo " Found"
pins=""
elif [ $machine = "PocketBeagle" ]; then
echo " Found"
pins="P2_35 P1_35 P1_02 P1_04"
else
echo " Not Found"
pins=""
fi
for pin in $pins
do
echo $pin
config-pin $pin pruout
config-pin -q $pin
done
\ No newline at end of file
include /var/lib/cloud9/common/Makefile
Here are some differences between the AI and the Black for the PRU.
Black
/sys/devices/platform/ocp/
4a326004.pruss-soc-bus/
4a300000.pruss/
4a334000.pru/remoteproc/remoteproc1
4a338000.pru/remoteproc/remoteproc2
AI
/sys/devices/platform/44000000.ocp/
4b226004.pruss-soc-bus/
4b200000.pruss/
4b234000.pru/remoteproc/remoteproc0
4b238000.pru/remoteproc/remoteproc1
4b2a6004.pruss-soc-bus/
4b280000.pruss/
4b2b4000.pru/remoteproc/remoteproc2
4b2b8000.pru/remoteproc/remoteproc3
LED addresses
https://github.com/beagleboard/BeagleBoard-DeviceTrees/blob/v4.19.x-ti/src/arm/am5729-beagleboneai.dts#L134-L171
led0 {
label = "beaglebone:green:usr0";
gpios = <&gpio3 17 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "heartbeat";
default-state = "off";
};
led1 {
label = "beaglebone:green:usr1";
gpios = <&gpio5 5 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "mmc0";
default-state = "off";
};
led2 {
label = "beaglebone:green:usr2";
gpios = <&gpio3 15 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "cpu";
default-state = "off";
};
led3 {
label = "beaglebone:green:usr3";
gpios = <&gpio3 14 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "mmc1";
default-state = "off";
};
led4 {
label = "beaglebone:green:usr4";
gpios = <&gpio3 7 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "phy0assoc";
GPIO Addresses: Page 404 for TRM
\ No newline at end of file
#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) {
int i;
uint32_t *gpio1 = (uint32_t *)GPIO1;
/* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */
CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;
for(i=0; i<10; i++) {
gpio1[GPIO_SETDATAOUT] = USR3; // The the USR3 LED on
__delay_cycles(500000000/5); // Wait 1/2 second
gpio1[GPIO_CLEARDATAOUT] = USR3;
__delay_cycles(500000000/5);
}
__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";
#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) {
int i;
uint32_t *gpio3 = (uint32_t *)GPIO3;
/* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */
CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;
for(i=0; i<10; i++) {
gpio3[GPIO_SETDATAOUT] = USR3; // The the USR3 LED on
__delay_cycles(500000000/5); // Wait 1/2 second
gpio3[GPIO_CLEARDATAOUT] = USR3;
__delay_cycles(500000000/5);
}
__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";
#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) {
int i;
uint32_t *gpio1 = (uint32_t *)GPIO1;
/* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */
CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;
for(i=0; i<10; i++) {
gpio1[GPIO_SETDATAOUT] = USR1; // The the USR3 LED on
gpio1[GPIO_CLEARDATAOUT] = USR2;
// __R30 |= gpio; // Set the GPIO pin to 1
__delay_cycles(500000000/5); // Wait 1/2 second
gpio1[GPIO_CLEARDATAOUT] = USR1;
gpio1[GPIO_SETDATAOUT] = USR2;
// __R30 &= ~gpio; // Clearn the GPIO pin
__delay_cycles(500000000/5);
}
__halt();
}
// Turns off triggers
#pragma DATA_SECTION(init_pins, ".init_pins")
#pragma RETAIN(init_pins)
const char init_pins[] =
"/sys/class/leds/beaglebone:green:usr1/trigger\0none\0" \
"/sys/class/leds/beaglebone:green:usr2/trigger\0none\0" \
"\0\0";
#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) {
int i;
uint32_t *gpio1 = (uint32_t *)GPIO1;
/* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */
CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;
for(i=0; i<10; i++) {
gpio1[GPIO_SETDATAOUT] = USR1; // The the USR3 LED on
gpio1[GPIO_CLEARDATAOUT] = USR2;
// __R30 |= gpio; // Set the GPIO pin to 1
__delay_cycles(500000000/5); // Wait 1/2 second
gpio1[GPIO_CLEARDATAOUT] = USR1;
gpio1[GPIO_SETDATAOUT] = USR2;
// __R30 &= ~gpio; // Clearn the GPIO pin
__delay_cycles(500000000/5);
}
__halt();
}
// Turns off triggers
#pragma DATA_SECTION(init_pins, ".init_pins")
#pragma RETAIN(init_pins)
const char init_pins[] =
"/sys/class/leds/beaglebone:green:usr1/trigger\0none\0" \
"/sys/class/leds/beaglebone:green:usr2/trigger\0none\0" \
"\0\0";
#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) {
int i;
// uint32_t *gpio1 = (uint32_t *)GPIO1;
// uint32_t *gpio2 = (uint32_t *)GPIO2;
uint32_t *gpio3 = (uint32_t *)GPIO3;
// uint32_t *gpio4 = (uint32_t *)GPIO4;
uint32_t *gpio5 = (uint32_t *)GPIO5;
uint32_t *gpio6 = (uint32_t *)GPIO6;
// uint32_t *gpio7 = (uint32_t *)GPIO7;
uint32_t *gpio8 = (uint32_t *)GPIO8;
// Select which pins to toggle. These are all on pru1_1
uint32_t gpio = P9_16 | P8_15 | P8_16 | P8_26;
/* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */
CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;
for(i=0; i<100; i++) {
gpio5[GPIO_SETDATAOUT] = USR1; // Turn the USR1 LED on
gpio3[GPIO_CLEARDATAOUT] = USR2;
gpio8[GPIO_SETDATAOUT] = P8_17;
gpio6[GPIO_SETDATAOUT] = P9_25;
__R30 |= gpio; // Set the GPIO pin to 1
__delay_cycles(500000000/5); // Wait 1/2 second
gpio5[GPIO_CLEARDATAOUT] = USR1;
gpio3[GPIO_SETDATAOUT] = USR2;
gpio8[GPIO_CLEARDATAOUT] = P8_17;
gpio6[GPIO_CLEARDATAOUT] = P9_25;
__R30 &= ~gpio; // Clear the GPIO pin
__delay_cycles(500000000/5);
if((__R31&P8_19) == P8_19) {
gpio3[GPIO_CLEARDATAOUT] = USR3; // Turn on LED
} else
gpio3[GPIO_SETDATAOUT] = USR3; // Turn off 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:usr1/trigger\0none\0" \
"/sys/class/leds/beaglebone:green:usr2/trigger\0none\0" \
"/sys/class/gpio/export\0 177\0" \
"/sys/class/gpio/gpio177/direction\0out\0" \
"\0\0";
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment