8 Programming with NanoJ
#include " wrapper.h"
void user()
{
[...]
Out.controlWord = 1;
[...]
od_write(0x6040, 0x00, 5 ); // der Wert wird durch das Mapping überschrieben
[...]
}
The line with the od_write(0x6040, 0x00, 5 ); command has no effect. As described in the
introduction, all mappings are copied to the object dictionary at the end of each millisecond.
This results in the following sequence:
1. The od_write function writes the value 5 in object 6040
h
:00
h
.
2. At the end of the 1 ms cycle, the mapping is written that also specifies object 6040
h
:00
h
, however, with
the value 1.
3. From the perspective of the user, the od_write command thus serves no purpose.
8.3 System calls in a NanoJ program
With system calls, it is possible to call up functions integrated in the firmware directly from a user program.
Because direct code execution is only possible in the protected area of the sandbox, this is implemented
via so-called Cortex-Supervisor-Calls (Svc Calls). An interrupt is triggered when the function is called. The
firmware thus has the possibility of temporarily allowing code execution outside of the sandbox. Developers
of user programs do not need to worry about this mechanism – for them, the system calls can be called up
like normal C functions. Only the wrapper.h file needs to be integrated as usual.
8.3.1 Accessing the object dictionary
void od_write (U32 index, U32 subindex, U32 value)
This function writes the transferred value to the specified location in the object dictionary.
index Index of the object to be written in the object dictionary
subindex Subindex of the object to be written in the object dictionary
value Value to be written
Note
It is highly recommended that the processor time be passed on with yield() after calling a
od_write(). The value is immediately written to the OD. For the firmware to be able to trigger actions
that are dependent on this, however, it must receive computing time. This, in turn, means that the
user program must either be ended or interrupted with yield().
U32 od_read (U32 index, U32 subindex)
This function reads the value at the specified location in the object dictionary and returns it.
index Index of the object to be read in the object dictionary
subindex Subindex of the object to be read in the object dictionary
Output value Content of the OD entry
Version: 2.0.1 / FIR-v1650 100