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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。: B1 `, d/ g* b; Y# F' Q
#include <linux/init.h>
+ b# _6 K( n' K3 b#include <linux/module.h>* ?3 Q  n# e4 [" v
#include <linux/kernel.h>
9 D4 u& f* C! x5 R#include <linux/types.h>1 Z- a& m$ }0 D, [
#include <linux/gpio.h>' v' F+ k& S9 L- I1 L( E8 K
#include <linux/leds.h>
% p4 a3 D7 l2 B! M' d; \$ n! @#include <linux/platform_device.h>( z1 y5 g2 v" J1 Z) Z, \/ m

; g4 }! x4 S2 d#include <asm/mach-types.h>* A0 `. Y1 K& Z
#include <asm/mach/arch.h># u# o; l6 y8 a! R
#include <mach/da8xx.h>* o& s: @% r+ U0 }1 M2 _$ N
#include <mach/mux.h>
7 Q* B4 _) h& E2 y2 d4 x  `- l6 W/ O! Z7 C2 J# X
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
+ O" {5 G% ]$ I& H( s' q$ U#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
4 u! Y6 \! F) U  s! ?#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)6 s4 J: t, r" ~% s- R, O4 \7 `
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
1 I; @0 H6 F) ]2 c: e0 X6 O3 V* \+ A; K! c. e# e
/* assign the tl som board LED-GPIOs*/
* d) B2 K  @5 U8 |: C; Wstatic const short da850_evm_tl_user_led_pins[] = {5 X$ d) q: f8 _% t
        /* These pins are definition at <mach/mux.h> file */
( c* P& ^2 X4 Z9 V+ c" i- ?        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# c& j: ^5 M; Y8 `# e
        -1% e! Y/ s, t$ c6 m
};; x+ v7 }1 K3 @* @6 I) Y! k; H
" _0 X% O  f& c$ L2 ]' i
static struct gpio_led da850_evm_tl_leds[] = {
7 T) U! h  E/ F8 C$ |        {
- X' h3 p3 ^1 _3 e0 W) j                .active_low = 0,. k( X# `- _3 d9 }! S& a7 Q
                .gpio = DA850_USER_LED0,
4 r/ A* P6 {' A* h+ C1 N                .name = "user_led0",
7 [1 ?* Q7 u* L                .default_trigger = "default-on",
+ ~. Q/ c- l/ |0 |' j. u* T        },
6 Y7 t2 [1 [3 J3 a/ d7 G7 w        {+ s# M6 q' X; K& U
                .active_low = 0,* G7 C2 p1 Q" [
                .gpio = DA850_USER_LED1,
8 F7 L* m& Y+ M' m! i  j: s                .name = "user_led1",
/ a1 H) ~2 z8 m5 M                .default_trigger = "default-on",) t$ m) M$ t+ m* \
        },( S% H' L$ F& G$ j9 ]
        {' u& M! \" C% ]6 J6 K( |. Z
                .active_low = 0,  G( O( j7 @+ j. k: F. D3 N% E
                .gpio = DA850_USER_LED2,
5 L% H+ `: @: J* x' L4 z                .name = "user_led2",$ W! R1 c: }" b. g) J
                .default_trigger = "default-on",0 c1 l5 e* w- B6 q: U+ P
        },0 `9 ?! T3 }4 h6 ]# H; z
        {
6 r* X1 j% `0 k$ I( Y                .active_low = 0,
$ ~: ^( P1 x% l7 y% I+ N  }" o                .gpio = DA850_USER_LED3,
% M% z8 y- ^% U3 D/ r4 f7 Z5 C/ w                .name = "user_led3",# O* d) q. r0 `
                .default_trigger = "default-on",, v' y3 A9 x2 N# C1 d1 Z/ |4 D
        },
* C8 j4 l" m. w$ L};
; P, u8 m6 C1 A
4 B+ b/ B! k: _1 b1 h. @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 T: d8 F9 k4 |- D9 K9 P
        .leds = da850_evm_tl_leds,
% E5 Z! @' h$ Z) p7 R        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 {5 E; W6 O7 b4 T9 v};
  G+ q. ^& r' c- ?; J) Y$ A' A* L* m
static void led_dev_release(struct device *dev), r1 [- @# Q# Y& A, X/ x2 V; E
{# n$ N/ W( }0 n' X  N2 C5 u, B0 ]
};
$ C# r2 `5 P6 Y- V4 j
# a- A7 [. {! s* u3 F/ Istatic struct platform_device da850_evm_tl_leds_device = {2 X: e/ |+ D% d% W
        .name                = "leds-gpio",3 q* v2 H) E% b; |
        .id                = 1,
. ]& k* x( h2 t/ l) m        .dev = {; T$ A0 Q4 q$ }, j5 W
                .platform_data = &da850_evm_tl_leds_pdata,
% A, y6 k! e5 _7 c' Z+ m                .release = led_dev_release,  I9 g  U7 b* }$ D" ?
        }
, j7 d* M9 x1 s( w};- [) z/ D9 m' R- [

- Y, [1 w  A6 _6 zstatic int __init led_platform_init(void)8 Z. f1 N" c- `) o8 y" W
{
9 B& Z8 N7 }# x/ U7 P        int ret;
# ]% I7 j; ], y( d& a3 a2 \#if 06 {/ w6 c$ {& n" T/ M
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* N& f) k/ x7 H4 G* b% n* b; h        if (ret)
# C8 t! O. d: S                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ I8 s. r% S& y- R  G, h. X                                "%d\n", ret);" q# o. W8 o3 K/ X- B! O9 a
#endif
8 U+ a) g9 O, g5 J; O! L  p        ret = platform_device_register(&da850_evm_tl_leds_device);
* F' t" c, A# E3 }9 N3 s        if (ret): s. F. O; L! g! M0 P, x2 x$ ]2 P0 u
                pr_warning("Could not register som GPIO expander LEDS");
0 l' t3 q% F. B) X) z7 r        else' Y; y7 M% z8 p) S) U1 _- ~
                printk(KERN_INFO "LED register sucessful!\n");& V8 K( `* V0 ^

2 B) a3 T7 d; ^" j2 {9 T2 S        return ret;  S3 `* m/ z6 Y4 {
}) @% `1 l% l  ^
' w. i4 `) j  ^  r" t4 l- j+ t! a- H
static void __exit led_platform_exit(void)
" s" B. b8 H* {, S{7 ?# K4 r7 l0 B9 v
        platform_device_unregister(&da850_evm_tl_leds_device);( [. v6 T0 ?6 G' N, x! z) U; Y
* S3 O6 d  j6 X/ A' f
        printk(KERN_INFO "LED unregister!\n");2 k1 x( Z; O& f6 y- t$ i7 C) F7 A% T
}4 r, X& y9 f" X

: X) `, l- ~% b; w% nmodule_init(led_platform_init);
0 r7 t' o$ X# a9 ^4 s6 K- Mmodule_exit(led_platform_exit);% T8 N) t; [, q

5 ]. g6 f7 s9 z9 t& Z; |% wMODULE_DESCRIPTION("Led platform driver");
4 }& I! |) Q1 G# m0 E% dMODULE_AUTHOR("Tronlong");
! B$ [& z  B# XMODULE_LICENSE("GPL");- D$ h' j8 L5 V0 z) T0 `+ R

# J; R( Z+ Z, C9 X5 [) K
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-2 22:18 , Processed in 0.040574 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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