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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
7 v) o0 F1 _: U#include <linux/init.h>  m! q0 x$ S; f4 n0 g
#include <linux/module.h>0 I* a- v) e: M- U$ |. ~8 d
#include <linux/kernel.h>
# ~" t% b6 p, E3 _4 I  r#include <linux/types.h>) T; x5 O5 o6 c% w. n8 W
#include <linux/gpio.h>
: x8 J9 |+ z; m7 A; y8 A$ \#include <linux/leds.h>
" A- S! N% E6 C#include <linux/platform_device.h>
' U/ ~# w1 z7 U) p( O' e$ g0 \3 M, ~( O0 g& @# f
#include <asm/mach-types.h>
7 ]& J1 B0 h. {/ @3 f#include <asm/mach/arch.h>4 J3 i* v. @" ?; t
#include <mach/da8xx.h>
/ `; _# {4 D1 y2 F#include <mach/mux.h>1 ^+ G& _8 B2 P

; H3 K1 @/ p' |. }) C2 i#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)9 s* a4 g) a" Y4 d; K
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
3 X% @+ }  r5 F( K9 L#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
9 o% L! J3 R6 ~4 f#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
3 J% k7 p* z& T" i6 a* j0 O+ y. \- b4 j3 f3 Q& x- S3 b; _
/* assign the tl som board LED-GPIOs*/
: N8 J; U; o. r  `+ X5 Hstatic const short da850_evm_tl_user_led_pins[] = {
- e4 d! x; }' O# |/ ?) ^        /* These pins are definition at <mach/mux.h> file */& d( Q4 e9 h% V- C
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' I. h& u% d$ ~9 D2 @        -1
* Y8 g8 n4 a" N( E4 Y};
5 p& m8 p/ _% Y7 G6 w' n# {3 D
# Y  c3 ~6 J) v+ O" Wstatic struct gpio_led da850_evm_tl_leds[] = {6 @7 d/ u- _: _! n
        {
! L$ k- _) x) ]. g, n                .active_low = 0,4 j+ t& o) X6 q! J
                .gpio = DA850_USER_LED0,* W/ D" F- J. {) G/ j
                .name = "user_led0",' W% N' E5 R1 ~) A9 R6 f3 }
                .default_trigger = "default-on",* ^5 |$ a5 Q3 s! c9 v% K
        },7 [9 `; T) d8 {) A9 T8 q5 x
        {
0 h; E. F9 T) j1 w6 o5 n                .active_low = 0,
- M6 l3 A& F- k6 p# ?: J5 {                .gpio = DA850_USER_LED1,
6 C0 y7 z1 X; G" L9 {4 s7 @                .name = "user_led1",
9 z# I; `* Q" I+ C9 |# i                .default_trigger = "default-on",
" l& z8 p$ P+ b5 c        },
$ n" @. l$ D7 N3 W* Z% E& i/ N        {
/ y" Z, K% h1 K- i4 u; v8 E" g# Q                .active_low = 0,
( G* B# M' y5 ?. q1 J  U                .gpio = DA850_USER_LED2,
- ~+ T, Y8 ?+ j+ u                .name = "user_led2",
& P, j' @6 ?4 Y7 G- n5 x                .default_trigger = "default-on",* J, Y* ~3 w* ~, X1 v' j0 i! \8 l$ W
        },7 [8 P4 A! O5 z1 N
        {* p0 ~% A0 O9 \. r6 X
                .active_low = 0,: \: @8 h! t% M+ E' R$ B8 n
                .gpio = DA850_USER_LED3,- z( f, a9 ^' N& r; q
                .name = "user_led3",/ M0 D: ~+ a  q. x5 s# M" K
                .default_trigger = "default-on",
6 h/ O+ o5 Q* [" b% O3 L        }," x- o6 O3 q5 }4 f% }) b6 w
};5 k0 g! V) ~( D  j7 S% f

' o% K# Q% g$ nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 T9 G# D8 B' b3 h1 A        .leds = da850_evm_tl_leds,
5 s7 g8 l8 t; f- ]3 q/ |# W! y        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% D, V; F0 ]" s8 {9 C4 q) o7 I
};/ S& }* I" M/ i; x
. N$ K2 o( a: E4 L- P, P7 `; }
static void led_dev_release(struct device *dev)  n6 e& P" [6 `  [0 J4 {9 E
{
1 g9 o3 e( s3 s3 o3 ]8 R) l9 |};; }" D8 L: I# o/ s

8 B* n* o) E* U8 Cstatic struct platform_device da850_evm_tl_leds_device = {& v7 y1 h6 [  T' v, I# h6 O5 a
        .name                = "leds-gpio",* H- }/ n; |) L  s
        .id                = 1,
' {  e/ t/ t" E& D; B        .dev = {
# Y) F3 M& {4 F  @4 H; g: w0 O) `                .platform_data = &da850_evm_tl_leds_pdata,
+ O" v8 v4 O1 ]                .release = led_dev_release,
8 o! n: n/ v9 u% ]7 h        }; ^( H# A3 r7 p+ y+ B0 b+ F
};! L7 t* a/ O: Z) |: }' m4 ]

% A! b2 y- O3 K- v, s1 T9 P/ I' P$ Bstatic int __init led_platform_init(void): Y$ \. j& R1 f! E5 x7 [  C' h
{! @7 b9 g* M0 n5 t
        int ret;! ~) _& L0 b) d1 D3 q% k
#if 05 c- y* G' V6 x
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ I# i! E' {: X& P! D  ~; \
        if (ret)! D2 g) A% l" L5 J  h4 v
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: ~; n! S2 a+ J+ F/ R6 z" c                                "%d\n", ret);+ f9 |7 y5 A9 a. _" z. E3 U
#endif
, J) D" X  C3 O% g! ~, u        ret = platform_device_register(&da850_evm_tl_leds_device);
' E6 l; p3 S7 k5 k& S/ z- l        if (ret)$ H+ v! q! q/ [, k9 p
                pr_warning("Could not register som GPIO expander LEDS");
3 ^% d4 `/ r6 Y1 i        else7 Y6 L: r2 s1 n
                printk(KERN_INFO "LED register sucessful!\n");
8 A! e# d& z" z1 [8 b
' g. I9 C. Q' `) U2 l/ K        return ret;+ N& v. u, A! ~6 o' g- d! r' A0 N2 F
}: A& R5 R! g, d1 y5 [* b

- ^- y' f& {. y$ \6 g" M( qstatic void __exit led_platform_exit(void)
, H3 e% n% j9 S% G1 J! n& N; n" K4 S{
8 S; e2 j5 e0 v/ v% s        platform_device_unregister(&da850_evm_tl_leds_device);* c1 O# W  ~# o& l5 B8 E
" U  R' ^1 X; G* r
        printk(KERN_INFO "LED unregister!\n");
, z( c3 M. A6 V7 J+ g: b}( r3 T; W/ A" a. n
) O1 y2 P" F- ^) d0 l' z& z
module_init(led_platform_init);
) O% D1 j, R) E% }3 ymodule_exit(led_platform_exit);+ k* O6 M3 c5 X
, b' O1 m3 P: x6 l
MODULE_DESCRIPTION("Led platform driver");
8 w$ c+ D" z4 G7 q1 T- AMODULE_AUTHOR("Tronlong");  N2 x# s4 ]: d8 t5 E( l& ^
MODULE_LICENSE("GPL");
5 ]9 e0 [: f0 K0 g. q0 t- A' K) N5 N9 g/ Q/ G9 o2 U0 Z  i5 A$ S
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-27 02:20 , Processed in 0.047963 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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