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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
4 n* b8 [! B. V2 \* l#include <linux/init.h>% p7 h7 \% b! E0 F5 o3 k
#include <linux/module.h>
2 i! R1 j) G3 y1 z# e#include <linux/kernel.h>
" N4 F' K6 [& c5 c% o8 K0 B#include <linux/types.h>
6 E! k1 {+ j* Q" Y4 {' k; I#include <linux/gpio.h>; E7 O3 w3 g9 _& f1 {/ U1 c
#include <linux/leds.h>
3 _) p+ r  Z5 G! ]5 W9 K) }#include <linux/platform_device.h>+ s  N  G* v. `7 v1 w; |9 c
9 u& K1 O% \: C( a7 Z* C
#include <asm/mach-types.h>) G- R2 ]6 g, `5 k; A' ]
#include <asm/mach/arch.h>
# j/ K) f5 M% T#include <mach/da8xx.h>
* [; E! J6 o& ?, T6 z8 |/ I# N" ~+ j1 A#include <mach/mux.h>
6 ], b; J, h) p  R1 ^7 \9 `- V0 S& X$ {6 k
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
: S! a8 a8 y3 w4 X#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
0 O* B; @% g9 f" V/ P#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
+ k8 z6 O6 H: u' u: k# S#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)' k. f2 I2 V6 k3 ]) x. X

2 O; ~) y5 I1 x# w$ ]7 P/* assign the tl som board LED-GPIOs*/4 n  h$ L% f# Z/ S5 X0 T, R
static const short da850_evm_tl_user_led_pins[] = {
, D1 `6 \2 K; y* {6 S        /* These pins are definition at <mach/mux.h> file */
: S, D$ p. i1 P/ t% i$ U        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 M. X* x/ j  y+ q4 _8 u1 T- E* Y9 K        -1
* v6 _, }* r8 i9 H6 Y8 e};) H( c' a; ?. J1 K

7 s& o/ b. S1 S% P$ D; G2 nstatic struct gpio_led da850_evm_tl_leds[] = {% K7 e8 r) v6 z. i1 h. t% V
        {) P; L0 O+ P3 Y% u; M% _" B. Q
                .active_low = 0,1 C6 D1 j2 I5 H( X: t
                .gpio = DA850_USER_LED0,. F- ^1 \1 E1 n
                .name = "user_led0",
" }& U! {, z: F) C- ^9 u                .default_trigger = "default-on",
  P- V- \9 |  g: p8 Y) `) S        },9 {$ V1 F! A$ u) q7 b
        {+ X' K9 P& o. @4 l  F& s, a; C. V
                .active_low = 0,4 P4 f2 y; F5 K, A; r/ h+ g- V3 H
                .gpio = DA850_USER_LED1,+ n* I( l% H0 z0 B& e, p5 C
                .name = "user_led1",; G% K$ j; W" V1 Q
                .default_trigger = "default-on",: h) n$ _, U+ g# k  _/ Y
        },
' P7 \- J7 t8 |; Z        {
- g# l; ]% {& n# W2 G                .active_low = 0,4 m* J' ]9 i% i8 G. H
                .gpio = DA850_USER_LED2,
% a0 Z9 I! l  |# U4 R* y* S                .name = "user_led2",2 o* o6 u# B- Y; L
                .default_trigger = "default-on",
9 t. j& ?6 L. s! P$ n6 Z% V        },' Z  D  i* ]/ N: R. a8 `/ z- `3 P6 @; q
        {* c' a) _7 j% G8 I# P5 H6 M2 B/ }/ n
                .active_low = 0,
7 S9 Q2 [; p+ ?% Y# j9 r% d                .gpio = DA850_USER_LED3,7 Z* K5 ^. A/ [! ~; g
                .name = "user_led3",
  {  I; w* t5 x                .default_trigger = "default-on",
5 y8 d  G1 _8 f7 [, x3 L        },
  e4 l5 j/ i% X  P};
% w4 |  s- R" W  k! d, S2 m+ D; l' t( j& L' I; n3 R% L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ a1 w) W5 n3 T( F/ Z* n( l( [        .leds = da850_evm_tl_leds,
: B- v; y5 X' G( s        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& S# A/ u( Z3 J: z$ u
};6 Y$ u" R& _8 @' L) y, n3 @0 H

, k2 e3 ?; S# Ostatic void led_dev_release(struct device *dev)
/ E1 z3 ~4 N& b5 e" v2 t8 b% F3 H: X8 q{
3 @* j; n( @0 J8 A' b};
5 d0 i! ^5 Y" w7 b8 m' [9 V. ]7 x  O$ ]: ^/ u1 f& e+ Z: R& ]
static struct platform_device da850_evm_tl_leds_device = {5 z% U& e3 O7 w. z/ u  Z
        .name                = "leds-gpio",; |3 w0 t' W: R' Q
        .id                = 1,1 g3 r2 b# l% X4 {4 r" t
        .dev = {
$ ]1 [4 W* i( c' r                .platform_data = &da850_evm_tl_leds_pdata,. }$ m  \, \+ V5 M2 Y9 x; h
                .release = led_dev_release,
4 O0 O2 x' b4 V' p0 [! [; q/ L        }# _" Z% L" U! _# W" ]- V
};
) B& V7 ~5 e6 S, ]9 Z. r9 ^6 R/ t7 _7 b5 o
static int __init led_platform_init(void)9 [: R, h( d8 Q/ e4 i
{
; F7 ]0 v" w4 G- Y3 }        int ret;. y/ D1 h7 U2 F$ @$ T0 C" [
#if 0  q. k8 @' W! h: J; b- t7 |
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, o0 Z; K% N! n2 a
        if (ret): I7 ?) c% w& S" Z5 K( u
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# F1 F- P8 @1 `                                "%d\n", ret);: h# E# e% h7 C
#endif
, l5 e4 x. c4 L7 `" |5 p; G        ret = platform_device_register(&da850_evm_tl_leds_device);
. O2 O& x/ |/ W7 S% G        if (ret)
. s6 |& z) R/ o7 P4 J( t                pr_warning("Could not register som GPIO expander LEDS");
! |5 l! h9 M. o  H        else
6 z* ^5 N. V9 W+ |. b                printk(KERN_INFO "LED register sucessful!\n");
1 P$ ^0 T5 j, C! D5 q  s8 X
, t: A) d" |+ {$ {3 b        return ret;
' I6 }8 t0 }# p+ j2 |) G3 F4 A$ F}
2 L" W- D0 j/ p' H4 z5 W5 J9 z) M; P! Z& x8 q# y8 d% u
static void __exit led_platform_exit(void)
" }6 Q" f$ m- _) b1 c# `) b{
" {" c2 _/ @% g" u  w; N* K        platform_device_unregister(&da850_evm_tl_leds_device);
! R9 v0 ]3 S, F, K
" W! K6 }1 r4 T6 f- z( w        printk(KERN_INFO "LED unregister!\n");
0 |" Q: ]+ O! i0 `' `' K}: I) e# L1 G, e7 ~. E; \, ?. n
% v4 O. q9 S; `" a! @+ [8 A
module_init(led_platform_init);
( H) P$ O& k- D' |+ Mmodule_exit(led_platform_exit);
* k) X/ B: e4 o/ U" S% F! r* u. O, `( o  `- \
MODULE_DESCRIPTION("Led platform driver");
% ?8 `# l0 `) zMODULE_AUTHOR("Tronlong");
% T% F5 T  @2 w. CMODULE_LICENSE("GPL");( ]/ ?2 Z! L% `% y6 ?

- r) P6 o3 O+ ~1 n/ Y/ s
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-29 16:41 , Processed in 0.039558 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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