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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
, T8 f5 r9 X* V5 K4 D1 @#include <linux/init.h>' g! s/ l, T( V2 e
#include <linux/module.h>
% f/ h: Q  ~) U% D# v& C1 n- B* p#include <linux/kernel.h>
! }( |+ F$ o' {+ r* b% a#include <linux/types.h>
8 z, o4 A( y) y* h+ @& G, c( i#include <linux/gpio.h>
7 J$ |+ u7 ~; V' g/ L! A#include <linux/leds.h>
' n8 p* x6 {1 M1 ]: x9 N5 w$ t* }#include <linux/platform_device.h>5 ~# R, q5 j1 }3 b
, n& ^5 t# z' ^% ]- V
#include <asm/mach-types.h>
8 x$ a& w. e' w$ x: S: U8 y#include <asm/mach/arch.h>
) J- T& B8 x) S- w* O9 u9 u& Z- V, @#include <mach/da8xx.h>
/ f9 W$ P' p5 L: J#include <mach/mux.h>
7 m- }/ H6 f; L( Q: F# a4 H& f4 h) b9 d+ Z/ i8 p
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0): f7 x4 N3 u3 V, M" s
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)7 h0 O3 _$ ^( }* ^7 {5 S
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)( i  W+ ~4 W: q
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)- z5 W1 n" E) V; f

, H# M9 q7 _4 o6 j/* assign the tl som board LED-GPIOs*/2 \6 x3 j1 ]" {0 i. E1 g( Z
static const short da850_evm_tl_user_led_pins[] = {$ m/ k4 d9 h* M: c$ |
        /* These pins are definition at <mach/mux.h> file */" Q1 {$ T/ S1 X4 t4 G) c
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' S4 t! J# t3 C5 U- \        -1
# b+ Z% x. L% ^. |};1 O1 ~' h5 K  `4 c

, J3 P" Q; v4 p6 E; ?! r' a" wstatic struct gpio_led da850_evm_tl_leds[] = {
: x* W/ p2 {; O& o6 v        {9 w  n" \$ D8 E# E% G
                .active_low = 0,# K* f& N( N, R3 [
                .gpio = DA850_USER_LED0,! v; F- G% q/ [- T8 Q
                .name = "user_led0",
8 C: j+ D/ Y; J4 X) E0 j$ r  Y- X                .default_trigger = "default-on",
7 I5 j1 I- |9 \        },/ O/ B( u# Z) ]! m! F
        {9 @2 C! K9 J. `  B# G' C
                .active_low = 0,
0 G* N& H. m+ X% \                .gpio = DA850_USER_LED1,
0 |8 I7 t3 P$ i/ i- F                .name = "user_led1",
5 c9 h% \, s/ Z                .default_trigger = "default-on",
. f' r7 d5 k3 h        },4 P2 a& c2 N- K. l1 G- u
        {
! g8 T% j1 ^: G8 K                .active_low = 0,
3 x' p0 C8 r1 j* V7 J+ _3 j4 V                .gpio = DA850_USER_LED2,8 x0 f/ }3 V) R  g9 e
                .name = "user_led2",
" i& G2 a! r. N. C# W$ M                .default_trigger = "default-on",% I& \* i) Y' f0 n% r. f8 T
        },
2 m. `% Q( K6 X        {
, M; m$ _4 F2 D. {- m+ F                .active_low = 0,
3 G2 i/ C8 z# O                .gpio = DA850_USER_LED3,
6 Y! L1 J3 I* ^) y& o. ]                .name = "user_led3"," N% X  o1 ?1 D% O" F" ]
                .default_trigger = "default-on",  f$ [2 ]9 @( J  [1 t5 ?
        },
! d) {2 ^/ ]4 T};2 j* E- j* a9 p' S8 P  s9 b% p

- e8 k3 H" p! ]* Pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ M4 D1 ]$ q- Q2 g
        .leds = da850_evm_tl_leds,
. `/ m' s4 l3 P% a) O. ^1 x/ ~7 |        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 u( g$ Z5 c- n2 q% g' Y8 C};
! D3 J% N  G4 C; m
5 g% T/ |. W, j9 e2 C) ^static void led_dev_release(struct device *dev)$ c' }. {: X1 w( c
{( i$ W( O, H9 {0 D1 l$ y
};
+ c3 |  Z" e1 ?. D' w* e1 S
$ N' p( }# Z; P2 Ustatic struct platform_device da850_evm_tl_leds_device = {
: o5 c) ^1 Y! w4 v% R, P        .name                = "leds-gpio",2 e' @) a& g0 q( B% Y) g
        .id                = 1,
+ E' ]+ G: V& n( d1 q5 v        .dev = {4 i: O; C7 K1 d. ]: k' `/ m! u
                .platform_data = &da850_evm_tl_leds_pdata,
$ y5 f+ p8 P, j# G4 w" B6 t                .release = led_dev_release,+ F% f8 }& ~, q; T+ u
        }
9 t) L2 }( r% G+ [6 |$ {};
" ^+ R" l5 Y9 ]6 _0 F6 T
: y. e2 `3 `8 vstatic int __init led_platform_init(void), [- A& M- {: y4 K5 z* F$ g5 s
{
2 q( L# g: \  q1 K- `8 I( Q        int ret;
7 c% G) T1 {# c) Y2 ~#if 02 C6 o& R7 @) }* A  O* z
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) ?' i' @6 a* k' c* `        if (ret)* r; ~0 ]$ _, w4 V2 }- S: Y  N, o( Z
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- w7 e- M/ [# a5 I( n
                                "%d\n", ret);# v0 {2 H# a2 V- p  K# h8 R
#endif4 a) b8 D+ a' L/ j* h
        ret = platform_device_register(&da850_evm_tl_leds_device);! @( k+ L% s7 Y4 T, Y
        if (ret)( `( K4 y7 ?# }* X1 E' V( W- \+ c/ l
                pr_warning("Could not register som GPIO expander LEDS");' }1 U( v6 v* I5 x( l
        else
& g8 M8 d) P( R0 K$ B) C! [                printk(KERN_INFO "LED register sucessful!\n");
0 K7 w% z" e  M" a
0 ^" L% z9 [7 N" [! H        return ret;; I! y+ l/ `; T. ?! ]6 M
}+ {% @7 i( n$ [1 E7 e

( d3 F# w" c! r% Y2 Sstatic void __exit led_platform_exit(void)
; J, i5 I  t; f7 d& H9 b$ u6 _{# `: R& W3 X$ H7 ?
        platform_device_unregister(&da850_evm_tl_leds_device);
- G% s0 |; a$ |$ I( Y% K+ r6 ]/ N3 V# b
        printk(KERN_INFO "LED unregister!\n");
$ w5 G1 A. R' r4 j2 E# u, S& H! S}
7 {; y) `/ r# z7 \7 d4 \! u4 t1 @; O' |
module_init(led_platform_init);; n- Z+ V. N$ X% W; y8 K
module_exit(led_platform_exit);
2 C  @1 z* m$ i4 i2 ~1 {: ?/ C. D7 t  {; x/ k" T& A
MODULE_DESCRIPTION("Led platform driver");  |9 ]& g/ j$ {. c( k0 q
MODULE_AUTHOR("Tronlong");2 X6 U* z6 @' g8 @* [. b0 s
MODULE_LICENSE("GPL");! v/ z( g# J6 v) t" R, U5 |

4 o6 d& H9 f+ L) B0 ]4 D
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-7-8 14:45 , Processed in 0.038651 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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