程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。+ [  b  d2 P* r; C
#include <linux/init.h>
# k8 y: |  N) a% ~3 K#include <linux/module.h>9 s, ~( H7 q0 v2 T. j5 Q# n
#include <linux/kernel.h>
* R! H: h- g3 g/ P. c: ^0 g#include <linux/types.h>
0 B: p" q3 ]; K7 L- u) ?#include <linux/gpio.h>4 x( a4 D3 a. N& q: M$ Z# \
#include <linux/leds.h>) o: y( l- w1 G9 `- v! O3 x& P
#include <linux/platform_device.h>
6 j7 P! q$ S- P& J, G' e7 p: Y( }% j
#include <asm/mach-types.h>
! T' N1 z. v7 K) q" b1 r#include <asm/mach/arch.h>4 y+ L, _+ |1 X# b+ O- q, P4 R
#include <mach/da8xx.h>
/ T9 j. t9 R/ i- C#include <mach/mux.h>
0 q. l& Q2 M- b! @
& Z; I) f+ e1 s* C3 D- g& _+ i2 n#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)9 P' W$ ]" R3 M) e) S9 T6 G. V/ ^
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
: L7 l# q2 O' |! L& d' r: ~5 j#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)/ P! {+ m5 `7 F
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)- }' I! s* o4 L6 {. R

0 S; s0 [, `) j/* assign the tl som board LED-GPIOs*/
8 j1 f) U- ^/ H; }8 Tstatic const short da850_evm_tl_user_led_pins[] = {: K2 A& i" c  ^; [% T
        /* These pins are definition at <mach/mux.h> file */$ p9 Q5 N9 _  {- P! a! F& R
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 ^! s! n  @1 `        -19 L/ z3 Z! t7 I- k# a  b
};: J4 i  ?& n$ `

" r* G9 T% ^/ O& ?: [% jstatic struct gpio_led da850_evm_tl_leds[] = {# `; V9 ~1 m  I3 s) M0 A
        {' t0 g  k9 j9 d8 \# L8 g
                .active_low = 0,3 e) R1 z- E% `3 t1 k6 ]% p5 K  A& p# r
                .gpio = DA850_USER_LED0,' w& a- H4 x& u) s+ O1 ]
                .name = "user_led0",$ P5 s! V3 b" |. j
                .default_trigger = "default-on",
9 ]/ T4 w5 S: E( N        },
+ U) ?/ n3 c8 l* \        {4 a( u6 R$ X  R3 |/ R
                .active_low = 0,. t0 m- ^# [: n- O5 s: e
                .gpio = DA850_USER_LED1,
" f% }/ z% M( A' [% `  B) a% K( S                .name = "user_led1",
/ ^8 S+ Z  c. l1 ~7 M+ {* }                .default_trigger = "default-on",
! ]$ \% m; Y$ r7 H, {3 ~* o; l# f  W        },
( r5 H3 q. Q: q' N9 t# [- t# l4 [        {8 L+ j8 Y$ R* }! {! @% V
                .active_low = 0,; Z* B/ H4 U3 B( U" f: f- i- a+ @
                .gpio = DA850_USER_LED2,
6 w) W$ ?% W* ?$ l                .name = "user_led2",; J; t5 c5 D; }& O; E/ b
                .default_trigger = "default-on",3 j% V, \% c, R* W# q* ?: l
        },
2 |! ?, W% M2 p        {5 x5 u5 Q0 a: T! s
                .active_low = 0,
5 m, s- }0 }- a$ I) r7 D                .gpio = DA850_USER_LED3,
( F- F9 n, D' N4 _. v                .name = "user_led3",0 t  y- R' {2 }; {( z6 ?
                .default_trigger = "default-on",
* @8 D* k3 e5 ^8 ?" Z" B% B% T        },
; F1 M5 t7 }/ ^9 a1 R% m  C};  C/ h) ^' S, g" h( X, f

: a& R/ B5 I7 l7 n1 D/ Rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 M1 z& }& ]3 d5 T7 t
        .leds = da850_evm_tl_leds,
1 Y, O# H0 D" W) H  @) l5 q        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ Z3 m$ U6 r( l};1 w5 X; |8 U: j. |- [8 r
) n5 t3 p4 J: _0 p0 c; \* c
static void led_dev_release(struct device *dev)# @( d+ F+ I9 d  c; P
{
" S4 R1 n9 ^' \5 M};
4 ?% U+ E. ^  f' g9 X- |
+ e  ?% M1 v5 d5 P% g; X  y4 L& Dstatic struct platform_device da850_evm_tl_leds_device = {
( o9 U, g' K' \5 ~+ {9 A! e- s0 n        .name                = "leds-gpio",% Y6 _* f0 F/ l2 k  ]# t
        .id                = 1,
! O" ?3 P8 C9 R. k        .dev = {
# |2 a$ j* r0 e- X4 [% o                .platform_data = &da850_evm_tl_leds_pdata,6 P( a) n3 t! O, M, @5 r
                .release = led_dev_release,9 {- U2 u$ l  S6 G$ p! i  [
        }- A' @( J: `: V: h. m: _
};
, @+ d( a/ O8 i
! z" [3 S: k: I# t- F: R" b( Jstatic int __init led_platform_init(void)/ h, D' G0 s5 N1 d4 z1 S
{! Q  J$ {  M) [9 @( U. m# t
        int ret;& v( k5 Z! M8 r1 e7 w! H6 s6 ^/ u
#if 0
- \. F# O- p% y' q% }        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 \8 k* B9 ^: I5 N6 l  F1 I7 y5 o        if (ret)# @9 A1 `8 a/ x
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% o- h' m' s1 N6 `8 m0 F  y7 {
                                "%d\n", ret);+ h" f: n3 Y0 ?2 N& |$ o! P" L
#endif6 M/ o- P) G, {) a7 g) r
        ret = platform_device_register(&da850_evm_tl_leds_device);9 r: Z% S1 }' g
        if (ret)2 B! @( J) J& ]% W0 y7 P
                pr_warning("Could not register som GPIO expander LEDS");  }+ G* N, \9 E2 O* M: \& }6 O2 N1 Q
        else' R! q4 S( T' i
                printk(KERN_INFO "LED register sucessful!\n");
& j, \& v) H1 ^( i
! O5 ]3 k9 |! O4 X" D        return ret;
2 K. [; O2 K! H/ T" k' N0 I6 T}+ z* l, k$ k& N9 F( F
0 F! C3 l1 Z! l; p
static void __exit led_platform_exit(void)) e. `, Y& R  B/ K/ C6 u' f# e7 H$ p
{' C5 b" Z* P7 n
        platform_device_unregister(&da850_evm_tl_leds_device);
  Y9 k% T  @& k8 [
: }- C9 p2 I% M        printk(KERN_INFO "LED unregister!\n");
7 A" f! N- a& l6 j8 M}8 `. h; O  n) t: `5 ~5 }

) _, Y7 ~+ l$ _* A$ w1 _$ Rmodule_init(led_platform_init);' j% W- t0 w# `; U: K
module_exit(led_platform_exit);* z: I9 A3 I% }( |
% r" ?) f1 V9 v
MODULE_DESCRIPTION("Led platform driver");
2 `7 p3 c' \. p1 _MODULE_AUTHOR("Tronlong");
6 O7 I0 e8 @* _$ o, OMODULE_LICENSE("GPL");% a4 K5 R: D$ m2 M5 C

$ Z- @6 _  ^- Z7 O
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-9 16:03 , Processed in 0.037716 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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