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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
6 t/ {) q. w' I% y#include <linux/init.h>$ V, z0 A1 E5 \3 j
#include <linux/module.h>
1 E( N) J7 u5 _#include <linux/kernel.h>
% u  f) K6 ~3 `/ _. I#include <linux/types.h>* m1 u2 Q# s4 O" w
#include <linux/gpio.h>0 s" c" d; S% t8 j- e/ V) Z
#include <linux/leds.h>2 }( O4 I+ z& C% E# }- O% i
#include <linux/platform_device.h>$ G  [/ a' a. o7 U

9 C/ ?' D7 b! _( F( u* D4 N6 A( G# E#include <asm/mach-types.h>& I9 @) f& m7 `! {
#include <asm/mach/arch.h>
, h% `- t" P9 A. \% c: ?3 `# m; f) P4 D#include <mach/da8xx.h>
& o7 V- G: \& n% Y. X3 L* `, a2 a#include <mach/mux.h>5 _# o& F0 v+ s& }) M
% j' c* w1 d* [, |/ r
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)$ Z: Z* z  G" `. [4 J. P+ \
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)3 X, e( V1 e) }
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
' d7 m3 H, h6 ^0 M1 ?#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)) x" b3 S" v* X) ^
$ i5 S1 _5 e4 i3 ^
/* assign the tl som board LED-GPIOs*/
8 |& }5 c/ K/ d$ ?static const short da850_evm_tl_user_led_pins[] = {, j+ |$ Y; g$ ]
        /* These pins are definition at <mach/mux.h> file */
/ H8 h& Z& J' n# l- f        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ K' D: N: w9 [% v0 ^2 I+ {5 ^2 G        -1
; U! I$ C% C7 L8 k};8 R, m- `/ x2 H! p" }
8 I* K, v6 P+ u3 d0 D
static struct gpio_led da850_evm_tl_leds[] = {# z8 }% j5 r2 u; }, T' e
        {
& C% e& R" o3 Q                .active_low = 0,
2 X+ U: D! u! f+ c4 c8 P' `/ T                .gpio = DA850_USER_LED0,3 ]; z3 J) K) M" Q) ]& ]8 l6 J
                .name = "user_led0",
# x+ M2 Q/ @0 N, b0 I8 a; h                .default_trigger = "default-on",
/ g- |+ Z7 Z1 r/ \' Q1 s, W5 C        },
/ D; u9 q' [% U' d7 r; I- X        {
4 p, }. p1 p4 }  o                .active_low = 0,7 W; c4 [6 e4 T& T, y
                .gpio = DA850_USER_LED1,
+ K8 E2 D9 h8 g. O6 c0 r& x                .name = "user_led1",
$ ?4 o1 M% X; R+ `+ }                .default_trigger = "default-on",
/ n* u! D5 g4 b$ v1 o" y        },/ ]3 f3 K* S& T& {9 p; u% C2 N. o
        {
4 l9 t7 }1 ^& F! b( m                .active_low = 0,) ?: J+ o0 c% F. R4 c# q7 ?7 }; B
                .gpio = DA850_USER_LED2,! [7 L  `8 f/ P( ~
                .name = "user_led2",! M7 [) d7 M) N9 O* h! A. S3 T! M
                .default_trigger = "default-on",3 s+ E1 G- b  o$ J+ ?/ o
        },
  T. p% P% U* Z# }* d  Z        {6 w3 i# V2 x- b
                .active_low = 0,
( w3 h/ o) y& K" S- y8 N                .gpio = DA850_USER_LED3,
6 Y: V7 e0 f" M& `8 k                .name = "user_led3",( ]% G4 p5 N. g4 Z2 {& Q
                .default_trigger = "default-on",
' H7 {6 ~' e0 T4 V/ V: y( C% L        },* d$ U% {2 C$ A, j
};
7 }1 M8 g4 f0 A) u8 S# E- ?1 j) E  [0 O# o9 c
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 `' n! |, @9 y5 t& U        .leds = da850_evm_tl_leds,
' V. e! `8 x( {5 v: f6 G        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),  Z, e" c9 |3 m# }
};( G/ A; Z+ d0 C

* N% G' H& @, k! ]! Qstatic void led_dev_release(struct device *dev)
+ b: L' A+ L- ~" c9 G/ t{
9 G9 e, L1 ?" C};2 P2 ?9 |+ _7 l) X5 Q
) X9 M+ M, a: ^! O  m- e2 f
static struct platform_device da850_evm_tl_leds_device = {7 C5 y" j) Q! u7 t
        .name                = "leds-gpio",
! r9 J* p- f7 f- j        .id                = 1,  r+ f9 f3 @. a6 I
        .dev = {  z. E, a6 H; C$ L7 J
                .platform_data = &da850_evm_tl_leds_pdata,
6 r) J4 ~8 r5 m+ u                .release = led_dev_release,' \; \$ v" D: i' l( U
        }5 b0 o  v, I5 m& ?
};2 H& N% D7 l4 R
" o: w0 \8 B$ x7 V
static int __init led_platform_init(void)
5 E$ w% P" u5 d& R6 D* e/ T{! |6 w8 z7 r; L; P, M
        int ret;4 J( @( ^5 d" P* x" Q
#if 0
0 c, c7 i' M/ C1 O% C        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 c$ l, @( n) R
        if (ret)
1 l+ B( L' d4 S                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 l; e  x* u8 C! o. V                                "%d\n", ret);
' i, X' {1 |. R* P0 Y#endif
4 M1 f2 A; i9 S1 T        ret = platform_device_register(&da850_evm_tl_leds_device);
6 |, R1 K& h6 i  E        if (ret)
6 t* \1 A8 g9 F  b3 q                pr_warning("Could not register som GPIO expander LEDS");7 R+ ^: D% N0 G, r" I9 ~" b) {# ?" L
        else4 D  g$ o0 `/ [
                printk(KERN_INFO "LED register sucessful!\n");- k3 g' F. Q: V& W

& e  W+ j: k$ e1 C        return ret;
/ T# Y1 C/ n0 T}
" K1 i- M7 s/ D6 e" S: g! ?+ ], W# q* T$ W$ y8 Z8 Y! N* q8 p+ A6 E
static void __exit led_platform_exit(void)
7 F, A, h5 _$ ]  f{$ I9 P: M+ p3 L' S* [2 S4 n3 d* {
        platform_device_unregister(&da850_evm_tl_leds_device);$ N7 s5 {: ]# ]) Z
# \' B" J) [, B: j( k
        printk(KERN_INFO "LED unregister!\n");$ Q' y# M4 m) M3 i/ O
}
6 F1 K- o8 q- L! V9 x6 _6 w
( h/ z$ \3 Y- d# e  t) I, gmodule_init(led_platform_init);8 w' n: Y2 g0 |
module_exit(led_platform_exit);8 X. z2 w9 }' ~0 e- x3 ?! W+ z

3 G+ r8 C+ |! q: ^6 [. R, WMODULE_DESCRIPTION("Led platform driver");- Y) R0 }( E5 y' m& A% `( K
MODULE_AUTHOR("Tronlong");
( v' |) W+ V, [0 N( u( B4 p+ }MODULE_LICENSE("GPL");3 r! `9 a4 D+ U) t9 S% W, m. _, R

1 N/ E( Z9 s  \) E
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-21 05:11 , Processed in 0.036999 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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