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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。. d$ ]/ J% F& f# `
#include <linux/init.h>
% _# D. x1 P4 Y* U# ]/ |2 `* K! P#include <linux/module.h>
! r. H; a$ M& H, d# v- I: \& ~+ ]5 H#include <linux/kernel.h>
1 T2 W$ G1 ]2 Q$ {8 y#include <linux/types.h>3 w- L+ i- }' [* T
#include <linux/gpio.h>9 I6 L: [& l$ N: a: b6 g. _# _
#include <linux/leds.h>
: n) y8 _# S9 q) C: d& W, K# z" q- b# k#include <linux/platform_device.h>
) t# _' U& T" Q( c1 \5 M
3 c# W) J0 i9 L* M& ^#include <asm/mach-types.h>
% S( W" E6 g9 W' I' L#include <asm/mach/arch.h>
2 y/ g2 p2 U* C; K) A; `+ F6 E#include <mach/da8xx.h>
* H/ p" j) s2 J) W% j; y6 W+ j#include <mach/mux.h>: P* [+ C. p7 X* o/ ?3 h0 H
9 G; D. N8 B, [
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)( Z- ?9 R2 O6 p* t+ o
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
; V& }# u+ x! d#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
7 s6 h, {6 k" _: F' n/ Z#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)* M4 s! L7 J2 G% G# c

, X( D* o- k- E; L% F- j3 D/* assign the tl som board LED-GPIOs*/4 }. Q( d- ]. b/ Y6 m
static const short da850_evm_tl_user_led_pins[] = {
6 v" m( E5 x; s" Z! t        /* These pins are definition at <mach/mux.h> file */
8 i% Z0 T) s$ E        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 @4 B  S/ L* a" R, f6 [        -1
; x4 R2 _- C$ X' K5 X9 {9 c};
* E% M& b, k- V& W
) }* _; @' h) y1 p/ R4 o# W% \2 l" xstatic struct gpio_led da850_evm_tl_leds[] = {% f" O0 M  c9 J4 }5 f: x
        {7 `6 Z* A, x8 l2 s: @
                .active_low = 0,
; E/ V1 R6 t: d' v9 J" O' J                .gpio = DA850_USER_LED0,
6 h# C) |. L9 z                .name = "user_led0",3 o: E- C! z, ~) _0 ^1 y
                .default_trigger = "default-on",  [' t; O" W+ \! K" T. J! X$ `2 Q
        },) F- K* U6 k! \- M1 E" F
        {  N2 u6 Y$ z# q9 r+ A1 s7 j) w
                .active_low = 0,
( Y5 l% Z/ |8 F+ G( b0 _' H  W                .gpio = DA850_USER_LED1,
* ]. W5 ^( S& U; Y6 o! C                .name = "user_led1",( _2 G' c/ |7 O
                .default_trigger = "default-on",# N, J( ]. b' ]6 U) X
        },
9 N  X& d' }/ C$ }+ o( @        {0 y3 m- e" B* S
                .active_low = 0,/ M- `2 m( j9 j6 D% F
                .gpio = DA850_USER_LED2,
* G$ B/ C& d9 W2 y                .name = "user_led2",
  X& \; {/ H0 r                .default_trigger = "default-on",6 o) S/ F. s5 H! X/ V, x! P/ m
        },
) R) m, g2 ?: N* R' y6 v% C        {' R; h) F$ c- ?( o
                .active_low = 0,' }  x4 D2 T; J9 [8 H
                .gpio = DA850_USER_LED3,( a9 j; i  p: i1 ?- m# k. a
                .name = "user_led3",% g* J  I" s! o* r2 q
                .default_trigger = "default-on",
( g4 w' }$ w2 P0 n" R8 L        },% A0 ^% ?4 u" G1 @$ w* [
};- E2 S0 z, ?6 X, S1 K! K

  U( K4 o' D, `4 e4 o, x) y; X/ Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 g% U: q4 j$ c* G& X. ]        .leds = da850_evm_tl_leds,
6 X$ l$ f! }& _( N        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" |3 n! }; ^+ ?- Q; B6 X- }  z};# ^4 O$ T3 M/ @6 _; C2 Q$ B
, w% w9 I3 D' Z9 P4 L" K
static void led_dev_release(struct device *dev)
# z( [5 ?8 \4 D! X. F{- I* G3 |6 r& N6 J7 E2 _& V
};, [. [6 O3 a6 @2 h

% U7 @  U) [& n  z4 ^static struct platform_device da850_evm_tl_leds_device = {2 L) I6 `: {8 k) C% R6 g
        .name                = "leds-gpio",
$ @2 Q5 }- \. ]/ ?9 R5 `        .id                = 1,
; ?, Y8 H1 s7 i1 g1 B        .dev = {
/ M' R* B' T+ A* s  ^5 G1 t' o                .platform_data = &da850_evm_tl_leds_pdata,+ o3 x: e  E5 |' T
                .release = led_dev_release,2 x" V) O9 Z, Q7 r3 K
        }& H, P! m' l& a4 p; C
};
, Y( B' K# |9 n( ]- |9 L0 M9 R9 k1 I# x# q' {* p
static int __init led_platform_init(void)7 ^6 ?( R; G8 y
{
' O! L5 y# S  _3 j* ~        int ret;
$ x! t, K5 o' s( }' m- w9 v#if 0
. U' E+ ^3 I- j1 ~# ]0 B0 r2 |& _* p        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 O& d; s1 U6 k& Y- K6 h
        if (ret)% @; h& [9 K( P4 z
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# x& I- `3 x% ^( ~2 V" b
                                "%d\n", ret);! M  d0 w' @3 c- ~5 K& K0 Q- |
#endif
: e4 b; T( e6 T& i* h: T2 R        ret = platform_device_register(&da850_evm_tl_leds_device);
* c$ F# H5 `! H: |        if (ret)
. Y2 e- O2 Y7 ?5 Y1 A/ T8 V$ ]8 g                pr_warning("Could not register som GPIO expander LEDS");& T- \$ q6 q: z+ j. F5 x0 @+ ^
        else/ H6 }! b/ {% x: ~6 l& ?. t
                printk(KERN_INFO "LED register sucessful!\n");
' o: w2 B! G! Q% F3 d6 l4 ~: C+ i$ ]' a% E
        return ret;. q5 x6 w  s: Y  `( H
}/ K. j* B2 O# m

' Z- b( U/ E9 w6 L2 Y: Dstatic void __exit led_platform_exit(void)0 L# a( S3 o- s! K6 K3 Y
{
) y7 [& h. Y0 [  j" o% l4 {1 a5 C        platform_device_unregister(&da850_evm_tl_leds_device);
' ~2 {* e( ~: b- T2 q8 w; K& x; s! Q( l- `: P5 S
        printk(KERN_INFO "LED unregister!\n");+ }* A4 \7 n- c' J7 C
}6 [1 r& I, X- n  R( }' \

1 U7 a. F, h/ z# M- C4 gmodule_init(led_platform_init);
! a& ?9 r/ l5 A9 jmodule_exit(led_platform_exit);
2 ^* |2 g* u2 ]
/ k* h% @3 s8 ?$ U. \9 R5 wMODULE_DESCRIPTION("Led platform driver");# S: y9 \+ s, r* ?/ _* |
MODULE_AUTHOR("Tronlong");
% X$ X- @8 u" x  h$ [) W8 @% nMODULE_LICENSE("GPL");
3 K8 `; L1 E; y, f5 J/ V6 V
. V0 H# l" h- W& x: I3 h
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-20 16:44 , Processed in 0.046353 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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