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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
" R% t" g. _$ I. H" d% ^8 I#include <linux/init.h>; t( l; W1 G* p% K- E
#include <linux/module.h>4 ~' K" v" l  a& k0 K
#include <linux/kernel.h>
# M. y% i3 r) E" o( V#include <linux/types.h>
, n, t' O/ X+ |8 x! i#include <linux/gpio.h>2 N( A4 ^& Q2 e- R* m; a
#include <linux/leds.h>
2 |* Q3 X. b4 J) F" u/ |$ [+ S* h#include <linux/platform_device.h>
  s# R- S5 P! }* E& s2 X3 f. z
& @1 N7 p; k" A' f#include <asm/mach-types.h>3 h# w4 U* P* Q4 Y- n! U
#include <asm/mach/arch.h>1 I4 Z2 a& O' c4 @
#include <mach/da8xx.h>7 P7 f7 k6 S7 k( _, M2 J0 r
#include <mach/mux.h>& _/ m) L! V& ^$ W$ h
6 ~! D5 M$ D0 w# \
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
. w7 R& o. A  j/ Z2 j#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
3 ^5 f$ e+ J: ?* ]3 K8 C#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)+ B: m- P' Z# i2 L* @
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)" V7 G& o$ P3 L+ O# t) ^) ~( k' [

/ U( N( L! j" U  F( ?9 N/* assign the tl som board LED-GPIOs*/3 W- W& @8 n2 i) N
static const short da850_evm_tl_user_led_pins[] = {
" i7 K( a, ?8 h- p& @4 f$ g& _        /* These pins are definition at <mach/mux.h> file */
, i; U6 {  H& F# A        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 r2 Y1 ^, ~4 U; @, ~% J        -15 J: r& O/ `  r, p; B; X
};' H& k. x* E  _; V

, `5 R& p8 p3 I4 k" f& Ystatic struct gpio_led da850_evm_tl_leds[] = {# z! T5 s  p- B7 j$ n  v% C
        {7 D% ]- D8 A/ c4 b6 V  x
                .active_low = 0,
* [% [$ o! u/ F! L3 ^                .gpio = DA850_USER_LED0,
5 a2 u$ i9 I3 I, H/ f. I% e! m. N2 V5 D                .name = "user_led0",% V5 `" C; i3 c$ w
                .default_trigger = "default-on",
, Q+ T/ d) \  n* m1 B        },
. ]/ ^$ J# ~. H; w; q9 X        {$ T; c# q5 y- A" w  D8 F4 e; a) X
                .active_low = 0,
0 d6 h8 F6 N9 a                .gpio = DA850_USER_LED1,
- v+ r% @- G1 m3 r8 }/ J5 A0 G                .name = "user_led1",# U  h' |7 I) t
                .default_trigger = "default-on",
7 @) \! G$ b. b  x: A        },
- O6 `# J, ~' G: ^        {& {, k& K( G. ~# j1 i5 r6 \
                .active_low = 0,
, x: }5 I; y- B/ x                .gpio = DA850_USER_LED2,* f7 Q0 f- M0 _6 |$ w
                .name = "user_led2",/ U* H: U# C8 {8 k; e% m
                .default_trigger = "default-on",- C% [, g' V6 n
        },
; g2 P+ z2 {/ W1 N! c        {
4 x) p6 y; e8 u                .active_low = 0,( x3 V) w8 p' J0 c
                .gpio = DA850_USER_LED3,
& R: d7 i3 D/ h6 L' P                .name = "user_led3",
* f% T( U" R( ~                .default_trigger = "default-on",
4 b5 x+ e! G% N! E& `        },- E/ u: W  y5 \& s
};
% V6 W2 N; U8 r7 ^, r  \
! f. z5 q! `. W+ {: w8 bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 T; B, w$ J; P* C, J$ m
        .leds = da850_evm_tl_leds,
# ]; {( B( g, Y, h% g( v8 T* I        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ R) K9 j. T; q( `; T* m};
. T4 W  v4 c% q0 c3 A3 A' J4 U, i8 \0 h* t) y. J* Y2 S$ W5 _5 }9 V; f1 P
static void led_dev_release(struct device *dev)
! _3 E: u0 K6 X- M* f{. }6 B/ ^1 a$ k( L7 ~" _
};
; N5 n  r1 x- x: K
" Q, Q- H8 U6 Y( [# |. v) fstatic struct platform_device da850_evm_tl_leds_device = {
1 ]$ K& B3 k1 R3 }# k5 h# K        .name                = "leds-gpio",( t1 D+ d( l4 [1 R1 |- a
        .id                = 1,
' [& s% s" |* t        .dev = {3 E2 j7 r6 v% R$ }
                .platform_data = &da850_evm_tl_leds_pdata,8 b& ?! q6 \. |, s- d3 z
                .release = led_dev_release,
+ [* x+ |+ U9 h$ e4 G+ N( n        }
2 x1 x. N% r) n: @$ r};/ e& a/ t! c# W
8 ]3 x' _- `8 O* {  s1 z
static int __init led_platform_init(void)
% P# ^1 C/ _' T! N: G{
- w0 k+ f) _, d# g" n$ f        int ret;
, [- X. S3 h# h/ l#if 0; M4 t, A' M9 e% y
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 c2 E) G  T7 x* c2 K        if (ret)
2 ~9 E  @6 G4 [1 s5 b6 c: m                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 K% \: x4 I2 |6 Q# ~' g
                                "%d\n", ret);
; _8 e2 y" W% U$ y9 z( L- h' L) i#endif0 x5 b9 d! u( w( n6 o+ }- Y8 W
        ret = platform_device_register(&da850_evm_tl_leds_device);& O& a7 d' G+ s+ |" c& x
        if (ret)+ G( V* h# {8 B9 I! T( m
                pr_warning("Could not register som GPIO expander LEDS");, P8 K3 Q8 L' U' c7 P9 X
        else
8 u; U. [0 F% r/ c: x4 |                printk(KERN_INFO "LED register sucessful!\n");
" _. h5 j$ j$ l& X0 {- Z* Y1 z1 Z7 c% C
        return ret;
' k% Y! I% G; y5 F, Z9 H) {& s* H}. `. l5 X, Z: K3 N# t4 V" h% \. @

  c  L& X( w; B  k6 {& kstatic void __exit led_platform_exit(void)' ?: |% Y8 k) M  M7 O
{
& s$ v% |) Y# M$ P        platform_device_unregister(&da850_evm_tl_leds_device);
) F( u/ D8 _7 W* N7 z5 n( F& O) w( c& \) \/ |  Z
        printk(KERN_INFO "LED unregister!\n");  X3 z; H! V( F4 H
}' j* `/ z" j, b5 w% _7 Z7 S! g

" ]+ j& u# s8 a! ]! C! z7 n. I1 ]; Rmodule_init(led_platform_init);1 q+ N: i0 \& D8 f# v' L/ s1 k6 {" t
module_exit(led_platform_exit);+ H" W4 H" X+ D! Y- {9 t  J1 F
: W- m$ E, m0 {' o; ]) L! Z
MODULE_DESCRIPTION("Led platform driver");
: f: q4 T" C; a0 b7 sMODULE_AUTHOR("Tronlong");
; D& v& j5 l7 Z0 Z; d4 xMODULE_LICENSE("GPL");
* M2 ?1 g& X* s) n+ G8 i$ o3 n2 J; D1 X2 U) [1 F
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-8 16:53 , Processed in 0.039086 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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