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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。( b' @( ^: g9 y& A  \5 e/ |8 x
#include <linux/init.h>" b$ S0 S* L% P7 s5 ]
#include <linux/module.h>. f- {( g+ t$ J* R( v
#include <linux/kernel.h>; o8 H& w' o+ H# F& m* s
#include <linux/types.h>
* i9 g& ^, d! |0 g# T: X/ z* k! V( K#include <linux/gpio.h>
* {- U8 @( T1 B#include <linux/leds.h>
+ _9 y2 o$ k; b$ n, B#include <linux/platform_device.h>
. g- _) y! u7 Y$ e, }0 w8 i
2 O/ G1 S8 L9 Q0 a8 ~; }#include <asm/mach-types.h>% ^. L6 M6 O% _9 p( b: {, z+ w
#include <asm/mach/arch.h>
# `+ {& B4 b  z% Q& r' M#include <mach/da8xx.h>
; D& G9 m/ V/ u0 u" X" I* e#include <mach/mux.h>+ O2 |( S& _, ]; G2 G3 n4 Z. g, v" i
% D5 q! l( S( m+ H2 w! h: x. ]
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
+ |, G7 G1 K4 `, U) A% v#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
. F: J  y4 |! b$ |2 J#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
2 K$ P% {; s6 e# B/ `#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)/ v7 F' D4 j" R7 e

3 V! o1 Y& D$ G, D/* assign the tl som board LED-GPIOs*/# f: |. H% F" @& m: s2 w8 k( T
static const short da850_evm_tl_user_led_pins[] = {8 S2 P9 x; r, n: [
        /* These pins are definition at <mach/mux.h> file */
  Y; |# l0 {" F' W        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 W* K2 k/ O) d* a+ Y
        -1# T. X* X/ n3 `
};9 P6 P: N6 Z! p$ o7 O9 o
  @( I" C7 \( }2 x2 y" U  `
static struct gpio_led da850_evm_tl_leds[] = {4 L! C' j; z9 r  H( J
        {" i+ l7 c/ J9 l2 E3 i
                .active_low = 0,- {" U& O7 ?& }! d" z% w% m" t8 z
                .gpio = DA850_USER_LED0,( R% r* z7 I5 k; k
                .name = "user_led0",& t7 W# h% v. v* b" f% T
                .default_trigger = "default-on",+ A& V8 p4 V  W
        },6 z, a% L  R# d  Q' w
        {
0 F6 c9 p$ O- z  @8 \! K  v  x                .active_low = 0,, g( C% L+ f- o" ^% I) O
                .gpio = DA850_USER_LED1,
$ @+ e* \9 z. Y/ d, Y' b                .name = "user_led1",0 }* }5 ~, ^* v  s# J7 Q
                .default_trigger = "default-on",! q+ D" I3 p# g# T/ K: D4 e
        },
# o7 ^7 J6 v6 f        {6 u3 d9 i2 N9 ]2 _4 G
                .active_low = 0,7 e. b1 a$ x$ f' d9 c! n# Y+ s
                .gpio = DA850_USER_LED2,
" w0 K* B9 X" z2 T) w' c& l( |                .name = "user_led2",+ p* C+ y& ]7 D; ?# H/ N
                .default_trigger = "default-on",% v1 S# n) Q4 K% |6 S
        },
% ?+ a# U& @/ g( S        {+ m" ]4 `2 I* U. Z3 h: H/ ^0 d
                .active_low = 0,
$ U$ x) b- p- L. D! n, `                .gpio = DA850_USER_LED3,3 G% C5 p/ L, V9 U# m8 y! [
                .name = "user_led3",& I6 J& u2 l1 o- }1 E- u) e1 @
                .default_trigger = "default-on",8 G  _( i& _, m  Y1 s
        },
& U" `' x# D- a8 R};
0 p# s4 s, u' p- t/ Z3 v- W6 t/ d$ o- I, u% C; n5 L6 l: j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 G! k+ i; x/ d" W) T
        .leds = da850_evm_tl_leds,. S# m5 j! J# e* U
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 k  `$ A2 P8 `( k
};
2 t! K1 ?7 w  D  O3 v. Z: B
. K) o) H' N+ Z3 E7 estatic void led_dev_release(struct device *dev)
% G% r- K' U& {" c6 m{
: m5 r) T# o6 _};
7 ^0 R- U" B, _! P7 z, Q5 g4 r4 z5 ?8 ?8 A
static struct platform_device da850_evm_tl_leds_device = {
( h, Z: T2 s  w$ a        .name                = "leds-gpio",, I7 Z) r3 k) v
        .id                = 1,0 B# U. b0 H0 z( p7 l
        .dev = {, e6 q9 ^! |  W1 u- k
                .platform_data = &da850_evm_tl_leds_pdata,) u" |* `& {2 t9 {* H3 w
                .release = led_dev_release,
/ D  t, D, [0 M% N9 j, Z6 D: }        }# V" o! A% J* I5 G1 ?
};9 L6 s- Y& P5 t- i( l$ d8 H& t8 [
$ M9 x- y) r5 {' Y6 `8 J9 D
static int __init led_platform_init(void)( b1 z- {" d$ E: H- K. j
{
0 P4 l5 U1 }" A' d& s& y% _        int ret;6 W1 m, D( e3 L6 T
#if 0& a8 q' V( D) {, j0 F. n
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' f, Z1 D  x8 M2 Q5 x9 y        if (ret)% m7 G' {$ @0 O7 K& D; X
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 y2 F+ H1 c7 p- V# o                                "%d\n", ret);- n) t; l/ a; O+ g5 [# ~
#endif
& Q1 R: K: h* c- Q8 B4 @        ret = platform_device_register(&da850_evm_tl_leds_device);
; m7 w) {9 N" ^        if (ret)0 ]) X/ y' H# Y7 W7 T
                pr_warning("Could not register som GPIO expander LEDS");
7 d; X2 y+ A$ N  Q) s        else
% F1 b2 z/ R2 X* x! G2 W5 b                printk(KERN_INFO "LED register sucessful!\n");1 G7 T' t+ u$ H. x( S+ v

9 d8 }; @7 d1 S8 _: I# \: ~4 F, \( t' A        return ret;
+ V0 b- A2 S% V/ }7 |' J9 l3 v}
) `1 w* K5 h! r' |8 \- J  K6 r! C  _8 I6 p! K) {) K" X5 o
static void __exit led_platform_exit(void)" n3 u$ P! j4 h: l4 @2 `
{
" f+ M* n7 @) a% W" H+ z        platform_device_unregister(&da850_evm_tl_leds_device);1 m) T  I9 Q3 V4 l

, n4 Q4 i1 ^5 w: `3 V4 P" w& I) o        printk(KERN_INFO "LED unregister!\n");+ y3 A( B  Q, p4 Z$ D: Y7 h% J
}& H& G+ V9 R  N* ], Q

, K4 a, b$ e& c( M- {  J* ^7 \' ?module_init(led_platform_init);
( N4 c0 B) I9 c$ l; q* J* Pmodule_exit(led_platform_exit);
, C5 G' z- U/ u* d+ R- S) F5 l" B. w% ~3 X: t& {2 ^2 @
MODULE_DESCRIPTION("Led platform driver");
5 u% M9 j' q4 U- k4 O: lMODULE_AUTHOR("Tronlong");
4 t3 @8 ?8 ]# RMODULE_LICENSE("GPL");7 |  _! U5 z9 \) J- I3 Y
  H# A/ d4 Z2 Z2 ~' K4 x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-16 07:24 , Processed in 0.045996 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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