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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。# h' t* g! K: E8 _' U, U: D
#include <linux/init.h>8 e+ Y2 p7 O7 i
#include <linux/module.h>( ~# z. z8 k  z% q6 K7 G; ?8 _1 W' r& t
#include <linux/kernel.h>" {/ ]* L+ p& J. l7 e' ^
#include <linux/types.h>, w/ _+ v6 N' q1 L
#include <linux/gpio.h>! B/ P, O3 T( H: s( r6 }* k: x) Z
#include <linux/leds.h>* l, J  n1 O& T7 y
#include <linux/platform_device.h>2 w& p! _9 z6 V# _2 X5 v- I6 k

  v1 y7 l* _9 q, W#include <asm/mach-types.h>
' r8 Q- d9 o. d- Q#include <asm/mach/arch.h>
0 L* E/ E+ v/ m" ^3 u#include <mach/da8xx.h>
2 a( l' u2 w* g% m! ^#include <mach/mux.h>
, j0 s, C$ d4 c4 g" c7 v2 L5 y* S9 {
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
0 `; ^( y9 A$ h, T, T5 h#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
- W& `& {2 A/ Y# \* X#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)4 J( @1 @; O5 D$ U. E2 V
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
' I9 b$ L% j+ r% w: g4 P) a5 Z' F5 E! c7 N  f( I( F  n
/* assign the tl som board LED-GPIOs*/7 b* h6 p- k* K
static const short da850_evm_tl_user_led_pins[] = {
  E1 @8 f( N/ E! g        /* These pins are definition at <mach/mux.h> file */5 k8 u! @( n) B% c( f% G" Z& U9 w
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, x$ r- j5 c& V3 j" r2 m
        -1" C  x, O! Y( A+ S
};( ]3 ~" u8 w( N& K

9 S' S0 j% Q. I! _# xstatic struct gpio_led da850_evm_tl_leds[] = {: O9 w$ C' F/ \% g" P
        {6 P# m) O0 \1 t% u
                .active_low = 0,9 V3 U9 v# E9 g9 J( `
                .gpio = DA850_USER_LED0,& a* @* a) Q) c) V1 L
                .name = "user_led0",
( z$ B$ o- O- P/ ~6 d, o2 l" `' T                .default_trigger = "default-on",, Y- [7 @6 K, Q4 O. y
        },* h! x  [+ u+ a: U; y
        {9 l- ?8 L9 ~6 o; ?- |  G$ ?4 c
                .active_low = 0,
+ F: \! Y6 \! }/ U7 d2 O3 M                .gpio = DA850_USER_LED1,
9 Y  X* F  H9 T5 _7 m2 x                .name = "user_led1",: G2 L; Z) g, b! o  |, D: y
                .default_trigger = "default-on",& X, B  I& \; V
        },
, q1 R3 y0 u+ p* b) e$ Y        {! |( }) d( N$ u5 v9 B( K( ^3 g
                .active_low = 0,5 \  B$ ?  V# w* B
                .gpio = DA850_USER_LED2,$ ?8 y# p4 s0 D, k8 V3 Q
                .name = "user_led2",6 S8 d2 J2 Q; T/ v; F* @& X9 |
                .default_trigger = "default-on",
7 j9 L! H+ n3 ^, W6 p$ ]9 x& N  _        },' A1 r1 T# p& A% _: `& D$ C* H
        {" V5 }& I# \4 a) h8 H1 R& Y7 t
                .active_low = 0,# H4 c, e6 b- \$ [  x
                .gpio = DA850_USER_LED3,, `  u  @# {; _0 w
                .name = "user_led3",
: ~( y! l2 O  p9 j' {! A- |1 T                .default_trigger = "default-on",! }$ j4 Z0 [2 k- o' |; f7 n2 z
        },  U  y" L  _! ^( Z- r" u
};8 w8 P( ?3 A' R9 x# w" e
- q0 `# U' t; C. T
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" c  ?0 \5 J3 g6 M/ e        .leds = da850_evm_tl_leds,3 @0 `( y- A! L! R$ R2 M
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' W# P6 Q9 |% o& t6 @};! O. @2 X& T9 Q) B+ A( ?

( p' x) L' m0 Xstatic void led_dev_release(struct device *dev)
' B0 a8 ~! N0 r+ V$ p{
5 F  p* C# V* |1 I0 F. ~# c+ K};
0 A" E6 y8 E9 i9 s8 v" P) m' s" y( `& B, c  j% N0 N. \
static struct platform_device da850_evm_tl_leds_device = {) q8 T" t9 ?3 d
        .name                = "leds-gpio",' K4 g4 x- Y$ L' m
        .id                = 1,8 g8 [3 g5 a. b) H- e/ S2 p& t
        .dev = {+ n+ E5 V5 ~% G! X, H/ N+ Q
                .platform_data = &da850_evm_tl_leds_pdata,% P4 z4 V* _, x9 c2 L3 H% f
                .release = led_dev_release,) F3 }( L& f( j
        }9 ^* k8 [' X! L/ u- E( e
};
; v! }, x4 n8 B+ g
" q, ]& `/ D( T& i% b9 mstatic int __init led_platform_init(void)
  `" H4 d9 g& l- h0 V$ I7 q{% d! h' ]# X9 B
        int ret;! j* N5 d. R- l, z1 o' Q& F8 _  n
#if 0
. K2 ^& V* ~: F$ I$ S; u: m. [2 Y        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 f% m0 S6 |9 B& A        if (ret)1 q8 N! t) S! o, ]
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. F- x* L. U: ?                                "%d\n", ret);) b: ]% t8 S* ~
#endif
' C1 ^+ W& C5 m7 w! c: n        ret = platform_device_register(&da850_evm_tl_leds_device);3 i) R4 @" ?, J% b
        if (ret)8 h* n" X; q1 P4 J! b6 h
                pr_warning("Could not register som GPIO expander LEDS");  \$ `- U; O3 X1 @$ {' {
        else
* Z9 Q3 m/ o+ i+ b                printk(KERN_INFO "LED register sucessful!\n");) u5 A  `) f3 z; G+ D5 c, l" r

5 A. Q( _0 ~( q/ I; [9 U% W8 l+ h; W% c        return ret;8 J7 Z; I; T4 p+ O( D( `
}  w8 X7 b. W" H+ e: v5 @" V( T

% @) N2 {' t' f9 `7 z' A9 Cstatic void __exit led_platform_exit(void)( l6 y5 Q; _) w1 I* `
{/ [0 L2 e% K& ^; P
        platform_device_unregister(&da850_evm_tl_leds_device);
9 ]6 P, O9 g0 w# E- ~; E& P3 o' X3 _7 W) g+ B$ m, {
        printk(KERN_INFO "LED unregister!\n");
6 ~4 t) l5 V: o) l( |5 y! V8 p8 I/ l}
! y. M  u) T9 E9 v% r
  Q3 i4 T5 g3 I# _# ]module_init(led_platform_init);7 N! B% F0 L- Y  [4 @: T) i
module_exit(led_platform_exit);
# T- c2 v4 g8 V' w
4 p, {: e$ X4 E* Y- Q9 t( f) RMODULE_DESCRIPTION("Led platform driver");
+ F( O7 \3 ?& ~) _* U! ~MODULE_AUTHOR("Tronlong");
! g& N3 ^8 V- A2 I. lMODULE_LICENSE("GPL");
# J! k( ]# j$ c' f' J: J
& m, k3 M% ~# M* [. W! |
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-14 18:18 , Processed in 0.055132 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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