Beaglebone black ,使用 PRU ,我必须向二进制代码发送一个事件,这只是循环播放。 二进制(程序集)必须理解事件并停止执行将事件发送回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
我想使用函数 prussdrv_pru_send_event ,但程序集中的代码如何?
答案 0 :(得分:2)
C ++
#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
.P
class DownloadFileFromURL extends AsyncTask<Object, String, Integer> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected void onCancelled() {
super.onCancelled();
}
/**
* Downloading file in background thread
* */
@Override
protected Integer doInBackground(Object... params) {
try {
URL url = new URL((String) params[1]);
name = ((String) params[1]).substring(((String) params[1])
.lastIndexOf("/") + 1);
// Log.v("log_tag", "name Substring ::: " + name);
URLConnection conection = url.openConnection();
conection.connect();
// getting file length
int lenghtOfFile = conection.getContentLength();
// input stream to read file - with 8k buffer
InputStream input = new BufferedInputStream(url.openStream(),
8192);
File download = new File(Environment.getExternalStorageDirectory()
+ "/download/");
if (!download.exists()) {
download.mkdir();
}
String strDownloaDuRL = download + "/" + name;
Log.v("log_tag", " down url " + strDownloaDuRL);
FileOutputStream output = new FileOutputStream(strDownloaDuRL);
byte data[] = new byte[1024];
long total = 0;
}
// flushing output
output.flush();
// closing streams
output.close();
input.close();
} catch (Exception e) {
Log.e("Error: ", e.getMessage());
}
return 0;
}
protected void onPostExecute(String file_url) {
// Do after downloaded file
}
}