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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
1 H1 @9 O: w2 B" }! a4 E#include <linux/init.h>& S( n/ v0 z9 t, C5 w! m4 ]( r& o3 j
#include <linux/module.h>' `, @( s( O' C
#include <linux/kernel.h>* s% U0 e4 Z' N4 h
#include <linux/types.h>
7 u/ ~3 D: T1 ~5 [9 n#include <linux/gpio.h>& `* t: U3 V' T
#include <linux/leds.h>
% I  E8 C0 i. C* y% z: l#include <linux/platform_device.h>
7 g) f, C2 [! Q* t  c5 k' }0 t: D
$ j% Q$ A2 _1 @* u! l#include <asm/mach-types.h># @5 s# x5 ^$ u0 g3 X6 ]& m# h
#include <asm/mach/arch.h>
4 e. ^) u1 D. r6 b8 D2 y#include <mach/da8xx.h>
; s3 X8 G( k0 q9 `#include <mach/mux.h>7 V9 \; b7 j% s4 m
7 L5 l/ T! M  y: {# Y! |9 }2 Z
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)# c: o( i/ p9 W' u0 [
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)9 U; K7 R) H7 P
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)% i4 @: a- N! D
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)6 u* p7 g# L) l0 t! Y9 l

/ e0 E/ L, v3 G, M9 g9 N+ z4 e/* assign the tl som board LED-GPIOs*/' h" l' I9 T2 `% h3 g- [
static const short da850_evm_tl_user_led_pins[] = {
- S( I- i4 K# W" N7 x        /* These pins are definition at <mach/mux.h> file */% _" P: f; \- k: d3 g% |) k/ z
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 S6 X4 [4 p' D# d- I" a7 }        -1, L. @  p3 z6 Q$ p/ c
};
3 f- z7 G8 j3 @) ~: F5 H& l0 \
/ v' P( ~0 _) C$ \3 Estatic struct gpio_led da850_evm_tl_leds[] = {$ r/ P$ O( f4 c0 B
        {+ c. `4 |7 ~9 }/ @/ `+ w
                .active_low = 0,
$ g- u) D" v5 C! M5 Q  J                .gpio = DA850_USER_LED0,% N6 v1 @2 F4 f3 ]- f- J
                .name = "user_led0",
" q" B6 i( m5 L. W  M$ M                .default_trigger = "default-on",
; d- h0 n0 H/ {* _        },
" K" V, e0 f' d9 E        {$ N0 v2 [# Y2 K5 c
                .active_low = 0,# }$ J2 |. T' x" {
                .gpio = DA850_USER_LED1,: t- U8 [5 E( N' g: f5 ]3 j
                .name = "user_led1",; S* N1 K1 Z9 h& c9 }
                .default_trigger = "default-on",
$ w  V! R6 r7 k        },- p+ M0 }. r  @, x/ v6 J
        {7 z# a4 Y$ c6 Y# I( U5 y
                .active_low = 0,
1 m5 ^- `0 ?, _                .gpio = DA850_USER_LED2,
$ X3 D" G, C% _" S3 y/ j                .name = "user_led2",% T( b  n* C; [9 A
                .default_trigger = "default-on",7 A" s+ l; O: m$ B. {1 c
        },# f" d: c( G. B5 U& |# r; w9 z
        {9 I7 W$ N* N1 y  V' ~* U
                .active_low = 0,+ W  Q2 C& H; A1 x
                .gpio = DA850_USER_LED3,
. O8 r9 _8 Z* B" p* k; {                .name = "user_led3",* y6 y) ~2 \3 F
                .default_trigger = "default-on",
0 b5 R- _( v- p  Y' Y) O# R        },: r; S3 R( |5 s: C+ H: d/ F
};
* F  e' W" A2 ^$ y. l
8 _9 \% a  L5 w  l) Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 T& H6 {" T. [: l- ~) T        .leds = da850_evm_tl_leds,
8 w( r  ]/ h7 r, D3 ^& d' o8 d$ ]        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' v1 a* {4 j+ Y1 ?4 x0 k- }  h/ T2 {" _
};0 U. p5 r9 K2 Z# C4 T; S
* y- M/ s' U* X  }! i8 B
static void led_dev_release(struct device *dev)
9 `& y" {$ b  v+ x{+ B6 |; h" z/ h$ x% h5 \5 ]
};
" F- B9 H) ?0 Z
+ m- {! @% G. G% o: J; Hstatic struct platform_device da850_evm_tl_leds_device = {
4 ?- \" U" L( v5 Y9 D- I" `        .name                = "leds-gpio",8 _1 ^8 |, W! L3 n- e
        .id                = 1,- K* s2 w2 h5 {7 g3 C& u( u
        .dev = {$ I7 j8 _- ]1 J2 s, X$ n
                .platform_data = &da850_evm_tl_leds_pdata,
" Z( D" K1 c+ Z$ A                .release = led_dev_release,: O4 d" H4 l2 T  @! L5 f! s& A( n
        }4 B. Y  k/ H: O8 R
};
" i. a! s: L6 C8 z
9 ?& N/ ]( s: }) N4 z6 @& `) ]static int __init led_platform_init(void)
/ L0 e6 l& u. T5 W( B" x. Y! H{
  K: r5 }; `6 u: v) s5 \/ N        int ret;: d7 c0 \+ P; l
#if 0
) y3 E9 _0 D! U9 S# ?0 |        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 x2 [# H; k2 E% O
        if (ret)* M/ S: K+ c% k* ]6 R7 X. j' t5 d& T6 h
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) J, u: t" d# w% `                                "%d\n", ret);
/ j3 H2 i" K$ I, u1 i) L, y- z#endif
" a( ]) }% ~; s4 J( b        ret = platform_device_register(&da850_evm_tl_leds_device);  I; C; C. {+ P8 D
        if (ret)
! x) C; g0 @. h9 a; z! l% Q                pr_warning("Could not register som GPIO expander LEDS");$ a8 {- G* z. r2 z9 d: Q" ~& x. N( g
        else
* q4 t6 |) v3 }                printk(KERN_INFO "LED register sucessful!\n");+ y$ a2 v3 C( M' U
+ x2 J  j/ k# U
        return ret;4 u: \7 \8 M# C5 P. ]& i9 K1 P  w
}0 |8 ^  M/ p5 e$ c' U" F# Y
/ n- ]. b/ H# i6 ?% l/ M1 c
static void __exit led_platform_exit(void)1 e, e+ W9 q/ [+ Z
{4 D5 B  J  V" I
        platform_device_unregister(&da850_evm_tl_leds_device);
5 `+ X. ~- g  I! G/ i" d' L* L- \  R; v6 L. t
        printk(KERN_INFO "LED unregister!\n");
) ~/ x* T8 Y% X# m2 x3 ?" D, T}6 ~' h+ |) {$ k& o5 m8 a9 I" V- U

1 b7 a9 b6 u5 [% u, Kmodule_init(led_platform_init);
7 _. f0 S" C6 c% `. z3 \  F$ u. lmodule_exit(led_platform_exit);
4 t: ~5 \, B0 ?* w2 J  T  ^9 j; n' `( G2 w- ~7 O9 K" E
MODULE_DESCRIPTION("Led platform driver");
& b) C% e& p+ b+ y6 }- \: fMODULE_AUTHOR("Tronlong");2 {$ I  [- Z2 J& N$ R7 F& y* T3 v
MODULE_LICENSE("GPL");2 x, V+ f/ h; g0 L, @
% h: U2 \3 d6 p3 @
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-7-27 05:27 , Processed in 0.047060 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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