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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
  {3 O: O$ ?/ z#include <linux/init.h>: O7 _% u, ^; i: r# n# g
#include <linux/module.h>
  c/ d' m4 y$ R4 v#include <linux/kernel.h>, j: i# E, W) g9 i/ \
#include <linux/types.h>' x& @. |! L) I+ I: M
#include <linux/gpio.h>
/ H9 P  W: h2 _#include <linux/leds.h>$ T0 u% B' t* n+ q: j1 K
#include <linux/platform_device.h>
  O$ O. m) j* u8 h& F3 j( S) j
#include <asm/mach-types.h>/ [0 i0 t9 _) B. @' t4 s
#include <asm/mach/arch.h>
) X) L! C7 P; W  P. K#include <mach/da8xx.h>$ ~6 O3 n  T, E- ?& }+ w/ W& N
#include <mach/mux.h>9 y- a: G: d/ B: P) _" i0 ]

6 J+ }3 `) n8 O! l' ]5 T#define DA850_USER_LED0        GPIO_TO_PIN(0, 0); Z& N! n! Q4 o7 s* q+ ~
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
) A/ O" H# E- [#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
  k- m& `2 m# H6 j#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
/ g3 h! Y* a. t; i. i! N
; U- G7 W1 L8 _& c8 g" |7 {) u/* assign the tl som board LED-GPIOs*/
9 r' r; p1 E* D4 C# J  U: ~static const short da850_evm_tl_user_led_pins[] = {
. h2 r4 m' o( t' S+ S5 k        /* These pins are definition at <mach/mux.h> file */7 k7 s& \! w% k) L) Q
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 M4 C' ?# {) D/ p% c' \# ?& a
        -1# D: K6 N" k- F. M- s3 M
};
3 Y- D* \( d8 T3 C% @2 x" t0 a' b( c& `5 i# P  g+ D
static struct gpio_led da850_evm_tl_leds[] = {
6 v* h2 C9 P8 w7 k6 T6 R        {
& J7 w4 m) r: a% A3 m  I                .active_low = 0,
3 f' I9 I7 F  V) g; E. @                .gpio = DA850_USER_LED0,
) G' b  l. j) [8 |5 Z" M& w3 M                .name = "user_led0",
7 A: ^2 q& t; X3 y0 Q2 v/ q. ]( `                .default_trigger = "default-on",
0 E+ L/ n9 O4 X( J, l        },
* q6 ~4 @, v$ ]) L        {7 I. p- G! U" a6 |" Y: {. j
                .active_low = 0,, j+ z4 C$ O# n4 D/ O
                .gpio = DA850_USER_LED1,. R  l- Y) ]3 }/ A& E4 ^* k5 j8 J
                .name = "user_led1",
9 \9 p  H7 J4 ], f                .default_trigger = "default-on",
. d! M6 T2 `( {5 h0 k6 v$ y0 |  k        },
5 B6 C" m! u: Z) n* |9 `$ x5 ?( F  \        {0 m; x) @* Q6 F" r4 z' d) L- E
                .active_low = 0,
/ e/ x& b1 t) H4 J                .gpio = DA850_USER_LED2,3 R' b, y2 Q) U0 O3 u+ [: y+ o
                .name = "user_led2",- q, \* t. u1 F8 i$ D/ N: H% o
                .default_trigger = "default-on",! h, U" a8 [: H! l4 T8 W' F
        },
& b( S- a( q5 l4 t  @/ ~        {, {" ^7 w3 g1 k2 ~
                .active_low = 0,
1 z  Z7 c4 c4 J4 @9 T) {- B: c) [                .gpio = DA850_USER_LED3,
: \8 i' o* i: V, x                .name = "user_led3",  m2 J, L6 `  @1 u) D9 u( n& b1 ^
                .default_trigger = "default-on",$ e4 J% ~  O* Q/ g4 |
        },, {7 l# m, V6 h7 c7 M7 n9 Z; d  H
};
/ ?3 o$ ~( w9 o; w3 L5 c: V: s" N' C3 U9 L% R1 y5 X2 e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 D4 O; E" W/ s        .leds = da850_evm_tl_leds,! L" W- J$ F9 Z6 u3 ~' Y/ c  |
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& q6 p6 o. @* k3 A$ V4 q4 ^, c};
: c8 L3 S: v7 l  @2 F6 t; r; w; X
, R2 x2 e2 R+ x0 Pstatic void led_dev_release(struct device *dev)+ O' k0 `" n7 O
{: y7 y' \, X# P4 U! `
};
- g. ^+ {) U" F7 O- }& [
. @8 O8 ^4 ~$ ^' M' F4 @+ xstatic struct platform_device da850_evm_tl_leds_device = {
$ [6 m6 ?' C: ]2 L( o        .name                = "leds-gpio",) o: w- |; c# ^6 v! L
        .id                = 1,
$ f* `$ x6 p4 y+ Z  q        .dev = {
: y$ v$ G! J( s( ]                .platform_data = &da850_evm_tl_leds_pdata,
' O0 \/ c9 h) {2 [# E/ z, S                .release = led_dev_release,
  Q* v4 ~! E; I        }
' ^5 X! d+ t) a+ B# k};, ?' q  ~3 H  P. U, V. a4 n& f( X1 x) K
. G* T' T  [3 j) K. l% e: ^+ Y( o
static int __init led_platform_init(void)
: U( @8 [' f# {; D' @{
! R% S! f) ]% r        int ret;7 K. S" g4 V: s6 L9 Y  V
#if 0
8 M% R7 }- H5 l% Q" o        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" U$ D4 w! `( B8 g
        if (ret)
1 N1 g4 _; I* V6 p1 `# s4 t# U                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' ]' Z$ E! s" D- A* l( U                                "%d\n", ret);2 g' v' D0 O- H) `+ d* L% {) v
#endif
7 Z. E( p5 T# f) S& I        ret = platform_device_register(&da850_evm_tl_leds_device);
! }1 g. w2 e+ K6 S        if (ret)7 `. w) G) q" O/ B9 `
                pr_warning("Could not register som GPIO expander LEDS");/ w, t$ p( j, K8 V, n- W: M
        else
6 x; q) H" \9 E2 h                printk(KERN_INFO "LED register sucessful!\n");
4 P6 m/ A; r6 S4 n& E4 U4 @& m( V; p3 G4 @
        return ret;6 `  E; S; `" R7 [
}  o! U7 A+ x& _* O6 r$ o' W/ H5 q

  @/ s/ n2 W5 u/ Y/ Ustatic void __exit led_platform_exit(void), |9 ^) {: ?% s& X1 f' {% l
{0 m! h* C; ?0 f1 ^6 r
        platform_device_unregister(&da850_evm_tl_leds_device);
7 L* h, ^' h- Y7 Q, `  l3 n# o7 J  v5 [: L9 z) O( ?
        printk(KERN_INFO "LED unregister!\n");
$ E6 H2 F9 M& c9 S* G2 k4 ~9 F! V; {}0 h7 _: a; L% F) F$ I& X4 l
# n+ C0 {1 u1 ?7 j0 d) Q  j8 t
module_init(led_platform_init);
- [" E" G% y* ~0 ^: j( jmodule_exit(led_platform_exit);! K4 H- f$ \- q3 T' r9 m& P
( |. C% R3 ?  u$ [/ v
MODULE_DESCRIPTION("Led platform driver");. Z+ e5 o4 G3 {# K  U3 K
MODULE_AUTHOR("Tronlong");
. Y* r1 w2 A% x' J' z* }- aMODULE_LICENSE("GPL");6 B! I' C: t+ z5 Y9 t9 F1 |6 _
+ `- s2 M/ u: e( S7 }3 ?
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-28 08:17 , Processed in 0.039929 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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