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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
' W" E+ V' T' g#include <linux/init.h>. Q. S6 J: d" s1 ?, J
#include <linux/module.h>
0 Y' p- E' `0 g% c8 ~: \  n#include <linux/kernel.h>
8 C; ^8 s9 _; x/ I#include <linux/types.h>
% B4 M0 k1 r! W#include <linux/gpio.h>) d9 s$ J6 V- t& v' m" j( f6 u
#include <linux/leds.h>
. W7 S0 n; V, I, o: M% C/ O! e/ @#include <linux/platform_device.h>
0 ^! p' \% E8 y5 A' T2 w3 q0 x5 x$ I4 I4 y5 J# J
#include <asm/mach-types.h>
9 J. v9 H  p! B: L2 K#include <asm/mach/arch.h>
& k' k! s5 ^4 T' v#include <mach/da8xx.h>( U9 X/ \8 {. `3 G! a1 O
#include <mach/mux.h>3 f/ {6 w7 k1 X' R* u

  B3 f! ^7 b: i2 s% F#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)/ J: I# @5 ~6 h
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
7 {1 n" x0 i6 F/ i6 g$ M* f#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)( \& k1 @4 V& O
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ y1 a* P4 R0 G
$ K5 u9 E" M- @! b& S. U' T
/* assign the tl som board LED-GPIOs*// ?; N6 x% ], L5 @
static const short da850_evm_tl_user_led_pins[] = {! C2 P: _* d& O$ D8 x+ P3 y
        /* These pins are definition at <mach/mux.h> file */
5 Z8 f# k! K7 O" ~& ^' {; B) V        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. V/ h9 J. }9 D7 X
        -1! w3 E% U8 d' d) P+ a
};$ d% V, K* L4 g  W" V3 A
4 w8 [* \: B9 |7 t  W) `. T6 U
static struct gpio_led da850_evm_tl_leds[] = {7 I7 h# B: p. m
        {
& y* V) `; r+ D0 W                .active_low = 0,
. p( q- w( s0 s( P                .gpio = DA850_USER_LED0,
0 n7 E  H& |# a3 i* ^% A                .name = "user_led0",1 z4 c: q# X$ M3 ~5 c9 Y
                .default_trigger = "default-on",
8 {, J  C& V! m9 Q        },4 }7 A( y# `! H; J6 }( {& M
        {
* ?1 `0 c9 _$ I$ P                .active_low = 0,  }. ^. b1 i1 p0 t7 U- K7 l- a
                .gpio = DA850_USER_LED1,5 A/ v) X+ Q& S: Q
                .name = "user_led1",( x3 A  x- N$ Z% z9 j' R' O
                .default_trigger = "default-on",
2 X2 p- O+ G. G9 R# A% B/ w        },
9 @" c8 a( C: @8 F( D0 h; Q        {
8 U4 g+ c/ _+ A( a9 @# ]                .active_low = 0,. u9 ?, G: i9 w. j8 {1 u
                .gpio = DA850_USER_LED2,  {% p3 c6 T% e! V6 Z
                .name = "user_led2",0 o3 j6 Q* @  [* c  C
                .default_trigger = "default-on",* a' Z( ?6 r$ s: U9 N& [
        },! ^1 r$ N4 O; V- Z5 l1 I/ ]
        {
5 q+ B  a1 i( S! y0 D* o6 l; z6 I                .active_low = 0,
" q) }$ K# ]4 C. m5 v* F                .gpio = DA850_USER_LED3,5 ~( }7 \+ t4 m% r, G
                .name = "user_led3",! f$ Y. C+ L+ n: u
                .default_trigger = "default-on",) H( ~. d7 w3 A% |" v
        },: J6 ~1 }1 y0 i* T  e4 I/ N6 A
};
  i0 |  ~) A% ]  R% C. ]7 z
3 E$ a2 U3 H# x& @0 D% S. zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 H( G% d- C+ i, F- E
        .leds = da850_evm_tl_leds," s) F6 O& R, i
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 C! |; S$ U) Y; J- W# ]};( R+ p4 z5 a+ m0 w+ C, b2 H! Q* _9 A

: i1 w1 `* A" t! d. f+ m6 f0 u! fstatic void led_dev_release(struct device *dev)
5 m. u, Y6 R% C, w, ^" @{
! ?; g/ C+ y1 o" `+ p};. P2 M. {9 U0 J, H) E( m

2 p/ [: n8 j$ ?5 p, [3 Fstatic struct platform_device da850_evm_tl_leds_device = {
$ }" H! c; e; x- Y5 g' t$ R        .name                = "leds-gpio",
0 e& _  {+ d% M& X7 ~# N! H3 u        .id                = 1,; c1 ?9 E2 X( p# u$ `' a9 t; v2 {
        .dev = {
0 ?) _! X( z4 b                .platform_data = &da850_evm_tl_leds_pdata,$ y$ D" f2 P* R* f
                .release = led_dev_release,
) S/ K4 j7 r) b) }" A- r, U# q        }" u0 \8 F8 G$ G7 z  J
};5 X% D% u' C; Z6 v0 h$ H  e

/ t' r8 b/ K% _, T& mstatic int __init led_platform_init(void)
" J3 P4 F' @  V8 [) B7 w# f{6 B& T) y# I/ r" m
        int ret;: i/ Y0 {" P4 p2 N3 I
#if 0; N1 V( b, l/ }; ?
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 S( y4 V' i$ x5 B8 ^
        if (ret)& z% _$ T! G, f  m1 _& E6 F
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 g( p6 o" g2 j7 p% q+ {                                "%d\n", ret);1 B9 S# ^4 e  X! T: M
#endif7 t/ G3 h8 B8 {5 ~4 [7 w
        ret = platform_device_register(&da850_evm_tl_leds_device);
2 a- d( Q7 ]5 o8 a/ @        if (ret)
, k6 s( x# M3 g                pr_warning("Could not register som GPIO expander LEDS");0 a" \; {- I/ r2 k+ h% W
        else; f. B0 L- p& F, \" H3 w
                printk(KERN_INFO "LED register sucessful!\n");$ E$ U# S! E+ T# ~
! h( D6 x0 E. ?! ?9 S' I) i
        return ret;; P$ r$ h& p/ x9 l; I
}
* e$ Q9 f- t. J! N9 Q8 f  t# [& s& V5 [. p) ]4 Q" U+ \1 q( d
static void __exit led_platform_exit(void)$ p3 t( U" y( |  ^
{2 g4 |+ @( l) Y# t6 i0 L
        platform_device_unregister(&da850_evm_tl_leds_device);
* A  s  o, f0 T% L- d6 z3 M3 K  T) d8 _
        printk(KERN_INFO "LED unregister!\n");
, E' {5 B( K' y' \! Y}* ~. Q4 z% c1 n. y! N: U

0 Q5 U: e$ w& L& |& u. Dmodule_init(led_platform_init);
$ x/ U$ j' j" N- [0 c6 L9 x/ Qmodule_exit(led_platform_exit);" w+ F5 Z1 f  r0 r4 c5 e9 w
: @- R) ^  {9 a3 ]2 \
MODULE_DESCRIPTION("Led platform driver");( s0 _/ n/ ]# K  `
MODULE_AUTHOR("Tronlong");5 X- x* _1 A  X! v: ~7 G
MODULE_LICENSE("GPL");5 X8 a# x; Y1 o, T) Z( H

  M" ]1 z. W7 N) g, i
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-6-27 15:02 , Processed in 0.039583 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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