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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。7 u7 t( j% V4 z# ]% _5 V1 u/ I
#include <linux/init.h>
$ G: w5 Q' e+ b2 K7 f* j& W1 Z#include <linux/module.h>  K) a  u0 _8 {
#include <linux/kernel.h>. _( F- [+ A0 N6 I
#include <linux/types.h>
7 j8 R, P3 `% ?1 y. _3 t: ?6 K' v#include <linux/gpio.h>
6 `0 |( W# m/ O#include <linux/leds.h>
5 O' z' X; V  d( \#include <linux/platform_device.h>
! s$ j5 e: p8 a3 H9 c* q) Q
9 n, F8 o2 b6 D8 D; y#include <asm/mach-types.h>1 w3 Q5 J; f, ?. w
#include <asm/mach/arch.h>9 x; V  H& D3 v/ A5 H! k
#include <mach/da8xx.h>, t+ d8 c0 n. ?
#include <mach/mux.h>
6 {9 F: \3 W5 p  a( ]4 _6 f
( L) a0 b. P. A% l) j9 J8 M8 Q#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)! J0 z2 l# L7 E+ w' }
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)& d$ h& O+ ?) M, x; ]1 [5 m
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)" o3 K0 Y$ n# ^0 |
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
+ L5 l3 Q6 C, P1 O( s$ B5 W, g0 `, X9 A
/* assign the tl som board LED-GPIOs*/
4 J/ P4 Q5 h, rstatic const short da850_evm_tl_user_led_pins[] = {) t" b* Z9 V5 h( j( k
        /* These pins are definition at <mach/mux.h> file */
( [  o4 |- ~' w        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) U7 y' l9 B" N0 D; K9 Z7 n* Y
        -1
0 @' X' g7 c1 b+ B  T, o4 }4 c};# Z6 D0 c9 Z' d

% X/ |) v9 z" w9 y7 s6 m. `static struct gpio_led da850_evm_tl_leds[] = {$ c7 h5 z2 w, k" o+ H5 ~7 b
        {. O2 [1 `: A, c
                .active_low = 0,
& `0 m- h8 z8 }5 `$ y+ {                .gpio = DA850_USER_LED0,$ c: S8 y* m, c* d3 O/ o$ z
                .name = "user_led0",% J! N, _  F% i- \% b2 l: q4 c: `
                .default_trigger = "default-on",1 D% F% W; _1 U2 P8 G4 Z. j& t
        },
: ~6 E6 K; j  S$ p        {7 s6 k; \% ~9 S$ q  g- C
                .active_low = 0,
/ x, n# n4 ^  j4 f                .gpio = DA850_USER_LED1,* f; D7 P- g0 C3 O  h
                .name = "user_led1",
2 U4 O+ p. I  R( h/ q                .default_trigger = "default-on",7 f5 g; j0 {9 }9 P: e
        },( T" W) [8 D2 y! P5 [3 h* \
        {" F4 l3 B0 C* x! N. Z% k; o- {  V
                .active_low = 0,
  O- s0 p8 S7 W$ w# d                .gpio = DA850_USER_LED2,
$ Y! ^+ _( Q: j: l6 t" w                .name = "user_led2",
9 Q" G1 A/ Y1 m0 X# f9 }                .default_trigger = "default-on",4 x) z9 {: O2 T6 R8 T5 |7 f/ r! ~* a
        },3 r# N% W; h& |* Y
        {5 W) ]4 V0 W1 H) ?
                .active_low = 0,( l% ?9 z* u3 t& k& R) a9 p5 t
                .gpio = DA850_USER_LED3,
8 q1 @0 U' U' a; f. C1 B                .name = "user_led3",
5 C7 O) e5 b" a9 S" P+ e                .default_trigger = "default-on",
0 e* _; \# I8 k; _; T        },/ c& }( r9 j. e, B
};6 W$ B0 C  E3 I
$ Q$ ^+ Z0 K' {, p- W" S. W8 \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& X* I6 }2 t6 s9 N- \% n% [1 N
        .leds = da850_evm_tl_leds,
- y% c) z: Z  s/ K8 W' L- h        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 {$ B0 _4 b7 k+ s1 ~};
' F! ]7 B2 y, b  ~8 B# W* ?
' X& i9 X4 v% z3 R. k0 ustatic void led_dev_release(struct device *dev)
! g" g, Y( J* q  s! i9 {$ n( S{$ B: @' W# J9 ?; l
};
, [; b6 G, K  t9 a0 Q
  r6 i+ a1 u& y6 t1 pstatic struct platform_device da850_evm_tl_leds_device = {6 \$ D/ `" O1 _/ V8 X# h
        .name                = "leds-gpio",
* Y! @3 |" c& N# S+ a- u' k        .id                = 1,
! T' d+ X) M- @1 @        .dev = {( d4 `$ [9 W$ t1 C- q+ F& t- T- N+ X
                .platform_data = &da850_evm_tl_leds_pdata,. c2 u" X3 [; z
                .release = led_dev_release,9 P& [+ t7 u: W) s5 ]
        }1 L2 y7 C, J; |+ N' d
};" F1 \; E$ z1 d) F) p: M$ U( v

# J: c/ h3 f5 S5 Wstatic int __init led_platform_init(void)$ Q) ~& p7 |* a; {" h- e7 k7 G: |7 `
{
6 `2 c+ h9 p3 s* [2 I% `        int ret;
* V: v! R; \! G8 G- D; o) |#if 0
  X, w) v, G6 t, l        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% `1 a0 z) [8 ?6 p1 H1 u/ O
        if (ret)
& {  O' U+ E9 d$ t4 g. e" {. t                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ G0 s, ]: x+ `: k& S8 Z! v  z                                "%d\n", ret);' _+ h0 C" E. Z7 u: W
#endif: ]# n! |9 ]* U( x5 ^( Z
        ret = platform_device_register(&da850_evm_tl_leds_device);
# E* I; I8 ]5 c: I5 o: h. x$ P        if (ret)4 Z# O# z2 U6 N! y
                pr_warning("Could not register som GPIO expander LEDS");' i8 V! p: O$ @1 k
        else0 i7 P. M: P4 e2 ~  M
                printk(KERN_INFO "LED register sucessful!\n");0 P* N3 \8 V) U9 ~+ w' S

4 l: u2 L! _2 H  ^) w        return ret;
& g: J+ [* P+ X8 {9 |5 G' f5 ?1 s% `1 I}& N  @" N5 ?& F

( [0 ]; S5 Z* e1 H( M! \8 Z) z+ jstatic void __exit led_platform_exit(void)1 a5 {) N* d  f2 v6 e
{
) M* `3 |: ~& ]- P& r* \: x        platform_device_unregister(&da850_evm_tl_leds_device);
- \' o8 B3 f3 d- ~$ N5 j9 V* b% E$ D) |$ x  F/ [( S1 v
        printk(KERN_INFO "LED unregister!\n");
5 F& Z! S4 z6 ~4 F- c, z}
8 a6 t1 t- g  V% B: t* S5 v- z
0 Y  x* t9 ?6 D  w# jmodule_init(led_platform_init);
) A9 h* k9 \# C, ~  {% F: Rmodule_exit(led_platform_exit);& G/ D# J- i. V2 @% t

, a0 a* ]/ A0 {, i) t3 O6 N$ HMODULE_DESCRIPTION("Led platform driver");
) j' [8 ]* N9 d9 ~  n9 MMODULE_AUTHOR("Tronlong");
8 u3 G4 }$ W( y" h1 X2 B3 q' lMODULE_LICENSE("GPL");; @' |1 l1 @0 |0 @$ ]8 k  w1 @0 {& o* g

# E% ^# q8 |; L6 k& A/ h' o: Q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-26 07:27 , Processed in 0.039299 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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