• Wed 2021.04.07

    Continuation of thread Using low level access PPI on MDBT42Q breakout board from 2020.
    (can't believe a year has passed!)

    After a quick review of a basic 'Hello World' ARM Cortex M4 programming,

    htt ps://www.youtube.com/watch?v=w3M3oDBsIXs­

    rather than follow that flash process, I'd like to extend a function, or create a new suite of functions to solve the following:

    Ultimate project goal would read and write user programmable pulse generation, both in pulse width, duration and count. I require much finer control than what is currently apparent.

    Following the datasheet, it appears I need to bit control registers of this peripheral:

    p.238 25 RTC — Real-time counter


    Knowing that function digitalWrite() must do something similar, I tried to track down how that process is done.

    From jswrap_io.h I have located that declaration:
    L22 void jswrap_io_digitalWrite(JsVar *pinVar, JsVarInt value);
    The definition may found in the corresponding source:
    L267 void jswrap_io_digitalWrite()
    the actual pin output appears to be at:
    L277 jshPinOutput(jshGetPinFromVar(pinPtr), value&1);
    from which jspin.c that function source may be found:
    L258 void jshPinOutput(
    and within that function the actual output value:
    L263 jshPinSetValue(pin, value);

    but dead ends at L104 jshardware.h function declaration page.

    Tried again with the function(s) I'd most likely need to modify or recreate:

    L219 void jswrap_io_digitalPulse(Pin pin, bool value, JsVar *times)
    L225 jshPinPulse(pin, value, time);

    This too dead ends at L199 jshardware.h

    At this point my assumption is that there is an internal modulue, say 'native.c' that contains that functionality, but that guess is way off as on close inspection, there isn't a reference in that file either. What process/procedure allows/maps these functions to the output pins? Where/what is code to map function jshPinSetValue() to control the hardware pin?

    Over a year ago, I was successful at a basic build just using a GitHub clone of Espruino, but unable to locate my notes on how I did that, then. Maybe the flash page perhaps?

    So my hunch is I clone jswrap_io , modify as required and eliminate all errors until successful.

    I'm seeking a basic overview of what file content is necessary, along with some basic guidance on what is needed to create a new developer defined pulse function, where to put it (do I clone the exisiting jswrap_io.c/.h edit and use those modified files in my project?) and how to manipulate the bits within registers according to the Nordic nRF52 datasheet. Maybe it is as simple as L18 void jswrap_io_poke() and if so, is there a suitable example that can get me over that ledge?

    Thank you


Avatar for Robin @Robin started