📄 piolib.h
字号:
#include "daadioLib.h"#include "semLib.h"#include "msgQLib.h"/************************************************** PUBLIC**************************************************/#define PIO_MAX_PORTS 6#define PIO_MAX_CHANNELS_PER_PORT 8#define ON 1#define OFF 0#define PORT_A 0#define PORT_B 1#define PORT_C 2#define PORT_D 3#define PORT_E 4#define PORT_F 5typedef struct { int port; /* port number */ int channel; /* channel number */ BOOL state; /* current state of channel, i.e. ON or OFF */ ULONG timeStamp; /* current tick count from tickGet() */ } PIO_MSG_Q_DATA;/************************************************** PRIVATE**************************************************//* Offset of PIO registers */#define PIO_OFFSET 0x20/* Offset of output enable register */#define PIO_OUTPUT_ENABLE_OFFSET 0x27/* Offset of pattern register */#define PIO_PATTERN_REG_OFFSET 0x65/* Offset of PORT A register */#define PIO_PORT_A_OFFSET 0x21#define PIO_POLL_DELAY 1/* To obtain a port register offset we need to add PIO_OFFSET plus the port number with bit 0 inverted. This is due to each even numbered port is at an address one higher than its odd brethern, i.e. Port A (0) is at offset 0x21 while Port B (1) is at 0x20. */#define PIO_PORT_NUM_TO_OFF(port) (PIO_OFFSET + (int)(((port) & ~1) + \ (((port) & 1) ^ 1)))typedef struct { MSG_Q_ID intMsgQId; /* messsage queue ID used by ISR */ SEM_ID mutexSem; /* mutual exclusion semaphore */ BOOL initialized; /* indicates if PIO module initialized */ } PIO;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -