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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。& K5 [: b; \+ d
#include <linux/init.h>
! M1 x$ p. B0 K#include <linux/module.h>
5 ?, y( D9 ~/ P: n. i* e#include <linux/kernel.h>$ M, k. K* ~' \7 E
#include <linux/types.h>
% F4 j& a- F$ k( \5 ^  Q3 L#include <linux/gpio.h>
' _$ A) C9 V  H+ e4 i#include <linux/leds.h>
% _8 f; v. w8 J1 D#include <linux/platform_device.h>
8 s  ~7 H3 ]7 G; U. T3 u/ V, K: A+ e2 S) q
#include <asm/mach-types.h>4 P4 K3 V# L- M  m
#include <asm/mach/arch.h>% y1 f3 n) ~$ [, e
#include <mach/da8xx.h>+ L; F; H  J, A7 u9 r" G2 L" k& D1 y& P
#include <mach/mux.h>
& E) f6 @% j0 Y8 a  c5 E3 a% I4 p8 y+ \0 C$ w3 m! x
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
0 e2 p; r* z3 y" \4 y) l7 a8 w) v# Y#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)3 Y- R3 A6 `# h: p% o
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
" b# ]# n0 B- K1 a#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)3 e( M. m8 ?2 |3 g

$ M! |) n0 e, l% W7 Q4 C/* assign the tl som board LED-GPIOs*/  J; C! X' {" o7 }, d5 t: w
static const short da850_evm_tl_user_led_pins[] = {  L% p' A/ W/ ~1 m' g5 e7 @. r
        /* These pins are definition at <mach/mux.h> file */
' O0 j; ]  a# R+ U; q        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 p( x5 h0 p, A( n9 z; B        -1; k, R  [  @: W& J( ~- ^% L
};! @9 k, B4 x7 Z" K; b* z

4 m9 g; m& u9 V4 @static struct gpio_led da850_evm_tl_leds[] = {& a. \: p" D: p) f7 S( i% ^2 L
        {; C' D5 Q  t! R' T
                .active_low = 0,
# {' S0 n# B! _) O: D' N                .gpio = DA850_USER_LED0,* S7 f6 b; n3 F/ t6 t  d
                .name = "user_led0",
0 q, v+ Y. p4 P: L7 M2 R+ k) i% W                .default_trigger = "default-on",
4 x7 h* x+ j( _8 i* F+ a* I        },
" u' X: u. S. o. }        {: G6 K8 R1 ?1 V0 N, X% ]0 `
                .active_low = 0,9 t" }6 P4 W& W2 p7 T) u6 P
                .gpio = DA850_USER_LED1,
7 [9 E$ U3 S1 R% ~7 U                .name = "user_led1",- m0 T# K  d, o8 W
                .default_trigger = "default-on",5 s- T1 f; n- J0 {+ ^8 f/ Y% r
        },
( r4 v5 p2 R; o# J! v        {
8 K4 r4 q7 H( c3 u6 k# U# \                .active_low = 0,
& w* J; y  t4 P$ z                .gpio = DA850_USER_LED2,
4 }% y. F/ D! p6 l* }                .name = "user_led2",5 F3 O$ H6 f+ U; Y3 l3 H; ~
                .default_trigger = "default-on",, x* s' o9 t" p* R, l9 N
        },- P) H$ E( P. s7 p
        {* j; \5 Q' L+ t3 u# y: f, Q
                .active_low = 0,
8 g/ X! `! S! s9 f8 i0 P3 @6 ]                .gpio = DA850_USER_LED3,
7 K$ l0 `2 K7 ~" `                .name = "user_led3",/ Z! R6 V( f' b* ?0 A& n; E
                .default_trigger = "default-on",
: Y. u) o/ O0 U: H        },
0 G$ P: x( |% U. K5 ~) E};
! z6 \- ^5 L+ \5 S+ d1 F; c: K; ~4 i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% m- V* x: r' @4 ]
        .leds = da850_evm_tl_leds,7 i3 h9 p. b/ w8 w# B$ k
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 y2 Q3 \" q5 [- D: I};
* N( z& `  t2 A* `5 D& q0 j+ L! P2 X
static void led_dev_release(struct device *dev)* Y: U! ~0 |, n1 A1 t* I
{' ?0 b% b: X$ }+ A
};4 \3 R2 R% x( ?' Q' M4 i" E9 N

; t, r( h) e' p5 rstatic struct platform_device da850_evm_tl_leds_device = {! |) @% N5 G' F2 c; U
        .name                = "leds-gpio",4 P) |- u! g: a( T$ l
        .id                = 1,
; c# [5 r6 ]* L& w' q+ d" L        .dev = {" i9 P: g+ y$ ?# g; Q5 ?# a4 Y
                .platform_data = &da850_evm_tl_leds_pdata,' s+ }$ X  i. g3 c8 d& r, I* @: O
                .release = led_dev_release,+ v+ k! e& s7 c
        }, w& I7 s2 `  ?  e
};. A) h" N' I9 ~5 ]) g% V3 C1 W) ^

9 r5 B. F$ X+ Wstatic int __init led_platform_init(void)/ y* J' j8 G- B! i: T
{
! d; R$ w' V/ M  p9 s# ]2 k        int ret;6 w+ i% H4 z. {" E* S, e6 Y1 b
#if 00 \: U9 d3 A7 e- B& s4 w( Y, I5 `5 e
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 v0 D. U) ^( k, }2 L        if (ret)
' w! o) B7 H. F' u' y                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 K% f- n. R1 n                                "%d\n", ret);; k/ t' T. r4 `6 Q1 i
#endif
6 T- |; }0 N- I9 N4 E" N" P9 T        ret = platform_device_register(&da850_evm_tl_leds_device);
$ X% o$ a" Q) E: j- U        if (ret)9 o2 o' @+ a* _9 l( ?8 {
                pr_warning("Could not register som GPIO expander LEDS");1 L; w; P  J& F7 d: y' e
        else9 |0 n. @1 n2 V9 D" ]: a$ e
                printk(KERN_INFO "LED register sucessful!\n");
0 l7 @$ H* g. _$ t
" }" c$ [' f& D- S        return ret;
) X6 X" x7 k- C1 v0 M5 m9 U}' |3 x9 b8 y. E/ a9 R0 e9 v
4 }3 \! O! a$ z$ F3 U; C, A7 q; y  E8 T
static void __exit led_platform_exit(void)5 k3 i8 L  x, W! ]9 G, n/ S. ]
{/ b( ?0 |% C% g" s% k: H4 B& [
        platform_device_unregister(&da850_evm_tl_leds_device);
$ U5 p0 O0 t1 R1 c8 v0 A7 q/ W
' r8 w5 t! C% C! p! O        printk(KERN_INFO "LED unregister!\n");
+ C' M9 G6 H: e. {; D}
4 L+ E6 [& I+ V" u- J( N' e; ?3 c( F0 p8 a3 M7 P5 Q
module_init(led_platform_init);
3 G% n" q! n* X$ s( W' z8 j( rmodule_exit(led_platform_exit);
6 }" m+ P  m5 u1 ?+ B& ^& V4 K( l& ?! b) X! S) J
MODULE_DESCRIPTION("Led platform driver");- A+ e6 P9 c% H
MODULE_AUTHOR("Tronlong");
* v  F6 D/ X$ I: T' ~MODULE_LICENSE("GPL");
2 ^, s% g4 e* Y- s5 u4 X7 {  @3 s& ]2 `: Y! L
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-26 22:34 , Processed in 0.035223 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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