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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
5 ]9 V* M4 Z$ J+ ?+ l#include <linux/init.h>$ Y3 c5 q1 s9 j1 @3 I
#include <linux/module.h>9 c7 N) K* ^/ s. F
#include <linux/kernel.h># Q; Y; f/ `5 f  `; K: B
#include <linux/types.h>. U& g4 c' l6 ]5 S! n
#include <linux/gpio.h>
9 K: d1 ]" y* l) D+ e0 e#include <linux/leds.h>
- r; z4 ^; x, C& Q, w. \: C#include <linux/platform_device.h>
2 H& N+ o; O; K
5 ^0 [- J3 g+ }; x2 W6 Z4 U5 j#include <asm/mach-types.h>
( q+ ^' k: Z8 R) b! l1 R#include <asm/mach/arch.h>; n  U/ U& A3 g. W
#include <mach/da8xx.h>) }  p0 ^! t( R& [4 x% o# R7 `4 o4 i
#include <mach/mux.h>7 l$ Z/ ^2 Q( ]3 K
: B4 N& i: x7 f8 ~% {% T
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)" e# @* E& l- }
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)' D% B) g0 v, r: x
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)) V9 K$ L  V) e, E( V/ a: b
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)5 d/ G5 ?% S5 V3 A
) }" k0 }, |' [6 y  G& Y. r5 i6 H
/* assign the tl som board LED-GPIOs*// C  ~& E8 U0 O3 S" P' e" B
static const short da850_evm_tl_user_led_pins[] = {
( M) G& x5 d9 ~. i4 v/ P, ^- [8 C        /* These pins are definition at <mach/mux.h> file */4 Y7 D5 }! i/ ?) |$ q$ d
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: p3 _6 n/ u+ h/ `
        -1
& z6 z  t/ E" D2 ^( {};
/ R; _) r6 {, e$ Z
! f" g& Q( I- }; C, a5 X9 u) ^static struct gpio_led da850_evm_tl_leds[] = {4 [/ v# w& O! ~' C3 W# ?+ k  B
        {0 E3 k6 x* _2 Q% V4 `8 d# w
                .active_low = 0,7 [* d4 [/ Z) C0 S5 ?( T( E
                .gpio = DA850_USER_LED0,4 @$ J$ n( X( U' q$ `
                .name = "user_led0",
+ P* N% ^8 E( L6 A) R% a                .default_trigger = "default-on",0 K& m$ p6 U: Y& H5 ?
        },/ j, [6 A# t7 V; \& ~# I
        {9 V4 {, L1 d- Q6 g' i; y# q
                .active_low = 0,5 r9 {; d4 O! `0 C3 v6 a$ i
                .gpio = DA850_USER_LED1,+ g! K7 y4 F. ]0 ]8 j; X
                .name = "user_led1",
" ?' S+ J5 l# Y                .default_trigger = "default-on",
: u; r9 x  l$ x: F# p8 F        },
  ~! I: z) s- D  X7 Q2 K5 m        {
- J6 p6 P6 Q, S9 L/ ?9 F4 {                .active_low = 0,9 b# e3 v2 q# [, G4 }, E
                .gpio = DA850_USER_LED2,% U4 v2 w0 i0 A. O; @2 y
                .name = "user_led2",# x' E0 p$ E4 r; k& s$ t2 [+ `7 a% w+ ~
                .default_trigger = "default-on",, @# D7 h5 J, r' Y; F
        },
: Q, R/ ]+ u0 J" N        {
4 n7 z- T3 t' P/ a( O+ z$ k# S                .active_low = 0,; a7 F3 C; S7 d1 I4 ]! W6 z: H
                .gpio = DA850_USER_LED3,/ L& k0 P6 M* D( s; \* n" L! O
                .name = "user_led3",
1 h6 i* w1 F/ n. F7 j                .default_trigger = "default-on",
* X" M& z. x) F) D  i. r' n        },
! k; o4 t4 }+ s- A% ~7 a};
# R; Y6 I( S7 P5 B9 v' I6 Z
, C5 R4 C0 f* M- Q% d$ E6 E: Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' O( C' g# I5 H9 L/ \6 g3 p        .leds = da850_evm_tl_leds,+ ?4 r* D2 g# K. C
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ d: A, H1 p" i2 M/ l7 }7 t};
0 }1 ]9 O- P/ `( k' j; D7 o
/ b* J! u9 s. @7 T0 Cstatic void led_dev_release(struct device *dev)' `0 ~' Z3 R  B# F* v$ ]8 u
{$ ?$ ?. b" o: X) m6 w
};, v5 f0 U8 P2 i* p
) Q) A) W8 ~( G) G# g2 N# K
static struct platform_device da850_evm_tl_leds_device = {
( c9 R; ^# {2 T9 Z' l( u        .name                = "leds-gpio",
2 p( I. U2 d) o! N! y' S' @0 x        .id                = 1,+ k1 E* H# G! F( M& ]) r- x
        .dev = {3 Y1 n% B& [. W; P) H+ ]
                .platform_data = &da850_evm_tl_leds_pdata,
8 E% Z/ f' w& t# M7 J7 s                .release = led_dev_release,
: s. w5 ~7 y. J; ?" S. L2 `( p: f' j        }2 y/ W' f) K+ A7 i
};
+ b7 _8 D+ q" t0 K! V9 ^! ?4 M3 l1 \! X1 P; A1 L
static int __init led_platform_init(void)% P0 K; b( A! ?) K3 I0 M
{) x8 ]8 `" k+ ?
        int ret;
. j/ n# e* I. Y' B#if 0
, k: p+ M+ z. Y& x# e        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. N' i& z& a. K# X" b0 y
        if (ret)
0 f; V: ^) e" `, _/ [. [                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- D7 J/ N- u, r* g  W7 U8 h  R                                "%d\n", ret);
- e) Z3 A" p) s#endif
+ X+ T' w1 \% x' |! x" P/ g1 S        ret = platform_device_register(&da850_evm_tl_leds_device);
3 f3 ]0 M$ E# |8 {# a2 F# g        if (ret)
: o: y" P, Z* M' f- B  ?                pr_warning("Could not register som GPIO expander LEDS");
0 ]6 E% v' l3 Q# @7 Q, I        else0 R5 @2 M( x  J& ?( \5 q
                printk(KERN_INFO "LED register sucessful!\n");! Z) ]1 n' ^. s% E7 ]' e$ |0 C, B
6 H1 j8 F1 S# H& g5 c
        return ret;% v1 P( l( Z9 t7 t! G
}
, n3 J- q" Y: F/ B% ^. S+ p  e
+ v! G1 u. b0 p* J, v% t4 Ustatic void __exit led_platform_exit(void): b1 L% f. I' r/ L' C# S5 [- L1 c
{
. _  S" M: v8 C( @1 \& H8 ~* Y4 o7 Q        platform_device_unregister(&da850_evm_tl_leds_device);" a7 c4 j+ |# f$ {; J( M
; S5 Q! B4 u/ D3 \/ E7 n. m
        printk(KERN_INFO "LED unregister!\n");
: J8 a: }2 I' N' }2 ?% O3 E+ a. e}0 l9 G+ S, L  [# z  M( }1 M
& y2 p/ ^  [$ V8 W! E; e
module_init(led_platform_init);
4 E3 W0 I+ a; R' Y, Kmodule_exit(led_platform_exit);# Q3 J3 v& @/ z5 e2 O! V8 `) k
+ X) s  G/ n! \  V9 ]* _
MODULE_DESCRIPTION("Led platform driver");
' b3 R6 V. o- i3 DMODULE_AUTHOR("Tronlong");  [& [4 S# `" p, J* j! X- q- w
MODULE_LICENSE("GPL");
4 @( C9 F% U; v, |
. B7 m3 x% O5 N8 x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-18 07:44 , Processed in 0.041418 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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