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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
, F; a) c: t& R8 g#include <linux/init.h>6 _) C; h5 q3 h4 \$ K
#include <linux/module.h>% g2 x! x7 a) b7 K: X( u9 {9 M
#include <linux/kernel.h>' g4 X) I+ T2 g9 Q1 w
#include <linux/types.h>0 \& E+ w1 U3 h% }) x
#include <linux/gpio.h>* O' Q) {% R/ g; b. ~5 \
#include <linux/leds.h>2 i8 i6 A  ~: p5 T) d- \
#include <linux/platform_device.h>: y* J: M. _" }) I" e
" W5 u) O" l* m) y! R5 e6 m
#include <asm/mach-types.h>
/ E3 n2 O5 R( F0 l: M! Q#include <asm/mach/arch.h>  z+ y& Z: Y, R4 i( F& Y
#include <mach/da8xx.h>! t2 Y  x6 i. \' Z8 W
#include <mach/mux.h>; ?( e6 Q5 I# j2 g
5 X  u+ u; ?1 ~0 T7 o& x* m/ U# Q
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
5 ]9 _, Q6 f: C8 s#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)/ i( H  f( t9 X2 \
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
2 h3 D, k% \2 h/ d& K8 G% Q#define DA850_USER_LED3        GPIO_TO_PIN(0, 2). M5 i0 M& I. A/ h" J* O# D3 C

3 l: s9 B9 Y* J! g& B/* assign the tl som board LED-GPIOs*/, {& s  o/ ~2 D- t# c
static const short da850_evm_tl_user_led_pins[] = {2 c6 I2 d! ^! ~$ _! \5 N9 u2 M
        /* These pins are definition at <mach/mux.h> file */* @0 b( E+ Z$ |7 `" q: K6 \: ~
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* b9 M# A( q( b% I
        -1
4 e6 f' m5 b0 H& L};
1 [: g1 h0 J- A& v" ~/ D/ C& v/ ?! g* c
static struct gpio_led da850_evm_tl_leds[] = {
" `* c& ]+ V) [4 P: A4 c        {
9 j2 H. K6 Y3 U                .active_low = 0,
9 ?( [/ l* y1 b% h8 N* u$ |" A                .gpio = DA850_USER_LED0,
" [- A1 l# C$ `! W8 B- ^; s1 B  \                .name = "user_led0",
* H2 K. p2 p! O6 X                .default_trigger = "default-on",$ q  m( h4 }( z" s
        },$ U, ?8 }) e  \0 q: P, m8 p; a
        {1 ~0 x' c- N. }! @+ r8 U( p; Q
                .active_low = 0,
. f- q9 x3 V7 \9 _: I! u% a8 G                .gpio = DA850_USER_LED1,+ a2 ^: [* r0 A( b- m: v3 k, y: m5 M
                .name = "user_led1",( C4 T/ Q: o/ @; n
                .default_trigger = "default-on",
5 W6 S6 B7 C, J; O* b        },
9 s* V/ S$ k. m1 g8 _/ {        {
" i# A7 q: s" _                .active_low = 0,# I. ^2 \% ?1 i
                .gpio = DA850_USER_LED2,) p$ D! c, u3 i
                .name = "user_led2",. e: t3 i* |; ^/ H% o
                .default_trigger = "default-on",4 x; \- T: o( I
        },/ e6 `$ H/ T/ u) g. a( i9 d1 g
        {: R2 H( a  V' U- F4 F; _& l
                .active_low = 0,
6 D% z  v% M/ V8 x9 {                .gpio = DA850_USER_LED3,
1 k+ y- J4 D2 H6 X                .name = "user_led3",+ C+ {* u; R8 b0 |# `: K1 q2 s& U
                .default_trigger = "default-on",
; }- k: o, q' z7 ^- [$ T        },
4 Z+ l% w% _. J: N};
, h. F. M: E0 R+ v+ b6 H
2 ~6 M. u/ \) }# H( n. Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ ?( b9 L2 M$ B9 G1 X, d, H3 `
        .leds = da850_evm_tl_leds,% _7 X+ l5 h* p' `6 E' L+ V
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% w* |% s/ M  r: v" C};9 `4 A# H0 o$ c, B! |

+ Q& }3 t3 f  Q  }% W% `static void led_dev_release(struct device *dev)7 M9 D1 Z( d0 d7 a, R* I$ F; |
{+ n' @9 F/ R3 `; A: t
};- B" I6 b' G; f
; n; ~! `1 a  Z, a/ f
static struct platform_device da850_evm_tl_leds_device = {4 T7 O2 }& q7 k) v
        .name                = "leds-gpio",- I# t# B% f& |( b" W- O
        .id                = 1,! U7 w- w# M- O. {2 u& y
        .dev = {7 h+ j& q% U, k, L4 e
                .platform_data = &da850_evm_tl_leds_pdata,
1 ~2 I/ e0 V( ]6 n: c# X7 a) y                .release = led_dev_release,
5 \" O+ K4 P( I. p, A$ n9 X        }! Z4 q* U/ ?) N0 q' F# g
};
$ K1 C+ V" U2 M1 S
' c! M5 |* {1 H% n; Bstatic int __init led_platform_init(void)- v2 w# i( n0 X0 d  ?
{( b* ^. {, o# V( Z2 g1 G
        int ret;: r( u* T& |2 l
#if 0
9 c, c  `: f- z$ h/ i        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) m4 m: ?  c( f) a% ]
        if (ret)2 C) G* r4 {& J# E! m
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" Z# d$ }# u9 p* j, a. M0 ?4 j                                "%d\n", ret);2 `8 M5 c% m% s$ W( x0 G
#endif+ {, e' }+ [4 J4 _0 d
        ret = platform_device_register(&da850_evm_tl_leds_device);
& d* ]& E2 Q6 M5 F        if (ret)$ M2 o+ g- S3 D
                pr_warning("Could not register som GPIO expander LEDS");- X" D! O! _2 q
        else* D( v/ ?6 j5 v% \6 E  ?7 N
                printk(KERN_INFO "LED register sucessful!\n");
" I/ h# `, s. r' z- G6 f# M6 S& C( D" V8 d6 H+ s5 U# t4 o
        return ret;
( Z  \1 N" \, Q1 {0 g& [}( ~; K/ S" g2 T  G# {

4 z& x' i- o$ b, Q4 Y# \3 `1 @6 mstatic void __exit led_platform_exit(void)1 `2 ~: r" j0 I7 _/ |* B1 u
{( r  a' g& J- v+ g* O
        platform_device_unregister(&da850_evm_tl_leds_device);
; D6 ^7 h5 E  j# s* }  k6 B* g" h* V7 z0 l3 \- Y2 A5 U2 B
        printk(KERN_INFO "LED unregister!\n");
6 o. J5 q, I8 c: {) U7 V- K}) b5 T' N" w# A4 c! Q8 R' ]

/ k6 c( h. n: B' C, Gmodule_init(led_platform_init);0 S: Y8 p. `# q2 {$ `3 K2 C
module_exit(led_platform_exit);
- D/ N* p6 G8 S& a1 @0 x
2 y- B- H; c* ]5 X- P" y+ XMODULE_DESCRIPTION("Led platform driver");; I- q1 l1 N$ v! T7 x
MODULE_AUTHOR("Tronlong");$ q  `7 V. f$ y8 {  u
MODULE_LICENSE("GPL");& A3 f/ s0 H6 Q( ]/ K; G1 ~! |

" U' K) K1 _& i
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-29 16:24 , Processed in 0.043247 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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