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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
# t9 X" [9 b( T% [6 Z#include <linux/init.h>
) N' S) f5 c1 G% M#include <linux/module.h>
8 {: o4 N# x" a  S8 q9 T1 O8 z, J" d#include <linux/kernel.h>, x2 ]! K* H0 x! L4 F  S, N' g# ]
#include <linux/types.h>
" @, Z. a, [$ j# ?, |" Q5 P) E. ~, @#include <linux/gpio.h>* H+ y, t: s- [
#include <linux/leds.h>
- b, P  E1 T6 B5 d) C' l% w$ r! y#include <linux/platform_device.h>
. c. v. [' o" V+ [. q7 b! G4 E) ^5 n$ S# r! s- G
#include <asm/mach-types.h>; }- b, M' U3 H* G
#include <asm/mach/arch.h>. V6 [: {- F, G5 n- {! e
#include <mach/da8xx.h>
/ c* S# d. k0 J! c, z& u* `#include <mach/mux.h>
  A* U- p$ r# }& y/ d/ u' m2 K" h& S: }5 q7 N! m
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
" N+ k- v' B- @! S. x#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)9 k, k' \5 p6 V' x
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)! y% d# D' |, i# v) N+ l
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
/ k; F9 I& z- |+ k+ L# j- m; Y4 M' f% F" k
/* assign the tl som board LED-GPIOs*/0 k- m" J0 R: t4 z: F3 Q6 g& |
static const short da850_evm_tl_user_led_pins[] = {( P& |  B( E, K& k6 t( P
        /* These pins are definition at <mach/mux.h> file */
9 P9 j* ~: i& d4 b        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 i( H! Y& O% H. Y' y6 S& d
        -1
% c0 Z: C) Y% [0 O1 m# U( `9 e, ^2 D};! f" O0 o) E- `( t& ~; C

1 X( ?' ]' R+ z) m# [  mstatic struct gpio_led da850_evm_tl_leds[] = {& c( r" U+ K# @# ~; a4 Q
        {" [+ [5 C1 X, l; t! ]6 ]0 @% U' d
                .active_low = 0,
. l) I% ^9 A; |8 y. f- a                .gpio = DA850_USER_LED0,
1 |; ?! D- t- [+ `                .name = "user_led0",
$ M; d* u4 S9 O& w) {                .default_trigger = "default-on",
" k2 A9 H- ~  L% ?9 }        },
7 i5 M' O# K% t8 C3 r3 Q0 r# g        {
5 f6 ?+ s2 Q0 n6 `* f8 m$ l                .active_low = 0,
8 d0 o4 E) n, A9 |  M                .gpio = DA850_USER_LED1,3 q( Y2 @  }7 R# n5 s2 i4 p: A
                .name = "user_led1",8 ?: o; h1 [  D3 Q
                .default_trigger = "default-on",5 i/ G& u8 R! m' n9 P+ \+ Z
        },5 ~: }! C' ~& w/ B7 K/ }! a+ X5 a* b
        {) W/ l/ _- q( Z5 H. r& |
                .active_low = 0,
% C1 Q4 @# p, G- u, w                .gpio = DA850_USER_LED2,
* a6 H$ x5 I- N3 j7 s                .name = "user_led2",4 Q5 ?9 R7 ?& O- h
                .default_trigger = "default-on",8 \5 ]7 N! s5 X& M
        },7 c. ~( M% g: u6 _6 f8 H2 `
        {
- s& r' Q/ C6 P& e+ A, J3 ]8 d4 Y+ C                .active_low = 0,
6 u% g& D: Y; ]                .gpio = DA850_USER_LED3,5 }$ U- y$ `# O! q; E  \. z
                .name = "user_led3",- K' @1 e% g' z
                .default_trigger = "default-on",
5 c. p: M8 k( @& i$ @3 ?        },7 }; U3 v" M1 z3 t0 G1 r3 h
};
: H6 t- F6 `7 g/ J  D1 O# s  ~) w( v9 C- S0 D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( f; F' y7 ^. {9 r7 e8 l        .leds = da850_evm_tl_leds,
. I  g1 U0 c4 f- r- m# e        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- ?! c& s6 {4 `
};; P5 |- p$ z$ v
. p9 c. I4 W# U' s+ e% V
static void led_dev_release(struct device *dev)- D' U% V) I' t, R
{
  I# e: B2 B+ i# ?};  D  ~1 t# E6 K7 T9 g- c1 \% e
! `" s6 j1 i, f+ E
static struct platform_device da850_evm_tl_leds_device = {
" R8 F$ H* T0 K4 l" k        .name                = "leds-gpio",  ]4 o) G, C0 b) F9 Q) S8 @# q8 t. o/ i5 g
        .id                = 1,
( k9 A9 s0 A/ [  ^  D        .dev = {
. n- _# q6 ~  \% g, N) X; [- g                .platform_data = &da850_evm_tl_leds_pdata,# f; \; e7 g4 A* y, e
                .release = led_dev_release,
) M  f4 H2 P' M. C+ o        }
0 A# L5 B& R, a1 O};
1 K" t5 }: E9 t7 n+ @; X9 l8 a) b$ a
static int __init led_platform_init(void)  Y9 }9 X6 Q, u2 n
{1 G. ]: V" c/ M4 V, i
        int ret;. i) _- A- Y  L; v" _0 u5 n% p
#if 09 w4 Q$ I* y1 s& B4 ?, Y
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" o$ m" C1 p$ f! G8 ^4 `        if (ret)( f8 L  ]6 o" T: w
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 s0 v" V( S: F; }; s! @                                "%d\n", ret);/ @; K: I* D/ O  o" Z
#endif1 S/ U" K; }/ y
        ret = platform_device_register(&da850_evm_tl_leds_device);" O4 M  {3 I  t5 _. _
        if (ret)
  S* p& ]# d& A+ d+ O- Q- T                pr_warning("Could not register som GPIO expander LEDS");+ C  w; V9 ~; F/ G9 }
        else
: f' T' C5 G! `                printk(KERN_INFO "LED register sucessful!\n");7 B4 K. B, ^$ o' {  {" |( ]8 O! n( U
2 F" O% K4 Y% p3 ?7 M+ I: v! x* _
        return ret;2 l( ~; @5 q' p1 ~
}2 P( v2 v; ]8 ~: y

, B2 `8 G: q2 V! b0 e* ^& Cstatic void __exit led_platform_exit(void)
* y7 X( X. y2 F* A4 v* N{2 [  _# u+ C: e" F) t3 u3 \
        platform_device_unregister(&da850_evm_tl_leds_device);
0 U. i" e9 p2 A# ~2 n6 I; v. A5 H' q4 {/ b
        printk(KERN_INFO "LED unregister!\n");
2 x1 F0 E/ [. x1 B}! q: Z6 d# K1 m# ?
  ^! E4 s/ o( B& h
module_init(led_platform_init);
' k$ A/ ~$ ^) u/ U% emodule_exit(led_platform_exit);
4 k4 t; ^6 j, g2 G* a
4 E9 @0 {! Q8 i1 C- _MODULE_DESCRIPTION("Led platform driver");
- W- B- C9 X' P% E. M! ~; ~MODULE_AUTHOR("Tronlong");
$ b$ U' a- n% j# ?6 qMODULE_LICENSE("GPL");
8 n1 x4 v+ ]- h# C* S5 \2 ~' t! ]5 F
+ B3 f; C  ]$ a
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-21 02:25 , Processed in 0.043643 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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