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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。& S2 X$ p% q* a2 t
#include <linux/init.h>
1 V; o' Z( l! b! n#include <linux/module.h>
  n" h! N2 h3 J6 j7 D4 B#include <linux/kernel.h>
0 \! Q% w7 d. f1 y8 \' e#include <linux/types.h>! |! I: B0 M. t9 E* ]4 p
#include <linux/gpio.h>
3 Z: Y, T3 Q$ ?: t#include <linux/leds.h>
2 F- i  F: I. b8 l( {9 ?#include <linux/platform_device.h>3 e* M; R/ s1 g9 d' u6 t; W. S
" n8 e  @  E& T: y; i/ Y: l
#include <asm/mach-types.h>" @" z- O, k( }) a
#include <asm/mach/arch.h>. S3 \+ G9 V/ Z3 g
#include <mach/da8xx.h>
; b/ k5 {% _. \, R9 _) d#include <mach/mux.h>5 J: X3 h0 [8 G7 @4 ?# r
8 `- f4 w* Z5 q% m1 E7 v
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
2 n* _- n- T- F5 @#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
* {0 J7 G; a" W6 [+ q#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
( Z! e$ \$ Y3 X, ]' `#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
+ T+ P3 W, S' ]
) ~5 E2 a5 @( Z- u/* assign the tl som board LED-GPIOs*/
- x  q' Q) a, h: q! h' W8 W) Ystatic const short da850_evm_tl_user_led_pins[] = {
( v2 w6 ]% C- }4 ^  F  m        /* These pins are definition at <mach/mux.h> file */
9 I* V, p0 y  |7 w        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," b( k: P; C5 T# Y( n9 s
        -1; U  }2 K$ \( e) V; m7 I
};
/ }. P8 ^/ o* m% U) _; q4 b
/ R; W( o$ w$ |! Zstatic struct gpio_led da850_evm_tl_leds[] = {9 u" Q8 r4 P6 h
        {
- I% n! C, j; r+ z$ _3 H: g                .active_low = 0,
* Z# X" K0 y3 Q  X$ M9 Y$ Z2 {                .gpio = DA850_USER_LED0,
) O9 b5 l' a, s9 A. f% N% u                .name = "user_led0",
4 X. {9 n! M- l* {                .default_trigger = "default-on",
) r  M* _9 Q) `" L        },
$ _5 w, W0 R$ W; @+ S- N2 A6 V        {
# }' X7 {+ W& ~7 T                .active_low = 0,) A9 \& d6 K* g* l. t6 M& B4 L3 F, X
                .gpio = DA850_USER_LED1,5 Y3 b2 L6 T) G3 {$ _; g6 g1 T
                .name = "user_led1",# p3 c, ~+ m1 r$ _1 d8 F3 s
                .default_trigger = "default-on",, y+ h: y6 {7 j
        },
$ Z2 g, S2 ^% H* N. L4 Y8 O7 o        {5 \  G4 Z" c. V: D4 ^
                .active_low = 0,4 r3 m0 t* A& Y+ x# }. z& M
                .gpio = DA850_USER_LED2,
7 v& R5 y9 H  v% _* N; i                .name = "user_led2",
3 ^% K1 c  P! b                .default_trigger = "default-on",
% m" w) R' X3 x# V/ v6 A% y9 Z* @% E        },
# V* O% S! I+ c. {# F        {! s3 m( e/ y* }. F% ?
                .active_low = 0,
- A4 r0 E0 r% g( V; n% _                .gpio = DA850_USER_LED3,( M2 y' Y# H9 u+ m
                .name = "user_led3",
; r, q" O6 _: G; K% _/ W                .default_trigger = "default-on",; K4 |, P* y# S* K# i
        },2 y: n/ A9 s) F, b* R% [7 ]" V
};1 y  b6 o8 T  `, ^

( S- t. V) _# f4 ]( p  U. N! x* zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ l9 Z. w; b& P  C7 P        .leds = da850_evm_tl_leds,
  y' n1 Z) a- C+ _1 x: p4 h+ Z+ |        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 K# [, O9 H+ L- k: v};
8 ]+ U/ E3 F$ ^. G5 m% g) T2 D9 C. ~4 S3 k. |# S
static void led_dev_release(struct device *dev)
0 {* U6 o7 m1 {  D# j6 s7 }{4 d$ y6 o) I4 q9 O/ S
};
( J1 {, S0 f5 |& v$ d9 @7 ^" V  b3 u
static struct platform_device da850_evm_tl_leds_device = {& c: L: r/ B+ M- _# p0 x# T/ H5 _
        .name                = "leds-gpio",
* Y. R9 |, d6 `$ A) D1 F/ o# c        .id                = 1,# B* ~" f6 B' `. u
        .dev = {+ [3 D* J, G. l# ?- B. u( Q8 a5 I2 a+ }
                .platform_data = &da850_evm_tl_leds_pdata,
: H2 Y. u8 T/ D: q5 V8 }* _                .release = led_dev_release,- h) I! z/ ^  ~5 @$ }2 H
        }: ^9 u; U; u9 ^
};
. _: @( J( b, w( F$ `* C! p
6 g2 y: `% H. X. O% x8 s' xstatic int __init led_platform_init(void)
9 F' A4 S+ k8 Q; B0 F{
, f' w8 d& G6 z$ E/ R0 I* e6 D        int ret;
; P' |6 z' l/ P) z) y#if 0& U: g) [" g4 p+ A9 k
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; P" t1 \) c3 B& |        if (ret)" D$ n7 x) n# P; s
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :". t5 h* B& @4 Z
                                "%d\n", ret);# N2 Q3 y3 \. `  l( ^+ X% }4 g
#endif
- m9 c  r  W' K, L        ret = platform_device_register(&da850_evm_tl_leds_device);
. e9 Y$ W5 A( o+ f7 z3 s        if (ret)
& S. V! C  Z" ~0 b( }                pr_warning("Could not register som GPIO expander LEDS");  |. e  r9 O6 s$ ~* `
        else
: ^- ~; {2 a8 G, s" v1 q% g                printk(KERN_INFO "LED register sucessful!\n");9 h) M# y! M5 Y6 x/ l( q2 d

$ N8 `- \$ \' b9 f+ V# I        return ret;
" `" g" [4 i1 ~5 w6 E}
4 ~* B0 I, [5 x" m% j. b+ I* O. M& z* n5 K9 ]. O
static void __exit led_platform_exit(void)
: U# s  m) J3 {2 M{
0 J4 f% d& r+ e9 P, H: n        platform_device_unregister(&da850_evm_tl_leds_device);# n) J! a. e) J: D  @4 s7 N! _

4 o  D1 G9 c1 j        printk(KERN_INFO "LED unregister!\n");
2 W. X! a( C% ]}
. J6 ]0 X: K8 j% l/ c
# w7 [5 f6 M, |& ?5 P( Z/ @module_init(led_platform_init);  H) w  @/ R% z' F' Y; d- @( A
module_exit(led_platform_exit);$ p* V  m2 B7 ^  I* i0 d
. e1 `2 y2 I; q
MODULE_DESCRIPTION("Led platform driver");$ w0 ?, P  d$ A+ i( Z- y
MODULE_AUTHOR("Tronlong");
2 S* V3 ?9 h2 c& V& m0 UMODULE_LICENSE("GPL");, X' Y+ k! h( ^; Y5 L/ u) d' V+ W

. n3 N- g0 m! V* I! c' q0 L
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-14 22:57 , Processed in 0.040311 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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