Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A example replicated and build script working.
- Loading branch information
1 parent
2c5b184
commit e4abc9d
Showing
5 changed files
with
498 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
CROSS_COMPILE?=arm-arago-linux-gnueabi- | ||
|
||
LIBDIR_APP_LOADER?=../../app_loader/lib | ||
INCDIR_APP_LOADER?=../../app_loader/include | ||
BINDIR?=../bin | ||
|
||
CFLAGS+= -Wall -I$(INCDIR_APP_LOADER) -D__DEBUG -O2 -mtune=cortex-a8 -march=armv7-a | ||
LDFLAGS+=-L$(LIBDIR_APP_LOADER) -lprussdrv | ||
OBJDIR=obj | ||
TARGET=$(BINDIR)/PRU_industrialEthernetTimer | ||
|
||
_DEPS = | ||
DEPS = $(patsubst %,$(INCDIR_APP_LOADER)/%,$(_DEPS)) | ||
|
||
_OBJ = PRU_industrialEthernetTimer.o | ||
OBJ = $(patsubst %,$(OBJDIR)/%,$(_OBJ)) | ||
|
||
|
||
$(OBJDIR)/%.o: %.c $(DEPS) | ||
@mkdir -p obj | ||
$(CROSS_COMPILE)gcc $(CFLAGS) -c -o $@ $< | ||
|
||
$(TARGET): $(OBJ) | ||
$(CROSS_COMPILE)gcc $(CFLAGS) -o $@ $^ $(LDFLAGS) | ||
|
||
.PHONY: clean | ||
|
||
clean: | ||
rm -rf $(OBJDIR)/ *~ $(INCDIR_APP_LOADER)/*~ $(TARGET) |
195 changes: 195 additions & 0 deletions
195
pru_sw/example_apps/PRU_industrialEthernetTimer/PRU_industrialEthernetTimer.c
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
/* | ||
* PRU_memAccessPRUDataRam.c | ||
* | ||
* Copyright (C) 2012 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. | ||
* | ||
*/ | ||
|
||
/* | ||
* ============================================================================ | ||
* Copyright (c) Texas Instruments Inc 2010-12 | ||
* | ||
* Use of this software is controlled by the terms and conditions found in the | ||
* license agreement under which this software has been supplied or provided. | ||
* ============================================================================ | ||
*/ | ||
|
||
/***************************************************************************** | ||
* PRU_memAccessPRUDataRam.c | ||
* | ||
* The PRU reads and stores values into the PRU Data RAM memory. PRU Data RAM | ||
* memory has an address in both the local data memory map and global memory | ||
* map. The example accesses the local Data RAM using both the local address | ||
* through a register pointed base address and the global address pointed by | ||
* entries in the constant table. | ||
* | ||
******************************************************************************/ | ||
|
||
|
||
/***************************************************************************** | ||
* Include Files * | ||
*****************************************************************************/ | ||
|
||
#include <stdio.h> | ||
|
||
// Driver header file | ||
#include <prussdrv.h> | ||
#include <pruss_intc_mapping.h> | ||
|
||
/***************************************************************************** | ||
* Explicit External Declarations * | ||
*****************************************************************************/ | ||
|
||
/***************************************************************************** | ||
* Local Macro Declarations * | ||
*****************************************************************************/ | ||
|
||
#define PRU_NUM 0 | ||
#define ADDEND1 0x0010F012u | ||
#define ADDEND2 0x0000567Au | ||
|
||
#define AM33XX | ||
|
||
/***************************************************************************** | ||
* Local Typedef Declarations * | ||
*****************************************************************************/ | ||
|
||
|
||
/***************************************************************************** | ||
* Local Function Declarations * | ||
*****************************************************************************/ | ||
|
||
static int LOCAL_exampleInit ( unsigned short pruNum ); | ||
static unsigned short LOCAL_examplePassed ( unsigned short pruNum ); | ||
|
||
/***************************************************************************** | ||
* Local Variable Definitions * | ||
*****************************************************************************/ | ||
|
||
|
||
/***************************************************************************** | ||
* Intertupt Service Routines * | ||
*****************************************************************************/ | ||
|
||
|
||
/***************************************************************************** | ||
* Global Variable Definitions * | ||
*****************************************************************************/ | ||
|
||
static void *pruDataMem; | ||
static unsigned int *pruDataMem_int; | ||
|
||
/***************************************************************************** | ||
* Global Function Definitions * | ||
*****************************************************************************/ | ||
|
||
int main (void) | ||
{ | ||
unsigned int ret; | ||
tpruss_intc_initdata pruss_intc_initdata = PRUSS_INTC_INITDATA; | ||
|
||
printf("\nINFO: Starting %s example.\r\n", "PRU_memAccessPRUDataRam"); | ||
/* Initialize the PRU */ | ||
prussdrv_init (); | ||
|
||
/* Open PRU Interrupt */ | ||
ret = prussdrv_open(PRU_EVTOUT_0); | ||
if (ret) | ||
{ | ||
printf("prussdrv_open open failed\n"); | ||
return (ret); | ||
} | ||
|
||
/* Get the interrupt initialized */ | ||
prussdrv_pruintc_init(&pruss_intc_initdata); | ||
|
||
/* Initialize example */ | ||
printf("\tINFO: Initializing example.\r\n"); | ||
LOCAL_exampleInit(PRU_NUM); | ||
|
||
/* Execute example on PRU */ | ||
printf("\tINFO: Executing example.\r\n"); | ||
prussdrv_exec_program (PRU_NUM, "./obj/PRU_industrialEthernetTimer.bin"); | ||
|
||
|
||
/* Wait until PRU0 has finished execution */ | ||
printf("\tINFO: Waiting for HALT command.\r\n"); | ||
prussdrv_pru_wait_event (PRU_EVTOUT_0); | ||
printf("\tINFO: PRU completed transfer.\r\n"); | ||
prussdrv_pru_clear_event (PRU_EVTOUT_0, PRU0_ARM_INTERRUPT); | ||
|
||
/* Check if example passed */ | ||
if ( LOCAL_examplePassed(PRU_NUM) ) | ||
{ | ||
printf("INFO: Example executed succesfully.\r\n"); | ||
} | ||
else | ||
{ | ||
printf("INFO: Example failed.\r\n"); | ||
} | ||
|
||
/* Disable PRU and close memory mapping*/ | ||
prussdrv_pru_disable (PRU_NUM); | ||
prussdrv_exit (); | ||
|
||
return(0); | ||
|
||
} | ||
|
||
/***************************************************************************** | ||
* Local Function Definitions * | ||
*****************************************************************************/ | ||
|
||
static int LOCAL_exampleInit ( unsigned short pruNum ) | ||
{ | ||
//Initialize pointer to PRU data memory | ||
if (pruNum == 0) | ||
{ | ||
prussdrv_map_prumem (PRUSS0_PRU0_DATARAM, &pruDataMem); | ||
} | ||
else if (pruNum == 1) | ||
{ | ||
prussdrv_map_prumem (PRUSS0_PRU1_DATARAM, &pruDataMem); | ||
} | ||
pruDataMem_int = (unsigned int*) pruDataMem; | ||
|
||
// Flush the values in the PRU data memory locations | ||
pruDataMem_int[1] = 0x00; | ||
pruDataMem_int[2] = 0x00; | ||
|
||
return(0); | ||
} | ||
|
||
static unsigned short LOCAL_examplePassed ( unsigned short pruNum ) | ||
{ | ||
return ((pruDataMem_int[1] == ADDEND1) & (pruDataMem_int[2] == ADDEND1 + ADDEND2)); | ||
} |
158 changes: 158 additions & 0 deletions
158
pru_sw/example_apps/PRU_industrialEthernetTimer/PRU_industrialEthernetTimer.hp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
// * | ||
// * PRU_memAccessPRUDataRam.hp | ||
// * | ||
// * Copyright (C) 2012 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. | ||
// * | ||
// * | ||
|
||
// * | ||
// * ============================================================================ | ||
// * Copyright (c) Texas Instruments Inc 2010-12 | ||
// * | ||
// * Use of this software is controlled by the terms and conditions found in the | ||
// * license agreement under which this software has been supplied or provided. | ||
// * ============================================================================ | ||
// * | ||
|
||
// *****************************************************************************/ | ||
// file: PRU_memAccessPRUDataRAM.hp | ||
// | ||
// brief: PRU_memAccessPRUDataRam assembly constants. | ||
// | ||
// | ||
// (C) Copyright 2012, Texas Instruments, Inc | ||
// | ||
// author M. Watkins | ||
// | ||
// version 0.1 Created | ||
// *****************************************************************************/ | ||
|
||
|
||
#ifndef _PRU_memAccessPRUDataRAM_HP_ | ||
#define _PRU_memAccessPRUDataRAM_HP_ | ||
|
||
|
||
#define AM33XX | ||
|
||
// *************************************** | ||
// * Global Macro definitions * | ||
// *************************************** | ||
|
||
#ifdef AM33XX | ||
|
||
// Refer to this mapping in the file - \prussdrv\include\pruss_intc_mapping.h | ||
#define PRU0_PRU1_INTERRUPT 17 | ||
#define PRU1_PRU0_INTERRUPT 18 | ||
#define PRU0_ARM_INTERRUPT 19 | ||
#define PRU1_ARM_INTERRUPT 20 | ||
#define ARM_PRU0_INTERRUPT 21 | ||
#define ARM_PRU1_INTERRUPT 22 | ||
|
||
#define CONST_PRUDRAM C24 | ||
#define CONST_L3RAM C30 | ||
#define CONST_DDR C31 | ||
|
||
// Address for the Constant table Programmable Pointer Register 0(CTPPR_0) | ||
#define CTBIR_0 0x22020 | ||
// Address for the Constant table Programmable Pointer Register 0(CTPPR_0) | ||
#define CTBIR_1 0x22024 | ||
|
||
// Address for the Constant table Programmable Pointer Register 0(CTPPR_0) | ||
#define CTPPR_0 0x22028 | ||
// Address for the Constant table Programmable Pointer Register 1(CTPPR_1) | ||
#define CTPPR_1 0x2202C | ||
|
||
#else | ||
|
||
// Refer to this mapping in the file - \prussdrv\include\pruss_intc_mapping.h | ||
#define PRU0_PRU1_INTERRUPT 32 | ||
#define PRU1_PRU0_INTERRUPT 33 | ||
#define PRU0_ARM_INTERRUPT 34 | ||
#define PRU1_ARM_INTERRUPT 35 | ||
#define ARM_PRU0_INTERRUPT 36 | ||
#define ARM_PRU1_INTERRUPT 37 | ||
|
||
#define CONST_PRUDRAM C3 | ||
#define CONST_HPI C15 | ||
#define CONST_DSPL2 C28 | ||
#define CONST_L3RAM C30 | ||
#define CONST_DDR C31 | ||
|
||
// Address for the Constant table Programmable Pointer Register 0(CTPPR_0) | ||
#define CTPPR_0 0x7028 | ||
// Address for the Constant table Programmable Pointer Register 1(CTPPR_1) | ||
#define CTPPR_1 0x702C | ||
|
||
#endif | ||
|
||
.macro LD32 | ||
.mparam dst,src | ||
LBBO dst,src,#0x00,4 | ||
.endm | ||
|
||
.macro LD16 | ||
.mparam dst,src | ||
LBBO dst,src,#0x00,2 | ||
.endm | ||
|
||
.macro LD8 | ||
.mparam dst,src | ||
LBBO dst,src,#0x00,1 | ||
.endm | ||
|
||
.macro ST32 | ||
.mparam src,dst | ||
SBBO src,dst,#0x00,4 | ||
.endm | ||
|
||
.macro ST16 | ||
.mparam src,dst | ||
SBBO src,dst,#0x00,2 | ||
.endm | ||
|
||
.macro ST8 | ||
.mparam src,dst | ||
SBBO src,dst,#0x00,1 | ||
.endm | ||
|
||
|
||
// *************************************** | ||
// * Global Structure Definitions * | ||
// *************************************** | ||
|
||
|
||
// *************************************** | ||
// * Global Register Assignments * | ||
// *************************************** | ||
|
||
|
||
#endif //_PRU_memAccessPRUDataRAM_HP_ |
Oops, something went wrong.