程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
; z, X+ R  T  y/ I0 d7 y1 l. j#include <linux/init.h>
" c% a2 J3 ?$ Z0 B0 m#include <linux/module.h>' F# `% L1 A3 f$ n' w
#include <linux/kernel.h>
0 ~) h8 x: f8 [( j9 Y$ M#include <linux/types.h>
7 e8 K, F% j- c5 @#include <linux/gpio.h>, H: V  h* U+ |$ E; G
#include <linux/leds.h>8 m# x/ V0 t; {1 R
#include <linux/platform_device.h>
7 o3 ]2 P+ K! K. Y9 P$ C9 `* C  K% V; }  g: b& ]: i. r
#include <asm/mach-types.h>
. ~, n7 a8 S. g1 J; M9 O, O#include <asm/mach/arch.h>
  z# P1 {. I# O* \" u: `#include <mach/da8xx.h>& a% r( u5 Z7 _0 d. M$ a
#include <mach/mux.h>% T; E6 g( n- `5 ]/ ~7 G& ]$ g$ P

4 ^  l4 b! g. L$ M# M2 p% l#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)- Z: s% `! `; r* n& P( I# z% n
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)! s. l* ]+ ~$ v5 ?! ]' G
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
  O0 K1 K, g' l$ G#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)( W* _$ ?7 n/ `# W9 a. N7 f6 Q* ^, M
! \  W+ j6 X4 _6 v: Y
/* assign the tl som board LED-GPIOs*/: o0 J- T; t" {" G
static const short da850_evm_tl_user_led_pins[] = {
, T4 f) X) N8 d8 u4 ]4 D        /* These pins are definition at <mach/mux.h> file */. B1 a! D$ M  e2 p" v  l3 x, j
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: ?* n5 ]$ u- |* A        -1. P% |/ s( p0 n$ U# D$ l* A
};
# |$ X7 I' f3 S( R1 @: E8 x+ a. h( n+ d- Y6 g
static struct gpio_led da850_evm_tl_leds[] = {& e, p; V9 E, `* U' C( H( y
        {
. q, p" C$ _* Q6 X                .active_low = 0,
1 l( g/ o: g% E5 N                .gpio = DA850_USER_LED0,: h8 i9 N& [- @0 r: X" L3 t
                .name = "user_led0",
$ V  O: G8 Y9 W- E+ q                .default_trigger = "default-on",) n* d9 E% Z4 M" X# r% ]$ k: I' |
        },& ~' w3 \0 U1 w9 F
        {5 d6 C# a9 Q- f% o# {
                .active_low = 0,5 C3 ^$ M  \' Z
                .gpio = DA850_USER_LED1,
) a8 m2 f8 ^& N9 [                .name = "user_led1",: l6 h% x  n9 D, b2 H
                .default_trigger = "default-on",* z% h& J7 f3 b. X
        }," x1 U- C8 J% L# @3 g' o
        {
/ B$ E! o- {% |6 D                .active_low = 0,  U& }) s, m$ w" Y# x
                .gpio = DA850_USER_LED2,
; d, y3 _2 y8 v% A2 y+ f                .name = "user_led2",
5 E' o1 X" Q0 l: b) p: {                .default_trigger = "default-on",
  c% S% n# R+ Z. U, I+ n# |/ b        },' {' b% q7 e3 m) F# u
        {" x2 V8 e) l3 t2 I9 b
                .active_low = 0,
  q) f* q' x- k, _3 F                .gpio = DA850_USER_LED3,( z! B4 E# [+ v
                .name = "user_led3",
1 k5 W/ P% P* g8 ], k2 t                .default_trigger = "default-on",- \2 c7 H. I8 k  b
        },3 S  f8 O( ~+ r
};
5 O4 u$ F3 r0 Z+ K% x9 W+ g( N5 q: b$ J' K
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {  v9 ?. \+ B  U% p) s
        .leds = da850_evm_tl_leds,
7 o' L) g9 [9 I, @6 [6 P        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' b- x+ l+ ?" |8 U* c: w$ c
};2 Z( W2 ~& {3 Z# z& ]$ N6 E% E
' e7 z  ?; x" i2 g+ o4 x
static void led_dev_release(struct device *dev)1 \: P$ h8 ]+ t' ~3 U, P/ b8 d# T2 f1 o
{
# N' O, L# \# j3 k) m6 r};
, `. q, O9 [. g) l0 o+ M  \: m
, h* I% r( `$ f2 Mstatic struct platform_device da850_evm_tl_leds_device = {
9 J2 |# O1 U( R, W, [        .name                = "leds-gpio",
2 u  ~* q) @# ]$ N0 D. U        .id                = 1,
; P/ R# l1 g) {$ ~8 ~* n- Y        .dev = {
3 G+ r7 u( [( e% M                .platform_data = &da850_evm_tl_leds_pdata,. n# [+ Q) E, j. ]+ i
                .release = led_dev_release,
4 I$ V9 `- t% j4 {! Q! G0 [! i! ?2 i        }5 q8 {" r5 G9 G+ k" w
};; l5 u+ w# O1 E) h! u; c
6 a! c7 k3 N. m# @4 L/ v) c
static int __init led_platform_init(void)
, @3 C* G2 x$ f: ]& G0 g{2 Z; k" }% z3 y4 \* f) J: v- m6 c& @, U
        int ret;
8 h( B; p6 b# _/ x5 K* q; a#if 0: Z" @# w- b7 v9 T' O6 C1 _
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& o) e& o/ j2 x2 z( j* [6 B
        if (ret)
! b# _# P  y3 v( [# F0 j6 t  `                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 s- G* z/ j9 |: M* O2 E0 A1 \2 x: e                                "%d\n", ret);/ x# `* h: U5 r+ w( L/ Z5 t2 L" n7 I
#endif
$ u) R$ A5 s& S) k; Q/ j        ret = platform_device_register(&da850_evm_tl_leds_device);4 u2 i/ O5 c8 g, p( \  R4 |
        if (ret)
- _0 U( P* o* j/ N, b$ D                pr_warning("Could not register som GPIO expander LEDS");- g  k' a$ p5 I1 E! Z( j
        else* I: [( y: t2 S( b, M
                printk(KERN_INFO "LED register sucessful!\n");# @- q8 ?& ^/ X* a% H6 o

) V/ _, U* h% Z7 V        return ret;
( X: H2 q0 E2 }}* \# L  ]2 _% k8 J, x

8 k5 \  J! c- I# p5 C" `. astatic void __exit led_platform_exit(void)9 x! `: }' c; p+ f) w
{
) N6 W$ \' P* z% ?& @- K0 j7 \        platform_device_unregister(&da850_evm_tl_leds_device);
/ G# w: m# L6 z6 x1 y" m5 E2 r0 j) Y. C  r& ]% X% J
        printk(KERN_INFO "LED unregister!\n");/ V' B) f: ?; r( n' V+ D# S9 y% e& q
}
3 b' e# N) h, m9 U% H" `! U- X) Z/ }+ m- D$ O
module_init(led_platform_init);" x1 D' F: s: R8 e; @  q
module_exit(led_platform_exit);
8 g) ^6 n" q1 [5 w: ^/ M
0 f9 P) Z! ?) }; i2 uMODULE_DESCRIPTION("Led platform driver");
3 ~; Q  k6 I9 s0 m& hMODULE_AUTHOR("Tronlong");
0 E; x6 {  w! f) r6 I; wMODULE_LICENSE("GPL");: T3 }) Q8 l+ G0 V8 I; b  V
( W& v6 I' j% M5 n' l7 [
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-29 18:29 , Processed in 0.037744 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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