Skip to content

Instantly share code, notes, and snippets.

@alexanderhiam
Last active June 14, 2016 19:51
Show Gist options
  • Save alexanderhiam/e9237b835feae932d973 to your computer and use it in GitHub Desktop.
Save alexanderhiam/e9237b835feae932d973 to your computer and use it in GitHub Desktop.
BeagleBone PRU remote procedure call concept
#include "pru_rpc.h"
/* This is a function that supports remote calling from the kernel or userspace.
*/
PRU_RPC_return_code RPC_digitalWrite(PRU_RPC_args *args) {
uint8_t pin, state;
if (PRU_RPC_ParseArgs(args, "bb", &pin, &state) < 0) {
return PRU_RPC_INVALID_ARGS;
}
if (state) {
__R30 |= ( 1 << pin);
}
else {
__R30 &= ~( 1 << pin);
}
return PRU_RPC_SUCCESS;
}
void rpcInit() {
// Register the function to be called with the name digitalWrite:
PRU_RPC_RegisterFunction("digitalWrite", RPC_digitalWrite);
// That could also tell the kernel driver that there is a "digitalWrite"
// procedure available, so it could then tell userspace applications what
// remote calls the currently loaded firmware supports
}
int main() {
rpcInit();
while(1) {
// Do other stuff here, the RPC driver will automatically call RPC_digitalWrite
//if it gets the "digitalWrite" command from the kernel
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment