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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
( h6 {% l% n6 p5 _* A( ~#include <linux/init.h>
+ `: j1 Z9 A' \# q#include <linux/module.h>$ X5 D* B% Y6 |4 e" k: {
#include <linux/kernel.h>: E% x7 _! M- o, a. K8 @! d
#include <linux/types.h>
' p) b  x6 N3 \8 }#include <linux/gpio.h>. C" {% E( H+ h$ u5 d5 C4 O
#include <linux/leds.h>
/ B  d5 ]' Z8 Q) C8 I/ f$ j#include <linux/platform_device.h>
) s+ i, A* f* B+ [3 n6 _  m7 w6 N; k
0 D) B! u% B2 s1 k/ B% [#include <asm/mach-types.h>  V7 l- F6 K5 W9 K
#include <asm/mach/arch.h>+ f# {4 \1 `* p
#include <mach/da8xx.h>
1 J: v& S( C; m8 M  P/ w# e#include <mach/mux.h>" Q2 p( z' ]9 a9 a  X! q
* }2 ^3 n6 T& _. u7 s
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)/ \3 d! ]2 ]/ Z5 r  ~
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
( H, t% k9 L5 K" y4 z7 p3 u#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)0 g% q; }6 ]* ]! x2 R
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
+ ]$ V3 n, x; L/ r. r
6 P. o! Q  p  A* R, b0 k/* assign the tl som board LED-GPIOs*/7 g4 V2 [" b! Q* \  {
static const short da850_evm_tl_user_led_pins[] = {
: U) T& w. x. g4 ~6 D3 k        /* These pins are definition at <mach/mux.h> file */$ W3 B5 d- u* u6 Z, G
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 x3 B% E) m' z5 \, v7 [' P; y6 d
        -1- _' J. {5 P- o+ b
};9 r* e* c) ?! @, X+ N7 j. c/ ]
+ P: Z1 _4 H7 O
static struct gpio_led da850_evm_tl_leds[] = {
! h" z. y. I, R. p) [* @" q' w6 M' @        {, |( K; u4 F: y9 |
                .active_low = 0,
7 _7 H) ?0 d7 D4 q. _/ B8 t2 T" [' ~0 D# Y                .gpio = DA850_USER_LED0,
7 n& u% ^/ h* z. O* b                .name = "user_led0",
& p) a9 e" Y+ x* [8 g! A; _& S% H                .default_trigger = "default-on",
+ B* Y5 o" I" @        },
; @9 E, D' l' N6 A* t' g! b        {
3 _( |6 G& e; ], N* g                .active_low = 0,' i2 ]- p7 ?; k" J2 q: ?
                .gpio = DA850_USER_LED1,( S& H1 y& J1 [0 {9 L; h* k
                .name = "user_led1",3 H. x# Y  ~, _0 T/ l
                .default_trigger = "default-on",7 c% ~) u1 M) l+ @' T+ Y
        },
7 ]5 u' }7 m) y. l1 P2 C  n        {1 m. v8 A  ]3 W( N) C
                .active_low = 0,
) k/ }; b8 ?! V& Z) @                .gpio = DA850_USER_LED2,
% O3 C5 h6 y8 E                .name = "user_led2",
' T# X1 |" B9 k1 g" ~6 Q# ~                .default_trigger = "default-on",
& l6 J$ U; B* d/ j6 Z) K8 P        },# [+ I( w. Z: J) h
        {7 f% z* B) H' O8 b8 ~
                .active_low = 0,
& W( u7 k9 i& v; V8 f9 s# `                .gpio = DA850_USER_LED3,
5 s/ V0 {; v. u* n, m4 \                .name = "user_led3",
8 g  e, S+ @+ I7 A& j: m                .default_trigger = "default-on",# b4 U) G; \; b; F1 N; J6 y
        },
5 @5 t7 ?8 ^2 {) g7 l: E) s};
8 h2 s! f( M$ L3 y6 n
  n; T$ o$ n2 s" hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: J2 J$ A/ p6 v+ J" C& I( g# t; |
        .leds = da850_evm_tl_leds,
$ q( f. K  D' M( r" j        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! B8 k$ {  O' n1 y8 T  a  T2 [; W1 M
};1 Y! ~7 u/ b/ S

) S- L2 V4 J0 W! s/ s, fstatic void led_dev_release(struct device *dev)* h7 m6 M$ s5 a( {2 Q$ Q# ^6 ^. X& ?
{  [' ~- Q! G" v  R
};
& f$ p) |. _* w! g: @' Z( _
$ L$ L' y/ a" z6 B. U0 B  qstatic struct platform_device da850_evm_tl_leds_device = {
9 N& w% [- {; O% d* _4 G        .name                = "leds-gpio",
8 r4 ^2 t1 I; _4 w% O        .id                = 1,8 _% s. P+ j7 j! [8 C
        .dev = {$ h; h' t: O, I4 S1 |4 I7 A, }/ R
                .platform_data = &da850_evm_tl_leds_pdata,
- ]* \, I- o5 C' u6 h                .release = led_dev_release,5 d7 }2 @1 Z5 {* x
        }! W, P1 ?0 y# A- W* B" l( p0 b& p
};
$ u& _9 d1 v2 N1 f8 `% a' q7 W9 R0 V5 X# f) l4 m2 r( R& S& Z
static int __init led_platform_init(void)
0 d. {6 v5 L/ Q4 V5 H7 {  @' q{7 p/ M5 u6 x9 w* B* y
        int ret;
" S$ c$ s8 }! d#if 0
  w+ A, h, G4 W5 _5 ]6 K. C8 _- o        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 ^! @/ K% y- F* _7 |1 t9 m5 O
        if (ret): Y- e9 {) E. s5 e! r$ b2 r+ t2 e
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* h  L6 V( a9 w$ s& X1 e
                                "%d\n", ret);. i( o+ [. J2 P! ~8 o8 Y
#endif
' E0 S9 I3 ?* U5 S        ret = platform_device_register(&da850_evm_tl_leds_device);
& i: F6 J/ j. Q/ y9 K        if (ret)
3 [8 Q) U8 D0 P* _5 O' l* [                pr_warning("Could not register som GPIO expander LEDS");
, z( J$ I  g9 B        else
  b3 t5 X% |; p3 Z1 P' b4 {                printk(KERN_INFO "LED register sucessful!\n");
5 U, B3 w/ ]* S1 {7 j% a1 H$ m" Z2 b" w0 z4 O
        return ret;' ^6 l, B0 P" m2 u- d. B
}
0 n1 t4 D1 D0 s; D* p- t; p% z% B" R3 m: C* O: X  d
static void __exit led_platform_exit(void)
2 E) N! }+ `! ~# `$ N% c{3 o" \- Z2 M5 O( F
        platform_device_unregister(&da850_evm_tl_leds_device);) c6 b% z0 i( p- G# R8 x0 R
3 m7 A5 M+ g9 I% s5 ^' e
        printk(KERN_INFO "LED unregister!\n");
6 N. m' l* b1 _4 m+ c- q; Q}
, m0 q* n4 `( P7 m# f+ k8 w( q! `2 b
module_init(led_platform_init);$ ^" i* S, Y: I7 }
module_exit(led_platform_exit);
: k7 q3 T. v3 P& R" b; p
" O' w3 H( L7 \: e# a/ E$ pMODULE_DESCRIPTION("Led platform driver");. }: q$ {- c* M9 H! Q
MODULE_AUTHOR("Tronlong");
7 m, K; d! g" G4 d) i1 Z% OMODULE_LICENSE("GPL");
. B- r- m* K% E1 j8 O
: o6 c$ ]5 d1 [6 k% x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-16 16:56 , Processed in 0.039905 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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