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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。9 f# O  G+ G) O6 v+ |4 H* q
#include <linux/init.h>
1 k; E- H" c* I( i) K9 C; p8 F3 B, m#include <linux/module.h>9 e6 Z6 B1 O1 P0 P8 N. n3 s
#include <linux/kernel.h>7 u  h% t' O+ D3 S6 x6 \9 Q
#include <linux/types.h>( I6 G3 n4 H+ c; E" J, Q% ~
#include <linux/gpio.h># u! }: `& H% l3 e' `0 ]. P# y- w: W
#include <linux/leds.h>
4 w  G! ^0 Y/ [7 L' @2 g#include <linux/platform_device.h>4 ^) h; Y' l& L; o0 q, D! v

+ F# R( P* b/ l5 V: l1 p#include <asm/mach-types.h>
# S. U% l( r( N2 i#include <asm/mach/arch.h>6 g/ L  T6 f9 |& q/ v  {8 v$ t
#include <mach/da8xx.h>
5 t9 V  q% ~$ F" ]$ p- o* t5 _: }#include <mach/mux.h>) Y2 n2 H- j7 J3 G7 _$ V. r
- u' a/ Y0 @- A  M# o
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
9 L$ \8 B; O! `#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
7 k( _7 v/ s+ N#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
" b* ?9 D. U7 _+ Y4 L, p; d/ d#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)2 @' M6 b" M) W5 A3 ]+ j( h

  Y. Z2 B, ^5 d9 v/* assign the tl som board LED-GPIOs*/# N6 x! ^0 h& [$ P8 C
static const short da850_evm_tl_user_led_pins[] = {+ e. q0 b* v7 v" v
        /* These pins are definition at <mach/mux.h> file */
3 u/ q5 W& `& N% Y; t        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# R; T+ d4 Q, ^8 S% P, R8 w( y+ e7 g        -1( Z$ b5 J& z& O5 u- z
};5 Z1 D+ @8 _9 E* B/ |

. h" ?3 b/ `2 w7 U$ F0 E) Cstatic struct gpio_led da850_evm_tl_leds[] = {
; w9 N9 z+ L3 X$ o3 p7 ~        {% h: @& H+ `! J- h7 E0 d( m  Y
                .active_low = 0,' g' v% y7 J; F& a
                .gpio = DA850_USER_LED0,
% E; F& `) c3 H                .name = "user_led0",
1 y1 m% W& n2 S                .default_trigger = "default-on",! }2 |8 |) y9 A4 I) E
        },
; U/ h2 b8 |0 [0 E# Y        {( w) O/ s( V" n% z2 X$ e; T
                .active_low = 0,
5 K' [" y; Z* v6 f+ W                .gpio = DA850_USER_LED1,
) {# E, d" J2 Y8 J                .name = "user_led1",
2 A8 t& L$ C- j$ P                .default_trigger = "default-on",  K5 f# S) ]/ X) M8 k* P# ]
        },6 h6 j  q4 B9 Z. S) p7 y
        {
3 `( v8 E/ r2 F6 N; u' q- m4 D                .active_low = 0,1 g' C+ x/ ^+ M7 V
                .gpio = DA850_USER_LED2,1 Y% @, i' s) ?( ^& W/ ~
                .name = "user_led2",
6 h; ^3 L  Q2 A5 n* @& k0 [; v: v                .default_trigger = "default-on",
7 V  G  G  L/ o        },+ \* v3 K9 Z' z- H; W9 P( F
        {
0 K$ Z- z' o1 v! ^- D# y' A) E; ^                .active_low = 0,& c% C5 J8 |# ?0 ?  @- V' k
                .gpio = DA850_USER_LED3,
3 o- q/ |# ^' O% s                .name = "user_led3",0 P) i/ d7 A! f: v; \9 z
                .default_trigger = "default-on",
) S% [; G  p2 w& r) d, ?        },2 A/ g2 P9 T) r1 m
};
0 d' C* C9 n0 f
" `3 @  d2 t- R9 _+ d& `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ c; g1 ?- E& g
        .leds = da850_evm_tl_leds,0 D" Y- f5 v* i  }, x" S" C1 \
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 ^4 p" A9 @8 j, H+ b, Z( ?8 V; \
};2 X' r8 D# H3 ]& [( p2 ^" C

! c0 i2 ?% y% y2 r# [- y, T! gstatic void led_dev_release(struct device *dev)
3 t0 I' }# f! f: }" d{
7 |9 O& f: u& y; V( n};2 R' Y' ^- @' k1 z) L$ f

' e+ `) A4 L# pstatic struct platform_device da850_evm_tl_leds_device = {
& t8 k/ v  C9 _7 t/ @        .name                = "leds-gpio",
7 Z9 \" A0 g) k& {        .id                = 1,
9 K& p2 g7 d3 G3 J        .dev = {' m) [0 Z  y1 s- o
                .platform_data = &da850_evm_tl_leds_pdata,  O' ?; [1 m& K6 @2 J
                .release = led_dev_release,
4 ^! q8 y, S, T0 ~        }3 E/ D1 n5 y2 V, P0 _& m$ a
};. p9 B' V  V6 S. S9 i- s

2 X" C$ w2 u# M/ t9 mstatic int __init led_platform_init(void)% \+ w! I$ E/ q% v: k' t& c
{
2 F' |$ q; B: J3 [$ k- t        int ret;! A; [% C: N( D0 ^/ @1 z% ^, I
#if 0
: [8 x" Z/ I( p2 ?( L        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ }( [0 _/ ?  l1 d3 ^$ M
        if (ret)7 H! N0 d: Y: Z6 c0 m, J1 k& g/ @
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" g$ i+ V6 J" C' o: o$ t0 d8 x                                "%d\n", ret);4 ^1 |' J; `, k+ S& A4 J
#endif
5 a' ?* O7 V: M  b+ r        ret = platform_device_register(&da850_evm_tl_leds_device);
- `- Y0 U4 I& n! G) C+ \        if (ret)$ y, G! a( |' y" _0 B7 k
                pr_warning("Could not register som GPIO expander LEDS");% |7 B% q% f+ S
        else9 E' j9 `; |9 X/ Z( Z1 r4 J9 D
                printk(KERN_INFO "LED register sucessful!\n");. A: a4 B( w0 b3 r# `. g2 x6 \

. \2 U, ~8 _- K" f! y1 F+ D' V7 F4 C        return ret;
; D* a$ o0 x% `4 I% m}
  Q, n) y$ t% D6 _
; f0 y+ w8 w& g9 f. Bstatic void __exit led_platform_exit(void)
" [: |- w. H" L3 u' Z+ U& G{
6 p+ I& w( ^  a9 I7 O. ^        platform_device_unregister(&da850_evm_tl_leds_device);
% N2 Z$ S& a8 e8 v  x: B
+ B0 Y; R+ {: T# }' s        printk(KERN_INFO "LED unregister!\n");! C" ^( {9 A! f1 J0 p, b; Z$ {9 p
}
/ D; B& s) l- ~  g' o) U: j) }/ ~( r2 F, ^4 v
module_init(led_platform_init);
7 Y6 A! O5 B4 X! B) y- Q, |8 smodule_exit(led_platform_exit);5 ]3 e, Q, B! B( H) y% r! l

( s3 x, N) o; ^! E. IMODULE_DESCRIPTION("Led platform driver");
5 P7 D7 v5 Q+ PMODULE_AUTHOR("Tronlong");
' s5 z8 V8 P. gMODULE_LICENSE("GPL");
3 c7 [, T6 S1 C" F/ {6 g* [
( i) ^, F) P1 h# l4 ]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-26 11:13 , Processed in 0.037189 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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