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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。8 l# d7 D6 W& i' J+ ^( t- I# |
#include <linux/init.h>
$ J& E& U* W7 ]# |#include <linux/module.h>
" @+ s+ q& S: V$ y. P#include <linux/kernel.h>. r1 [& p* o& J8 y( [
#include <linux/types.h>
0 l" @4 |. A/ s( K: e) _& M5 N1 r#include <linux/gpio.h>
# h, ?9 z( e: q! s3 O) y#include <linux/leds.h>5 l) x* F* L. [
#include <linux/platform_device.h>4 I1 }  Z2 i" ]# f; L. L5 X0 H  a

: O- h8 @9 v9 t/ l$ T#include <asm/mach-types.h>  ~# D1 D$ T2 v1 V3 H' W
#include <asm/mach/arch.h>  v0 k/ f" C% S6 t* g5 `
#include <mach/da8xx.h>( a0 {: h: |( D- I5 R; z
#include <mach/mux.h>5 _1 P& h! R% N2 S9 o5 W  M( S

+ X% u% j6 Z  f4 W# J  r* b#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
6 F7 M$ }- j" ]#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)5 H" B3 ^$ {8 R; k  N, \7 e
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
1 t2 f3 a" j+ v( E7 s0 m- y#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)% b2 y3 l  M" @; h$ i8 d/ F2 u* c

* n; |4 ]' a; d; g* `! r/* assign the tl som board LED-GPIOs*/
* C$ @5 v: i- O( Cstatic const short da850_evm_tl_user_led_pins[] = {
' D8 N( x' H. b" h$ e        /* These pins are definition at <mach/mux.h> file */* X4 Q% t# X4 N, a. T
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 b/ T8 F; O+ y$ V7 t        -1( ^( s# s' d2 _
};2 Y3 P2 \6 m9 N! t
6 ?# o0 y, g8 g. _: @, d, s
static struct gpio_led da850_evm_tl_leds[] = {/ V* L# K5 ^( N! k; T8 N0 s
        {
5 l) X) \" {) c/ ~  q) ^                .active_low = 0,
) h$ H+ c( F* |5 {+ |  i  B                .gpio = DA850_USER_LED0,
4 g9 }# Z+ g5 y: r                .name = "user_led0",. c' V9 y# B5 E- S/ ^& x
                .default_trigger = "default-on",
' R" r. f) D/ s+ w3 b. M% \2 ^        },
9 b$ v& o+ e6 v7 ]        {2 |9 t5 Z( q$ d; F
                .active_low = 0,
! `8 @; i7 C+ D& N  M9 m. p: d$ s/ _                .gpio = DA850_USER_LED1,5 B% k" `; M2 x6 \( c" d) t: U; F0 V
                .name = "user_led1",6 j' d! N8 h  P; l  x
                .default_trigger = "default-on",- h5 n; W  N. h/ k8 w4 T  t: W
        },; f, p0 \9 B; k! g, N- i
        {1 i6 Z* K: A5 ?$ c, s+ C; f% S: H
                .active_low = 0,
" Q2 ^* p: M1 M% F5 W8 Y$ o, o                .gpio = DA850_USER_LED2,
0 o  _% ^+ {8 ~, C$ }* B                .name = "user_led2",, |) W. i+ l: Q  Z: i  @
                .default_trigger = "default-on",
1 t& j4 i6 M8 N        },+ x8 [6 o5 O, B+ |' ~4 ?% v( g
        {
3 ]6 w7 E  f* w) D                .active_low = 0,) I, r1 D) d4 k) }2 k+ Y7 D
                .gpio = DA850_USER_LED3,
7 l' C5 w- \9 B$ |0 {/ W* s                .name = "user_led3",  @! ?% r( ?4 N5 W7 j
                .default_trigger = "default-on",/ w% M1 S5 C7 z; k, m& c$ G
        },4 r0 ]9 H  |  T& Y/ j% X/ T9 ]
};" a  s- t. j4 @
7 _, g; W: Z$ ]4 }" h' P4 Q9 y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
  N: k. V/ y7 {) V" s        .leds = da850_evm_tl_leds,
- N0 Z) ~: A3 {+ K0 H5 R6 A        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 {* y/ j3 S) b2 R+ K: Q" U};
: H9 Y' T* ?& U+ t( B% m" h1 H- v" _. u, R
static void led_dev_release(struct device *dev)
- v5 a! X  k; M1 g2 m4 _7 a( L{( G& _/ w- O1 _0 j6 H: H
};0 @; u( n* ?# h2 g: _# t  q, R& }

! c( K5 R6 S& T- v' }static struct platform_device da850_evm_tl_leds_device = {: K! n" U& K9 o- s5 m! ^) u" [
        .name                = "leds-gpio",
. V% [2 _" J8 m$ n; o6 v4 u        .id                = 1,7 J+ R) ?7 i4 U0 c
        .dev = {
5 U6 G- i9 F1 m: L+ l4 R. O                .platform_data = &da850_evm_tl_leds_pdata,
# _2 W8 }# M! N                .release = led_dev_release,
# e3 q/ K1 `( T. c        }
; v5 T! ~8 Q1 t+ Z};. X9 S: n% y+ ~& q* [5 Y4 \/ W

& u* r( K0 S2 ]' gstatic int __init led_platform_init(void)4 |! E: x* n& G/ n: v! l
{/ L; J- F$ b; R( l7 V, m
        int ret;
4 N* G% n6 E. d1 m& |. S" v#if 07 F7 d( L& |8 @* t) v- o. k7 I
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 ?3 q- H4 ^# M" W! {        if (ret)
; K2 I" t6 J% c" {8 E                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* z. d, k( s- y" w3 O
                                "%d\n", ret);
/ B, c6 m: @5 t8 N9 }1 e#endif
9 }8 O  L5 z+ ]+ l2 b! G; w        ret = platform_device_register(&da850_evm_tl_leds_device);' }# B2 C/ T8 ^. I' |! D, W- J
        if (ret)" v+ D) S& Z* C9 b5 H, \  ~  C* k6 o
                pr_warning("Could not register som GPIO expander LEDS");( F$ Z- s2 S$ w* ]
        else
' D/ ?4 \9 e; A* k                printk(KERN_INFO "LED register sucessful!\n");
1 \3 b7 h8 b) |, }1 ^& `& e5 e$ x) u  C" ?
        return ret;0 j) Y* L# s  l# ^' W5 n/ G0 i3 _
}8 u8 S* `8 E! `# ^, u

" [3 j& ], h: b( h0 G! X' a, y2 Cstatic void __exit led_platform_exit(void)
: z: Z. z! x' a% _{& `; c; J$ y: ^( H* ?8 T
        platform_device_unregister(&da850_evm_tl_leds_device);& r6 ^9 J* H$ K8 l
3 N0 ~: l2 |3 K- ^1 M* V$ t! `
        printk(KERN_INFO "LED unregister!\n");( I( S# B6 x$ t' _& J
}
3 ]" Y  m3 n, ?" k. ~1 f
+ C- y; D* [5 i$ \2 i& s; imodule_init(led_platform_init);* _/ b5 J7 V2 B4 B; p$ P
module_exit(led_platform_exit);
' H4 h" H) P+ D4 T+ }% P
: b+ i( X5 C# ?! i. `6 DMODULE_DESCRIPTION("Led platform driver");
( W) f. `5 A+ V( _MODULE_AUTHOR("Tronlong");3 U/ \% P2 Y2 \' i) D, i& _, W5 }
MODULE_LICENSE("GPL");) {$ \( ?7 F7 E8 Y' L

$ Q+ B8 ~; k3 {5 f: [
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-15 23:38 , Processed in 0.037997 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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