📄 intro.3hal
字号:
.TH intro "3hal" "2006-10-12" "EMC Documentation" "HAL".SH NAMEhal \- Introduction to the HAL API.SH DESCRIPTIONHAL stands for Hardware Abstraction Layer, and is used by EMC to transferrealtime data to and from I/O devices and other low-level modules.\fBhal.h\fR defines the API and data structures used by the HAL. This file isincluded in both realtime and non-realtime HAL components. HAL uses the RTPAIreal time interface, and the #define symbols RTAPI and ULAPI are used todistinguish between realtime and non-realtime code. The API defined in thisfile is implemented in hal_lib.c and can be compiled for linking to eitherrealtime or user space HAL components. The HAL is a very modular approach to the low level parts of a motion controlsystem. The goal of the HAL is to allow a systems integrator to connect agroup of software components together to meet whatever I/O requirements he (orshe) needs. This includes realtime and non-realtime I/O, as well as basicmotor control up to and including a PID position loop. What these functionshave in common is that they all process signals. In general, a signal is adata item that is updated at regular intervals. For example, a PID loop getsposition command and feedback signals, and produces a velocity command signal. HAL is based on the approach used to design electronic circuits. Inelectronics, off-the-shelf components like integrated circuits are placed on acircuit board and their pins are interconnected to build whatever overallfunction is needed. The individual components may be as simple as an op-amp,or as complex as a digital signal processor. Each component can beindividually tested, to make sure it works as designed. After the componentsare placed in a larger circuit, the signals connecting them can still bemonitored for testing and troubleshooting.Like electronic components, HAL components have pins, and the pins can beinterconnected by signals.In the HAL, a \fIsignal\fR contains the actual data value that passes from one pinto another. When a signal is created, space is allocated for the data value.A \fIpin\fR on the other hand, is a pointer, not a data value. When a pin isconnected to a signal, the pin's pointer is set to point at the signal's datavalue. This allows the component to access the signal with very littlerun-time overhead. (If a pin is not linked to any signal, the pointer pointsto a dummy location, so the realtime code doesn't have to deal with nullpointers or treat unlinked variables as a special case in any way.)There are three approaches to writing a HAL component. Those that do notrequire hard realtime performance can be written as a single user mode process.Components that need hard realtime performance but have simple configurationand init requirements can be done as a single kernel module, using eitherpre-defined init info, or insmod-time parameters. Finally, complex componentsmay use both a kernel module for the realtime part, and a user space process tohandle ini file access, user interface (possibly including GUI features), andother details.HAL uses the RTAPI/ULAPI interface. If RTAPI is #defined hal_lib.c wouldgenerate a kernel module hal_lib.o that is insmoded and provides the functionsfor all kernel module based components. The same source file compiled with theULAPI #define would make a user space hal_lib.o that is staticlly linked touser space code to make user space executables. The variable lists and linkinformation are stored in a block of shared memory and protected with mutexes,so that kernel modules and any of several user mode programs can access thedata..SH HAL STATUS CODES.TPHAL_SUCCESS call successful.TPHAL_UNSUP function not supported .TPHAL_BADVAR duplicate or not-found variable name .TPHAL_INVAL invalid argument .TPHAL_NOMEM not enough memory .TPHAL_LIMIT resource limit reached .TPHAL_PERM permission denied .TPHAL_BUSY resource is busy or locked .TPHAL_NOTFND object not found .TPHAL_FAIL operation failed .SH SEE ALSO\fBintro(3rtapi)\fR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -