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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。$ m3 Q4 I' r- f; j
#include <linux/init.h>
7 D+ i7 c  a& r! R7 x5 B* M- `* J. X#include <linux/module.h>
* q$ d8 ]( C+ ^) Q2 F6 Y( K% F6 F#include <linux/kernel.h>) ]; y! r& |5 [0 r1 |6 @$ `7 y( ~5 j
#include <linux/types.h>& H  e2 i" Y% {, ]4 E2 ]
#include <linux/gpio.h>
! V3 i6 Q3 x9 W. F9 x#include <linux/leds.h>* K" J/ C4 t8 ^/ j
#include <linux/platform_device.h>
, }$ U  u3 [% W# F* K$ |1 q
" Z# y# |7 E( P- S#include <asm/mach-types.h>
) w  k5 i* f' s& a# t; k#include <asm/mach/arch.h>
% x9 {3 ]6 s, m# t7 d% d#include <mach/da8xx.h>% b& a5 {) m- L+ ]
#include <mach/mux.h>
$ @/ F, n" o3 `/ K7 R
" Z8 V& Z* _6 n/ @/ h#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)$ |) L( G/ F# m  Q3 p, K0 Q
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
( e7 l  j6 j( x7 J) B* a#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)4 Z$ j  w7 D! r) |- h
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
; X2 ^" Y; J! a1 Z
- G' I# X4 T4 l4 j/* assign the tl som board LED-GPIOs*/
7 ~8 r. q5 I0 m# d& i5 Mstatic const short da850_evm_tl_user_led_pins[] = {
: [" R8 d  r! W* m        /* These pins are definition at <mach/mux.h> file */
* B0 i# T+ t2 }0 P% b        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ N1 ^8 L+ u8 q% Z
        -19 m8 _4 O4 B& F* J) T' |3 v+ |
};+ w$ p5 m0 Q4 e6 _! x
7 C: S3 N! i$ ^+ P7 X- F
static struct gpio_led da850_evm_tl_leds[] = {
" ]7 g! h/ T: R, B; H( `3 V        {
2 |# [- b3 M! e                .active_low = 0,
! s; Q" T  e0 i" I- U1 D                .gpio = DA850_USER_LED0,$ t5 r: S, N9 B  n; Y" X; V5 J
                .name = "user_led0",0 @6 h% W* P" }4 F$ V, s
                .default_trigger = "default-on",
$ j+ s  U1 \$ T& ]        },
- |# J3 U# i/ u( W! y; P7 H        {/ y# ]# O9 G- d, e0 k
                .active_low = 0,* X- L6 H0 P. v# J* I
                .gpio = DA850_USER_LED1,, X5 o- ^" Y) Z
                .name = "user_led1",
1 t2 Q+ ]# P& Z9 [; U9 B                .default_trigger = "default-on",. g0 @- x; ]4 s  `' F1 |8 `; o- P
        },
1 p% {+ p% }# f/ x3 [) g        {8 ~/ k& _# E& Y* C7 |. s$ [: P
                .active_low = 0,/ j0 U& h8 S' i0 v$ z# O% f
                .gpio = DA850_USER_LED2,  |* b" W; \- b0 t5 @
                .name = "user_led2",
: d. |! k4 f; T# N+ [8 U                .default_trigger = "default-on",
3 _( A4 Y+ |2 A5 o3 D: T% Y        },) [, L% V2 x* F, J7 X9 b! l
        {
5 q2 G8 J6 a1 s# |                .active_low = 0," d2 t; J. I: p" l
                .gpio = DA850_USER_LED3,
/ H" u' {2 V6 h( q) Z, M, H                .name = "user_led3",( W5 g  `" r" E+ {0 X
                .default_trigger = "default-on",& y' q9 G3 |% ]
        },, a8 h3 @6 R6 m, X
};) H: R* Z$ U& g; T

: w, A- v5 @+ s9 ~" y( Xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ k+ T: l; g1 ~9 V. N
        .leds = da850_evm_tl_leds,
8 X9 q1 h7 C6 F, L        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( [$ t; H! D% ]6 \};
7 C' f# h' [7 m. U2 K
7 U% {; N4 o0 d8 i% Y& istatic void led_dev_release(struct device *dev)4 V) q6 T& d, x
{1 R& ?+ m! I) ]0 d
};; r/ x: v: K0 X& i9 B( P+ c" o

4 _2 b; E5 b- P+ Estatic struct platform_device da850_evm_tl_leds_device = {
" p) Q8 I' o- @( o        .name                = "leds-gpio",
, r  x+ ^2 D0 @& ]: V" Q0 C, t& e" T        .id                = 1,
4 k' w* ?4 o5 l' @; o" V# [        .dev = {# L( A+ |* C0 V: f
                .platform_data = &da850_evm_tl_leds_pdata,4 G4 f8 Z- U% x" \" H
                .release = led_dev_release,
  r4 ^; O: V  r9 O% o        }6 W5 {( n4 {; _; M
};
5 t  C3 @- ~- b8 V+ B$ X2 G5 t( I. t
static int __init led_platform_init(void)% S5 w+ T) X2 V6 |8 u- P& L# m1 m9 j
{& y- I& E) n0 a( ?4 @6 G' @8 E
        int ret;
# M# Q( V4 t2 o4 `0 M#if 0
- [' ?& V4 l! Y& y5 t        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 b" S- V! H* ~        if (ret)* d% x9 T2 `% e
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 f1 _" C; d' @                                "%d\n", ret);. \4 A2 r  y6 ~7 F2 F. t
#endif4 d) b- }: g& s# H0 z
        ret = platform_device_register(&da850_evm_tl_leds_device);
, I, T, U1 C$ ]  h5 U' x) }        if (ret)
, Z% y, C5 z0 b8 U- V& _) ?                pr_warning("Could not register som GPIO expander LEDS");5 O& N4 `+ V( N' a0 L1 _
        else
" M4 r6 e# N+ F( I3 c& d+ e' V% u                printk(KERN_INFO "LED register sucessful!\n");
6 \0 }1 v; Z$ Z0 O9 m+ C7 U' a
. g+ l, A4 z1 ^        return ret;
8 D- V$ C) \, N* n, }}
6 `* W/ z6 s: ]- P! p9 [* g2 c& L5 a$ m/ i+ i8 B" j6 B
static void __exit led_platform_exit(void)
1 g2 p, E; [: M{
+ C& \, O# W: E9 e        platform_device_unregister(&da850_evm_tl_leds_device);
% h- w& u1 Y, J! L( F3 n3 @; |* n' Q1 d) ~7 y1 d, {1 k' t1 \3 }9 ]6 a9 \
        printk(KERN_INFO "LED unregister!\n");/ v" b/ N2 L* i* F2 g" ]
}
) ]# U3 g2 w5 N! \  Y
4 I$ j# Y3 M! N! D/ y8 T% ?module_init(led_platform_init);
* D! z9 o$ Q3 ?4 B3 Wmodule_exit(led_platform_exit);
6 r1 J& y2 V) W6 y$ @- m3 ?( L  }4 M8 U# O
MODULE_DESCRIPTION("Led platform driver");1 L* O2 z( X2 j6 G4 j3 N
MODULE_AUTHOR("Tronlong");1 c/ k3 Y- ^1 O5 ~
MODULE_LICENSE("GPL");
) l. N# M1 T# v3 w1 g4 T. L
+ ?0 Z$ _  ~3 z1 X
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-6 17:48 , Processed in 0.038640 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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