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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
4 T1 j& y* o6 e& F# g& v#include <linux/init.h>
$ I$ P3 u* ~$ t) ]#include <linux/module.h>
/ x9 l* j8 x8 g( e6 R, Q. l% @5 M9 ~#include <linux/kernel.h>! i+ n% V- v$ y0 N/ w: @
#include <linux/types.h>2 Q, k# R4 x$ B" g& B" J
#include <linux/gpio.h>  [. q! f9 t1 @
#include <linux/leds.h>4 `1 f# Q. R9 g; d% A  w5 L: {% ~
#include <linux/platform_device.h>
% [) k  x: A4 J- `8 h# t; z$ ~
2 q8 ?- J! c! w1 T: P) D) _#include <asm/mach-types.h>  A. [8 ]  P3 c! ^: H7 R% r
#include <asm/mach/arch.h>  }- Y- X" w+ {3 ?6 \; j
#include <mach/da8xx.h>
! `7 j$ J. N( j$ R3 ^7 V2 o- p) j#include <mach/mux.h>: ?9 m8 S. p6 a/ A  j

9 q/ x- H: N, ?#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
* b6 y6 K8 T) V#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
5 `% Q" i! Y$ U+ i  F#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
% Z) ?; s( @- a7 O: [- D0 J8 C#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)( T4 i& Y3 d1 M/ S

7 W5 D) H. n# M! A0 K/* assign the tl som board LED-GPIOs*/
1 N" P$ H& o% p$ S1 sstatic const short da850_evm_tl_user_led_pins[] = {
7 O5 B3 V$ \  [  s. V& u        /* These pins are definition at <mach/mux.h> file */6 I6 M- ^- e& f" |0 B0 I3 O
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. b+ U4 P& ]% z& ]  l
        -1' D& S+ L) o0 `
};
( p9 `+ l( e: T, L+ q; E: F; v
# w( ?- f/ X* f0 Gstatic struct gpio_led da850_evm_tl_leds[] = {% H' U* P, E* w# ]  I* z# A
        {
. f0 t1 Y# _+ ~% d3 a                .active_low = 0,
# s! a" f' g& r$ n- Q                .gpio = DA850_USER_LED0,, D" `/ j- ]/ B" W+ e2 A* R6 d" R
                .name = "user_led0",$ P$ b. W$ w  q7 O9 {: h' W
                .default_trigger = "default-on",& i+ h, }2 P, ?) U. b
        },
% N( f3 o; V% n: J& \2 K/ |# O        {1 O) C4 m5 s9 Z7 A
                .active_low = 0,9 Q2 Q9 }  q3 I2 Z* V+ w5 W
                .gpio = DA850_USER_LED1,$ L* y' _( d2 b% J& p/ |
                .name = "user_led1",3 A' V/ `$ ~' \" W
                .default_trigger = "default-on",
% v% q) Q3 |, Z( w( ^; _7 w        },9 }3 s( S2 R+ j  x
        {. P' O1 b0 |2 @" U7 k( X
                .active_low = 0,
0 O4 T8 a6 }: G% f% @3 Z" ]1 ^                .gpio = DA850_USER_LED2,
2 V# o! u5 t3 c8 @                .name = "user_led2",
4 L( z6 d0 f- g6 H                .default_trigger = "default-on",
2 u* W+ A9 C8 U" C) s2 F        },
7 r6 V+ m" z: L9 b        {* L* E9 X7 T+ V* R- G1 S
                .active_low = 0,
1 o& c0 d6 T" m7 C% l: z                .gpio = DA850_USER_LED3,% R# h+ p7 j) R$ g7 T1 F
                .name = "user_led3",& I# J9 k+ G9 f
                .default_trigger = "default-on",
( }- q: i& B) o. e* |3 I        },; j; A( o2 c( d# A/ n6 S4 E
};2 ^' g! w" V/ Y5 {5 ^6 t& z8 w
* ?0 W: N8 |4 w8 C- U  e' |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
  A& R; W0 S1 x5 B        .leds = da850_evm_tl_leds,7 a5 r$ {2 T& r
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 T7 P6 F( U# {# a) M
};
) k; `8 H8 ?7 X, K$ u5 }. Y& V8 Z$ ?9 Q: A& }( H- T. `$ q
static void led_dev_release(struct device *dev)
- Z. v$ z' N: W2 k  x6 w{
5 N; ^, J) F. q( a4 Z6 W5 u3 Z};
6 ^9 ]4 M1 \9 B! s6 K7 P' @% @+ [0 d3 M1 j: U% n) ]9 e
static struct platform_device da850_evm_tl_leds_device = {
# f6 s' O! a: y2 p" n) t" `5 [        .name                = "leds-gpio",, v2 q3 I/ E' F) b% R7 R& C1 w* V: O; C4 ]
        .id                = 1,
2 b( Z3 I( j5 ?        .dev = {5 O6 W) X( j% k5 L
                .platform_data = &da850_evm_tl_leds_pdata,
- Z+ S( Z% b$ o# e. t$ q                .release = led_dev_release,
) |; v/ a* Z, {0 D( I+ P; I4 ^        }
0 Y' [: Z& e6 w0 }& h! a, W) I+ o};' r4 q  a* x5 P/ s, R  d

  x# G+ K/ B) [; |- q2 rstatic int __init led_platform_init(void)
" V/ E% q6 I/ k/ D$ E) p{
, y# E) }2 F7 J7 R2 q9 i% I# O        int ret;' c5 R$ a8 W% B  c
#if 08 ]0 {4 V' t/ i6 N/ ~7 J
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);  \3 f( }3 K& O* v
        if (ret)1 ]. t) E: r. c4 w+ W4 Y
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- e$ G0 \. u1 {0 [8 d                                "%d\n", ret);
+ Y! c" w6 E3 v4 ^#endif. f8 t+ {% b; _3 w
        ret = platform_device_register(&da850_evm_tl_leds_device);# I2 {! R- ]" C3 f, I- y/ a% N5 c) H
        if (ret). a. X( e8 v- e$ n' j
                pr_warning("Could not register som GPIO expander LEDS");8 }1 p! Z3 n5 p: o; Y( P3 \% t# [
        else+ D1 n3 ^4 g2 D" Y" T' @. J
                printk(KERN_INFO "LED register sucessful!\n");6 H& d1 I* b2 [( z; s) D: W

7 H+ d, g. k0 j, O* v* F        return ret;; X3 L* ~' ?3 f; L& q( s2 u
}( B6 l- ~5 A# M1 d% `

& M( b, T0 _. v9 L) e3 Ostatic void __exit led_platform_exit(void)  A8 k7 E9 ~- K5 K
{- _) S* g8 n3 k& N- _
        platform_device_unregister(&da850_evm_tl_leds_device);
' \* |9 P, N0 A
2 b1 y: r! c9 u+ |% F. K6 s        printk(KERN_INFO "LED unregister!\n");4 _" {/ M  y# Q# I& a  p5 U: q
}
/ b, H( x' s0 ^' Q. s& ?
9 i" H% R3 Y4 T5 jmodule_init(led_platform_init);
( ?$ M; f$ X, Imodule_exit(led_platform_exit);
* V  \' F& |( X7 P8 s
3 Y9 R' |+ t! I' U1 S( ZMODULE_DESCRIPTION("Led platform driver");
3 s! w( R" A: `8 e7 w- t( JMODULE_AUTHOR("Tronlong");
1 L5 C6 J4 g: ~1 I5 ~9 r7 D; Z5 B8 QMODULE_LICENSE("GPL");& f# s- l2 g  {/ {4 \
9 L( q. \+ A# |# t( @
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-1 15:33 , Processed in 0.040592 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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