我试图通过使用函数通过结构传递端口地址,但我不知道如何更正指针的工作。这是我的结构和函数的代码:
typedef struct {
read:1;
last_read:1;
changed:1;
unsigned short *port; //Here the declaration of the pointer that will receive the address
pin:1;
active_state:1;
} Input;
void Setup_input(Input s,char *port, char pin, char active_state){
s.port = &port; //HERE I TRY TO PASS THE ADDRESS OF THE PORT TO THE POINTER OBJECT
s.pin = pin;
s.active_state = active_state;
事实证明,我做的不正确,我无法正确读取或控制 PORT。我正在使用 Mikroelectronic PRO 编译器。