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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
1 d1 @6 }- t! X( ~* T2 V4 Q1 f2 b#include <linux/init.h>
0 ]* h+ C/ G% _7 [2 v#include <linux/module.h>
. l' K. K: c# o! I& J#include <linux/kernel.h>
8 K+ i7 P8 f5 Y#include <linux/types.h>/ E" ?/ t7 |) Y& ?# f9 Z
#include <linux/gpio.h>5 h2 Y" o& {- G: O" _
#include <linux/leds.h>
( \! L8 A/ Z) K#include <linux/platform_device.h>
3 v) ~1 v4 F5 q- Q2 E
# j2 u- H& L( {#include <asm/mach-types.h>
2 g6 q1 @5 m5 k, A#include <asm/mach/arch.h>
6 T( \. m$ O' G* v9 ]: g, g2 t#include <mach/da8xx.h># R( L8 F, y8 d' F! h& O
#include <mach/mux.h>
# I/ ~, q" w' z1 U8 S: s! Y/ a" O' l
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
3 s( A; `& g* B3 H; ]#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)  r- x! a- j6 ?
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1). p5 A: o, b1 V
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)  ~$ {. A. _. J/ P9 W' N
9 y) d% W. z" N+ J4 b: r3 ^- X& v, c
/* assign the tl som board LED-GPIOs*/5 Z5 M* G5 @" x! k
static const short da850_evm_tl_user_led_pins[] = {1 D: I3 p  C8 [: Q7 F
        /* These pins are definition at <mach/mux.h> file */
8 u. i3 h6 r) x4 `0 {: _5 P& U, D2 D        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. l! L7 E2 Y! I9 P  U5 i        -1
+ j$ q* S2 H, E9 \6 O};
: _- W$ J+ r- ]
, d6 g4 L  o. c0 r; Ystatic struct gpio_led da850_evm_tl_leds[] = {7 J% S+ W2 R. p  @0 I
        {3 j) s) n/ u9 F* Q3 A: p2 }
                .active_low = 0,+ W$ h8 z5 {, H# E# B! D+ P! O. S
                .gpio = DA850_USER_LED0,
/ g9 F7 C5 \' F$ a% \                .name = "user_led0",
6 g/ Q8 U2 G, N" E: k  K( U                .default_trigger = "default-on",) L7 Q" k1 g% s7 N
        },
# w* n+ P& y# h3 a  `9 V        {0 d+ t- f. V0 z$ H+ d$ E3 a- x  O9 D- q
                .active_low = 0,1 K& ~) X1 _+ O7 b
                .gpio = DA850_USER_LED1,  q: D0 C. d) S- r" q8 a5 f
                .name = "user_led1",& Q2 x& V; ~" O, e" @- ?6 H
                .default_trigger = "default-on",0 H2 J) T* H5 m* Y! S- x' l# p
        },6 X( [3 o. D: D+ U. O
        {1 U! ?, ^7 g2 D- C
                .active_low = 0,
" \# H2 F1 X) }1 }                .gpio = DA850_USER_LED2,
; A! ?' G; t4 h6 g* n. ]& W                .name = "user_led2",5 o- N" i- ]4 J8 u
                .default_trigger = "default-on",
/ I$ l1 X6 W) W        },
4 ~* c, a/ q& r7 f. M) z        {
4 M: \7 ^: P3 _1 N$ k5 I+ w" m% l  _: }                .active_low = 0,
6 \" I$ Y3 F# z. A1 E7 F                .gpio = DA850_USER_LED3,' w- p, b, B$ ?6 I& t- n
                .name = "user_led3",
* b3 k$ \- B# [. F, [0 l8 h                .default_trigger = "default-on",
9 x4 A8 N+ X. K- e! n* d( ^        },
, F+ M* p5 Q4 ~; N- S( w! e};" Y; x" l+ _0 z; z* d# s

1 a$ u" ?3 g$ y# }7 y4 n+ dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 Y0 {' C, Z: p* U; H- Z4 b
        .leds = da850_evm_tl_leds,  e4 Z1 C: D9 k4 r
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 U( r3 i; L) O6 E6 [& E5 `2 x};
# q( T9 G# {0 _  ]7 Q& K4 d5 M( z; I: i- }6 O7 B4 R" ?
static void led_dev_release(struct device *dev)2 K3 t7 w8 a# y, ?
{# E2 K  H# v3 v% d
};( a5 j6 b2 T  ~" L% P/ [1 r" T

: K0 W' r8 K$ |. Cstatic struct platform_device da850_evm_tl_leds_device = {. q& ^* h0 T2 v/ r! s0 S
        .name                = "leds-gpio",8 t" t3 [& X( Z' p0 \7 m. ~. r
        .id                = 1,7 e' R( l2 S! {( U
        .dev = {
& Z$ \% r' B& D, V                .platform_data = &da850_evm_tl_leds_pdata,+ E1 C2 l) n( Y( r
                .release = led_dev_release,
- k3 |4 O  p3 ^5 y$ o3 V        }
  g: i$ M. U3 G};
( N1 O, q* f8 `5 y8 v1 L
- w; [; k8 ^2 [5 M  sstatic int __init led_platform_init(void)
4 g  G* W( U! w+ G0 O* ^/ F5 J2 W: j{; x7 t3 f8 p; E- K# j! T
        int ret;0 L3 F8 H4 i9 M/ p  o& ?6 }
#if 0
; ?3 `) y0 s# l        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: L: a! x% J: T; h4 _) x" z( g
        if (ret)
6 p% q6 H; T7 W1 r. P7 L                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 @6 X. _4 `" k) R' z+ y
                                "%d\n", ret);, \/ m7 F4 s/ {; D# `) g
#endif
/ j' E+ d6 E1 w        ret = platform_device_register(&da850_evm_tl_leds_device);
: r1 y  G  _" c6 J4 A/ R        if (ret)
& h- M4 A; y5 ~7 P9 d                pr_warning("Could not register som GPIO expander LEDS");! Z* ?( N* x# i5 b4 v
        else7 o6 I7 g$ I: j7 o
                printk(KERN_INFO "LED register sucessful!\n");
7 p& A4 p* m1 I" `. K- d, s: [
: j+ f6 f: u# x$ t6 R. a  X3 `        return ret;
" e4 o$ p8 W  F& |, \}
  n: ?1 C5 w+ Z2 ^5 H( m, R7 t4 |+ W
static void __exit led_platform_exit(void)) ^+ Q! c4 j$ b2 ]* ^
{
9 ~, K2 _4 P( M- J        platform_device_unregister(&da850_evm_tl_leds_device);$ y4 H9 P4 L+ E! z

- j( n/ ]$ e$ S, e) M+ Q3 Q. \        printk(KERN_INFO "LED unregister!\n");. H" g- u, Z9 l
}4 W! X& x. V' b3 s, m
1 }1 K" P5 Y3 ?2 f4 D+ ~! w
module_init(led_platform_init);: Y- `4 ~" o$ E" t
module_exit(led_platform_exit);0 Y; A; g7 e" _' t: O8 H

  w& J) D2 Y$ g- y4 U) vMODULE_DESCRIPTION("Led platform driver");
7 o9 ]7 V: U& ^7 J& ^  NMODULE_AUTHOR("Tronlong");7 X$ Q% P* F. |8 C8 T( r9 Q  c! T
MODULE_LICENSE("GPL");# y% [/ z% l) N/ k9 x

: e9 H, l8 K& z
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-5-24 21:34 , Processed in 0.046054 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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