![NANOTEC PD4-C5918M4204-E-01 Скачать руководство пользователя страница 80](http://html1.mh-extra.com/html/nanotec/pd4-c5918m4204-e-01/pd4-c5918m4204-e-01_manual_3241520080.webp)
Manual PD4-C (USB)
11 Programming with NanoJ
Version: 1.4.1 / 22.07.2016 / FIR-v1626
80
11.6 System calls
11.6.1 Introduction
With system calls, it is possible to call up functions integrated in the firmware directly in a user
program. Because a 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 and the firmware thus has the possibility of temporarily allowing a 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 must be
integrated as usual.
11.6.2 Access to the object directory
•
void od_write(U32 index, U32 sub-index, U32 value)
This function writes the transferred value to the specified point in the object directory.
index
Index of the object being written in the object directory
sub-index
Sub-index of the object being written in the object directory
value
Value to be written
Note
It is strongly advised, to generate processor time with
yield()
after a
od_write()
has been
called up. The value is immediately written to the OD. However, to enable the firmware to trigger
dependent actions, it must receive computing time and therefore the user program must have
been ended or stopped with
yield()
.
•
U32 od_read(U32 index, U32 sub-index)
This function reads the value at the specified point in the object directory and returns it.
index
Index of the object being read in the object directory
sub-index
Sub-index of the object being read in the object directory
Return value
Content of the object dictionary entry
Note
Active waiting for a value in the object directory should always be associated with a
yield()
.
Example:
while (od_read(2400,2) != 0) // wait until 2400:2 is set
yield();
11.6.3 Process control
•
void yield()
This function returns the process time to the operating system. The program is resumed in the next
time slot at the same location.
•
void sleep(U32 ms)
This function returns the process time to the operating system for the specified number of
milliseconds. The user program is then continued at the location following the call.
ms
Wait time in milliseconds