1
0
mirror of https://github.com/bashrc/LKMPG.git synced 2018-06-11 03:06:54 +02:00

Modified example

This commit is contained in:
Bob Mottram
2017-05-16 18:43:51 +01:00
parent 9dac267b5f
commit 52afed3ffc
3 changed files with 288 additions and 282 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -3553,6 +3553,8 @@ MODULE_DESCRIPTION("Handle some GPIO interrupts");
** Bottom Half ** Bottom Half
Suppose you want to do a bunch of stuff inside of an interrupt routine. A common way to do that without rendering the interrupt unavailable for a significant duration is to combine it with a tasklet. This pushes the bulk of the work off into the scheduler. Suppose you want to do a bunch of stuff inside of an interrupt routine. A common way to do that without rendering the interrupt unavailable for a significant duration is to combine it with a tasklet. This pushes the bulk of the work off into the scheduler.
This modifies the previous example to also run an additional task when an interrupt is triggered.
#+begin_src C file:bottomhalf.c #+begin_src C file:bottomhalf.c
/* /*
* bottomhalf.c - * bottomhalf.c -
@@ -3602,7 +3604,7 @@ DECLARE_TASKLET(buttontask, bottomhalf_tasklet_fn, 0L);
*/ */
static irqreturn_t button_isr(int irq, void *data) static irqreturn_t button_isr(int irq, void *data)
{ {
/* Do something quickly */ /* Do something quickly right now */
if (irq == button_irqs[0] && !gpio_get_value(leds[0].gpio)) if (irq == button_irqs[0] && !gpio_get_value(leds[0].gpio))
gpio_set_value(leds[0].gpio, 1); gpio_set_value(leds[0].gpio, 1);
else if(irq == button_irqs[1] && gpio_get_value(leds[0].gpio)) else if(irq == button_irqs[1] && gpio_get_value(leds[0].gpio))

View File

@@ -46,7 +46,7 @@ DECLARE_TASKLET(buttontask, bottomhalf_tasklet_fn, 0L);
*/ */
static irqreturn_t button_isr(int irq, void *data) static irqreturn_t button_isr(int irq, void *data)
{ {
/* Do something quickly */ /* Do something quickly right now */
if (irq == button_irqs[0] && !gpio_get_value(leds[0].gpio)) if (irq == button_irqs[0] && !gpio_get_value(leds[0].gpio))
gpio_set_value(leds[0].gpio, 1); gpio_set_value(leds[0].gpio, 1);
else if(irq == button_irqs[1] && gpio_get_value(leds[0].gpio)) else if(irq == button_irqs[1] && gpio_get_value(leds[0].gpio))