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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
; ~9 P% D: e+ P* t#include <linux/init.h>
' ]& {2 R- S$ U, e) I#include <linux/module.h>$ ?1 x$ w7 e0 K$ [" I) X
#include <linux/kernel.h>2 L& L5 I( b' L+ y7 K8 S
#include <linux/types.h>$ f- ~/ X$ _9 n( |' \* X$ [
#include <linux/gpio.h>0 L/ _3 }" J3 L2 y2 `
#include <linux/leds.h>8 Y  }, ~! i- ~! z. B. h' ^
#include <linux/platform_device.h>
; f. x8 v0 P* N6 L5 m/ T
# G3 [0 U5 g( b' V) K% y+ u#include <asm/mach-types.h>
8 {  ?; t3 N+ n2 z7 s, S#include <asm/mach/arch.h>1 _, f/ H1 h. A& i+ `4 O
#include <mach/da8xx.h>' F! q- |$ O* ~+ |% D9 C
#include <mach/mux.h>2 O8 f: q, `- c3 k& {0 g3 g. L1 }

' T3 a3 x( E4 L. {#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)  f& K& n) s! u2 h% x9 Q
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)7 c1 x: k* e' b/ |; q
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)" b/ @" ~6 K+ i" D+ K( M8 d
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
+ O  q. p: p3 {" Z4 k- n
5 ~3 ]% n( F! x1 V' E/* assign the tl som board LED-GPIOs*/
- u' F* O. M5 J  j) mstatic const short da850_evm_tl_user_led_pins[] = {
  j* w, f6 W+ I. T6 k        /* These pins are definition at <mach/mux.h> file */
/ F3 B' a% c9 |, i+ ?# C" g# y        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 p$ m. m! z/ o# b* f- q, G
        -1. S2 g' x5 D" n# a
};
  t5 O; c. e# T/ g+ `% k* `9 M+ y  X2 E8 _/ l$ s
static struct gpio_led da850_evm_tl_leds[] = {% ?1 K( u/ N5 |* U; f
        {
' a9 ^* H( ^4 x) @7 K) ^' P                .active_low = 0,
! _& q& w! F$ j* J1 w                .gpio = DA850_USER_LED0,
# q# \7 L- h% v( B                .name = "user_led0",
* }6 }( |3 |8 Y+ J- H7 \9 f: W# |                .default_trigger = "default-on",' C, j5 k' F" ]0 R4 E/ q
        },# s) k9 k) _0 u# L% }" Z* E; x
        {
; a7 }8 E% A% c$ [6 Z* P                .active_low = 0,; ?$ i" u+ y" C$ p' F: I8 K
                .gpio = DA850_USER_LED1,+ l1 @6 c- R; u0 D
                .name = "user_led1",1 F/ k$ R+ ~# M- P5 |" J$ X& u; L
                .default_trigger = "default-on",, t, r8 s) H. G& F& ]* q" @- A4 W
        },
, _) r( Y9 E; d+ q        {
0 N7 c! J' k5 M8 G                .active_low = 0,' K5 g' ]  b8 i
                .gpio = DA850_USER_LED2,
$ z0 @; D8 D+ P: F4 g( A5 r3 @                .name = "user_led2",
+ @3 @+ c  w+ ]- y                .default_trigger = "default-on",
4 j, n9 u0 b3 Q0 G) _        },
( c' C8 `/ j* z+ X) n- N        {4 M$ D! y, E+ |' S; M
                .active_low = 0,- u1 ?) Q# g& L" P1 ^) u2 ]
                .gpio = DA850_USER_LED3,
: I" D5 B4 y8 \7 f2 a0 u3 A3 t                .name = "user_led3",' p/ Z+ \- m, a6 p- x
                .default_trigger = "default-on",
. I4 H* ^+ o" w: B, n; n( J        },$ f/ L1 z, m. A4 E2 }
};
% T7 q: r8 G3 \/ N6 l
' N2 I3 L( Q, z8 `( Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 m* }! ?( [$ m2 `' T% U6 ]; o
        .leds = da850_evm_tl_leds,
' S( I* H# ]  b) g! }        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 c, {* E6 v2 |+ A0 k};
4 }" a( A# f% _8 ~+ T! e, A- K- C# n! n
static void led_dev_release(struct device *dev)1 C% [( ?" _9 N, q, `' h
{
( {( q. A) S, R; Q. W7 u};0 W& p; P& E8 v5 j5 S4 D6 v
7 g( X6 O! N7 m! j3 e
static struct platform_device da850_evm_tl_leds_device = {
4 P6 Y" H( G7 a8 A* t        .name                = "leds-gpio",7 o- A6 `5 F% y
        .id                = 1,6 R. _8 [9 {+ F" C# ?" A  N
        .dev = {# Y$ ]( o2 r. a3 ^
                .platform_data = &da850_evm_tl_leds_pdata,9 _6 e  s0 ~9 w+ f0 \6 r
                .release = led_dev_release,
: D* }8 X+ a7 U5 A9 w        }
! K* M9 f5 x4 x- G" M/ n9 t};! G6 D6 D9 B) c  T
# f" W+ [% H  G6 K' f( Z# Y; u+ \& ]
static int __init led_platform_init(void)$ ^4 l+ [+ J0 m# Q; P# m
{4 N7 n' H& K4 j5 {/ ]
        int ret;, B- s( H! I/ m3 [, l
#if 0/ j; E1 M" b' b4 N. G
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: s3 c( U# Y/ g$ G( g8 e
        if (ret), C9 z& e% U; H; ^. H3 I9 ]
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :". v9 G. p% j. q1 `9 u* E
                                "%d\n", ret);
5 H; {# A6 _% u, b- B) s: y) n#endif! G* D+ G6 X( x; F/ E+ w
        ret = platform_device_register(&da850_evm_tl_leds_device);/ t' b& a/ |5 c3 b
        if (ret)' q% M/ k; Z; F
                pr_warning("Could not register som GPIO expander LEDS");
" U" x  A" p6 \. X1 ], M1 D        else
+ N6 F' F; Y- ~( O                printk(KERN_INFO "LED register sucessful!\n");
) S5 j' k  e5 X' i- E2 a7 g" X  b2 O: E$ ~) L; V& g  G
        return ret;) N' L$ Z) o9 N
}
  F, A) ~- o, X9 Z  Q$ k6 \1 P& @6 B5 }' P
static void __exit led_platform_exit(void)
- i! `4 ?; s" U2 |0 v3 D' w{
" Z7 Z9 y. I/ ?' i! ?; [. W3 ^        platform_device_unregister(&da850_evm_tl_leds_device);
3 |; d5 m" w+ B- F
. G5 V6 d7 e" k7 A        printk(KERN_INFO "LED unregister!\n");0 _2 J4 {, z* ^. }
}/ a1 s* T+ M2 T# _) j" m" z0 |

  q0 ]% Y3 q3 t$ W7 r5 a7 `# U% umodule_init(led_platform_init);. ]1 c$ n" Q, l6 R: l! u8 Z
module_exit(led_platform_exit);  R' P7 ]3 `: I# z, D
8 z1 S1 d% h' v1 m/ x
MODULE_DESCRIPTION("Led platform driver");
# M; J; ~, M7 @- x& @MODULE_AUTHOR("Tronlong");  }. o: i/ U6 a: {
MODULE_LICENSE("GPL");3 `" u1 w6 W0 Q; s

/ G/ v! j" @+ p: ~8 K/ T( m
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-28 07:53 , Processed in 0.038090 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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