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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。* j" O4 A. L9 b
#include <linux/init.h>; W$ U; m6 k* F
#include <linux/module.h>
3 z# O% f6 o, B7 K. V#include <linux/kernel.h>
+ E! A( K0 e7 y7 t: x* A! X! [#include <linux/types.h>+ C5 k! P( Q1 e, |5 ~
#include <linux/gpio.h>2 E4 |4 k$ C4 E4 q' w3 h
#include <linux/leds.h>' L+ ]- |/ H& B! B" E
#include <linux/platform_device.h>$ b9 f; [/ A+ C  l/ K
9 R5 T" H( D- m( w  E9 I; g5 w
#include <asm/mach-types.h>
1 |5 J+ T* `* r7 K7 H#include <asm/mach/arch.h>& ~8 c, @: K: R5 ^
#include <mach/da8xx.h>
: X, b" y6 _2 {0 D# W7 ]#include <mach/mux.h>
. Q, e2 J3 R5 C2 E( u5 K$ h0 y. I3 q/ g( ~3 @
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)8 H" R0 T& V7 D9 H
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)% W1 u) }# h) ^& ]  o0 s
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)& n: l4 `1 o8 i% O
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
7 c  L! G3 G1 @+ _: X9 ~3 R; o9 T$ P  F  ]5 V  Q2 R6 x9 D/ i
/* assign the tl som board LED-GPIOs*/
) F4 ~! U5 G7 h3 C! m5 [static const short da850_evm_tl_user_led_pins[] = {- v7 T$ F" l  Z5 n3 m! |" ]
        /* These pins are definition at <mach/mux.h> file */
0 S9 F- S) N( [        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) F$ h! W' I  \        -12 C/ x. H) L2 ~2 p
};
5 }8 b' ^7 p2 V9 B
( i( c( g0 w, F7 Z  a  ^static struct gpio_led da850_evm_tl_leds[] = {5 _7 m3 D" `4 h9 L, B
        {1 N: H+ w/ z. [. D
                .active_low = 0,
4 |6 _. h4 s! f& m                .gpio = DA850_USER_LED0,
: d1 v, y% x- c! J- t0 _$ Z: w' D                .name = "user_led0"," Q+ Z2 e4 B, K2 L7 `$ F
                .default_trigger = "default-on",9 V- z/ Y8 r" {' b1 j$ R3 q6 n9 E3 c, A
        },
7 x7 q7 g' D6 y$ }, t: M        {& w- D: w& ], M  _& R8 A1 }( ]" c
                .active_low = 0,
  l2 p% r) I9 i& ?( [! y8 H3 _                .gpio = DA850_USER_LED1,% a, e# q  U3 R& O( M3 y+ |0 ]
                .name = "user_led1",
; f' S' L1 ^% T7 Y3 g! T                .default_trigger = "default-on",3 h9 f( r( ~  w$ ?; t& M$ w
        },
6 J- o: z  w6 e4 ]$ B: V9 x        {
* H* N8 e- t: E$ J0 R7 L& X9 m                .active_low = 0,: ^+ l! [+ p1 j% b5 P/ g$ Z' w2 l
                .gpio = DA850_USER_LED2,5 I6 i. n$ X' ?% B* [) b
                .name = "user_led2",
1 h5 a8 z8 ~' q* u0 Z" P5 w                .default_trigger = "default-on",
( I9 ^) r6 l3 x  l        },. T) _/ D$ S7 E8 w
        {
( u) Y! _* Z% f0 ?0 ~" l& x                .active_low = 0,
& [3 l: K$ A" A4 V# t# q/ {                .gpio = DA850_USER_LED3,0 ]/ Y# @2 c- e1 G+ I
                .name = "user_led3",
8 W9 H! S' S  k. T' `                .default_trigger = "default-on",
, k, S" J9 N5 Y        },
- b" Z, G" A( Y# @: \& S3 t1 \' g$ }};
' g9 v6 c" N- d* B. D* N
% h, g4 r4 K" L4 w" C. Zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 ^6 f3 c1 l" Z) T        .leds = da850_evm_tl_leds,6 q8 B* y; q: r) D" _% D+ V
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 }9 r: w4 m; [$ b( s/ r
};2 P5 h! F6 F0 r# @" r# Z) A

1 U& @6 _) @( U4 i$ G2 z  o8 ~  R0 estatic void led_dev_release(struct device *dev)
) n2 Y1 B' e3 E* A{7 h% }% a2 {% t4 K
};
' A' O' c: I" b; m/ n# e" f9 _; d: z9 D- e/ g
static struct platform_device da850_evm_tl_leds_device = {1 d# c( b! O# f) F
        .name                = "leds-gpio",
% n, p5 K( z7 z  t( ~- r        .id                = 1,
2 Q, F$ g8 a1 d$ U9 F        .dev = {/ L5 F7 n1 n5 S
                .platform_data = &da850_evm_tl_leds_pdata,; s" i' |- c1 g* q& Z( X1 y
                .release = led_dev_release,
# U5 q; G+ c1 M, k" r5 B$ G8 [  h        }
9 X3 n) e$ \! a7 B: F# Q};
, e; t% d2 @, |
: n- R1 H* b& o3 S" p' h# J1 j- sstatic int __init led_platform_init(void)
- g; ]# k, F3 _2 a6 j{! K6 t# S# T+ F/ d6 I
        int ret;5 U8 X$ Z) C, z
#if 01 v+ I( S1 H) v4 u/ ?
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" y$ _+ Z  v% V& ^        if (ret)
5 [3 t+ T; [7 d" Y( R                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 X! R- R) _  N/ E                                "%d\n", ret);
! N, P" ^2 f( i/ f- ?& f1 F) h& ]#endif
* Z" B& I5 H! ?% @        ret = platform_device_register(&da850_evm_tl_leds_device);
0 j; s- m8 w% G5 X        if (ret)
( H" V7 a/ x4 T+ S5 P                pr_warning("Could not register som GPIO expander LEDS");
3 U$ @  Y- D7 k, o1 N        else
4 ~! S5 D! B: F# `9 m/ |1 s                printk(KERN_INFO "LED register sucessful!\n");% |! p5 M. m/ @. E2 Q

: ]" Q; ^# q# i3 a: h        return ret;
3 R' D7 w8 o& f5 T  V1 @6 l( o' k$ {/ W}
" j: y& }" t: S! i; |
. X, W: [% U; ]) ]6 D8 ~% m& Z. Lstatic void __exit led_platform_exit(void), Z" Q! \5 o4 T9 p$ ?. J0 m" ]/ k
{
* ^( U" @% e3 P        platform_device_unregister(&da850_evm_tl_leds_device);
% r4 z. ?. M+ `7 N
! E- z: x& `0 T" O        printk(KERN_INFO "LED unregister!\n");+ C% w( G  Z6 P- _0 d
}
  i& u7 I' v# l% c: V
) N  M9 t8 n1 ^- L2 @# k5 vmodule_init(led_platform_init);4 I/ N2 _& ]0 S0 A) g- J5 j
module_exit(led_platform_exit);! `, b- U8 q% j% k8 f
2 d+ s+ N  Y/ ]3 |- y
MODULE_DESCRIPTION("Led platform driver");9 x+ V, a* J+ M0 @  C4 N; z
MODULE_AUTHOR("Tronlong");
3 u, Q# J& D8 ?- VMODULE_LICENSE("GPL");
, ?) J9 N- i6 f, [% g# q1 v/ d: N1 Q4 m0 h0 E; H
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-11 23:06 , Processed in 0.038813 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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