Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
4b60779d
Commit
4b60779d
authored
Oct 21, 2009
by
Mike Frysinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Blackfin: add an example showing how to use the gptimers API
Signed-off-by:
Mike Frysinger
<
vapier@gentoo.org
>
parent
7a1a8cc1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
0 deletions
+89
-0
Documentation/blackfin/Makefile
Documentation/blackfin/Makefile
+6
-0
Documentation/blackfin/gptimers-example.c
Documentation/blackfin/gptimers-example.c
+83
-0
No files found.
Documentation/blackfin/Makefile
0 → 100644
View file @
4b60779d
obj-m
:=
gptimers-example.o
all
:
modules
modules clean
:
$(MAKE)
-C
../..
SUBDIRS
=
$(PWD)
$@
Documentation/blackfin/gptimers-example.c
0 → 100644
View file @
4b60779d
/*
* Simple gptimers example
* http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:gptimers
*
* Copyright 2007-2009 Analog Devices Inc.
*
* Licensed under the GPL-2 or later.
*/
#include <linux/interrupt.h>
#include <linux/module.h>
#include <asm/gptimers.h>
#include <asm/portmux.h>
/* ... random driver includes ... */
#define DRIVER_NAME "gptimer_example"
struct
gptimer_data
{
uint32_t
period
,
width
;
};
static
struct
gptimer_data
data
;
/* ... random driver state ... */
static
irqreturn_t
gptimer_example_irq
(
int
irq
,
void
*
dev_id
)
{
struct
gptimer_data
*
data
=
dev_id
;
/* make sure it was our timer which caused the interrupt */
if
(
!
get_gptimer_intr
(
TIMER5_id
))
return
IRQ_NONE
;
/* read the width/period values that were captured for the waveform */
data
->
width
=
get_gptimer_pwidth
(
TIMER5_id
);
data
->
period
=
get_gptimer_period
(
TIMER5_id
);
/* acknowledge the interrupt */
clear_gptimer_intr
(
TIMER5_id
);
/* tell the upper layers we took care of things */
return
IRQ_HANDLED
;
}
/* ... random driver code ... */
static
int
__init
gptimer_example_init
(
void
)
{
int
ret
;
/* grab the peripheral pins */
ret
=
peripheral_request
(
P_TMR5
,
DRIVER_NAME
);
if
(
ret
)
{
printk
(
KERN_NOTICE
DRIVER_NAME
": peripheral request failed
\n
"
);
return
ret
;
}
/* grab the IRQ for the timer */
ret
=
request_irq
(
IRQ_TIMER5
,
gptimer_example_irq
,
IRQF_SHARED
,
DRIVER_NAME
,
&
data
);
if
(
ret
)
{
printk
(
KERN_NOTICE
DRIVER_NAME
": IRQ request failed
\n
"
);
peripheral_free
(
P_TMR5
);
return
ret
;
}
/* setup the timer and enable it */
set_gptimer_config
(
TIMER5_id
,
WDTH_CAP
|
PULSE_HI
|
PERIOD_CNT
|
IRQ_ENA
);
enable_gptimers
(
TIMER5bit
);
return
0
;
}
module_init
(
gptimer_example_init
);
static
void
__exit
gptimer_example_exit
(
void
)
{
disable_gptimers
(
TIMER5bit
);
free_irq
(
IRQ_TIMER5
,
&
data
);
peripheral_free
(
P_TMR5
);
}
module_exit
(
gptimer_example_exit
);
MODULE_LICENSE
(
"BSD"
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment