How to disable interrupts from JNI code?

34 views
Skip to first unread message

Dave McLaughlin

unread,
Jun 18, 2020, 4:27:40 AM6/18/20
to android-ndk
I need to disable interrupts for no more than 5 to 10us in a JNI library as I need to be sure that the GPIO high pulse gets extended by any other tasks.

I found these Linux functions in another driver but I can't seem to find the header file for it in the NDK.

local_irq_save(flags);
local_irq_restore(flags);

Does anyone know the correct functions and header files to disable interrupts?

Glenn Kasten

unread,
Jun 18, 2020, 10:03:41 AM6/18/20
to android-ndk
Android native code, including JNI, runs in user mode and has no more permissions or capabilities than managed code (Java, Kotlin).
You'll need to write a device driver that runs in kernel mode.

Dave McLaughlin

unread,
Jun 18, 2020, 9:33:01 PM6/18/20
to android-ndk
Thanks Glenn, 

I came across an HX711 driver in one of the Linux github sources so I was able to build this into the Android kernel this morning. I now just need to figure out how to use this and read the data from it.
Reply all
Reply to author
Forward
0 new messages