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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
/ ^0 Q5 N3 ]- W' a3 g6 Z2 i#include <linux/init.h>
* n6 ^  I4 i" t- U8 Z& M#include <linux/module.h>
4 I7 ~7 U4 M- m! X0 c0 M, _#include <linux/kernel.h>! m9 T9 \3 R( B/ h0 E8 f0 h8 D. ?
#include <linux/types.h>
; c# u/ T( G0 j- Z& p2 e9 `#include <linux/gpio.h>" x# h0 }, |# |- Z2 m- [6 R/ I
#include <linux/leds.h># U4 I. @8 u! `0 ~/ ^' ~5 q2 ^" p
#include <linux/platform_device.h>" q- Q  X. {3 j5 `# Z

( v& y  U6 L. t#include <asm/mach-types.h>- ~% ~2 |" C! z' f. ]& D
#include <asm/mach/arch.h>
" e$ W  Q' k$ q9 c$ _#include <mach/da8xx.h>$ a* a$ ~: f% c8 g" j* `" m- S
#include <mach/mux.h>
2 E0 p/ N8 f6 p+ o4 I0 S; W" A8 N9 M! K8 y" N% ^
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
6 k1 L3 a0 o2 z4 Z* s8 r- E) J% r7 o7 B: {#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)1 c) j+ |" S7 D
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)' K/ ?4 ~! x8 C0 f
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)1 w, P1 S' d7 ^0 Q

9 ~' a; A3 ]5 n2 k/* assign the tl som board LED-GPIOs*/5 J7 v& g! j& q; E' r
static const short da850_evm_tl_user_led_pins[] = {$ `0 W# X1 U: \! n( d
        /* These pins are definition at <mach/mux.h> file */
% `3 F+ V& q- ~+ G, @2 Z        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 P$ z8 D% o3 W; \* c
        -1. l9 C- k. R- N/ o% Y. G4 \0 P" h
};  j, ^  `  ]$ @
+ |# _$ J% |" V- O; [( \. N3 |
static struct gpio_led da850_evm_tl_leds[] = {
* x, k3 I9 G) ]% C, q  O        {
; O$ B( p4 s9 s. E! V2 n% F* r                .active_low = 0,9 X6 S6 ?: R7 K, f' W0 r
                .gpio = DA850_USER_LED0,
. ]- j' @/ d. D3 r/ L0 o                .name = "user_led0",
5 @- P$ [4 V! ?0 \; X                .default_trigger = "default-on",. D( E- w1 O% Z/ W
        },. X. G! w* G) X  \4 ^! |! `8 b
        {( {; v; y; d: q" {6 S
                .active_low = 0,
9 P) h- z  n! E% J. ~                .gpio = DA850_USER_LED1,
0 ]) ?; g$ Y  I) _8 m                .name = "user_led1",+ G1 K6 g& d/ b0 T
                .default_trigger = "default-on",
: z0 U5 o+ r6 Q; [# h+ `4 `        },4 `2 A4 Z& F, }3 o) ]1 b: ~
        {
) p3 h0 T; t+ [/ m! Z+ g2 u                .active_low = 0,2 t: l/ _1 g3 i5 j0 y& A+ {7 B
                .gpio = DA850_USER_LED2,
4 Q9 H8 U9 A  o% k; v5 \                .name = "user_led2",
, {6 K5 W4 O% ?8 O1 R+ u( x7 Z0 X9 G                .default_trigger = "default-on",
& w5 C8 |' N) V        },  F: W. y& g% P& s+ d
        {3 [% m; W: A3 |6 t8 B3 Q3 i- H$ f% {
                .active_low = 0,
; G4 |' D1 h" O8 W                .gpio = DA850_USER_LED3,$ w/ e+ t. I2 r& M
                .name = "user_led3",
' b: h6 E/ k& l2 S. [  F# E( R                .default_trigger = "default-on",
8 X# H6 ~; O; L1 y4 w        },- z& F% p, K. m" U
};
+ Z  R3 u0 Z! R& w$ \
& k' j  N7 F: A: E3 h% |- W$ |9 t, Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 r0 y6 a" ^, P        .leds = da850_evm_tl_leds,
( Y) g9 K6 h/ a        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& A' h+ I% E4 c) d; B};% {  a, `; B6 b: W) L( f6 p0 K

2 G' h8 `* }1 L: ]% k3 Wstatic void led_dev_release(struct device *dev). }' y+ U, l; X6 a& r4 x4 T1 z
{
* o. R/ j; \% s3 C};4 m: V3 a# }/ e3 o2 X* A( a
: o# v+ s7 x& [4 W! X
static struct platform_device da850_evm_tl_leds_device = {
/ O) h8 j! T2 W% A* s        .name                = "leds-gpio",
2 E6 f" w3 }% l        .id                = 1,
1 j4 U7 U6 w/ @& g" Q" [        .dev = {
! N  z7 ~( }7 u9 E+ s                .platform_data = &da850_evm_tl_leds_pdata,
1 A  t) r$ e. S* L' y5 B                .release = led_dev_release,' y% _" H+ c" B: \
        }9 U, U; \6 X+ V2 U4 k$ ?( {
};* f5 X/ b+ P' B8 k% w
* p5 w: l4 z4 `, o& [. n
static int __init led_platform_init(void)+ @. ]$ z" y5 |" e
{
3 [) x5 x) _; i8 @$ i$ X  j        int ret;
9 w, ?/ I; q! `$ s! l1 P1 z#if 0  G; ]; `( ?4 L3 b* W8 _6 L
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 c7 _7 {+ d9 l; H        if (ret)
7 y' @5 b8 b! z# Z& W  \6 S5 d                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 E; ^2 E) z0 w0 [5 \' K* G9 L6 Q: V
                                "%d\n", ret);
/ n* L5 a1 d% X- I- t  m3 {#endif
+ x! c5 ]; [% X* M' e0 M" |        ret = platform_device_register(&da850_evm_tl_leds_device);7 F( u: C- V  r1 S! y
        if (ret)
3 }( S' u, j2 [1 a$ V7 O                pr_warning("Could not register som GPIO expander LEDS");
' i8 X" B6 }4 d: _6 z4 ~( n        else& H0 T6 ]* z- N. m% p( y3 ?, g; p
                printk(KERN_INFO "LED register sucessful!\n");
; H  \  W0 H) a9 ~% g2 E; O& ]2 x1 D* e. G' r$ f
        return ret;0 U  Z; Z: S! H5 w
}
: S2 `; c6 L5 t4 a3 {) ?  x% |: ]) ]
2 w) p8 d6 M. a' jstatic void __exit led_platform_exit(void)5 s7 l) n. \, V# k* Z! N
{
# x$ y" y% Z3 s, {: ^3 s        platform_device_unregister(&da850_evm_tl_leds_device);
( J( @& v2 r. g; l& q; h* x& n9 A8 H7 z# v; J
        printk(KERN_INFO "LED unregister!\n");$ }! Q+ p& W4 h7 R
}
1 k' d5 S4 ]2 n2 N. @* U4 n$ o* F* p
9 D1 b9 Q- x6 X4 l5 U6 Z* bmodule_init(led_platform_init);
: b0 [% r% I* u2 b" ?module_exit(led_platform_exit);: ^  g5 r$ O$ U$ |% w6 E" T

. u# Z2 Q2 K& y; G* VMODULE_DESCRIPTION("Led platform driver");
) G) c: w9 D8 C5 a  z$ Q' J) \MODULE_AUTHOR("Tronlong");
/ n& M8 C/ t+ _( v) b8 L" L2 ^" yMODULE_LICENSE("GPL");
4 R7 Z9 e8 f$ _* d; W$ _" t& Z. n/ s( z( u* D
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-10-13 06:54 , Processed in 0.042202 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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