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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。7 w! A) \/ P  ?% k& A) |
#include <linux/init.h>- W8 U5 U- g* ^' v, \" k
#include <linux/module.h>5 t' B& t7 o- b
#include <linux/kernel.h>
7 H3 o  |! ?2 ~" ^) m/ N#include <linux/types.h>( q$ I' R5 q/ z8 f2 k
#include <linux/gpio.h>: d( B+ U; Z! j2 o6 X/ m2 B
#include <linux/leds.h>
, |( t3 U% s  A) {) c1 i$ ?& v#include <linux/platform_device.h>
# o: C( k; ^9 F0 f
* B) r6 y; X. ^, z. ^9 o/ \* r% Q9 s#include <asm/mach-types.h>* x1 p9 X5 D1 [: ]6 A
#include <asm/mach/arch.h>& g% E9 a. `5 a& P) P. I5 x+ {
#include <mach/da8xx.h>
" D! ~& {. ?# Y  ]" P! c" k  h#include <mach/mux.h>6 o) Y! N  _- I
& x9 v2 r5 k5 G4 R4 `
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)5 @% _  ^8 D7 q  l+ N
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
! z  G) u0 a2 l- H! G#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)# S  b: k3 Y8 f2 ^
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
* Q$ v" S! I7 Z/ I$ o$ ^& H5 k
0 L4 h# }7 D" K$ W/* assign the tl som board LED-GPIOs*/
8 ~- Q# z. V0 g; ~& t8 x: U4 Jstatic const short da850_evm_tl_user_led_pins[] = {
- F6 {, e! l3 g2 C* ^) ^        /* These pins are definition at <mach/mux.h> file */8 L9 h5 H; W, K  e+ i, y, i5 D
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 m# |& K& a7 K. G        -1; b# x: e8 L. G' T" h4 o, w
};
! O1 V1 e* G, t  B7 e& q7 {: {8 i, c9 h( V
static struct gpio_led da850_evm_tl_leds[] = {, c. Y0 z% ~! v
        {2 X: V  P/ c; E
                .active_low = 0,
( S0 M- L% K9 t4 S. I                .gpio = DA850_USER_LED0,
8 c8 i# h. h" K) i- i1 y                .name = "user_led0",  D* |& u" z3 Y4 N0 \4 ^
                .default_trigger = "default-on",
4 Z- R# J2 i5 ?; @; f. {# L        },
' j5 |/ p- Z/ ?3 a# t% k: N( A3 v        {4 v/ f/ M# y6 Q% O1 R* ^: n
                .active_low = 0,
+ ]# o" M! }* y) p& _" O                .gpio = DA850_USER_LED1,
" i* V% K& M! t                .name = "user_led1",
7 U3 E3 D) y$ [! p4 c                .default_trigger = "default-on",/ V! U' y  N8 m
        },1 `* |0 \$ @  a* v
        {
- J* Z/ V5 T" x: u                .active_low = 0,  p; j3 _' X. y& s' j8 o3 `. s
                .gpio = DA850_USER_LED2,& V- `9 t2 f4 H6 W
                .name = "user_led2",
1 u! Z& A/ @1 {5 z                .default_trigger = "default-on",4 \/ z$ y! I: \6 H# A
        },+ i5 t; u6 ~+ k4 S+ x8 ~
        {* H% K" A. f! Y0 G$ w6 H
                .active_low = 0,% i! s' Y. ~' ~
                .gpio = DA850_USER_LED3,
! P+ m5 d: r: A- {# @: L- w* M                .name = "user_led3",
! X9 S; m3 K$ J% L0 i, M                .default_trigger = "default-on",
& Z' e( L0 o* g        },
; _1 w# w' V- v};* [5 a. z' h, m$ ^# o$ Z" U

0 Z2 C3 p* t; P' ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 D5 |; Z+ c# m% o7 ]" [        .leds = da850_evm_tl_leds,1 _+ @. ^6 e1 u& F
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* p. t0 p5 E" T- G- _$ y
};9 J7 R$ [& Q, Q0 i- U( ?4 ?
+ B9 d' m0 F% q6 j- \( e0 J- Q2 R; t
static void led_dev_release(struct device *dev)- L' N) @5 n$ ~. T) y: {
{' z/ k0 o3 E( @, a
};
+ ?% c9 p2 ~& [7 l0 i% g& P9 j' P  r! p% V6 ]0 t" E; E
static struct platform_device da850_evm_tl_leds_device = {
% s" B2 h& I1 m; [" c% p        .name                = "leds-gpio",; \, x7 M" O* t* @' E
        .id                = 1,
3 K' \  i) p+ Q- Y        .dev = {4 Y& K+ R5 ^( b: _. T3 f
                .platform_data = &da850_evm_tl_leds_pdata,
8 E: F  c7 k; U. B2 c( |                .release = led_dev_release,( e- A# a& @2 S& k
        }" }4 ^" l5 n2 A9 x6 C1 R1 x" O
};
* v2 N; c4 W) f4 |. y' ~( A
/ i" o8 ~% C! a) _0 Jstatic int __init led_platform_init(void)4 S. P% z* _8 J( A' y
{  J  I; s7 o/ ^) _
        int ret;5 j9 n& K  e! C6 |
#if 0& R: f& [7 }$ s3 V( \( i7 S
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& {+ P& P. Z! ~. w) S        if (ret)
+ R1 B4 \: D- b0 H$ W! {7 r                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 Z. W: a9 e9 R8 y- f
                                "%d\n", ret);
! r7 j/ _! B% R5 d6 _5 f, n% `2 ?#endif
) Z4 x8 s6 V( U3 \* ?        ret = platform_device_register(&da850_evm_tl_leds_device);
: R* }; Z) @; g& w: j) f. J9 x        if (ret)
( |* @& K6 @* e* Y. k/ }5 S                pr_warning("Could not register som GPIO expander LEDS");6 ^$ d2 y& V5 _# r. P& }# T! }+ E; p% R
        else
2 Z$ B+ Q8 S, P4 f                printk(KERN_INFO "LED register sucessful!\n");) ~( h: I- `# c# s$ ]1 U& b
5 p" A: j7 R2 S& `% _
        return ret;% n% Y3 |4 \$ n4 K
}0 c& j5 E& ]) n

; t% l" @$ E0 m3 ], E0 \static void __exit led_platform_exit(void), p6 u2 ^  ?; i. r& E9 {+ Z. f
{
& L% _) u* n6 D        platform_device_unregister(&da850_evm_tl_leds_device);9 w! k7 ~6 m1 O
/ e6 t- w3 @# u& q1 M) J
        printk(KERN_INFO "LED unregister!\n");. c( H3 E  X' a3 Q6 O, x5 U6 e! f8 ]' r
}
  T. |% u7 Z1 V8 H" [# O+ K) K. w2 c: s/ e% {6 v' T6 e
module_init(led_platform_init);, K$ X- d$ R' R1 S0 D# Z
module_exit(led_platform_exit);
' I7 A/ b* K* n, u1 J/ B' u" v
0 [$ \' e4 P5 |, ^' YMODULE_DESCRIPTION("Led platform driver");
; R+ Z+ X% R6 E) L7 [" kMODULE_AUTHOR("Tronlong");
# U6 Y4 m& Q  qMODULE_LICENSE("GPL");) @: I) Z% O$ v; Z5 t
" q1 U! n3 b* X6 e
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-25 03:12 , Processed in 0.040952 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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