mirror of
https://github.com/bashrc/LKMPG.git
synced 2018-06-11 03:06:54 +02:00
Modified example
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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))
|
||||||
|
|||||||
@@ -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))
|
||||||
|
|||||||
Reference in New Issue
Block a user