Reputation: 1305
With a Beaglebone black, using the PRU, I have to send an event to the binary code, which is just looping. The binary (assembly) must understand the event and stop the execution sending an event back to PRU_example.c.
PRU_example.c ...
/* Load and execute binary on PRU */
prussdrv_exec_program (PRU_NUM, "./PRU_example.bin");
sleep(1);
?? prussdrv_pru_send_event ( ?? ); //kill PRU_example.bin
PRU_example.p
...
LOOP:
jmp LOOP // Jump to the lable LOOP
...
HALT
I suppose to use the function prussdrv_pru_send_event, but how is the code in the assembly?
Upvotes: 2
Views: 340
Reputation: 1305
c++
#include "prussdrv.h"
#include <pruss_intc_mapping.h>
prussdrv_exec_program (PRU_NUM, "./PRU_example.bin");
sleep(1);
prussdrv_pru_send_event(ARM_PRU0_INTERRUPT);
//wait till it will be completed
prussdrv_pru_wait_event (PRU_EVTOUT_0);
prussdrv_pru_clear_event (PRU_EVTOUT_0, PRU0_ARM_INTERRUPT );
/* Disable PRU and close memory mapping*/
prussdrv_pru_disable(PRU_NUM);
prussdrv_exit ();
.p
#define PRU0_R31_VEC_VALID 32 // allows notification of program completion
#define PRU_EVTOUT_0 3 // the event number is sent back
.macro MOV32
.mparam dst, src
MOV dst.w0, src & 0xFFFF
MOV dst.w2, src >> 16
.endm
#define temp32reg r10 // temporary register 4bytes
// clear interrupt
MOV32 temp32reg, (0x00000000 | 21)
SBCO temp32reg, CONST_PRUSSINTC, SICR_OFFSET, 4
LOOP:
...
QBBS END, r31,30 // Exit when receive an interrupt
JMP LOOP
END:
MOV R31.b0, PRU0_R31_VEC_VALID | PRU_EVTOUT_0 // Send and output interrupt
HALT
Upvotes: 2