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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。: _& l) T# Q( b0 f! K
#include <linux/init.h>- w. n+ x# ~' V5 l& ]
#include <linux/module.h>
2 I( k1 p, c7 V6 E: I3 y#include <linux/kernel.h>
& }. n5 Z5 }1 s4 Z: d  R: J, t+ ^#include <linux/types.h>9 H. j' ?+ Z* i) i2 A7 [/ L1 @
#include <linux/gpio.h>
. f; s% C7 c% M0 F/ K9 i#include <linux/leds.h>. M7 H4 H# A+ c& N# C
#include <linux/platform_device.h>' ~7 ?% {1 |! n# x& l8 z
' A- ]! N" v6 A( v$ r
#include <asm/mach-types.h>
9 k+ y& t9 O: y  ]9 C0 j0 p1 x#include <asm/mach/arch.h>7 E, f! j0 M7 M, _/ I7 S
#include <mach/da8xx.h>
$ b4 L, w! C7 }: `1 b% |#include <mach/mux.h>' ~6 F- J' m' Q  }* ^

' ]3 B5 n1 h" \1 A1 Z; k#define DA850_USER_LED0        GPIO_TO_PIN(0, 0): |2 m; C+ O: _1 i  S. r6 P. ~( S
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
4 T0 ?6 S0 W! M#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
8 J/ `3 Q/ G1 i6 s6 t#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
7 J( Q, ^6 Q" e7 m
+ h- e, S, \, v1 ~% ?! P/* assign the tl som board LED-GPIOs*/
9 }- @. S2 E- \static const short da850_evm_tl_user_led_pins[] = {0 Q( w+ O) d1 N  T, |3 z( |, A1 o
        /* These pins are definition at <mach/mux.h> file */, |! W1 e% t- p0 U3 H
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 E( }( m! ~$ A        -1) j8 z0 M4 z* p, H9 X) y
};
( j7 @2 M) ]& I; m7 c9 a3 _" P# y. l/ D1 {5 j
static struct gpio_led da850_evm_tl_leds[] = {% X# `1 F  I* z
        {
/ ^. x# q$ A8 n, L* v                .active_low = 0,
7 t) U2 O# w1 M. W' o) E, T                .gpio = DA850_USER_LED0,' P/ v# h9 a+ W& @' S# |5 G$ @, o
                .name = "user_led0",
9 i! F  b2 u! U. g                .default_trigger = "default-on",
  d* `3 W5 ^2 }. v% I        },
' y8 Q6 h  P/ x( l/ l# y0 a: F        {3 G6 h2 @$ R! [' S( D5 Q6 K
                .active_low = 0,. H' d; X0 Z: Q! i
                .gpio = DA850_USER_LED1,
- x6 R0 x* ~- y                .name = "user_led1",) J' X3 i$ H2 M1 @  w
                .default_trigger = "default-on",
( l+ k1 ~/ K: R6 |        }," G4 T1 ~7 {1 i/ |. J* Z8 s
        {9 E6 Y* ~. v, G* l4 N
                .active_low = 0,
7 M0 |- @' S1 u0 O4 c1 l                .gpio = DA850_USER_LED2,
# {, K( x/ V1 u  b$ u                .name = "user_led2",4 s: @$ G% S8 \
                .default_trigger = "default-on",0 H& D3 Z. m# Y* a7 o
        },
+ V/ B' s% a! K( W        {. s/ d5 R% U/ ~+ V. i! F0 l6 q
                .active_low = 0,
! C, X7 `& C: S  r& Y# H  O                .gpio = DA850_USER_LED3,
, H8 ~# g7 a7 _  A% S1 y% q: x                .name = "user_led3",
# `+ t5 Y. e7 V; O4 R6 r                .default_trigger = "default-on",
; R: D9 _  S) ^1 P  T' l3 X        },
' h8 [9 a8 n4 e9 ]0 d};
$ P5 f% G1 W7 v+ @) V4 L6 ~* u2 N& d! i7 v9 y" ]
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, P! y5 ?) `( b1 G& x6 B; |
        .leds = da850_evm_tl_leds,7 m! f, p! A0 L
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 y( H  Y# S- P$ c};
; n' {$ G: @& ?9 c, y
/ ~6 L& H0 h  E/ R; h' Dstatic void led_dev_release(struct device *dev)
0 |# w. d7 t0 k$ D{( o  z# p2 E! }8 x
};
6 L- j6 m- n; d: A: c% h
$ M8 n0 A* ?. g: ^% Q+ b; G) }, N$ Istatic struct platform_device da850_evm_tl_leds_device = {
3 T! `& `/ _1 {! C4 o2 Y$ b. l        .name                = "leds-gpio",
6 K; G. [8 w% r  f! Z; `, p. {# G' u        .id                = 1,
$ D/ ?( Z! S; F! e        .dev = {
8 x& `9 u* d& N3 S                .platform_data = &da850_evm_tl_leds_pdata,$ K: U6 L# L3 s* o0 Z
                .release = led_dev_release,
9 h- d4 y; d) o1 ~3 \. e' c% {/ Q        }4 [& q7 o  A* Y: B: {1 B. M$ G
};5 F" ~7 d/ u. L7 T# X; T

4 N5 z( Z+ t2 C6 n  Vstatic int __init led_platform_init(void)/ h" y8 x: T; X! t' B
{, D, {- y. q/ e# v
        int ret;
* W0 Y$ {  B9 v( T& w3 b# G#if 0
* x: O5 B; }  m6 C        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" L( e7 r- G5 ?& D8 ^# q0 C- N        if (ret); W- `8 `& P% Z# }) L! m2 h% \& D
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" D8 C- k) x* y6 p                                "%d\n", ret);% F$ {2 z7 t3 @. F6 H
#endif* h" e7 s0 L. W/ x' T3 C
        ret = platform_device_register(&da850_evm_tl_leds_device);  ], J: q& L, r
        if (ret)# L' U( X" w$ Z3 M) z+ O, F
                pr_warning("Could not register som GPIO expander LEDS");: u! ]$ ?4 y$ n
        else
" \7 z/ D2 o. G8 `8 F4 i                printk(KERN_INFO "LED register sucessful!\n");: M9 {7 A$ T( @5 |9 X

8 A% U: p6 U9 h5 ]" J        return ret;8 I4 R. f! l: u& f* o
}
1 @6 ]5 k6 z+ X: a0 a* a+ K. Q# P& _% _/ c
static void __exit led_platform_exit(void)
5 c0 _5 o- D" C( O7 V3 \{
' {% J5 @8 T) F% `& E( j. c5 Z        platform_device_unregister(&da850_evm_tl_leds_device);
& r. @- v( b9 B' x( E2 }: i& {9 I! n# m0 }! y& N8 i
        printk(KERN_INFO "LED unregister!\n");0 `' Y$ k0 I, C$ {' L
}" r" @0 [4 C. d' W

1 Z- M5 F% T4 Tmodule_init(led_platform_init);2 y- [( H' a, j, G3 i& i
module_exit(led_platform_exit);2 v6 u4 N' W; |9 |9 U3 D! {2 e

8 F' ^7 `9 W, O- g* B) C% [MODULE_DESCRIPTION("Led platform driver");8 f9 ^5 z( @2 N6 A
MODULE_AUTHOR("Tronlong");
+ d% S) Q  p% \% Z& `* t0 LMODULE_LICENSE("GPL");& T  ~5 ]5 M; B
! w" E. e1 V6 R( F
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-9 01:50 , Processed in 0.045776 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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