程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站
点击跳转“创龙科技服务通”

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
: Q$ |, f. t9 r4 l. h#include <linux/init.h># s; C& c" ^9 z- e
#include <linux/module.h>' r& e5 q0 h$ i. X) R
#include <linux/kernel.h>; i0 D0 @) ~- k5 X  r, _6 X
#include <linux/types.h># s" g: p" O* S( \
#include <linux/gpio.h>
3 X/ Y4 Y3 R0 L4 N& ~#include <linux/leds.h>
3 Y. _6 P! p" h5 F  B& H! Y#include <linux/platform_device.h>) F  X1 e! b8 O! i* i/ p# F( f
3 w9 m( t( S1 B6 f
#include <asm/mach-types.h>* f; m$ q9 z; J; I6 [* D# @
#include <asm/mach/arch.h>. q! m. s# _+ m8 P+ o/ J$ R1 ^
#include <mach/da8xx.h>
. q9 V. m7 c) P- k$ H#include <mach/mux.h>. P* P( J4 m6 m: S9 b5 z; ^- U
( {+ i: M# }$ h3 l# X
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
  j* k2 t3 t. P. q8 k# O& B#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)# F9 K" M/ `3 [/ D4 \6 K1 b
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
. |& G- y! A/ U* G1 Z6 w& @9 \8 D$ ]#define DA850_USER_LED3        GPIO_TO_PIN(0, 2): ~4 W+ j- u& a

5 f# q  R( B0 V  \; P/* assign the tl som board LED-GPIOs*/
$ i! S* N9 ^$ T( x. \static const short da850_evm_tl_user_led_pins[] = {
! P- l' T. F* f        /* These pins are definition at <mach/mux.h> file */: Q' W+ Y9 L" p: `$ @3 k( F( v" A
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 R1 D/ c- P3 @, _        -1
$ d/ G% ?- k8 ]$ z" ?0 h# e: Q};
) D8 Z+ z2 V# S2 ~5 q3 Y1 X& W
+ |! p( b6 E% P  M0 h8 F: sstatic struct gpio_led da850_evm_tl_leds[] = {
* B2 X* l; J9 F) _5 w        {
) V6 v& |' V- p) @6 b                .active_low = 0,  |8 T2 y0 L# b- w, g
                .gpio = DA850_USER_LED0,  V/ ~, W" I' K
                .name = "user_led0",5 [2 u" M3 k$ R# `
                .default_trigger = "default-on",' o9 h5 s: M! D
        },
5 t4 K3 w% g% h: A        {& L6 x, a2 }. ^" a
                .active_low = 0,9 Q; Q. P8 B+ c4 @( _
                .gpio = DA850_USER_LED1,
1 F& Z& t$ A. W/ w) w' k                .name = "user_led1",2 \4 q. t+ Z5 Y$ ]6 |
                .default_trigger = "default-on",$ c" ^: @5 h6 j  |9 [3 p
        },
3 A% I' s2 O+ j. r        {/ w3 Z- Y6 ~# Y( g
                .active_low = 0,
& {% `  A$ K- r9 ~                .gpio = DA850_USER_LED2,5 _3 j& \8 @6 B1 A
                .name = "user_led2",2 @3 N" [' [  R- k9 S* I
                .default_trigger = "default-on",  h/ H" Y3 \$ B# z; Y
        },$ i) c: \) P2 w8 M: M* f6 L: y
        {
, D$ H' v) h# h& V( q9 h                .active_low = 0,
# F) s2 x- q3 Q+ }9 ~* A2 P                .gpio = DA850_USER_LED3,
" F$ _" q3 p" C/ A                .name = "user_led3",
; ~; D" @' T( Z9 f% k3 f4 E- X  q                .default_trigger = "default-on",. C. E8 P* x0 R* z; }3 c6 c+ u
        },
1 K! c/ b. e: `9 d};9 L- U% `/ ~0 S4 x) v

9 c. l1 a6 A$ O2 Q" j$ c* Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- Q! W3 W7 \7 u/ c3 N3 _        .leds = da850_evm_tl_leds,
% |( ^  h( ]8 M        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! v+ j" [" e) G1 }& l4 T
};
& W" t0 l& a6 H' C# ~# Z" G- |4 X& b# t
static void led_dev_release(struct device *dev)
$ I4 ~4 @3 Y1 t{
3 k& L7 w7 c7 _6 P  ^/ A};* k& z, |# s7 D  p  l+ q
% A3 g+ L$ I9 o/ l  F. x
static struct platform_device da850_evm_tl_leds_device = {
5 X8 |7 I6 i+ ^% C! P: Y# T0 o8 d        .name                = "leds-gpio",
* d$ d  s& k# ?, \        .id                = 1,
$ a5 y! C; D" a1 G5 [; w8 k) x5 g        .dev = {0 u5 z6 R* U/ }. v# f! P
                .platform_data = &da850_evm_tl_leds_pdata,1 ~+ Z* o& {7 s6 L5 d! j
                .release = led_dev_release,8 F9 z6 i$ g$ m4 I
        }
2 j& N+ o# V5 t5 a3 _3 q};
- Q4 U( U* z' l+ S' H9 p6 m# E. L5 m; P6 A4 L$ w
static int __init led_platform_init(void)
  H0 I/ i  X, C6 `4 F" u$ l{5 h* e- t! ?! t9 l1 X- k
        int ret;7 E; I. z7 U# o2 o1 X
#if 0
$ w# V8 U: z, }) b        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) H% Q& J& W" K" d5 m3 ?. S
        if (ret)2 P/ l& k5 ?6 F' T. |  D
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"  [0 S( I( ?+ r& J  M9 G# y
                                "%d\n", ret);% p! T& r9 t7 b1 ?7 C; e0 V
#endif: i$ P$ _4 y2 E! k7 u$ N
        ret = platform_device_register(&da850_evm_tl_leds_device);* ^% W+ [% A2 b: b- J. W. }
        if (ret)) L0 l- d3 Z& m& H/ _/ e5 Z& c8 {
                pr_warning("Could not register som GPIO expander LEDS");! I+ K1 \& I) i- b0 \  Q
        else. `% _( x! b% N) A. R/ o
                printk(KERN_INFO "LED register sucessful!\n");* y9 A- R- f! p2 F
6 c" O0 g0 s& k$ c+ P
        return ret;
: n" d; g5 V# L7 x8 X}% A! F) D2 W# Y" E

3 F2 m/ |5 A( m+ `0 x7 E* ~5 y; L$ D+ Pstatic void __exit led_platform_exit(void)
7 Z7 v0 [' y0 `% d& T{
, h  l7 _& A  H0 Q  r        platform_device_unregister(&da850_evm_tl_leds_device);
5 o* t* d* \) Z* p1 B1 S/ y% b' i# n4 O/ {' _
        printk(KERN_INFO "LED unregister!\n");, }% w1 U% p/ X; ~
}
, u$ |! E" t2 B3 e! G+ R3 _! a$ M3 U) ~+ y
module_init(led_platform_init);( f# [9 [% k* [/ f! h
module_exit(led_platform_exit);
; |6 U8 z' C" A3 ^7 b) g; ~( M+ ?8 H' W& R
MODULE_DESCRIPTION("Led platform driver");
; _- J- p( J% M7 j/ h( oMODULE_AUTHOR("Tronlong");
# y/ _- {, m) p, |5 ^MODULE_LICENSE("GPL");2 ~8 k5 J$ L* c

; J( \0 J& h/ T3 ^
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

点击跳转“创龙科技服务通”

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

GMT+8, 2026-8-14 08:50 , Processed in 0.046674 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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