A20 GPIO中斷型別差別結果迥異的問題思考

2021-09-07 22:04:10 字數 3000 閱讀 4843

a20gpio中斷型別差別結果迥異的問題思考

最近在使用全志a20做開發時,發現在處理中斷的時候,用電平觸發模式,報中斷比較亂,用邊沿觸發則很穩定,不會亂報。筆者感到比較困惑,筆者用電平觸發寫的code如下:

reversehandle = sw_gpio_irq_request(greversecar_gpio_hdle.gpio, trig_levl_high, \

&sw_reversecar_irq_handle, &privatedata);

if (!reversehandle)

privatedata.trigtype = trig_levl_high;

static int sw_reversecar_irq_handle(void *para) else if(privatedata.trigtype == trig_levl_low)

sw_gpio_eint_set_enable(greversecar_gpio_hdle.gpio, 1);

return 0;

}

中斷型別設定成debo中斷列印資訊有問題,具體如下:

root@android:/ # [  519.018955] irq sw_reversecar_irq: 2 io:188, value:1

[ 519.024773] irq sw_reversecar_irq: 3 io:188, value:1

[ 519.030576] irq sw_reversecar_irq: 2 io:188, value:1

[ 519.036378] irq sw_reversecar_irq: 3 io:188, value:1

[ 519.042169] irq sw_reversecar_irq: 2 io:188, value:1

[ 520.898643] irq sw_reversecar_irq: 3 io:188, value:0

[ 520.904456] irq sw_reversecar_irq: 2 io:188, value:0

[ 520.910363] irq sw_reversecar_irq: 3 io:188, value:0

[ 520.916215] irq sw_reversecar_irq: 2 io:188, value:0

[ 520.921995] irq sw_reversecar_irq: 3 io:188, value:0

[ 520.927832] irq sw_reversecar_irq: 2 io:188, value:0

[ 520.933612] irq sw_reversecar_irq: 3 io:188, value:0

[ 520.939432] irq sw_reversecar_irq: 2 io:188, value:0

[ 520.945317] irq sw_reversecar_irq: 3 io:188, value:0

用邊沿觸發寫的code如下,

gprivdata.trigtype = trig_edge_positive;

gprivdata.irqreqhandle = sw_gpio_irq_request(gprivdata.gpio_hdle.gpio, trig_edge_positive, \

(peint_handle)&sw_reversecar_irq_handle, (void *)&gprivdata);

static int sw_reversecar_irq_handle(void *para)

up(&gprivdata.sem_lock);

sw_gpio_eint_set_enable(gprivdata.gpio_hdle.gpio, 0);

sw_gpio_eint_clr_irqpd_sta(gprivdata.gpio_hdle.gpio);

if(gprivdata.trigtype == trig_edge_positive) else if(gprivdata.trigtype == trig_edge_negative)

sw_gpio_eint_set_enable(gprivdata.gpio_hdle.gpio, 1);

return 0;

}

edge時還可以設定中斷型別為trig_edge_double,筆者暫時沒有採用,中斷列印資訊正常,如下:

root@android:/ # [  517.116361] irq sw_reversecar_irq: 0 io:188, value:1

[ 518.103095] irq sw_reversecar_irq: 1 io:188, value:0

root@android:/ # [ 520.918512] irq sw_reversecar_irq: 0 io:188, value:1

[ 521.876038] irq sw_reversecar_irq: 1 io:188, value:0

[ 527.796107] irq sw_reversecar_irq: 0 io:188, value:1

[ 528.843397] irq sw_reversecar_irq: 1 io:188, value:0

[ 531.335858] irq sw_reversecar_irq: 0 io:188, value:1

[ 532.306660] irq sw_reversecar_irq: 1 io:188, value:0

[ 534.552011] irq sw_reversecar_irq: 0 io:188, value:1

[ 535.101586] irq sw_reversecar_irq: 1 io:188, value:0

筆者不清楚原因,懷疑是晶元驅動的問題,但是驅動也就那樣寫了啊,難道是晶元設計的問題,當然這種也就是在剛有中斷時會有亂irq上來,如果用delaywork延時一下處理也是可以繞過去的。望哪位大俠清楚的解釋一下。

zynq新增GPIO中斷程式

核心原始碼為adi官方關於ad9361的核心,編譯工具為petalinux2015.2,開發板為zynqxc7z100 一 修改裝置樹 1.開啟petalinux專案下的.project spec meta user recipes dt device tree files system top.d...

export gpio 中斷 使用GPIO監聽中斷

include include include include include include define msg args.printf args 函式宣告 static int gpio export int pin static int gpio unexport int pin stati...

K60 GPIO外部中斷

k60幾乎可以把任意乙個gpio用作外部中斷 要用外部中斷,就要配置好暫存器,寫好中斷函式 我這裡用a口的19號引腳作為按鍵外部中斷檢測,a口的10號引腳做led輸出 void init gpio 第五行的 gpio init struct.gpio isr porta isr 是把中斷函式的名字賦...