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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
* J! c$ `5 g  o! c4 a3 ^+ \#include <linux/init.h>
4 {" z6 x* M+ U% a) o0 E#include <linux/module.h>
2 D8 j3 p, c4 ^$ q" _8 l#include <linux/kernel.h>
2 @: h+ f- D7 {#include <linux/types.h># l6 C1 T% {- d0 V. p- s
#include <linux/gpio.h>
# k6 h, m7 m& |+ j* p* s#include <linux/leds.h>! h; X" L; M7 Q% D2 b7 A
#include <linux/platform_device.h>
% b0 Z6 C% c* p7 N' ^! [9 P  e1 E/ v/ d2 X1 t7 W. |; g/ J
#include <asm/mach-types.h>; V$ y5 o& Q( c
#include <asm/mach/arch.h>
, {0 d& H5 u0 j6 t3 a# a#include <mach/da8xx.h>* I  a% T. z/ y& L' s
#include <mach/mux.h>
, m$ h4 }& @& V, o4 R% Y- F
0 O! R1 N# t2 k( s* |) U3 s#define DA850_USER_LED0        GPIO_TO_PIN(0, 0). B( b* o7 t& H5 w$ Q
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
; {7 u, E, y1 l' J" h. g- I  T/ R! d#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)8 k) j! U+ @7 z, }' K9 @$ U4 u
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
" a: ]& G  O+ w" \, I( [4 `. B
2 ]: r: Z9 n, S: A/* assign the tl som board LED-GPIOs*/
2 \* x. V+ F( O5 T+ pstatic const short da850_evm_tl_user_led_pins[] = {
+ \# ]6 W; R  U        /* These pins are definition at <mach/mux.h> file */
1 r7 w6 Y% ^/ ^7 ?+ c6 S        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* j: X% J. E, q* \3 m5 v6 `
        -1
3 c9 c6 c4 A( q" `2 @3 j; ^' X};
4 u/ m' b, g; K$ A; b; e4 w7 k, v* [& N* Z( a
static struct gpio_led da850_evm_tl_leds[] = {
% B9 w1 n% z( E. N' N0 M        {2 A( k& z% d0 A& l, |
                .active_low = 0,. }' ]4 c2 K: t0 `
                .gpio = DA850_USER_LED0,; u; z6 g4 X/ ~- O
                .name = "user_led0",2 ]# ~1 [4 ~' w. q8 B/ g% P
                .default_trigger = "default-on",' y; |3 d$ g" K8 E- A
        },
0 @" c9 u4 v' k# r" N        {
2 o* t  w" X; R$ C% v. Z% h$ f! ?                .active_low = 0,
8 l0 y$ f9 Q, y0 R4 L0 e  E8 q6 Q; C                .gpio = DA850_USER_LED1,
3 e8 @; P' W) E1 Y4 u                .name = "user_led1",
& A3 e, h  X! X% C& ^( H+ [3 [: F- @                .default_trigger = "default-on",
& X( C$ x. e8 @! x5 n        }," ~0 T1 D& N6 E  r
        {
$ L6 F# B3 K& j7 q                .active_low = 0,
7 J3 s% L  h' U+ v0 l1 ?+ k( E                .gpio = DA850_USER_LED2,
$ E& p) j# h# N9 Q                .name = "user_led2",7 N/ a( ?& V+ I5 T0 Z8 Y
                .default_trigger = "default-on",! U( @; h0 N1 [3 c
        },8 f, A; @! l# W0 ^
        {
) T& D8 G/ O: ]& ?2 m                .active_low = 0,4 }* i5 t) K! f. ]" K7 o
                .gpio = DA850_USER_LED3,. z! N6 V3 B& c
                .name = "user_led3",
0 N! L, O1 i" @                .default_trigger = "default-on",0 N9 K- ]' H8 m  F$ t2 b
        },
6 t% t- }' _7 `5 S. {6 r" P# a};7 f" O9 B6 b, o0 C3 C
6 L8 K; l3 ~2 ~- ?# X+ v, P) r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. x8 Z4 x) |; `- A$ n) n. ~2 {
        .leds = da850_evm_tl_leds,: v! n% w( W! i
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),  h) J+ T' c- {0 R! a2 T9 [5 A
};
4 t  l4 A* g. E4 Q% _; Y% w# N* o' P. @
static void led_dev_release(struct device *dev)8 h. y" I1 D/ Y; W4 ~
{
! v# H; |# m. s2 l; y};+ M. |/ k# P" L

" t* e: w. e$ K; s+ |static struct platform_device da850_evm_tl_leds_device = {
. W- [% H9 O5 p        .name                = "leds-gpio",
" ]. w! F1 m' y8 Y4 ~$ }( p) B        .id                = 1,) ?& ]6 Z% x$ Z1 {+ g0 |8 j
        .dev = {
( y* A% U- P/ ~* x- E/ s                .platform_data = &da850_evm_tl_leds_pdata,
# I1 Q; R: m8 O1 M5 f                .release = led_dev_release,! o2 H. R, c6 f, J1 I) Q, C
        }
/ H! ~' S$ q$ G8 C. X) [" D1 S# H};
" b( F: G5 j4 b# |; n- v+ A- g6 q% m) R& J$ F, R7 Z3 x, }
static int __init led_platform_init(void)) B0 n* ]0 E( w1 W4 v/ X; U2 ?
{
6 u6 S! X2 ]- @  }. O4 ~        int ret;1 q% T" c2 _. Y7 O( w+ ]7 d) G/ Y
#if 0% c  A; N% n+ C% l/ Z, H8 O3 w
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' N" }1 ]8 t* x  J2 ~        if (ret)
' s* k4 p5 |" F4 U                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: ]* v0 x% M: ~" w! m                                "%d\n", ret);8 q0 k! i* W- V- Z; h
#endif$ v5 H( o" F) J, X
        ret = platform_device_register(&da850_evm_tl_leds_device);% L* c; d5 G+ @3 ?9 K. q
        if (ret)
3 C: q1 k7 F9 R  G                pr_warning("Could not register som GPIO expander LEDS");
7 |  U+ Y# x0 W8 ^* }0 ^) d        else
# p" s+ I9 x! J2 H; i0 L                printk(KERN_INFO "LED register sucessful!\n");
5 [8 X# B+ U8 h# O: F8 Q. n& E" X( t' v$ X) b# `; A9 P
        return ret;4 h" }! j$ R4 L5 n
}
" n" b9 n7 w5 T* l% ]8 q3 g% H0 U
) l% }5 M& c0 q6 @static void __exit led_platform_exit(void)) S. H$ O3 W) W, |# z
{
5 B  F1 X; x- K# ~0 j% k9 P% Q) M        platform_device_unregister(&da850_evm_tl_leds_device);
3 t& o% |  X3 m) i" ^9 ]. H: M, M+ {4 C5 C% y! \
        printk(KERN_INFO "LED unregister!\n");
, |4 ~# p& x* X}
; w4 N/ \  W+ Y) c# o% ]3 I9 k6 {# e" p2 w8 L5 p( c
module_init(led_platform_init);8 w1 m( b2 \! _. E) k0 K: C
module_exit(led_platform_exit);
" x/ d# T3 p) m& S( x/ `
4 E% M- f# l; y- S, q3 a% }2 D  sMODULE_DESCRIPTION("Led platform driver");& S' Z: b) U" e0 D
MODULE_AUTHOR("Tronlong");. F0 E& q, d$ C4 ~9 I
MODULE_LICENSE("GPL");  r" ^0 x0 B( P6 I5 {
9 q* T; ^# Q  G' Z* K
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-21 17:50 , Processed in 0.037780 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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