程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。0 S3 ?5 u) L) E- d" k: Y
#include <linux/init.h>2 T3 l4 ~+ y: S9 f6 @# c3 N+ Y
#include <linux/module.h>
  ?6 K8 T! f4 l1 z7 I#include <linux/kernel.h>
/ k; \: b  Q9 V% p. A#include <linux/types.h>, `1 c. x3 N# j, ?0 D$ F6 T2 T
#include <linux/gpio.h>
1 O/ V# J( d; I#include <linux/leds.h>
* X) s. a6 `" D3 I1 N" _#include <linux/platform_device.h>
* Y0 F$ K$ B. z- H
# ]9 X6 B( w" g5 j" S#include <asm/mach-types.h>
: e' w: Z3 a" X9 F) C" L8 y#include <asm/mach/arch.h>% d9 S* M  v% _- v3 m0 m
#include <mach/da8xx.h>! G# R, z: Q- G2 C) U$ U- D" C
#include <mach/mux.h>6 }. E: c1 [) c- t7 [
  d# W9 q0 _( U! W
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)9 O! b7 K0 G& a/ r4 P
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)& j. m" [% q1 e, S  ~! q8 i) t
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)7 L' ~: q7 e: e' P
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
) y- l+ E; f1 x, i' g/ K& v% [% i0 c9 O. C" M* V1 U
/* assign the tl som board LED-GPIOs*/
4 G, `! {6 l. Z5 o9 h. `static const short da850_evm_tl_user_led_pins[] = {
. g& _9 G& Y- Q0 i6 A- k        /* These pins are definition at <mach/mux.h> file */5 U, W) }2 M7 H  r# A1 I
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* o4 B8 W6 [( X' a# A5 a        -1
0 i/ F7 ^+ e* E/ y. i7 X};! d; t9 B$ G1 \! q5 W( }) u
7 w+ F! I/ l# K
static struct gpio_led da850_evm_tl_leds[] = {* \$ `: V+ P& q0 S
        {6 E( O" E0 M! F
                .active_low = 0,8 C( m" C. ~1 e. C/ ~% Q
                .gpio = DA850_USER_LED0,& Z4 f) ]/ i6 }7 M
                .name = "user_led0",- u" E2 b5 b6 `# V  `: a" z4 ^
                .default_trigger = "default-on",3 t  Q3 B! q. q( y
        },
% h- f* l! Q; a* R) W        {
& ^/ R2 F+ O& ?. K0 [                .active_low = 0,1 Q9 D8 K1 o; @& K
                .gpio = DA850_USER_LED1,) W0 g1 a) i6 j' f' _. M
                .name = "user_led1",
' A1 F* z. N6 j" m                .default_trigger = "default-on",3 Y. Y4 s, G: g/ L( n; `- C! B3 N& [
        },1 T( `6 \# a8 K& v7 \- F
        {) d3 {1 U$ N; f8 O3 M
                .active_low = 0,0 Q; j- E9 L+ C. m9 e# T# H& @
                .gpio = DA850_USER_LED2,
" }& f3 v& I' Q0 C- r' i2 ?4 E                .name = "user_led2",
' [, l% B& p( z                .default_trigger = "default-on",
, o. t. j* ~' K3 v. z+ l8 h        },( u9 ?' _$ {, c4 e* W! \! n2 I
        {* r0 j( t; n7 j: @( N# n& J
                .active_low = 0,
5 y, z7 l$ F" A1 Z: D' O2 c                .gpio = DA850_USER_LED3,
/ H. J" g# t3 O2 K5 I# f9 |1 z                .name = "user_led3",
+ n  D7 `0 W# D3 K* y3 }                .default_trigger = "default-on",* |+ ^( x/ C( @, u% g
        },
1 z' |8 M/ e0 h};' [; D6 x3 e7 J+ _0 E: ^

2 P- m7 N# [1 v# e5 Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 w& _! W1 {( r% q: a: H' l        .leds = da850_evm_tl_leds,$ h: k! f, T& @, n; V
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 x6 U% x( ~- K. k6 |};4 ?1 s  A( ]1 Y- a. ]
0 e+ ]* ^& ]& }1 ]( p
static void led_dev_release(struct device *dev)
; V0 J8 h7 a3 z{
3 K4 {7 t8 p1 S};+ w- d9 s& w* T) T" a

/ b" h7 o1 S% o& [3 Ystatic struct platform_device da850_evm_tl_leds_device = {
+ {) b$ |0 ]( X  P4 n; B+ S        .name                = "leds-gpio",
/ ^7 V% K4 s5 c* X        .id                = 1,4 b+ T1 b4 H5 D9 j. s
        .dev = {6 v8 V& E$ Q" A! p
                .platform_data = &da850_evm_tl_leds_pdata,
7 u4 U" t, v" a. O7 L6 y                .release = led_dev_release,
) W3 p  P1 Q7 j$ |8 j! H! L1 ?6 ~        }" X" r3 R  m! o- n( U5 t- {+ W
};
% s6 E! U( v  \, f. J* s. y9 |% ?% u& ~3 l8 t
static int __init led_platform_init(void)
  h* V. N+ R" j' I0 a{
3 x1 W$ Z& c+ _  f        int ret;7 g3 L5 V* E  h" A2 `& F0 O! Z
#if 05 q; ?" l5 u) c2 P5 S3 z. t% T4 n% f. j
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ [$ s- }. q0 U        if (ret)
# D+ `" b4 _" j; c- i8 d4 o                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" @. Q) ^1 r. e# x( E& M! E                                "%d\n", ret);9 m9 f4 T$ O+ i  Q& k/ A
#endif
% f1 T' c0 j' t2 I2 o( t8 o        ret = platform_device_register(&da850_evm_tl_leds_device);
% \3 C5 s% s4 y4 o+ @. n8 O        if (ret)7 }6 a% D4 _/ P" A/ j, J9 f; l
                pr_warning("Could not register som GPIO expander LEDS");9 @( v7 i4 T) \+ ^2 l3 T# ?
        else6 g# q4 `2 M/ c3 I+ S5 R5 z9 B$ W
                printk(KERN_INFO "LED register sucessful!\n");
5 c0 J9 n, o7 r# H3 a* z; Z
/ l8 N/ x% @2 L0 {        return ret;
$ h7 }% Z3 f' U6 E5 u: f5 P. Z& T}
% ]/ x5 N% H! N% w1 _: N
& z: |; ?( z" ~* T/ @0 Qstatic void __exit led_platform_exit(void)
; I: ^4 U/ f0 w$ A/ @3 b, R6 c5 ?{
& a+ k& m* V* N5 J  Z4 p. P        platform_device_unregister(&da850_evm_tl_leds_device);
! h  _# H, X, T+ e9 u
4 N: c1 T1 J5 M/ O  e, ^        printk(KERN_INFO "LED unregister!\n");
) l) `$ S. ]& l) l}4 t4 K1 U( H, c2 d8 W$ ^
1 y- _- Y7 T* g- O3 O
module_init(led_platform_init);
4 ]4 u2 K/ @/ ]9 l  H1 @module_exit(led_platform_exit);- C  r4 L  c( ^3 F- i
& B% f6 n+ y# \/ z! a0 W% b6 A2 T
MODULE_DESCRIPTION("Led platform driver");+ S3 C+ M; g8 P+ a9 }3 t: I5 K
MODULE_AUTHOR("Tronlong");. _5 F- {" ?; O% |+ K2 S9 l- x
MODULE_LICENSE("GPL");
: t& R9 @+ J6 K5 S  V+ }7 W0 e# T5 I; X) _* O( |
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-7 14:20 , Processed in 0.036884 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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