This file contains 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
# this program function must be added to the prussd.py daemon and then a seperate userspace program will be written in cpp | |
import struct | |
'''frequency = input("Frequency of PWM in Hz (from 1Hz to 1Mhz): ") | |
multiplier = 1000000.0/frequency | |
duty_cycle = input("Duty Cycle of PWM ") | |
on_samples = duty_cycle * 100 |
This file contains 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
#include <stdint.h> | |
#include <pru_cfg.h> | |
#include <math.h> | |
#include "resource_table_empty.h" | |
#define PRU_SHARED 0x00010000 | |
extern void start(void); | |
void main(void){ |
This file contains 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
;* 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 |
This file contains 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
;* 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 |
This file contains 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
#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 |
This file contains 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
;****************************************************************************** | |
;* 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) |
This file contains 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
/* | |
* 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. |
This file contains 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
/* | |
* 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. |
This file contains 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
#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 |
This file contains 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
#include "pruss.h" | |
using namespace std; | |
Socket::Socket() | |
{ | |
this->fd = -1; | |
this->socketpath = "/tmp/prussd.sock"; | |
} |