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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
# h, q" ^8 P0 S! [- R: X#include <linux/init.h>
* s3 g' w) z5 B* D5 }2 G#include <linux/module.h>
' J* f2 p) Q* X- b* }1 n# C#include <linux/kernel.h>
0 Q- M1 Y% D/ w#include <linux/types.h>
2 u' R% x- D4 c* d% C#include <linux/gpio.h>
9 w' n( w* T$ U0 [& ?  k  q#include <linux/leds.h>: r: y* @$ k! `5 y
#include <linux/platform_device.h>1 D+ E$ f) g6 [6 d

0 m" \* l4 S8 |#include <asm/mach-types.h>
" N- K: T& J8 C8 f#include <asm/mach/arch.h>
8 F7 n/ l% h  I% X0 D1 s) U2 c! Q#include <mach/da8xx.h># Z& j  |3 ~3 c$ O7 R# z# C
#include <mach/mux.h>; x* t" M1 c" {( [: L1 M) n' L
& z; V$ B+ v+ ~6 G% a
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
4 Z+ j: ~3 Z- k* z6 G- |#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)6 V' _4 @, q: s( X
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
/ i* P. A( s2 u; s$ \* x#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
0 X1 {' p1 z" i% ^2 }
7 g# Z  L' j5 o# h9 R  k/* assign the tl som board LED-GPIOs*/
+ M" @  B: g  Q" U: S  R2 C' Ostatic const short da850_evm_tl_user_led_pins[] = {$ D$ U" F! L, ?+ _9 s7 N
        /* These pins are definition at <mach/mux.h> file */& l* z- u$ e5 d9 \$ n. z
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
  a8 m  Q1 \; |$ K9 x        -19 G' X, }" A, w# w! N7 O
};( [2 w3 X) V0 M5 r# P7 r; U- j

7 X: p' P  `, \/ Vstatic struct gpio_led da850_evm_tl_leds[] = {
) E, z' O6 s' e3 e7 N; ^        {
$ p( `) x( K5 J: a0 @                .active_low = 0,5 M! l2 W/ e: h7 Q% ?. n4 j
                .gpio = DA850_USER_LED0,( x6 L$ ]' v+ q7 s- H% c' O: o
                .name = "user_led0",  ?  Y3 v- \4 X' A8 B6 }
                .default_trigger = "default-on",
8 a3 L, X, l) s  s# G5 D" f: G" A" ?: @        },: w# s% V5 {2 h7 b( h  s$ j
        {( Z, {: [2 [9 @# _5 ]
                .active_low = 0,
# ?# T7 V+ _+ ]                .gpio = DA850_USER_LED1,8 ~! _- E# x! Y  B
                .name = "user_led1",
1 a% I9 H6 ^, [. `) W" O% @                .default_trigger = "default-on",) I/ o6 X; @/ r. u0 S9 R: e
        },
) Y& i2 _1 v/ d9 m0 d5 G8 n        {
" K6 u; c+ l" A6 s/ l                .active_low = 0,
5 x, v# a; W9 m3 X- _% }) y                .gpio = DA850_USER_LED2,0 Q0 T1 [( [% U
                .name = "user_led2",+ J4 j9 \5 ?7 ^. y; L& D7 Y; r
                .default_trigger = "default-on",# H5 k6 r+ G6 P8 {3 {! ]  X. x
        },* S' v' P9 Y& K+ h( g
        {. M3 V% O5 F8 [; j3 B# k
                .active_low = 0,! ^8 b/ I+ ]+ C7 J/ r
                .gpio = DA850_USER_LED3,
& d* A7 {! J# k& y+ ]5 K                .name = "user_led3",
2 V6 m* r4 |% u4 F7 k0 ~                .default_trigger = "default-on",
( j& ~( E3 i. z. C. U8 g1 I/ h        },$ H/ e+ \1 w. n: `
};: _1 z9 f; i) {  T' q" o

" S4 P1 ^; E% q7 kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# K) A) S& R6 E! |6 ^/ F3 i0 F# G        .leds = da850_evm_tl_leds,
# _$ Z2 a9 M5 h* T        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. ^1 o* W( d1 m0 X1 w# u# W
};
& U+ i- V. s- l; d; s
  ~$ m( j' @3 b* A3 ^6 A1 s' Estatic void led_dev_release(struct device *dev)7 [8 P+ {1 S' r* `. d( `
{+ \& t* ]' Q& |7 ]' `; @* i  p
};
/ S4 R  C" |# j/ P2 v$ ^. t) c6 R* Z- J
static struct platform_device da850_evm_tl_leds_device = {
- U5 a  F5 B! B9 H& N. T5 N        .name                = "leds-gpio",1 Q+ z9 f9 {5 O
        .id                = 1,) ]4 O# d; D% J
        .dev = {
/ M$ N) @3 }7 t3 g0 G6 b! O( n                .platform_data = &da850_evm_tl_leds_pdata,9 e: J# k+ D- Q  r
                .release = led_dev_release,1 q) d. [6 v; O
        }' V- @8 {" H- }7 Y8 m6 b* d" @+ L& N
};/ p# H1 @' h% e

# p# S  l) i$ O) r( C4 N( ^static int __init led_platform_init(void)
: U% `5 H4 ]' L5 q2 P* l: U{. W5 i' m2 b; _  T( L6 }
        int ret;
; a5 c0 H* |& G2 s- C  o2 `#if 03 ?& ~( A3 q" M. M
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. U) c- o  a1 g! L* M        if (ret)0 N4 Q+ m6 [- ]
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 }$ E0 u) a( Z  h5 ?# R
                                "%d\n", ret);$ a# @' v4 T" x# D7 Y# }+ N5 i, P9 [* K
#endif
* |# l2 b$ A' ^' B; a4 O' j8 d        ret = platform_device_register(&da850_evm_tl_leds_device);5 y* U1 _/ l# Y  s' e7 H) ?8 ]
        if (ret)
5 E0 p. e  B) L  o) i9 U                pr_warning("Could not register som GPIO expander LEDS");
2 \5 e0 X6 A/ b: g/ ~        else8 b1 O$ t" E/ V
                printk(KERN_INFO "LED register sucessful!\n");
2 W" H5 |* @6 l/ |" i
  E$ Q0 E; `9 t0 d        return ret;
( U; z8 `- P- S( O* B}: m! w% ]4 \9 F( j, j
5 s; c/ S( J) O5 G% ~" D- f
static void __exit led_platform_exit(void)4 c5 j; m% g% u3 \- H2 S3 ?
{! u# }7 N+ ]) ]
        platform_device_unregister(&da850_evm_tl_leds_device);& a# \4 j8 G/ Y7 p+ U* M

3 y8 p5 g; ^+ e1 B5 k; O        printk(KERN_INFO "LED unregister!\n");
! I5 G7 ]2 d; K1 t) ~+ ^. P' R}
& {/ w( V9 Z6 j; c" V
! y, [: x  a" imodule_init(led_platform_init);1 z$ d0 d1 i* d- g8 ~
module_exit(led_platform_exit);# h" j" F; O% B: N6 P. r% _
% o9 y" Q8 H& V" u1 ~
MODULE_DESCRIPTION("Led platform driver");
' }; F$ B) a$ A) G' z) HMODULE_AUTHOR("Tronlong");
& j0 X% _, R$ V6 I) r# Z- dMODULE_LICENSE("GPL");
5 R1 \# G, m7 R5 L) }5 @2 M; T+ e" H
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-9 21:08 , Processed in 0.041207 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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