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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。' m" b6 a9 s8 {
#include <linux/init.h>
. A- R- ?/ R  @8 k# ~& E#include <linux/module.h>2 g, p9 h. o3 L4 F
#include <linux/kernel.h>
+ s6 b  M! x1 J% E- `# X#include <linux/types.h>/ l& D8 H& r4 b5 K8 U  u/ x
#include <linux/gpio.h>
6 }- D5 T: k, I3 o( t# e4 P6 M% E#include <linux/leds.h>
. B7 L$ a) Y- `, A  t#include <linux/platform_device.h>8 p; b6 g3 g6 w1 p+ w; _/ n6 ?$ R

- D1 u" G' F9 o( B8 f#include <asm/mach-types.h>" v9 f* s% \  ^. a* D7 {8 _
#include <asm/mach/arch.h>
: ^, B  W4 z/ l& B#include <mach/da8xx.h>
/ p8 B. P# T8 U# t; U" D9 d#include <mach/mux.h>- i. I9 E3 U9 L* C7 S

0 B% {8 H' _2 [3 M/ n#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
  f: |2 ~/ Q& [, `: b) |#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)7 \) p* q5 G3 |5 ~+ M3 T$ e0 `
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)8 Q9 n' F' r& u# t: l" m! R
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
& e* s" ~, k0 F; n& R3 p
0 y7 D, x2 W! R- L. _. p3 q/* assign the tl som board LED-GPIOs*/
$ \9 D6 E# z# k) mstatic const short da850_evm_tl_user_led_pins[] = {
! M, e4 S! j- r7 B) l        /* These pins are definition at <mach/mux.h> file */. ^* n. l; g' H' T2 ]( q/ r4 z# }
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ j! p. @9 p9 e: y
        -1
) _* t7 v6 A2 S: @& R. b};% W2 Q  x. P& |7 ]8 e9 Y( O9 G( j

% j2 L- I+ w: X1 H. L' \' e4 sstatic struct gpio_led da850_evm_tl_leds[] = {
6 F- }% A: F9 }        {
6 |* s  F! d7 @+ l2 O9 O5 l: c                .active_low = 0,* z: w& Y2 y0 N7 N* B; Y% M
                .gpio = DA850_USER_LED0,
0 O/ A5 T7 n% O9 \5 g+ m                .name = "user_led0",
' j5 @# G& O: M" |! X+ Z                .default_trigger = "default-on",9 Y* t' ^) M% {1 H! v$ K: p5 s
        },# r  |* X( g; p  ^4 S
        {) @' b# o0 k" o
                .active_low = 0,
) ~- h& c2 u. g% K, B8 b                .gpio = DA850_USER_LED1,3 J: p1 E9 H, v* s
                .name = "user_led1",+ i6 t: T) R% R! B
                .default_trigger = "default-on",, ~6 }  i' v- b1 `$ I; B
        },; N+ ?* J& i# H& @3 `( ]8 k# M
        {
8 G+ b2 h# F. K) {7 K                .active_low = 0,
% t. h+ J9 C, Y7 G! a8 I                .gpio = DA850_USER_LED2,
( d& c# N: A& E0 J                .name = "user_led2",
3 U$ R& s, f& Z: I( v                .default_trigger = "default-on",) q3 w) N: \* f5 K+ {7 P
        },
# h& {0 O1 ^# m* _' [+ Y* ~        {* t9 `* }0 p8 r. W! h
                .active_low = 0,
3 D. f1 p- @2 o+ v5 I% V! K                .gpio = DA850_USER_LED3,
& L: C' U4 g! u3 o* o1 E" f                .name = "user_led3",
/ P' U5 \$ ]( o" c1 c- p1 R: n" e                .default_trigger = "default-on",
% c/ `7 C3 I: ?+ X) w$ T: h8 m% d, E        },
- G6 b$ P3 d& e};) _* c5 c+ Z  M

+ m; o1 E+ z0 Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. e" J% v9 p. a, f; o/ ?4 Q
        .leds = da850_evm_tl_leds,/ N8 V/ I6 G; y- r( n: q3 G
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& e' e5 ]. m& p# u+ I4 A1 f7 Z
};/ C3 k7 x% W+ h: t. P" n' j

, D" j! _# }( V7 [$ z: M+ Vstatic void led_dev_release(struct device *dev)
# \9 G/ Q- k4 H: N6 ^* d{
. \& r; D/ h, X8 f: M: z6 T};
( W$ b2 e8 s8 E9 o9 M4 j  `8 O% @0 e; T& o
static struct platform_device da850_evm_tl_leds_device = {. D# t, ^& \& L. Y9 Q. ?' \! C
        .name                = "leds-gpio",
" p; L6 M1 w3 {' H) t" Q        .id                = 1,3 u2 W2 \* z3 b4 ?: ^7 @
        .dev = {7 P4 R/ A( ~9 r# r6 @3 j8 q
                .platform_data = &da850_evm_tl_leds_pdata,
7 P4 t- H- n- x& i: N                .release = led_dev_release,8 E; G6 P% h4 a9 Y, _) `4 y7 F2 k
        }- E' V9 G1 P( L5 _
};' |4 O/ ^6 Z9 @
0 }( S9 Q& u/ ~' }( N
static int __init led_platform_init(void)
0 X- V& Y3 i. p4 \; u* j{, }5 X' A* Z' _
        int ret;! f3 B7 f  d- w% }$ ], d6 C( s
#if 0
7 k1 H% n7 U6 _- R  h2 ^0 ]8 T" m        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 T! |1 E5 l$ B" {        if (ret)& u+ B+ P7 y# Q
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- P& b. h0 A% ?+ u                                "%d\n", ret);5 p0 g( _( A1 T+ I1 p& K. T1 N
#endif6 o3 B2 L# I' p
        ret = platform_device_register(&da850_evm_tl_leds_device);% l( N5 s* x0 ^1 U4 L
        if (ret)
6 @8 C0 P# N- j$ a                pr_warning("Could not register som GPIO expander LEDS");
& A- f9 d# F0 W9 H+ ^/ n! X        else* j4 W$ B# r. [/ v
                printk(KERN_INFO "LED register sucessful!\n");
4 |. p  X( l$ U) T
# e+ M1 o1 B3 w: O$ T& L        return ret;5 Z/ W( X2 c8 d  G* I5 x0 Z$ J
}( X3 u2 N5 V/ l6 F: T* |

$ V  T. G0 M1 N( {9 G7 qstatic void __exit led_platform_exit(void)
1 I( Y" F9 }' q5 X6 A! }$ n{  q6 l/ g# |* y6 W
        platform_device_unregister(&da850_evm_tl_leds_device);
1 s* i& n6 d* u8 m0 p4 j3 z
. ?; H1 f' S# @; P( P, M" c" Q        printk(KERN_INFO "LED unregister!\n");9 A7 p4 [  c- e8 J# n* M: i. W) Z
}
) _$ e& _+ x" O7 o- y- {
. @+ W$ k/ A) k! J  @5 z& _module_init(led_platform_init);: e% M; n( H* p4 }6 _
module_exit(led_platform_exit);9 S: x" N" @6 s+ i2 D

) f) z6 V( G2 J" h9 {MODULE_DESCRIPTION("Led platform driver");1 D1 X6 v. w; B8 t6 U0 c8 q
MODULE_AUTHOR("Tronlong");
; R) s7 I% Z( P) sMODULE_LICENSE("GPL");* F1 V& y" f1 y$ v0 X

% h, T" D' S2 {, T7 B8 f
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-14 19:16 , Processed in 0.039600 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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