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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。, q& w: x! K% ~; _
#include <linux/init.h>( e3 F- d  N1 m3 g) v0 c: v1 P
#include <linux/module.h>
2 O% A$ s2 V9 u. l#include <linux/kernel.h>
, T; i* R8 ^/ m2 V" {, }& i  a1 c#include <linux/types.h>
# N6 v; @6 g2 ^9 b#include <linux/gpio.h>
% l) }7 G% p6 @+ u% f' y& |* c#include <linux/leds.h>; _# w( V$ \' }7 v9 ]
#include <linux/platform_device.h>
! ?6 F, `8 b" T$ R
' \+ r* [- |3 v8 c/ K! C#include <asm/mach-types.h>  ^$ z* U* b9 j
#include <asm/mach/arch.h>! l! D7 ~6 x2 e& {* p
#include <mach/da8xx.h>  o8 p# p/ K! [) p# H3 n
#include <mach/mux.h>
* P7 {# M! I8 v; l% C  x! ^4 n- K  I, \% Y- h5 x
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)5 i7 H+ |# q! j/ w/ c! c
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
: @: P' i  z# }5 S3 o, _5 m#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
' a! z4 d) _5 v' W5 K3 K9 R#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)- z' Z. k! J9 C5 q2 C9 B
1 G) n1 k' g8 u, a9 s
/* assign the tl som board LED-GPIOs*/* w" y8 B0 l; Q! f
static const short da850_evm_tl_user_led_pins[] = {
, }1 h# s" O- I7 P0 o        /* These pins are definition at <mach/mux.h> file */
! T6 }7 V$ C6 D2 n        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* M9 p1 h3 V( U$ ~- j1 O) l        -1
. J  r6 ]- I& b8 |};
: p# t& G( Z* `- L/ v2 c$ ?
0 k, \' b' C% h, U2 @static struct gpio_led da850_evm_tl_leds[] = {4 z! E1 w: z8 s8 B4 i
        {
: o2 H& h5 \! u5 _7 \3 t  @+ g                .active_low = 0,
1 t3 R& K+ F) k- _$ p                .gpio = DA850_USER_LED0,% W9 E# c; v" V1 Q; `2 B- X2 s1 [
                .name = "user_led0",
" h* g- e$ l; o6 v- i* {0 m* x                .default_trigger = "default-on",
" T" J. o( J$ t. I* C+ B        },
* q/ v( I* H* i$ B        {* T9 M$ L$ _8 b0 N: g5 V& [
                .active_low = 0,6 V. A1 H+ @0 W, W; ?) f
                .gpio = DA850_USER_LED1,
& \6 @* x6 \, X- S! P- d4 ?& x* J                .name = "user_led1",8 w/ `: L. t* O# ^$ t; L2 V  }
                .default_trigger = "default-on",
' |2 z4 }0 c7 s( O; j        },  G* w  |& B3 l! s9 I
        {
' h( Y( B5 m- C9 G4 S( b                .active_low = 0,
, l6 U9 x4 h2 S8 K! W, ^                .gpio = DA850_USER_LED2,
& M. k% `" K9 W1 d1 \                .name = "user_led2",
4 D, T. M7 _1 Y7 _                .default_trigger = "default-on",( c! {% @" E' g. b/ y
        },% G% H( ?: q: @  L) ^( M
        {& W7 t, v' T4 f0 |/ x4 W1 D2 ?
                .active_low = 0,
9 s" k! E0 u1 T4 n                .gpio = DA850_USER_LED3,
- x- B) m5 h# P                .name = "user_led3",
' `( g( p! P9 r7 I1 A( q7 s/ Q, N7 T                .default_trigger = "default-on",( E% P1 w# F) f3 }
        },2 J7 y9 [8 q' d: v: p( j
};2 l# v8 d& R1 h; M1 T
: O4 g: i3 O" Q' ?7 j! N/ @5 j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! [3 ]* I" F! r: b% y" a5 F
        .leds = da850_evm_tl_leds,1 g5 b9 a7 O1 ^  B* W; ]+ e$ l
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 |6 ]* d2 J- N$ }
};
( x. \5 u4 Z/ ~. H3 M& c8 ?
  Q- M9 M3 o2 H* R% x1 [$ g7 fstatic void led_dev_release(struct device *dev); M! P& `, W0 E: k3 I* p! P' F
{4 i6 N- \; [; m) ^1 p  w1 L
};
" k8 h: h/ T0 L4 K, {" u2 _/ D6 x5 R0 v
static struct platform_device da850_evm_tl_leds_device = {; [3 j, w0 W/ S+ b) K+ I
        .name                = "leds-gpio"," @  h+ j$ E  F+ W
        .id                = 1,8 K- w# Y0 }+ e2 @
        .dev = {0 n/ _$ H3 _/ ^/ F
                .platform_data = &da850_evm_tl_leds_pdata,
; N7 @. f/ Q: f# M: }2 A                .release = led_dev_release,3 e0 w2 W- d' D$ I0 j7 n. r) V
        }
& Y9 u2 w* R6 ~2 R4 w/ \' a};
# i8 z5 N: O- k$ Q  z6 ?% E- l! C. y3 \5 f5 J) K
static int __init led_platform_init(void)
* r5 O  y" W6 t4 g) s! r{1 O- {- L4 F7 f+ N! q1 \* z
        int ret;5 p+ _) k8 c% ~/ E: s; ]' o
#if 0
/ d8 `1 E& f5 Q7 j; c        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ d; A! h& n* V$ {8 S5 x% i
        if (ret)
/ O, J) Y" l# U' @                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 F# O; U8 E0 {/ n8 _                                "%d\n", ret);
+ m# R. B# L, h  E7 b3 \; F- X#endif
" M2 T# ]8 k! r) D1 r, S        ret = platform_device_register(&da850_evm_tl_leds_device);  @5 V/ c5 Q% U* O2 f
        if (ret)
6 g" X3 Z6 |% R* y7 {: M                pr_warning("Could not register som GPIO expander LEDS");
/ S% M* u+ _% b- G5 @3 T! }        else
$ c8 z. v* p+ w" }' M                printk(KERN_INFO "LED register sucessful!\n");
5 f% s. j# s1 Y. ~2 ]
1 F8 u) J, M) Q0 o        return ret;1 k* f' K5 c2 Y( z
}% X0 I/ {# |" G( m3 E) p
+ N2 i- x9 U4 f/ @) b1 P
static void __exit led_platform_exit(void)  U: J3 L  ]1 V2 @- @
{
5 R- I4 @6 J! d7 Y% J0 c1 o# \        platform_device_unregister(&da850_evm_tl_leds_device);
$ K, S) i! G. {$ c
* m1 \6 ^2 A( A! O+ b; c        printk(KERN_INFO "LED unregister!\n");
/ N  ~# x* a" A+ S* S" y}
; R9 g9 Z$ h0 \3 o' U7 Z/ S4 ~; p# T$ D) H9 l5 d4 m, S
module_init(led_platform_init);
: @4 u- ]* j: X0 p0 i7 C6 }module_exit(led_platform_exit);
  _0 j9 g6 p  D  k% S1 V: j( U6 a% I" D  {, C: K- [  G7 z6 ~) M
MODULE_DESCRIPTION("Led platform driver");5 F* J+ G3 j; M2 Z
MODULE_AUTHOR("Tronlong");; ^# f& o7 x# n
MODULE_LICENSE("GPL");  g6 A3 h! H- O" A8 d

: w7 V: C5 j5 w0 f! n0 K
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-24 17:52 , Processed in 0.037475 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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