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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。6 [6 ^8 a5 u3 A% ^& L7 S  r
#include <linux/init.h>
+ t# E( b% l% x; c+ n+ F+ Q#include <linux/module.h>
0 `" g2 j2 H* h) i3 K- x. B/ q#include <linux/kernel.h>
, _$ X3 e* [) c# `; `#include <linux/types.h>! A8 p; D# F5 u
#include <linux/gpio.h>' h3 ~* g: Y4 H, i+ h
#include <linux/leds.h>1 v( {, Z( M$ P; P2 m7 V
#include <linux/platform_device.h>- }7 t( l. ~2 b  L
8 R* Q* A' U; R7 v7 ]+ l
#include <asm/mach-types.h>
" K; \0 L' w1 M: V* _#include <asm/mach/arch.h>( L) C% B& k* z4 E6 h' a' r# N
#include <mach/da8xx.h>) Z! o; S/ T9 E9 K+ A! k
#include <mach/mux.h>3 K: x# d8 V& C; e
1 r% J" N# X3 ~! ]$ [: V7 B8 l
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)$ j- z$ X( @) _+ M: ]
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)% Y. A4 X9 e: a; M6 C1 t# Z  I
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)( O& f9 m, |( ?( E0 {/ E4 [
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
& v5 D3 w' D% T- f, ^1 a% [! E5 u8 z5 G9 y9 P9 ]
/* assign the tl som board LED-GPIOs*/1 p2 Y4 L. R/ J: s9 r8 y- _
static const short da850_evm_tl_user_led_pins[] = {
3 F3 |* f, d( L4 `! F        /* These pins are definition at <mach/mux.h> file */
) R% `2 Y/ S( b) N# ]5 ]        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# m: ^1 b# V0 Z* A' B+ [        -1
) S" l: v$ ?1 y. T; O6 Z};
' y" H, M9 M  W9 \) E, v& q" \% u% U* r2 O3 Q0 O/ r, g
static struct gpio_led da850_evm_tl_leds[] = {! T7 E! @1 f' ~
        {. I( |) D$ v5 o3 O  w0 f
                .active_low = 0,* {* Y3 x% H2 I& j
                .gpio = DA850_USER_LED0,
" p1 y4 y6 c( }& l) D* b                .name = "user_led0",
: n5 W5 s! D% I                .default_trigger = "default-on",
, X$ W1 t1 q. e# G8 B7 K        },
( f0 {% q! j8 x. H5 _8 q        {9 E! O9 J% N6 y
                .active_low = 0,3 J3 T$ g4 l( o( P- Z! @
                .gpio = DA850_USER_LED1,
0 n3 F" R1 n7 o7 ?$ U' A& J                .name = "user_led1",4 u" A: R. B2 d/ v
                .default_trigger = "default-on",
% W: U- ~9 @# G$ g8 Y        },! t) v* Y7 W$ k7 [- p- g1 W
        {1 K, c# U4 V2 R* I3 J1 i
                .active_low = 0,; p! L, M& `- C' k
                .gpio = DA850_USER_LED2,& a$ W; H- P. l2 a" u
                .name = "user_led2",
/ ~. [3 O. Z0 ?: U. A: e9 r$ J8 S+ d5 [$ I                .default_trigger = "default-on",7 h% |" X! k' c7 t/ O
        },# v* @& `2 }2 i- O
        {
+ M2 ]+ r4 N) g" L                .active_low = 0,
9 U9 \& P; B+ ?4 w* Q                .gpio = DA850_USER_LED3,
1 {0 `$ |, s/ V- U- j# Z4 S                .name = "user_led3",
2 B8 D* w! @+ [9 C2 q, o  V                .default_trigger = "default-on",
5 C/ s. o( H' d/ l2 ~        },4 n$ K7 r3 P- I. V# }% i0 u
};
" W  x5 u7 a/ I7 o3 C3 [
0 {) A7 h- S, n: T- N" Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. A5 _* t. [% |4 w# l8 l
        .leds = da850_evm_tl_leds,) s' H5 _0 t7 _9 ^  u
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; e, B: j! m/ z2 W% d. T' t
};- N8 y8 z- [& d' X3 e4 v6 q

5 k: F& q/ I: A7 s' }9 i6 L& S: Dstatic void led_dev_release(struct device *dev)9 f: z+ I5 I( S, R& i
{
7 u: r- d  ?+ |1 x};; @5 g; [; s! B  E% Z  g- b
# \* B# `7 F' X- i5 r4 @
static struct platform_device da850_evm_tl_leds_device = {4 {* w" D  ?9 I$ C0 i  {+ a1 M) v
        .name                = "leds-gpio",
! ]8 Z; G% L) |        .id                = 1,7 F' V& T4 [% C3 i* r8 t
        .dev = {
0 [. R: ~$ T5 L( I                .platform_data = &da850_evm_tl_leds_pdata,
5 f! `# y) W7 o8 w& b8 w4 c                .release = led_dev_release,
7 `4 V% ]; Q: e5 Q; Q4 C. _        }1 C% f* W7 o8 d+ G- T  S% n
};
/ [) X# }4 \5 q& Q: f# y7 C
7 k6 D+ o, ?! L8 d# \static int __init led_platform_init(void), Y& p3 F% g5 z* V7 E% B! Y, Z
{
& R$ J6 L5 {+ o( j        int ret;8 E9 X+ h/ X7 ]/ }; i
#if 0
1 B: Z  E" n2 a/ J" z% b        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& `: Z9 H; e" z; g: O3 {3 U
        if (ret)( c& s. E7 t3 F+ t3 t1 T' }- p
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, G' R! U2 K4 n2 w. h9 I                                "%d\n", ret);) I" U6 P. [! F% }# S; k
#endif
4 U; F* U" v/ }# F3 _+ k9 N. L- s0 g        ret = platform_device_register(&da850_evm_tl_leds_device);
* T2 o, d: w) W        if (ret)
/ M/ w" u6 p' \/ c. b0 h* O  p                pr_warning("Could not register som GPIO expander LEDS");
1 F$ F' Q$ J( Z2 \        else
! }8 V4 G8 O" u$ U9 n                printk(KERN_INFO "LED register sucessful!\n");
. O( @- R. P7 \3 W+ u" x. Q8 ~7 c3 U, |% C8 ]9 v
        return ret;
8 g; w6 [& I- F& Z) M* O/ {. W( r}% c8 b1 |; e: l$ `

& y7 e; B1 n' |5 N: kstatic void __exit led_platform_exit(void)
" \7 m' V6 {9 L! l; _9 w{- F+ k3 A4 w, `8 U
        platform_device_unregister(&da850_evm_tl_leds_device);
2 O, G' A0 i( {  [0 B) E2 I% T' W3 V  T, m6 u! D0 ]
        printk(KERN_INFO "LED unregister!\n");. N, q+ ?! Z% E$ J& |: z0 h
}" z) g, y( G4 ^6 M0 b0 t; e

# i0 f, }8 u/ ^2 ~8 l4 g% @+ dmodule_init(led_platform_init);
+ z# ?# Q  p+ r; Z0 T+ ymodule_exit(led_platform_exit);
$ n0 N+ e9 `2 P6 w0 o! s% a* n% X7 B  A
MODULE_DESCRIPTION("Led platform driver");% H4 u7 H9 u, |) G4 g/ s
MODULE_AUTHOR("Tronlong");- Y* L. g0 o( _+ T
MODULE_LICENSE("GPL");
+ [% C/ D! f% W' p
9 P4 k; l/ ?) ~: j3 r
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-1 16:52 , Processed in 0.040809 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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