📄 test3a.c
字号:
#include "pioLib.h"#define MAX_TEST_CHANNELS 3SEM_ID semId[MAX_TEST_CHANNELS];STATUS test3A (testFunc, arg) FUNCPTR testFunc; int arg; { int tid[MAX_TEST_CHANNELS]; STATUS testATask(); int i; pioInit (0x3e); for (i=0; i<MAX_TEST_CHANNELS; i++) { if ((semId[i] = semBCreate (SEM_Q_FIFO, SEM_EMPTY)) == NULL) return (ERROR); if (pioSetInputMode (PIO_PORT_A, i, PIO_TYPE_POLL, PIO_ACTION_RELEASE_SEM, PIO_STATE_CHANGED, semId[i]) == ERROR) return (ERROR); if ((tid[i] = taskSpawn ("tTestA", 200, 0, 5000, testATask, i)) == ERROR) return (ERROR); } if (testFunc) { (*testFunc)(arg); /* wait for tasks to process input */ taskDelay(2); for (i=0; i<MAX_TEST_CHANNELS; i++) { if (pioSetInputMode (PIO_PORT_A, i, PIO_TYPE_IGNORE, PIO_ACTION_RELEASE_SEM, PIO_STATE_CHANGED, semId[i]) == ERROR) return (ERROR); taskDelete (tid[i]); if (semDelete (semId[i]) == ERROR) return (ERROR); } } return (OK); }STATUS testATask (channel) int channel; { BOOL state; FOREVER { if (semTake (semId[channel], WAIT_FOREVER) == ERROR) return (ERROR); state = pioIsOn (PIO_PORT_A, channel); pioSet (PIO_PORT_B, channel, state); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -