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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
2 v9 h: O9 T" c  M% V' y9 l#include <linux/init.h>
% U# ^. F6 V+ q3 Z9 I#include <linux/module.h>
& j' v% E$ ^& k) U#include <linux/kernel.h>
, I$ b$ g4 R/ m* v7 b#include <linux/types.h>
9 T4 N0 t) X" K2 B9 Y% N#include <linux/gpio.h>; V2 m' M# t0 ^) v. R0 B
#include <linux/leds.h>( Z& L6 x4 a" f6 ?- d
#include <linux/platform_device.h>0 V; t5 z4 D4 j4 R4 ~. ?6 H2 w  Y
) p4 e9 p6 {6 m& o3 Q4 {
#include <asm/mach-types.h>
7 ]/ c2 i& D* l" j3 Q# g5 n#include <asm/mach/arch.h>3 ]; H3 p4 b& F2 H% W# _
#include <mach/da8xx.h>( X& A) T1 N, t% k! t2 z' t6 R, z
#include <mach/mux.h>) x8 T! G% M' `0 E" T( o- d! }* Q6 `
# `& @0 e! y: o6 n
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
/ Q0 R8 ?. D5 }#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)$ [+ r& E' y+ d: E
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)0 i6 E& h5 t9 B0 _- d  ?# F
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ H. m( ~* S1 ?. X  P

4 h' J5 g# F* F( B: w6 G  S6 G/* assign the tl som board LED-GPIOs*/
# v6 m5 y1 Q9 }+ Z, Z& u: J3 A  G3 hstatic const short da850_evm_tl_user_led_pins[] = {
7 m& z4 i/ E6 C* D8 E& F1 c        /* These pins are definition at <mach/mux.h> file */
6 _3 ], X! K/ E9 U( q; `        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 s2 f5 u; u  x: O8 b) D% i$ U
        -18 T0 @4 t- _  Q- }. H$ ?1 w: o
};( G5 k  v  w1 B
1 C* V2 h8 y# h# V( R# u3 `
static struct gpio_led da850_evm_tl_leds[] = {6 }7 l% C3 \( {
        {
5 [. X. c2 g! Z% ?- q  P$ y                .active_low = 0,6 E' R8 x2 I8 b3 H8 E
                .gpio = DA850_USER_LED0,
; N- H3 e. H' [- e  D                .name = "user_led0",& |4 h. w  n; }0 F
                .default_trigger = "default-on",  D( M3 _4 B6 m7 E
        },
$ T, _" c& {4 s        {! O& r. |5 d7 s( G! C0 O+ E
                .active_low = 0,* }$ f' F) v" X. g
                .gpio = DA850_USER_LED1,
; v* Z3 x, z/ w4 O                .name = "user_led1",
" u+ d, }# x+ _" X: }" ]# u                .default_trigger = "default-on",
% t1 N* N. Z/ }5 E. C( z* H        },
. M5 o" c5 l! i! D! D. F) ?( P9 y( t5 F        {1 X. d) M% C$ P/ ]) g) k' u
                .active_low = 0,8 E: C$ `1 }( @1 p; ^6 _  `
                .gpio = DA850_USER_LED2,
, H% u+ h. ~' H) ]& [                .name = "user_led2",9 |: K; a. X$ V1 ~8 e
                .default_trigger = "default-on",% \/ F2 ?( H  }8 C! K8 p
        },
  `$ t8 j: _0 t( u+ w6 T        {
" [9 C2 e" o8 B; `' G% p                .active_low = 0,7 N0 Y0 Z3 I+ R. `
                .gpio = DA850_USER_LED3,
- x' Z7 W* g* ?  T* e# z, |                .name = "user_led3",
0 z: Z' L6 s  D/ n                .default_trigger = "default-on",2 q0 z8 s, F8 [9 B8 V4 f1 E1 ]) f
        },
: a: }9 }; n  w* G};4 x9 V7 j, P+ v. T" |+ |

! \# u. q: e& Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 ^; T4 b7 J5 X3 t6 M
        .leds = da850_evm_tl_leds,% @# A; j3 B6 w/ @3 p: R
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),  d& H: G  ^0 G* q. k) R+ U% t5 {
};
* C3 _! k8 O9 y/ k: a% @6 E' ]$ g' i! E& t+ r
static void led_dev_release(struct device *dev): ]) s1 B) D3 ]; E5 w; j
{
, v4 J3 F& W+ a};
# ~+ D& }! V$ r% E
0 S# x6 G, C+ gstatic struct platform_device da850_evm_tl_leds_device = {" Z$ x; D* Y- S. r1 |5 a
        .name                = "leds-gpio",  h7 u; P" p! k2 t
        .id                = 1,6 u+ H( T% L( r6 x& H+ X. R
        .dev = {. @7 k# t( U' A! n) w' C8 B% h
                .platform_data = &da850_evm_tl_leds_pdata,
3 L' k( K! I$ d: j6 g% A                .release = led_dev_release,
) r+ X: l" P1 }/ e( m        }1 M# O( [" N( P) r+ j! K
};
2 Q4 B3 _# _. H
, y" U( `* S3 X$ [static int __init led_platform_init(void)
: R9 g: I9 \$ ^* S! b$ D{
: q" G& N% T  R# h* y: i; @        int ret;, u3 P( S; ~. u4 w9 n# o0 ~
#if 0# n: X1 u) a! a' R5 v+ X
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) P6 p7 g5 m! t7 Q        if (ret)# N* h9 X+ M3 {/ A! k& m% f
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: ^, S+ r* H5 P1 L$ P7 g                                "%d\n", ret);
1 A6 m' w( ?+ _, a' l/ m$ U#endif
7 l1 V$ v' D; Q/ |        ret = platform_device_register(&da850_evm_tl_leds_device);
9 N) d  l7 D3 b        if (ret)
; g, Y& M6 d6 o; K, x- A                pr_warning("Could not register som GPIO expander LEDS");4 ~* p7 n  N" o0 |) a& l! X
        else
* k" h9 X- j3 W9 a3 f( |# z                printk(KERN_INFO "LED register sucessful!\n");
' k& D# L3 H# y- [$ x" ]& s' ~5 |, X  S, R. f& h: n
        return ret;! ^* O4 Z) B$ c! F5 i5 |* A
}  o7 Y- x! ]1 |+ K
) r9 ?3 N: ?4 y; {- h
static void __exit led_platform_exit(void)
- l4 u$ L3 g. J' a# \{. h  G/ Z# Z4 D& `9 q
        platform_device_unregister(&da850_evm_tl_leds_device);
$ o+ o' A2 x, \; _) t3 U: w) s4 _! \2 S. }& m- D. U
        printk(KERN_INFO "LED unregister!\n");. L5 B: o6 j+ @' `3 _
}7 m) a( D9 o: {' y- Z1 s: @5 `1 A
" h8 C, K3 y1 h6 r& L7 O
module_init(led_platform_init);; _% l& }! C1 ?/ ]7 v
module_exit(led_platform_exit);
& }3 O8 B! h* v6 K' n: \6 l) F+ Y2 G4 Q( R9 x5 V1 e  ?( z
MODULE_DESCRIPTION("Led platform driver");; w( C5 A+ c( ]3 H; @+ d* A
MODULE_AUTHOR("Tronlong");
( ^. W; o( |- a' {7 K; }MODULE_LICENSE("GPL");
% l' M4 G% I! a# Q& g9 m" k
: Z& }+ c5 n& C/ i1 J
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-30 17:16 , Processed in 0.040299 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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