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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
, u* @. d# L: S  r#include <linux/init.h>
: V' W* z1 C5 \#include <linux/module.h>/ e* a- o# H* t. Z$ Y  M  z
#include <linux/kernel.h>
6 M, b" `. @+ ?& _7 E& D$ s5 ^#include <linux/types.h>
0 r% Y! U' R, e% J#include <linux/gpio.h>
: K0 g0 y: D  J#include <linux/leds.h>9 C  H; t5 V- H0 |$ Y8 w8 u
#include <linux/platform_device.h>
' C$ N! y, J9 |5 u' U: `# Q: j/ I0 a2 ^6 j' V6 y
#include <asm/mach-types.h>
0 A; ^& y, y, b& i#include <asm/mach/arch.h>
! o8 E3 |5 k; {5 }. H#include <mach/da8xx.h>0 @% W" ^$ A( ]8 e' s
#include <mach/mux.h>
( Q$ |# T' T" A3 h: I* s
$ C$ \. s+ n0 L" ^! I#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)0 w# _! m$ x5 h. Z  |5 u' ~
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
$ D- A: G' J) K0 V% K" f#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
, ~1 D1 M1 e0 J#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)7 l& r7 P% X9 `( @# T( T

% J) V+ e0 R7 F1 A; A/* assign the tl som board LED-GPIOs*/' M8 |! ^' u' [. j( o: K
static const short da850_evm_tl_user_led_pins[] = {, P/ M8 A- o' @7 z3 M
        /* These pins are definition at <mach/mux.h> file */+ v# q2 r3 t+ a5 w; ~4 q; K$ G6 }
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 U; u! u) _+ n7 M        -1, L6 N$ `# Z% w
};/ E5 C" Q4 m7 ?6 _" ^$ d

! S) z" ?( t  z8 V, k' ]static struct gpio_led da850_evm_tl_leds[] = {
# @4 u: W! |6 \5 f) i2 o        {
3 C  a4 `3 o0 f1 o) g3 R, U# b                .active_low = 0,  L; t( e- K; b0 F9 L
                .gpio = DA850_USER_LED0,. _  L# m5 e1 R6 Y; c) ~7 ^: s
                .name = "user_led0",
% r* S* T- D0 P. v' a: u# I2 t7 }& M                .default_trigger = "default-on",) u$ \# q3 U5 o' W& J$ x1 N
        },1 C1 V: H! @+ s# |; D
        {
- D& ?( ]8 k4 U+ {8 k, G                .active_low = 0,9 {9 ~- E6 Q+ c4 J6 ^4 t6 M
                .gpio = DA850_USER_LED1,
  U/ S* M3 ^; G- k- U% s/ c( R                .name = "user_led1",
. Z: B1 M! s9 ]: W0 x                .default_trigger = "default-on",# D6 X3 c0 s# `" j9 N! y1 p8 y# u
        },
( n. [8 S5 J: {5 D4 p/ I0 ]        {
& }5 ~. Q+ @, b1 Z: M0 x                .active_low = 0,
( E& J/ J1 b* B8 k                .gpio = DA850_USER_LED2,; |; }% q7 R, g' \" K& m! f
                .name = "user_led2",- M' ?6 F6 u( C
                .default_trigger = "default-on",2 N0 L. x* O  U$ V8 x% v
        },
& n% `) }9 C! r+ X: w$ L8 p        {. U. C/ z- G0 o' P2 c
                .active_low = 0,* v/ ?- s7 L2 f+ {9 X
                .gpio = DA850_USER_LED3,
$ B, u! B, V6 \7 i0 j: w4 L4 k                .name = "user_led3",/ Y9 L" D' S# F: f0 K& H4 P" }/ r
                .default_trigger = "default-on",) S! ~, C$ O: H
        },& k9 Y  ?0 y5 b# m
};
0 U2 a- T. o# F
0 E% u2 p. G2 b# j/ X  g$ A! s. Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 E: q4 W! U& U' c% ?& f8 Z- v. N  r        .leds = da850_evm_tl_leds,
" v6 R( w7 I$ d" Z1 i/ H7 y        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( {3 ~+ H  p9 D- W- `5 R
};
0 G1 q; }9 G. p8 Y& i( h  t) i0 H8 J, v
static void led_dev_release(struct device *dev)
, `6 g6 o7 E. G. x2 ~{
- P! L3 {/ U, a7 o' G- R* `};
, C. m0 C4 V% Y$ W0 G# ]& ]' Z" j3 y; }, h
static struct platform_device da850_evm_tl_leds_device = {
/ ~7 g. Z% w+ i8 R7 K0 ]        .name                = "leds-gpio",
, R4 g  r6 N9 u# U+ N  T        .id                = 1,, j" g0 }. [5 O- z, @" V
        .dev = {
$ r, |4 h3 k: U% \                .platform_data = &da850_evm_tl_leds_pdata,
# Q, C: T3 R1 \                .release = led_dev_release,$ S; W, m$ Y- [) L& @6 ]" h1 l0 q( V
        }
, m2 V% k* {! z};0 G# [: `( B3 j  b
9 g7 ?$ V& }  h
static int __init led_platform_init(void)
: u6 h1 w" Z1 R+ X{5 b2 q8 e9 k$ {
        int ret;
  c5 A2 u; E# ?( U+ \#if 0
2 M  R& N" w. ]. O        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# r+ o: [% Q0 B6 U( t        if (ret)
1 u/ M- ?, W) z/ [, C' J: B* g                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"  D9 E7 n4 s5 i2 v3 S
                                "%d\n", ret);
% T4 `2 d+ p: ~#endif: W: g7 @+ t+ a2 X2 V
        ret = platform_device_register(&da850_evm_tl_leds_device);
# E$ ]. f! d. m' R8 ~  o  Y. N        if (ret)
7 W0 T* G( G3 W2 @4 |6 D0 h: j# d  V                pr_warning("Could not register som GPIO expander LEDS");; Q8 Q6 l- I% Z
        else; t1 ^7 E# [6 U. F5 {2 A) X
                printk(KERN_INFO "LED register sucessful!\n");" l9 L. g# u4 L* Q% q2 h* Z

' x0 M% \: V5 G5 c# L        return ret;
! R! `' _& S1 X, j+ z}
" a0 e0 j6 z# N& C( g" J! }5 d7 P! G8 j) M7 b- A8 g9 r4 q! E! x
static void __exit led_platform_exit(void)1 `1 @, S0 q( K9 \
{
* c9 _9 J: }: ?! B+ z2 N3 H: J        platform_device_unregister(&da850_evm_tl_leds_device);; W7 d$ m0 l. l0 N1 |6 k! q
! `$ Y/ O+ P' }
        printk(KERN_INFO "LED unregister!\n");3 }& R6 c9 i& D6 m5 Y# Y' Z# k. q
}
7 t& g( G2 ^8 c) }# f. _- i: u4 B" A2 e( U' ]
module_init(led_platform_init);
, T5 t0 H" q+ i4 D7 smodule_exit(led_platform_exit);6 r" z5 b3 b. Q. k8 Z

* `2 {6 D- M6 o9 s' lMODULE_DESCRIPTION("Led platform driver");1 G& h8 N/ \& P6 O6 |
MODULE_AUTHOR("Tronlong");0 w1 w. _( `+ J/ Q
MODULE_LICENSE("GPL");
5 f# |4 B" U5 u9 S3 x3 k$ n7 P: V9 L6 {2 _6 Z* r% n
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-2 22:16 , Processed in 0.040547 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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