Siêu thị PDFTải ngay đi em, trời tối mất

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 5 ppt
MIỄN PHÍ
Số trang
25
Kích thước
105.0 KB
Định dạng
PDF
Lượt xem
769

Embedded FreeBSD Cookbook phần 5 ppt

Nội dung xem thử

Mô tả chi tiết

86 Embedded FreeBSD

Cookbook

and PCI interrupt disable. Each bit of the Interrupt Status register is defined

in Table 5-6.

Bit Description Value

0 Interrupt Enable 0 disabled, 1 enabled

1 Interrupt Polarity 0 active low, 1 active high

2 Interrupt Status 0 interrupt not active, 1 interrupt active

3 Reserved NA

4 Reserved NA

5 Reserved NA

6 PCI Interrupt Enable 0 disabled, 1 enabled

7 Reserved NA

8 Reserved NA

9 Reserved NA

10 Interrupt Clear Writing a 1 clears this interrupt

31:11 Reserved NA

Table 5-6. Interrupt Status Register

The Interrupt Status Register contains bits that program the controller

interrupt, enable and disable the controller interrupt, and provide the

interrupt status.

The interrupt enable bit, bit 0, enables or disables the controller interrupt;

when set to 1, the interrupt is enabled; otherwise, it is disabled.

Interrupt polarity bit, bit 1, controls the type of interrupt. This bit controls

on which edge the interrupt is active, low to high transition, or high to low

transition. The default is active high.

The interrupt status bit, bit 2, provides us with a status bit to determine if

an interrupt is active.

The PCI interrupt bit, bit 6, controls the PCI interrupt enable. A value of 1

enables PCI interrupts; 0 disables the PCI interrupts.

Writing to the Interrupt clear, bit 10, clears a pending interrupt.

87 Chapter Five

Midlevel Interface Library

The DIO24 Application Interface Library

The implementation of the DIO24 Interface library consists of four functional

categories. Each functional category is related to programming the different

features of the controller. The categories are register utilities, reading and

writing the digital IO lines, programming the configuration register, and pro￾gramming the interrupt controller. Each of the following sections addresses

the functions for the functional category.

The dio_get and dio_set Functions

All accesses to the PCI-DIO24 hardware registers are provided by two

internal library functions, dio_get and dio_set. These two functions are

responsible for obtaining a file descriptor to the device, if necessary; packing

the data into the ioctl structure; and making the appropriate ioctl call to

the driver.

static int32_t dio_get(int32_t reg, int32_t *pval)

static int32_t dio_set(int32_t reg, int32_t val)

The implementation of each of these functions is similar. Listing 5-1 demon￾strates how the file descriptor to the device driver is obtained. If the internal

file descriptor variable diofd is not set, the function attempts to open the

device and obtain a file descriptor using the following code.

/* if the device is not open, open it */

if (diofd == -1)

{

diofd = open(“/dev/dio0”, O_RDWR);

if (diofd == -1)

{

return(-1);

}

}

Listing 5-1

Once a valid file descriptor is obtained, the code packages the request into

the appropriate ioctl structure. Recall from the previous chapter that all

ioctl to the DIO device driver accept a dioreg_t structure, containing

the dioreg_t size, register, and value for the ioctl. The register structure

used by the DIO device driver is shown in Listing 5-2.

Tải ngay đi em, còn do dự, trời tối mất!