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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。( Z$ W; y0 h) o5 F% D. Z- q
#include <linux/init.h>6 t2 Q4 M. ~' b1 l) C$ _
#include <linux/module.h>2 Y: g# F  }7 l/ \  Q$ l/ F  Z
#include <linux/kernel.h>% \1 m4 Q6 r; F3 L  ]. d6 R
#include <linux/types.h>$ ^8 P2 \9 C: d! c9 }8 w5 u  y0 g/ G- P
#include <linux/gpio.h>* z# r) s0 [& C3 J( c1 Y8 {
#include <linux/leds.h>
1 ]9 m5 w& n! z0 T; ^6 }) _# G#include <linux/platform_device.h>+ `5 m/ B0 j% R" a" m) f* Q
; @8 Z7 W4 ^4 k6 X& _
#include <asm/mach-types.h>6 ^- o- N' I/ E1 a
#include <asm/mach/arch.h>- P* P: B1 I; B& O
#include <mach/da8xx.h>/ z' }5 P+ v, u* Z8 E
#include <mach/mux.h>/ R5 W2 J5 q; H2 n
4 Y7 s7 u5 ?- ^7 d6 G+ N& Y1 H; L
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)# [2 n6 x/ ?% C( {# K) q! i/ o
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)( V9 _8 z* v# I1 z  v# x3 g# G
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
4 o  E& v4 o1 b' I( m4 s#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ Z" a, [- h, r5 W& u

) l: H5 T: s; k- \/ Z/* assign the tl som board LED-GPIOs*/
6 N+ ^; _8 n& `) v( J/ v& Sstatic const short da850_evm_tl_user_led_pins[] = {
' W9 W  e; E: c0 h! D$ I        /* These pins are definition at <mach/mux.h> file */8 q# Q! R( e$ @+ R" ~' Y
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# ~) F# T' y8 i( l        -16 g2 D" D7 |5 G0 p: C3 f
};4 W8 p" S7 |: X4 b$ B$ x

$ u; h7 S& X% I/ _5 I; W7 ?  Kstatic struct gpio_led da850_evm_tl_leds[] = {
& }% V5 X4 T, T0 x        {  o1 S6 f3 A* ^( e" |- P% K; [& \
                .active_low = 0,, s# T+ d# m' w8 x
                .gpio = DA850_USER_LED0,
$ e3 s7 h( t  a- ~                .name = "user_led0",# s2 T! S2 E/ Y( S  Y
                .default_trigger = "default-on",
0 h5 C; t" [% ~9 L8 d) C' c        },
! H3 s: Q+ x5 K  c1 w- F        {
: n7 O0 @# \0 l) f" Y- j                .active_low = 0,* [5 S* H8 G$ p( ]
                .gpio = DA850_USER_LED1,
; u# p8 n9 j- k5 \, i" u                .name = "user_led1",
$ G+ j. B, M& `                .default_trigger = "default-on",
' g4 |: i. m- ]' c: j        },
+ j" \6 F/ I/ u* }        {: _1 C4 S0 M; ^4 i+ i- x
                .active_low = 0,8 O6 ?; k  `( C; g/ h
                .gpio = DA850_USER_LED2,
9 [. @3 s; e( {8 i. N8 V, j* q# r  G                .name = "user_led2",
4 x% A8 L: h# v* D" x# |                .default_trigger = "default-on",
) s7 E* h) d" X  h1 b- F" t        },
$ n3 L& d0 @6 C        {; {9 ~* l, C/ g- f4 y
                .active_low = 0,7 ~( K8 A1 \! k: A  X$ c# x# B
                .gpio = DA850_USER_LED3,
! J5 c* E7 T$ I: T9 ^# N; e                .name = "user_led3",7 Y$ _. V: B  c5 l
                .default_trigger = "default-on",
( m  [# w0 @0 V, N        },- E# H) l8 C+ h6 J" s- H1 g! M8 R
};3 `# t0 A1 m  o2 P. \4 S
0 ]" R" M$ G  J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& {, x! {. A7 m+ r4 C
        .leds = da850_evm_tl_leds,
: L; @: P$ f) k% z5 I        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 U" T2 `1 `- q# [. l# l2 ]};  e! ?7 g* n/ @9 X

# v% k8 K, v2 A; n. vstatic void led_dev_release(struct device *dev)
- f' L) |! l0 X, q1 J{
# ]; e# h1 X; E4 k, d" m7 x};( O6 y  _, B. \# c. m, X0 v
; U8 I. F: K8 T* F  `$ X! k
static struct platform_device da850_evm_tl_leds_device = {
( Y; ]' T3 x7 c5 S" k/ U6 S) T( T. d0 V        .name                = "leds-gpio",$ b+ Q& Z" K! B
        .id                = 1,) ]- U& _" R" R- ^) G6 P
        .dev = {
( u! @) s# H& T) S, U4 W                .platform_data = &da850_evm_tl_leds_pdata,
& m; S$ J* N- m' x                .release = led_dev_release,/ C: O+ i4 D9 `7 H3 M  r( K
        }* u4 _8 m# V/ |! D# y: ?9 f. J
};7 a. M! e* O0 c0 o

- ?' r( ?3 L6 z! K" J6 ]static int __init led_platform_init(void)% d  v* Y2 {2 a) v5 I( m( L
{
7 {5 q7 ~6 s$ R, r' x        int ret;
8 G3 ~7 f  p. \+ _1 H9 C7 g. _4 i#if 04 \3 @" ~6 W. _! T. s
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" y$ p" L2 s+ l        if (ret)3 }; @% E* W& u5 m$ F" y4 {( `
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :". ]+ ^, v* m8 I# }% y; K# a
                                "%d\n", ret);+ G, ?! k- Y0 V& {& V
#endif
/ y. g6 K7 r" d! X+ G7 z4 D        ret = platform_device_register(&da850_evm_tl_leds_device);
. y7 \- P5 U3 [8 T        if (ret)
% j+ u1 a$ c0 r. l9 o' @; A                pr_warning("Could not register som GPIO expander LEDS");9 E: P' }  }2 j% H( m* A$ Q
        else
, [" F- x, e$ f( z/ X0 t4 P                printk(KERN_INFO "LED register sucessful!\n");
# a4 }+ E; n4 L6 j7 N: h
7 U+ B9 F& B  l, x4 o2 b        return ret;" G% A/ p# k8 B5 T  u( i
}
1 c: N" ~  K$ X* A$ z" k0 Q- r
) S( T0 Y; v( a" x: l. nstatic void __exit led_platform_exit(void)1 a, H- E$ e. ?7 F6 n
{/ g' @" K/ a- l& ]
        platform_device_unregister(&da850_evm_tl_leds_device);
# ~1 Z% T* O" o
4 c6 R" w  L/ f! Z7 r7 c! s        printk(KERN_INFO "LED unregister!\n");) E1 Q3 F, W5 N* x0 \7 E1 i2 I3 u( w) p
}
0 R& B5 ?1 g$ O) L) u+ {
9 b7 G+ h8 K$ Y! v/ Fmodule_init(led_platform_init);
6 o7 {( U5 C/ L) [+ j3 w2 Kmodule_exit(led_platform_exit);
' ?: F' P+ Y/ }
! m9 R5 L( ~8 d% y% u4 a2 BMODULE_DESCRIPTION("Led platform driver");" V& r5 ]2 q! d; e: a& c( Z
MODULE_AUTHOR("Tronlong");
+ h/ H& q: a* F7 K# p  H6 EMODULE_LICENSE("GPL");; O' T: A2 a; ~* T" @
( y/ v9 h- V9 S. r" _  `
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-25 01:26 , Processed in 0.037127 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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