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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
: c& j3 [. x: y9 |6 Q# F  g" Z4 g5 l#include <linux/init.h>- W" j9 h7 u. N% ~. |7 V
#include <linux/module.h>
$ P+ g' M2 S+ E9 ]" g#include <linux/kernel.h>
  w9 A5 r+ n  i- p1 r; Q- T5 [#include <linux/types.h>
  {3 V$ x8 Y8 N9 t1 z/ t8 ^#include <linux/gpio.h>
" t- g# j$ d& m7 K$ F' f+ @% T0 q#include <linux/leds.h>
2 I( F$ C1 Z5 o0 G3 T8 n; E#include <linux/platform_device.h>
5 S  m. m  o3 W. h" M2 L' x" _4 v
( j0 h( k$ u) i0 i. O  w, I#include <asm/mach-types.h>
/ S3 T% v* d2 s* Y8 ?* S#include <asm/mach/arch.h>
; z8 N/ o1 X' |5 m, d& [#include <mach/da8xx.h>! i, ~5 a$ n, L! k( X" Y& Y
#include <mach/mux.h>
( X. b7 Q! g  a0 W# X! l0 p- O/ I& P  ^
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
( W5 `3 h; N: B5 @4 W#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
; r5 v: I  N; H1 R  y( X2 L#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
' w; ]. e- ~+ h( o0 W- D#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
/ B6 W1 k: ?2 t: k4 z& c% ]  ^: v
, ~: P5 q! s5 ]  U$ N/* assign the tl som board LED-GPIOs*/; n0 y$ g1 Q* V! d% o- X& q0 h
static const short da850_evm_tl_user_led_pins[] = {
; \, ~* ~6 Q) C9 b3 Q        /* These pins are definition at <mach/mux.h> file */
- {0 ?: K6 \. U* a' g* T        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. |0 H/ {9 J, N! N' K        -1
, \+ s- @! G/ V) M};
% S9 @" F1 ]/ U6 @1 b" q$ n  {4 W2 W6 H+ D: i" j
static struct gpio_led da850_evm_tl_leds[] = {
' {6 u. W- P7 n' ]: M7 q" o        {
  E+ J" _; g5 F% L                .active_low = 0,0 |/ z9 `9 @* P, H9 ^
                .gpio = DA850_USER_LED0,$ j" Y7 u: ^8 [. Q: {
                .name = "user_led0",
; V: V7 _4 O2 a5 ~$ z                .default_trigger = "default-on",4 J# ]5 P$ s( A" |
        },
' P6 k. u1 C7 ]" i' s  l        {
, ~. R% N" Y) v                .active_low = 0,
2 W/ d! ?8 y8 T9 k( w6 n8 B                .gpio = DA850_USER_LED1,* c3 x. E+ Y6 O$ n" B4 o7 m
                .name = "user_led1",- M/ H  d$ o1 G# A; l* H6 W
                .default_trigger = "default-on",5 d0 h4 E/ l$ W  r+ W, R8 g
        },
9 X+ p. x. {- v( m5 O( N/ u% ?        {
. C$ r7 ?) l# K* V1 |) }                .active_low = 0,( a0 N. l! M: f6 \- S+ m0 D
                .gpio = DA850_USER_LED2,2 a& e% t; \9 f  v% x4 |' @* H
                .name = "user_led2",
0 I" Z! C! b% A, W+ ?                .default_trigger = "default-on",
  `0 y) _3 ]8 p        },
: Q5 R. K, l* H, {/ S4 W        {
& o  s) D, u7 `. k/ a( v                .active_low = 0,' x! a% c, F' R
                .gpio = DA850_USER_LED3,- e- D* e7 |" F# c
                .name = "user_led3",
% ^+ w: B/ i; }' C                .default_trigger = "default-on",9 G* i+ {9 w+ c* l/ d8 G
        },
9 k- V. V5 A1 [+ q4 O};
1 r' n+ q8 ]0 G
* R6 N0 A: v' k* s2 jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" C/ d1 W  Z. |" K# `
        .leds = da850_evm_tl_leds,
7 {( Q+ e4 ]' ~$ H        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' R4 g7 A; j" R) r};
* m; \; J. a( _- z
, N, l/ P* l- P' b! }static void led_dev_release(struct device *dev)6 i/ i- K( ]* f6 \
{
# U& G. t* I& x9 h};- e' k4 I7 U4 g+ x% `
0 x* j- l; n' C
static struct platform_device da850_evm_tl_leds_device = {' i+ c! `5 a" M" ]3 P/ Z4 h
        .name                = "leds-gpio",7 R* t% m( R9 b
        .id                = 1,
0 q( E9 _7 V2 L1 f5 p        .dev = {
* a6 w" k! s" Q/ Z4 A+ b                .platform_data = &da850_evm_tl_leds_pdata,! ~  [5 b/ A1 ~3 v- ~1 N, a
                .release = led_dev_release,
  }$ e5 Y- @3 c$ H# W; n        }, B/ R" \7 }9 o9 w2 t& Y! A
};$ H* u/ B1 I+ ~9 R" e0 E

! B4 P' |9 C* e+ ?* j, x2 z2 mstatic int __init led_platform_init(void)
+ r9 m3 L3 U) O. [{
  Q% \5 [3 y+ a) |  ^        int ret;
/ P0 [% E) j& k7 T& F: H#if 0) z3 ]$ L# z5 H' j0 b; f& O, H+ `8 t9 Z
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# S6 h2 g- X5 w: c
        if (ret)
: `8 ^- ?  P8 H7 O3 s2 B* q* W# |                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 a8 Y9 S/ ?" \) r                                "%d\n", ret);. L  O* o! |6 w( C' J
#endif- ^; ^  d) x& `- P, i6 d
        ret = platform_device_register(&da850_evm_tl_leds_device);7 N6 t& \' r  q' B  X  K  s2 f
        if (ret)/ x8 N0 q. [9 v
                pr_warning("Could not register som GPIO expander LEDS");
% A  M0 w: D. y0 P9 w5 b& \9 a( `" n4 f' b        else
8 }7 S& }- v- Q% g2 ^/ c/ p0 o                printk(KERN_INFO "LED register sucessful!\n");
' b* c! o- N7 k) J3 ^2 |3 V0 C# w. S; P% c: D9 ^2 Z  |
        return ret;
6 |, m5 G. j$ L$ \% s, n}1 ^6 W' h+ J1 ]- [4 L
& N- V: k3 `+ h2 T" @% S
static void __exit led_platform_exit(void)
6 M- J3 O: M# v& O- o{
8 C6 s2 x" J4 I- g" u' ]        platform_device_unregister(&da850_evm_tl_leds_device);
3 `# h4 J  ~3 f6 ^* P3 L# l+ i/ U) m' f
        printk(KERN_INFO "LED unregister!\n");9 I5 U0 u9 g- g) V* t" b" i6 W
}
# ]2 }# j$ K# Y. y5 n+ n# j
' l$ c! p( x+ v- g  Vmodule_init(led_platform_init);
- I1 {1 \' W4 h$ Jmodule_exit(led_platform_exit);
9 d+ J9 U( s1 \1 r4 V0 N6 {2 y* L' V+ M  T
MODULE_DESCRIPTION("Led platform driver");5 I6 w6 f0 S/ r1 ?4 m* D  C
MODULE_AUTHOR("Tronlong");
: |5 X- a8 I* |6 B2 y. \% GMODULE_LICENSE("GPL");
$ N0 g: Z& g4 K" r1 c$ q
0 _, a7 R3 z' |  Z( ~
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-8 18:13 , Processed in 0.045653 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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