Mercurial > hg > beaglert
diff core/PRU.cpp @ 15:901d205d1a3c
Updated to latest PRU library; external PRU file no longer needed. Also catch SIGTERM as well as SIGINT to clean up gracefully.
author | andrewm |
---|---|
date | Sat, 07 Feb 2015 16:41:56 +0000 |
parents | a6beeba3a648 |
children | 670be80463a3 |
line wrap: on
line diff
--- a/core/PRU.cpp Fri Jan 23 15:35:10 2015 +0000 +++ b/core/PRU.cpp Sat Feb 07 16:41:56 2015 +0000 @@ -18,6 +18,7 @@ #include "../include/pruss_intc_mapping.h" #include "../include/GPIOcontrol.h" #include "../include/render.h" +#include "../include/pru_rtaudio_bin.h" #include <iostream> #include <stdlib.h> @@ -249,7 +250,7 @@ /* Allocate and initialize memory */ prussdrv_init(); - if(prussdrv_open(PRU_EVTOUT_0)) { + if(prussdrv_open(pru_number == 0 ? PRU_EVTOUT_0 : PRU_EVTOUT_1)) { rt_printf("Failed to open PRU driver\n"); return 1; } @@ -331,14 +332,17 @@ } // Run the code image in the specified file -int PRU::start(char * const filename) +int PRU::start() { /* Clear any old interrupt */ - prussdrv_pru_clear_event(pru_number == 0 ? PRU0_ARM_INTERRUPT : PRU1_ARM_INTERRUPT); + if(pru_number == 0) + prussdrv_pru_clear_event(PRU_EVTOUT_0, PRU0_ARM_INTERRUPT); + else + prussdrv_pru_clear_event(PRU_EVTOUT_1, PRU1_ARM_INTERRUPT); /* Load and execute binary on PRU */ - if(prussdrv_exec_program(pru_number, filename)) { - rt_printf("Failed to execute PRU code from %s\n", filename); + if(prussdrv_exec_code(pru_number, PRUcode, sizeof(PRUcode))) { + rt_printf("Failed to execute PRU code\n"); return 1; } @@ -450,8 +454,11 @@ { if(!running) return; - prussdrv_pru_wait_event (PRU_EVTOUT_0); - prussdrv_pru_clear_event(pru_number == 0 ? PRU0_ARM_INTERRUPT : PRU1_ARM_INTERRUPT); + prussdrv_pru_wait_event (pru_number == 0 ? PRU_EVTOUT_0 : PRU_EVTOUT_1); + if(pru_number == 0) + prussdrv_pru_clear_event(PRU_EVTOUT_0, PRU0_ARM_INTERRUPT); + else + prussdrv_pru_clear_event(PRU_EVTOUT_1, PRU1_ARM_INTERRUPT); } // Turn off the PRU when done