Skip to content

Instantly share code, notes, and snippets.

View pratimugale's full-sized avatar

Pratim Ugale pratimugale

View GitHub Profile
@pratimugale
pratimugale / main.c
Created June 23, 2019 15:25 — forked from shirriff/main.c
Example code using a timer with the BeagleBone Black's PRU microcontroller. This code generates 5 pulses with 100ns width.
/*
* Demonstration of the BeagleBone's PRU, using a timer.
* Ken Shirriff, http://righto.com
*/
#include <stdint.h>
#define DELAY_NS 100 // Use 500000000 for 0.5 second delay
#define WRITE_PIN 15 /* P8_11, Ethernet output data, pr1_PRU0_pru_r30_15 */
// PRU Interrupt control registers
@pratimugale
pratimugale / main.c
Created July 2, 2019 15:40
Demonstration of writing to PRU shared memory using RPMsg to communicate between ARM and PRU.
* Copyright (C) 2016-2018 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.
@pratimugale
pratimugale / prussd.py
Created July 7, 2019 02:01
Writing raw data using RPMsg
#!/usr/bin/python3
# prussd.py - Daemon to process PRU access requests
# for non-root processes
#
# Copyright (c) 2018 Mohammed Muneeb
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3 as published by
# the Free Software Foundation.
@pratimugale
pratimugale / pruss.cpp
Created July 7, 2019 02:10
For raw data
#include "pruss.h"
using namespace std;
Socket::Socket()
{
this->fd = -1;
this->socketpath = "/tmp/prussd.sock";
}
@pratimugale
pratimugale / pruss.h
Created July 7, 2019 02:12
For raw data
#ifndef PRUSS_H_
#define PRUSS_H_
#include <stdlib.h>
#include <linux/limits.h> // realpath
#include <string> // string handling
#include <sys/socket.h> // socket
#include <sys/un.h> // socket
#include <unistd.h> // close()
#include <errno.h> // error codes
/*
* Copyright (C) 2016-2018 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.
/*
* Copyright (C) 2016-2018 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.
;******************************************************************************
;* PRU C/C++ Codegen Unix v2.1.5 *
;* Date/Time created: Wed Jul 17 08:36:15 2019 *
;******************************************************************************
.compiler_opts --abi=eabi --endian=little --hll_source=on --object_format=elf --silicon_version=3 --symdebug:dwarf --symdebug:dwarf_version=3
$C$DW$CU .dwtag DW_TAG_compile_unit
.dwattr $C$DW$CU, DW_AT_name("main_pru0.c")
.dwattr $C$DW$CU, DW_AT_producer("TI PRU C/C++ Codegen Unix v2.1.5 Copyright (c) 2012-2017 Texas Instruments Incorporated")
.dwattr $C$DW$CU, DW_AT_TI_version(0x01)
#include "driver_lib.h"
#include <iostream>
using namespace std;
int main(){
Driver& d = Driver::get();
d.wake();
d.activateMotor(360.0, 60.0, FULL, ANTICLOCKWISE); // 360 degrees at 60 RPM in full step mode in anticlockwise direction
;* Source written by Pratim Ugale <pratim.ugale@gmail.com>
;* This example is used to control a stepper motor by sending out precise number of pulse trains at required frequency(RPM).
;* The 4 byte ON_Cycles input must be in memory location 0x00010000 - 0x00010003 in little-endian byte order
;* The 4 byte Total_Cycles input must be in memory location 0x00010004 - 0x00010007 in little endian byte order
;* The 4 byte Number of Pulses input must be in memory location 0x00010008 - 0x000100011 in little-endian byte order
.cdecls "main_pru0.c"
PRU_SRAM .set 0x00010000 ; Set the location of PRU Shared Memory