out8.comp

来自「CNC 的开放码,EMC2 V2.2.8版」· COMP 代码 · 共 44 行

COMP
44
字号
component out8;pin out unsigned out_ "Output value; only low 8 bits are used";param r unsigned ioaddr;function _;option count_function;option extra_setup;option extra_cleanup;option constructable no;;;#include <asm/io.h>#define MAX 8int io[MAX] = {0,};RTAPI_MP_ARRAY_INT(io, MAX, "I/O addresses of out8 boards");int get_count(void) {    int i = 0;    for(i=0; i<MAX && io[i]; i++) { /* Nothing */ }    return i;}EXTRA_SETUP() {    if(!rtapi_request_region(io[extra_arg], 1, "out8")) {	// set this I/O port to 0 so that EXTRA_CLEANUP does not release the IO	// ports that were never requested.        io[extra_arg] = 0;         return -EBUSY;    }    ioaddr = io[extra_arg];    return 0;}EXTRA_CLEANUP() {    int i;    for(i=0; i < MAX && io[i]; i++) {        rtapi_release_region(io[i], 1);    }}FUNCTION(_) { outb(out_, ioaddr); }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?