程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站
点击跳转“创龙科技服务通”

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 11480|回复: 0
打印 上一主题 下一主题

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。4 Z, ~/ I5 ?+ o& I& c& a- b- A
#include <linux/init.h>
/ T9 H" x3 |2 T' Q9 Q#include <linux/module.h>
/ r$ ^& o0 S% f#include <linux/kernel.h>4 V8 z: k- J( N$ e. l$ _
#include <linux/types.h>) G( F3 D) ^; o3 o) ^1 t
#include <linux/gpio.h>
& J( T" z( H; R. _9 Z& `4 Q/ I#include <linux/leds.h>" s! H% J# L' J6 J0 e% x& g
#include <linux/platform_device.h>( R7 b* F  w+ b5 {

* \/ e% l) U2 |$ B* A5 u' I#include <asm/mach-types.h>4 h; T- x3 y# `- e" T* o
#include <asm/mach/arch.h>
9 w2 o# P$ L1 `5 b% B: I#include <mach/da8xx.h>
+ M' M" u% D9 l" y& Q6 j5 r#include <mach/mux.h>
  A2 ]! s, Z' @& s8 j3 Y! f( s0 L: F% G' y/ [# b
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
8 i" I( f8 y7 T2 ?- t( ~#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
0 H- v; l. H& r- X( j# W. X5 ~4 H#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
  D- I* K8 v2 X2 Q#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)) D$ ]8 X4 c/ |" ?- D: V8 v- [

( U5 F& `0 t4 i" b6 ]) j5 j- H8 c- l/* assign the tl som board LED-GPIOs*/: f8 [+ V0 l+ a" X
static const short da850_evm_tl_user_led_pins[] = {
! N. l+ F- M: ~! i: |        /* These pins are definition at <mach/mux.h> file */
2 Y7 f; I0 ~+ D: U8 _        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ U! i5 b1 \. R8 a' `9 G4 g        -1
' f3 r# a- X- }5 D! H& f};
* ?5 k8 A& g) @. c4 I6 E1 b$ R  W  H6 o5 l6 [0 M" X
static struct gpio_led da850_evm_tl_leds[] = {
- I, E. Y8 X0 F, ^        {6 [+ d; Z+ I5 b
                .active_low = 0,
1 Z2 R4 |; S% t' z                .gpio = DA850_USER_LED0,
, Z) i0 f- k( a                .name = "user_led0",
  p1 y/ v" u! \% J6 P5 f$ e. S, J                .default_trigger = "default-on",
. g+ [4 Y6 K, `4 w        },
2 `. f, Z8 o  q: W, n2 v        {
5 t1 Z& d4 X3 p5 D+ l- b- ]/ L                .active_low = 0,$ k- [$ D1 e- I: X
                .gpio = DA850_USER_LED1,- Z- A! ~8 T# b7 ~! ?$ G1 f1 y
                .name = "user_led1",$ }3 k4 O$ l: Q# W6 X
                .default_trigger = "default-on",
" H0 K9 h  T0 X" r( ^1 |1 N        },
; D" a) U  ?, g- B" K/ Z( U( R        {% y9 l* M) W$ \0 Q1 L) J8 o
                .active_low = 0,
  D1 n  n7 z( ^% n2 O+ h% H                .gpio = DA850_USER_LED2,/ _8 N: G/ n  d8 n
                .name = "user_led2",
4 p0 U  F( z. D# w4 B# b8 w6 z                .default_trigger = "default-on",
& L; ]( u4 }. I* Y2 O  X3 y% R        },
) Q- q9 e" x9 I; @/ w% p        {
. |) g" F% ?% y( r* \1 H                .active_low = 0,; K% ~5 F! w! o: K
                .gpio = DA850_USER_LED3,
4 ^8 B2 C6 E% [% R. K' Y( E                .name = "user_led3",
% `8 R0 y7 o8 I' `* l& x                .default_trigger = "default-on",0 L- S5 D  L# k6 d+ @: l
        },' X9 ?+ v1 D! H+ [& |2 k! N6 E' d
};; d) I1 e* d7 ]6 z, v' r9 z

" c3 d  P( F+ L# j  C# }, H+ ~% ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# r; L/ R8 p0 m. @
        .leds = da850_evm_tl_leds,4 }  D8 s; e/ r
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: V/ _$ {! i* G  _- d: s4 ~% F# W
};! R- s3 f0 K; L2 @0 d

2 W: a( M) i& j1 ]9 [5 Dstatic void led_dev_release(struct device *dev)+ ?/ e1 r2 k9 K3 X
{$ l- s$ R- _! y& v" n
};3 T# ?; P" V' S8 i# |4 s
! }3 d! D6 O- a2 ^% v% b6 `
static struct platform_device da850_evm_tl_leds_device = {, r# ]4 C  P& ^$ D- f
        .name                = "leds-gpio",
4 y6 @( l; W6 h$ P2 D        .id                = 1,9 b" |# Z1 K2 l: i+ A
        .dev = {
/ X) ]7 L: m( S. f* B9 V, J                .platform_data = &da850_evm_tl_leds_pdata,
3 a+ `4 R! ?: \" C1 c' F% z& N$ f                .release = led_dev_release,: c3 Q) l& J' {, Q- A/ C
        }* r1 r( b0 ^! _3 U. U
};- w5 S  Q1 U% k5 g% r

2 x/ ]. H. r% u- m- sstatic int __init led_platform_init(void)
! }% O3 ?* \" r8 @{
- W3 v* p5 s* v# c* Z        int ret;/ [8 _, Z% R! y. E5 h
#if 05 C  w0 w7 p% H
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: ]. R: Z" \, [- W4 m6 [
        if (ret)
5 C$ R8 \6 ?2 ?5 c: R                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 N  T4 Y8 r$ H; ?$ |! [                                "%d\n", ret);+ c/ c, a- y/ n3 `1 [0 ?
#endif
/ ~& ?# L% r* P/ T        ret = platform_device_register(&da850_evm_tl_leds_device);
& s+ u  @- A. i9 f$ ~! L        if (ret)
  W3 i1 b, N( K# ^+ G                pr_warning("Could not register som GPIO expander LEDS");
9 {( l7 f1 B1 z. j9 O; M0 I        else. K$ }2 w' t6 D9 }4 t: T
                printk(KERN_INFO "LED register sucessful!\n");/ i6 o4 k3 `0 q# G4 v* B6 K

; Q3 X2 Q6 {9 g' c) |. _        return ret;+ w& F) q( \. c" R* D$ w& H3 |
}
, [2 {8 T, r& s
7 [2 r) G# s3 V. G( q' K. R# Pstatic void __exit led_platform_exit(void)
% K# B3 F+ N  z7 b. v% N{
1 g" p, e7 C' \3 I7 w        platform_device_unregister(&da850_evm_tl_leds_device);
" }6 j! y5 u* {) h: i3 ?
. v' ~6 U* a- |: h5 W, V# {        printk(KERN_INFO "LED unregister!\n");% H6 R: Y) p; U  V: a
}5 K4 k# ?! {& V7 u! z8 u

4 I/ D* w/ a2 y' l: u* ^% F# m/ cmodule_init(led_platform_init);
( ?3 X" q( {& Pmodule_exit(led_platform_exit);
: Q* w# z# `3 R6 a+ @9 M; w7 X' f/ h) v3 H2 X
MODULE_DESCRIPTION("Led platform driver");
" ^' s/ E0 s# _. X6 x  m2 [& xMODULE_AUTHOR("Tronlong");7 |3 y3 f; Z9 S( y: J8 q
MODULE_LICENSE("GPL");
" `# v  P0 R& z/ j4 N+ e5 _' J- M; C4 l; @) a5 h
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

点击跳转“创龙科技服务通”

QQ|手机版|小黑屋|嵌入式开发者社区 ( 粤ICP备15055271号

GMT+8, 2026-7-9 02:29 , Processed in 0.040185 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

快速回复 返回顶部 返回列表