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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。/ ^+ u9 n7 s. |- I) `! @/ m
#include <linux/init.h>. j& q5 m2 ]! j2 o* o' |1 p$ i
#include <linux/module.h>3 X# K3 A: X/ D, e. U
#include <linux/kernel.h>
, v3 Q$ z9 v7 m+ N3 `#include <linux/types.h>
, o/ N% _8 ]+ ?0 j: [3 g+ j1 |#include <linux/gpio.h>
: t0 w' o0 d" _1 p7 D) C4 b% |#include <linux/leds.h>
% ~  x; g$ S; n! y/ w' P' `9 Q#include <linux/platform_device.h>
3 {& n3 L& s7 p- d2 M
! O1 S1 g5 j4 z8 t4 H! @& P#include <asm/mach-types.h>* m. ]7 e/ }7 Z9 _6 x
#include <asm/mach/arch.h>
. c6 `, ]0 [: E. l7 G#include <mach/da8xx.h>$ D" P2 U+ H  Y! J
#include <mach/mux.h>$ @  U# m1 M$ ^% J+ }
4 R8 q7 x3 }) \" u' X3 X
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)% N' h9 m5 \. {1 F/ i
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
: }, y: f3 W5 v#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
) z9 M& ?/ i  f#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)) B$ Y0 d; C* c* N
& ]; V- m" i, F& g+ Q) Z6 y
/* assign the tl som board LED-GPIOs*/, U" V3 G6 e$ Q2 q& S
static const short da850_evm_tl_user_led_pins[] = {7 k: J. H3 a+ d2 D. f
        /* These pins are definition at <mach/mux.h> file */
4 \% k" n+ u3 o1 t; @/ O6 _        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 _9 H+ f% n$ y! t3 o9 J
        -1
) L/ X7 t! x- ^3 y% |) A: E2 ?};
# Z: o& s2 ^; t7 ~# P3 g) ?; k3 B9 E% U$ E- }8 p) s( t
static struct gpio_led da850_evm_tl_leds[] = {; |2 @- |( R0 B. i6 e9 s
        {' `6 L0 G+ o; j0 @) v
                .active_low = 0,
4 D+ P0 y5 l# N# e* P# g                .gpio = DA850_USER_LED0,
  R9 Q; M) g7 z+ k5 V+ Q5 w- M                .name = "user_led0",
) n) o' E5 N6 c6 N( {                .default_trigger = "default-on",
+ ~# x: }& ]( L0 S/ f' c        },% H3 o6 c0 {3 W! w3 Z
        {
# n& L; M' e2 R8 Y2 F: c/ Y                .active_low = 0,% \, u/ I) P) w% |5 H( V5 A
                .gpio = DA850_USER_LED1,
2 B: s1 o$ F2 v, M% q! o                .name = "user_led1",( m5 V9 J1 y& g: i3 `8 d
                .default_trigger = "default-on",
9 B; G4 u6 v2 ]/ H        },
0 X7 v- W7 z3 X/ a5 x        {
. m, W9 ~, a# P2 h2 g9 e$ S                .active_low = 0,  L# _/ c4 p+ Y0 K& x& S
                .gpio = DA850_USER_LED2,) ^: ~- v$ x8 ]0 w
                .name = "user_led2",0 Y& [8 h/ v8 k7 O$ S% s( f
                .default_trigger = "default-on"," x, m% G8 T# q/ p1 p9 A( d
        },& _: z* E' G# {
        {) V# U/ S! @& y; J1 R& v
                .active_low = 0,8 V) ~, M. ]" ?0 n
                .gpio = DA850_USER_LED3,
: Q+ h$ U4 ?- D+ K! t                .name = "user_led3",
  a* I8 [6 c# S. Y4 i/ \                .default_trigger = "default-on",* Z4 }8 o! x, W9 L- h  n2 j+ J
        },
4 x2 v( c! G8 S' c* B$ r};
  {4 I' @8 l/ ?; x6 H% M, y! E0 Z4 d! o& O- }& {0 ~
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
  x  a0 {( r# x        .leds = da850_evm_tl_leds,
' ?, a* l' w" G5 O$ x+ n1 j3 P% c        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),  ?$ w5 u" ]( R8 _
};' s* K! _( S$ [% P, l

% ]" f+ L# }) X7 h2 Mstatic void led_dev_release(struct device *dev)" J' J( `. ~7 ?- ]7 Z* u9 D
{: _+ f! F/ d7 b. d4 e
};
- w7 o4 g$ T4 e$ o0 i$ r- _1 g, y4 D- w7 A1 y
static struct platform_device da850_evm_tl_leds_device = {
* g; o' N7 m1 n, u3 h% {5 V) s4 B        .name                = "leds-gpio",( b: z* E  e. r5 S
        .id                = 1,+ N2 K. Y+ ]# L5 N6 U
        .dev = {4 j- u& \, W* T! s2 G- x
                .platform_data = &da850_evm_tl_leds_pdata,. ], r# q! ]& C# E* b
                .release = led_dev_release,: t5 u. |! m  Z! W" c
        }
8 w* y6 n" }5 a2 B; E};
" z# Q) ^1 O( ?
* f' L+ m0 G1 m) c2 m5 {" I, }static int __init led_platform_init(void)# S5 p0 L% h2 `! G, l
{+ M6 @! n/ x5 P( @0 g3 b
        int ret;
: }+ V% Q7 x$ c0 `#if 0( r7 ]2 v7 N9 V1 P: `+ c) P
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. b# x0 W* D8 P9 U9 Y# W
        if (ret)3 \& G; `, ]1 e, n* L
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :", [8 @- `+ }) S7 ]3 M* ~/ V0 n$ v% c
                                "%d\n", ret);
& [' T- q1 f* I3 x0 M#endif
7 U! i5 Z, ~4 Z( i$ s        ret = platform_device_register(&da850_evm_tl_leds_device);
7 S$ b5 t# S, |5 ?        if (ret)' A/ `  l2 p) E2 _# Y. s9 H$ Q! z
                pr_warning("Could not register som GPIO expander LEDS");1 \9 y7 I) a+ |' k1 E
        else
0 q8 |  f6 }; y* J$ Q* q                printk(KERN_INFO "LED register sucessful!\n");
( h8 B+ k1 Y; O" I/ Y4 l" I; ~* c- d+ y3 ?% E2 [" S' [
        return ret;
, l) R  b9 A( X1 K6 M8 y& e}6 {6 e! q7 v/ \( Z! Y( Z
! P2 p1 d$ q9 g8 D
static void __exit led_platform_exit(void)
+ n( U* Z7 |" t3 p0 B3 X  b{
( t- A+ `* D% U9 v  c% W) B2 T% o4 {        platform_device_unregister(&da850_evm_tl_leds_device);% _6 b  G( R" I/ m! D: S* [: d

- m/ c4 U. ], m. [1 N        printk(KERN_INFO "LED unregister!\n");1 m$ e0 Y% L# z- E% w  S
}" v2 J' X6 a7 Z9 y* \. N7 }& m
/ n1 Z" p8 e4 i! L
module_init(led_platform_init);
& }& u. h6 N, o+ emodule_exit(led_platform_exit);: m2 d% v3 @$ a4 a8 T4 A
5 g) ]+ c4 a/ L# T
MODULE_DESCRIPTION("Led platform driver");
1 `7 I+ V9 a0 R0 T2 c  e- KMODULE_AUTHOR("Tronlong");
& ]( N9 M2 h# EMODULE_LICENSE("GPL");% Z( w1 S1 e6 Q% n+ a
+ W* G8 h" p1 g0 i. {2 j/ D4 ?
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-18 23:28 , Processed in 0.037220 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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