Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Embedded FreeBSD Cookbook phần 7 pps
Nội dung xem thử
Mô tả chi tiết
136 Embedded FreeBSD
Cookbook
}
else
{
printf(“illegal state\n”);
return;
}
if (dio_set_int(s) != 0)
{
printf(“set int failed\n”);
}
}
Listing 7-7
The int_handler function parses the user input looking for either the
enable or disable string to determine the interrupt setting. If the user input
is correct, dio_set_int is called to set the interrupt state.
The pciint_handler Function
The pciint_handler function is used to set pci interrupts. The pciint
command is entered using the following syntax,
> pciint value
where value is either the string enable or disable.
void
pciint_handler(char* args, uint8_t* p)
{
char state[32];
DIOintstate_t s;
sscanf(args, “%*s %s”, state);
if ((strcmp(state, “enable”) == 0) || (strcmp(state, “ENABLE”)
== 0))
{
s = enable;
}
else if ((strcmp(state, “disable”) == 0) || (strcmp(state,
“DISABLE”) == 0))
{
s = disable;
137 Chapter Seven
Remote Management
}
else
{
printf(“illegal state\n”);
return;
}
if (dio_set_pciint(s) != 0)
{
printf(“set pciint failed\n”);
}
}
Listing 7-8
The pciint_handler function parses the user input looking for either the
enable or disable string to determine the interrupt setting. If the user input
is correct, dio_set_pciint is called to set the interrupt state.
The setpolarity_handler Function
The setpolarity_handler function is used to set the interrupt polarity.
The set polarity command is entered using the following syntax:
> setpol value
where value is either high or low.
void
setpolarity_handler(char* args, uint8_t* p)
{
char state[32];
DIOpolarity_t polarity;
sscanf(args, “%*s %s”, state);
if ((strcmp(state, “hi”) == 0) || (strcmp(state, “HI”)) == 0)
{
polarity = activehi;
}
else if ((strcmp(state, “lo”) == 0) || (strcmp(state, “LO”))
== 0)
{
polarity = activelo;
}