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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。& E" K* Z7 @/ G& {
#include <linux/init.h>0 _$ h7 `8 Z' X6 i2 j  Z
#include <linux/module.h>* o$ m1 h0 t( ^0 I) H* q# I
#include <linux/kernel.h>: s2 U1 @9 D- V+ L
#include <linux/types.h>
) v1 X" c( T3 \# o! ~$ t: Z- ~#include <linux/gpio.h>1 z' Z3 n; T+ p2 Y1 ^
#include <linux/leds.h>3 m; Z* [" Q8 o: K
#include <linux/platform_device.h>
% a3 U# h7 K. c7 z( V% A
, L: Q, i* Z% m. g#include <asm/mach-types.h>
9 Y4 d3 y; {/ j' [#include <asm/mach/arch.h>3 p8 a, b% e6 y# S+ S; N
#include <mach/da8xx.h>. J: N+ W% c3 v. _0 k0 {
#include <mach/mux.h>
* `+ g) Z4 F4 [. H  r1 ^! i2 p, K/ a7 v: V3 j+ t6 U( e7 Y+ R/ I
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
; }; Q9 ?% k# k3 Y#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
2 z8 o1 I$ I, z* a$ w2 x/ d#define DA850_USER_LED2        GPIO_TO_PIN(0, 1); ]) N8 O0 h( n% u
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)# c* w9 P- O' [! m! D( m

, J5 ]6 }1 x5 u" W3 B; e, z/* assign the tl som board LED-GPIOs*/; x) f. f1 w0 G1 ?
static const short da850_evm_tl_user_led_pins[] = {
6 ^' o- w' G7 G# S. Q' t# E% G0 {+ s        /* These pins are definition at <mach/mux.h> file */3 N( U7 y( J" Y; R0 L8 @0 [& b3 {
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" @# X  x* H7 K3 p2 @& _- V        -1+ R( M! Y3 w3 v- h) C
};
  Z4 L4 u. Q7 Q( L
; G; X0 b- _! E! b0 |static struct gpio_led da850_evm_tl_leds[] = {& V8 A  Q: G* G! ?+ G  ?
        {
- [9 c) w' j  _9 U/ n# z/ ]* w4 ]                .active_low = 0,
1 s0 J' a5 R/ b& k3 F7 y" y- [) s                .gpio = DA850_USER_LED0,
1 @  o) W. j' b9 h5 V2 U: _                .name = "user_led0",
& s. Q8 W) [2 K9 g( U                .default_trigger = "default-on",& e1 H8 ~1 X1 ^/ u' J# a- V4 l; @5 V
        },
+ O+ V# {6 d% l4 |) l$ Y# z4 k        {3 q+ H% T( k  v: \2 w0 J1 |" S
                .active_low = 0,! O8 g1 q. J+ i6 }9 ^
                .gpio = DA850_USER_LED1,
1 y# {7 b8 r- s                .name = "user_led1",
; W; `* ~1 w8 O# V0 d( s                .default_trigger = "default-on",
9 ^" j3 a' z0 q5 h! Y6 @        },
: X8 V  t( S2 F: V: U        {
, ^! _7 |! J: i  z                .active_low = 0,' f& Z1 r+ |, f  K: l
                .gpio = DA850_USER_LED2,
% W( b% |/ H, h' _/ R- h  C                .name = "user_led2",' n& R9 P( r; f- t* r. b
                .default_trigger = "default-on",: _  L+ K' L0 l1 t# b& D
        },/ K+ d. K0 G8 _: n4 g" t
        {
5 P  k* K  I; m8 a. `/ g3 p+ i3 `                .active_low = 0,
# ^. a, d" n7 U- s                .gpio = DA850_USER_LED3,
% Z- ?$ }- x* I" u) q6 ~, r                .name = "user_led3",
% I# ]; b  ]4 o/ J2 b. B* ~1 D) G                .default_trigger = "default-on",& P) I4 z+ o) [2 ^+ ^8 i
        },+ J' l: [* m: a2 D
};
" F" ]' J5 @, Z! m: s3 y& ]: t1 U$ J" {2 T  _) j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* i' ]. C% i- r; F8 s0 H
        .leds = da850_evm_tl_leds,
# H  P9 A( T, n        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, C& s; H  d7 C7 X4 R% Q8 |};* a% ?5 H3 g" j* e5 }4 B
( d. k7 _7 h) w1 h% A* k+ {
static void led_dev_release(struct device *dev)% T( m& S6 e8 i& K& B; i9 E7 T
{
9 R+ ?. E' g7 g; ~0 c' M};& |- }# Z$ E. S# |
( g' T& o0 N( j, @) V! G4 `: r
static struct platform_device da850_evm_tl_leds_device = {
0 n5 i& X' v$ ]        .name                = "leds-gpio",, T$ d( N* P" M7 R' x
        .id                = 1,& r! r3 P/ m- t  y. }
        .dev = {  t. I5 d; k- S2 {
                .platform_data = &da850_evm_tl_leds_pdata,
) p) e0 M8 `& }+ Z4 G, {/ N0 e  C( r                .release = led_dev_release,+ [3 l  W& _7 e! j
        }
& W1 R5 z) S0 J0 d6 D};. @5 e* D5 C7 a% t7 J3 p
" a6 I; x" V/ [$ c" O7 |* ~, ]
static int __init led_platform_init(void)
- h& F" w6 z/ U2 M0 [; C{
6 e' D$ A& N' q! F2 @; U/ P        int ret;
( F' c2 n4 o7 V: a# q#if 0
. c3 I4 o) m+ T7 A0 ?* |        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 R% ^8 V% @8 [6 D( x        if (ret): B; b4 k9 Y8 q/ _# B3 E+ S
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 I% ?# y$ W" e& Y- D- j' d$ D
                                "%d\n", ret);
* o  g2 F7 c1 h6 d#endif
4 P: q% L9 J) X/ s  A/ h& j" ~        ret = platform_device_register(&da850_evm_tl_leds_device);* [, J- }& D: s0 w! V; l5 I
        if (ret)! P$ s1 z; o9 E! P8 p- e
                pr_warning("Could not register som GPIO expander LEDS");2 g# G% t! A8 L/ ]7 \/ K3 c
        else
0 j. i) e0 X) o% ^' d7 H- y                printk(KERN_INFO "LED register sucessful!\n");# b+ e" {& [3 Z

* k, r- H9 B0 m9 f0 T        return ret;& Y9 N! g4 F' Q: N& k6 I
}
$ j+ s. `. U4 e
7 V6 f" v5 r$ c7 w) F: J- Ystatic void __exit led_platform_exit(void)
1 O" E4 K: B- q# f2 b: s{- F5 e4 e' Z- @! \" |
        platform_device_unregister(&da850_evm_tl_leds_device);
  T3 ~( p$ Z7 Y1 I% K
5 |/ U1 P# i% {. y3 a! l' t        printk(KERN_INFO "LED unregister!\n");( Y; s9 L  q4 F9 c
}
  L9 R- h# @, a+ q5 D9 \4 I" ?, r' ?
$ l8 c! ]$ A! x- Rmodule_init(led_platform_init);
/ {8 Y: e' l# J" y8 `module_exit(led_platform_exit);! q! ], t7 M/ S) R. X  r- R* T
* w- O5 _: a' `% k
MODULE_DESCRIPTION("Led platform driver");9 Y" c9 n& P/ ~8 {1 U# [. \2 X- S
MODULE_AUTHOR("Tronlong");
5 \& i; G8 m3 f& @8 O9 w9 SMODULE_LICENSE("GPL");# w/ Z( O) y6 `7 m3 j
! }; I# o. h1 P, I) b4 N, j+ s
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-9 21:33 , Processed in 0.038292 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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