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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
" y) ^8 m6 z5 Z5 x#include <linux/init.h>6 {5 A% a0 m. x
#include <linux/module.h>
6 @$ ~- X1 ~3 q' x) n/ i0 G' Q9 T#include <linux/kernel.h>
, B) v- g  ~) u' f#include <linux/types.h>
& [  S1 m# ]$ K" `0 e#include <linux/gpio.h># s: z% e& Y$ i. T3 n, @1 z. E
#include <linux/leds.h>
, D9 J9 T/ O4 |. T1 Z& N  L#include <linux/platform_device.h>
0 N: k( B! j+ N8 y- X4 J; Y: }9 ^/ e  @* R) ^1 ~2 {8 [
#include <asm/mach-types.h>
; d0 C; t% E8 E8 {0 A#include <asm/mach/arch.h>( ]2 V  L/ d/ d1 `3 A
#include <mach/da8xx.h>: L' R8 I% V. h2 W& L! g5 o. v
#include <mach/mux.h>& ^5 M% T$ L% d0 e

, U4 R) m; R; V3 h- T) u  I#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
) q- G' v+ T! V( D#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)! ^2 {1 M8 i2 k
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
. q9 a6 w2 Z1 Q1 x1 j" w#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)- U8 D% C; r1 Y% @3 f6 a) F

1 ~# r- R! S8 d: L' _4 a/* assign the tl som board LED-GPIOs*/( `) O1 l( y9 T9 A  k3 Z9 i
static const short da850_evm_tl_user_led_pins[] = {0 M9 H2 _' R6 S7 ?, b% [+ u$ Z& I1 R4 a
        /* These pins are definition at <mach/mux.h> file */
( Q5 o+ P/ I7 j, o6 U4 Z5 D        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 q; U0 F0 ^$ M* J1 M7 ]3 H        -1
2 k5 [7 ^9 K2 d3 u+ F};
3 w3 `8 m$ W: j
# S' e  R* C* z  ^4 Wstatic struct gpio_led da850_evm_tl_leds[] = {/ l) e' i1 a6 X+ Y
        {. I0 |+ l  f3 W# H: M, U' R/ L5 b3 ^
                .active_low = 0,( T0 y9 _7 @7 ?" P, j: n
                .gpio = DA850_USER_LED0,
! Y* Y5 e. t: ]. R) S                .name = "user_led0",
' c3 ?- {9 {+ {" Z                .default_trigger = "default-on",0 z; ]" X- V! y( ~
        },
- Q4 {7 ^8 l. h$ E' r! g. ?9 f        {
* m, U$ w3 `0 O; i                .active_low = 0,9 E* h" H/ ]6 H  c& t
                .gpio = DA850_USER_LED1,
+ e; h/ s& g5 V! D# U                .name = "user_led1",+ G, t' _' e% C! p2 e$ `! }$ o
                .default_trigger = "default-on",/ G$ l. x+ H. G6 X
        },
4 e5 u) O) |- p1 M        {
: v# ?2 F8 m8 l9 O" k$ T, j                .active_low = 0,
3 Y6 I4 G3 K# i                .gpio = DA850_USER_LED2,5 Q8 K8 ~9 r& `" m6 e6 p+ x6 R
                .name = "user_led2",3 a- b$ X. s3 K* U
                .default_trigger = "default-on",
, J* R9 x( ?& A6 \" L. _* R        },
4 U9 A, J+ g9 s! F        {
3 k" }+ m3 f5 }3 X                .active_low = 0,8 [9 ~5 [- B: [4 l9 I1 Q1 P+ X
                .gpio = DA850_USER_LED3,8 P. w- W0 ?0 h9 w: a  G. |
                .name = "user_led3",
- I, W6 m3 ~) n$ U                .default_trigger = "default-on",
! r7 \3 |1 T0 F5 x        },; y% H& [( X. ~: ~0 n7 }  r0 L
};
& \5 I7 V2 D# ^# j8 `  P7 J* `2 ~2 a& B, A, b; s  Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 F2 F" ^  _5 u: Y
        .leds = da850_evm_tl_leds,- c8 }. x; G' w2 J8 x0 k- U
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' K( D" U. m% U' v. o" A};% G$ \/ g: e4 n5 ~1 o: X  N( g% |* ]
( b' y& D' {# G4 G) W4 ^7 Y
static void led_dev_release(struct device *dev)
" x' U1 F" o2 P; s% i{
5 B, ]# i" \& M* E6 j3 @& _};
* [+ ]5 l: N3 N# B, D9 B5 E
# }  U$ ~3 W$ L/ x& f  `: `& Fstatic struct platform_device da850_evm_tl_leds_device = {
" s; M9 o' t# ~( p) s; `0 g5 i0 I$ F* i        .name                = "leds-gpio",
9 b1 g- [( `* ~4 [' y        .id                = 1,. i4 |; {0 Z9 u0 k/ q2 q
        .dev = {! @' Y6 O* W  M$ V' I- Q  u- T2 Z9 T4 K8 o
                .platform_data = &da850_evm_tl_leds_pdata,
$ {' A; Q7 U! Z! F! ^. I5 s                .release = led_dev_release,! ~7 P+ a8 E& F, J0 p$ M
        }
$ E$ \; c6 O, V8 M2 \};, V0 l/ g! H! o: n

9 P  m# I! \+ ], v% Qstatic int __init led_platform_init(void)8 e- U$ ~: F" H/ z) A' |
{
9 E# ]7 {. T" @  t' e( X5 F        int ret;; ?5 ?: m5 C% {- U& i  E( I) a
#if 0, H7 _8 e9 M1 g. Z! z+ c
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 Y2 N; l; _5 ?* _        if (ret)
. u* {7 I) b6 K* ?- A2 X                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 z8 |' ~& w7 I- a3 h                                "%d\n", ret);! M* A5 |6 k( j4 w6 R0 I
#endif" {9 k5 L/ y" C3 b. {* e
        ret = platform_device_register(&da850_evm_tl_leds_device);
% a; q$ L2 Q0 C# K# ^        if (ret)
0 R, {' J: s" i& E1 c# l$ {                pr_warning("Could not register som GPIO expander LEDS");
7 ~/ f1 N: H) @! `" D        else
4 y1 A2 M9 R. e  }, k4 K0 [" R& l- ^                printk(KERN_INFO "LED register sucessful!\n");" k& B0 h% y% m$ e

4 F. q8 a/ }) A8 w. g7 p        return ret;
) f, l& N4 r3 ^" I/ n' J/ K* K}
8 u$ {, I: w1 C- s* S6 w2 Z9 R+ l* N! c& W
static void __exit led_platform_exit(void)
1 \- E5 z9 m5 m/ M# }{, G' r( W  K! v# q' K
        platform_device_unregister(&da850_evm_tl_leds_device);
8 g2 p4 W* T5 J  v7 R" A
6 Y5 u$ i5 x  j; R. }5 @8 O$ c) B- J        printk(KERN_INFO "LED unregister!\n");+ y: z' g9 ~, [- T" n  h
}, c  w% h5 i  P, A1 e3 Q

3 y3 ~6 k. h$ Q# w% l# ^) l4 vmodule_init(led_platform_init);
8 m9 `! U' D: q3 g, ]! a. Emodule_exit(led_platform_exit);! T, j6 Z3 R3 L6 a. {9 l! X
3 B. t8 f+ h, N- l) F9 r
MODULE_DESCRIPTION("Led platform driver");
! I# g: a  j' R/ FMODULE_AUTHOR("Tronlong");
) w/ S0 G5 w5 r( u8 RMODULE_LICENSE("GPL");( ]  S: G( l) y+ o% b. `) o0 s
* O9 c# d. [4 q# M) k
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-23 12:20 , Processed in 0.040121 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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