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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。+ f- U+ U; E3 e' P$ E# }; K- m
#include <linux/init.h>
8 `. }2 W- m$ ]0 C) K: ^0 ^6 ~2 h#include <linux/module.h>
" T/ L* v6 L. [+ a# o2 `# B& K' P#include <linux/kernel.h>$ b2 e! @' B- }' X
#include <linux/types.h>7 M9 l$ C7 y$ L2 v
#include <linux/gpio.h>
  c/ g  o6 |0 f4 [# F) X8 D& i8 s#include <linux/leds.h>* T. K1 h! w2 }
#include <linux/platform_device.h># ^( R  V  Q( l- V5 Y

' r5 W- L" R$ O0 Y, g#include <asm/mach-types.h>
+ A) D: t& r2 L#include <asm/mach/arch.h>
0 ^1 Q: m7 S& [7 _+ Y) S#include <mach/da8xx.h>
% a" B+ c5 J$ g#include <mach/mux.h>
+ Z. x9 @, o7 A1 f+ F+ A9 W
- {, w, V  z3 @  r2 N#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
* M1 r/ D5 \- z1 m#define DA850_USER_LED1        GPIO_TO_PIN(0, 5): Z& [( c' B) n
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
# i6 a8 v5 |! f0 }/ c% O1 f& c#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)- n8 ^4 @' [. C0 y) ?! ~
: K/ ^& n8 w  ]+ O$ z& X
/* assign the tl som board LED-GPIOs*/
) G/ @* w8 H0 e/ _3 `, A4 Bstatic const short da850_evm_tl_user_led_pins[] = {1 e$ c! d$ {& j
        /* These pins are definition at <mach/mux.h> file */  q1 k* [5 i& ]
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' K1 H/ V! Q( o' H1 O* q& t1 G
        -1# F8 G: ?/ |8 ?
};
+ D- ?1 X' G; c3 X) `3 E
0 v5 J8 U' F1 ^$ ^" z; X4 L7 ]: x1 istatic struct gpio_led da850_evm_tl_leds[] = {% F( t+ N# ]5 U! o0 M3 M
        {
, K* K' ^1 `! h& m  |                .active_low = 0,
7 O' ~, @3 w. E                .gpio = DA850_USER_LED0,. u! {' L, f/ w5 |! F7 z
                .name = "user_led0",
, t- [0 |6 K. N) Z# ~: A                .default_trigger = "default-on",4 i1 T, W. ^+ L/ u  X+ w3 D/ ]
        },# W! e) G7 t* j8 V
        {6 o9 }/ Q- m1 }9 M$ b
                .active_low = 0,
# h6 D: v+ v3 F1 ~) E: C9 ~                .gpio = DA850_USER_LED1,
$ t' ^, z; w- U1 i& {                .name = "user_led1",7 ^$ K. u7 w4 R& _0 O7 V
                .default_trigger = "default-on",
1 f: X2 R! y2 A/ |5 B+ G        },7 @$ M% W6 F; c2 t
        {5 J4 z  g2 w% [0 p6 d, @! {) ?7 {
                .active_low = 0,1 U8 G1 S$ I! m; B" ~
                .gpio = DA850_USER_LED2,; K: A- K' I3 u1 x7 @& N" i  T, W' \( }. c
                .name = "user_led2",- @; N) E8 d/ c/ o: X2 \# D# O
                .default_trigger = "default-on",: N+ ]. N9 @3 ]- A& i
        },
% l3 W% S9 h, I+ l# g5 w. A        {
- g4 C& Q9 z. c' Z                .active_low = 0,. l' K. O: r8 F. W3 M- ~% t+ H- P
                .gpio = DA850_USER_LED3,
: S4 v$ \6 u, `7 ]& ~* w                .name = "user_led3",% Z/ J$ a5 s9 n: g
                .default_trigger = "default-on",2 e- u4 f/ U, w
        },( l! b" _$ ?* f" [
};
" R8 @  f4 J3 O% z8 G+ Q) c- T" d" e+ A. a
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 [$ [' q7 \& x$ r: K$ S
        .leds = da850_evm_tl_leds,4 R- z; M' o9 L2 F+ \* B8 \+ o
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& {- ?. n* A" o: p6 `4 F6 h
};* n) c" D- l% A# p. T) w: o' _

4 x( {$ |6 A' d3 zstatic void led_dev_release(struct device *dev)5 i+ s0 n+ o8 A3 X7 V
{
, |8 m1 U& ^" a};
$ V! a* W2 e, ]9 t
8 ~5 K( ?% h1 E7 Q; V( ?0 ]$ x; f+ kstatic struct platform_device da850_evm_tl_leds_device = {
7 N; ~/ _0 M! X3 P9 c( Y/ N2 l        .name                = "leds-gpio",
5 H; Y- d# o. x& F        .id                = 1,
/ _8 y, b) S* o' F7 l1 |! }        .dev = {
1 Q6 V6 m- q0 c, o. R- U2 Q                .platform_data = &da850_evm_tl_leds_pdata,& e5 {/ O+ ]! Q! d1 O# h
                .release = led_dev_release,
7 E: X. V: T- Z6 q        }
! G8 J+ R9 E- X" ?};9 k$ ^! f3 Z9 ~/ {1 p! i, h7 C* D

" t" G3 P- T# xstatic int __init led_platform_init(void)
; p: o8 T% W+ c) R{! k, w4 E- B" D6 I) j, g+ C0 c
        int ret;3 ~3 h; M. U1 i# t" n) a/ {
#if 0
* y/ z0 e# C! X+ X3 b0 O/ s1 ?        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; i+ s0 \* m8 M$ e0 r) n
        if (ret)/ h$ @* Z8 K9 @* @. a
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 F- [* T' G4 C0 S* p& K: V* O9 K                                "%d\n", ret);1 [  X- }/ U! j! Q7 a! t/ r9 r
#endif
& s& W8 ]; t6 Y$ [        ret = platform_device_register(&da850_evm_tl_leds_device);$ M& Q- D& U8 U# n
        if (ret); u" ]; p6 M$ I' @- `# P7 J2 i
                pr_warning("Could not register som GPIO expander LEDS");
' X# f3 r: q+ _        else
* w" J8 a) ^) h( n; `- p% S! [5 ]9 J                printk(KERN_INFO "LED register sucessful!\n");5 a+ J% b. K9 m# [6 A4 h* ]
" Y+ t" o4 P/ }0 q9 g( `
        return ret;8 e5 U0 j9 l4 Q. m! M8 v
}# P2 d" |, \( c& ]  W

; `5 D- J( {: tstatic void __exit led_platform_exit(void)$ w6 S- k1 k5 ^' M3 G9 r0 H2 O3 d
{
! _' D7 d* }* F4 ~( P5 }" t" G        platform_device_unregister(&da850_evm_tl_leds_device);
: L3 H) {) j, ?' F: {
8 W  x, i# Y) f+ g; A! c" v        printk(KERN_INFO "LED unregister!\n");
6 o/ P, u& h/ V4 b. n4 p2 Q7 S}
' |& G4 Z  H' u& t% Y4 ]
. k* y- j0 G% ~' O. Pmodule_init(led_platform_init);. Y: y* f: Z4 q5 ~/ ?+ f9 y3 r
module_exit(led_platform_exit);* |4 f' ^. F$ E6 P8 K+ L
$ D8 j8 h& b# |# T. X. [& U
MODULE_DESCRIPTION("Led platform driver");! _: h( h5 X& a, n: B4 i2 U
MODULE_AUTHOR("Tronlong");
. G4 @, Z4 B8 G) U$ c- bMODULE_LICENSE("GPL");
- N1 X5 h4 v. V5 h2 r+ }; O( Z; Z  N, O+ p0 B# g
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-8 18:40 , Processed in 0.039365 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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