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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。5 [. N! j* g, B! y9 |; i5 M
#include <linux/init.h>6 k& V! o# _4 T& T* z* j
#include <linux/module.h>
; i1 W: h& M9 Y- {  J/ m#include <linux/kernel.h>
' x: Y! u4 }$ h0 S. y7 P#include <linux/types.h>$ h; k& l7 R7 s4 L4 W) \5 X  u
#include <linux/gpio.h>
, ]" r2 C% I7 B/ W#include <linux/leds.h>
7 g# [; |% ?  m4 {. V/ t) F#include <linux/platform_device.h>
& d/ [* v+ i; I3 d' z
& N$ q+ E! W) X0 V( |: Y" X% z9 p#include <asm/mach-types.h>' t! |% N  s: Z
#include <asm/mach/arch.h>! K" h+ X' I* C, ^. |
#include <mach/da8xx.h>
. R: ?8 x1 |! ?# v! A#include <mach/mux.h>
6 ^, z( ?5 a4 j! j/ x) l$ K) z" _. h
2 W: H0 t) ^0 D3 T' d* P#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
, z2 H! z& C1 N7 n) t#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
2 r2 B( N$ o' Z+ w2 M' H#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
3 O  `- m* [, h0 y; L, p7 J#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)# x$ O# d* j7 e
( L- Y; V6 W, s; `# F: S
/* assign the tl som board LED-GPIOs*/+ K8 j7 J+ P+ P( Q
static const short da850_evm_tl_user_led_pins[] = {
; H+ E/ m/ n7 o1 l* H+ h2 c/ Q        /* These pins are definition at <mach/mux.h> file */
; N1 @3 e- M% h9 O7 Q# b6 v        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% c) z) q% N+ ^8 @) x        -10 h1 A' |' n- Q6 V. @% L7 N( I- a
};! J/ C3 f4 h! Z* M) U& d& a
2 r2 T5 g: Z, p/ c& F. N6 f0 H
static struct gpio_led da850_evm_tl_leds[] = {* v, q% Y% H- m' _1 V8 d4 W# x8 k9 M
        {7 u1 \+ P8 T, l0 E2 M( y! w5 a' R
                .active_low = 0,* l$ \3 H- ]2 t3 J
                .gpio = DA850_USER_LED0,: f2 |9 M$ C# i, I
                .name = "user_led0",- p, n9 j9 j& c6 N% q! |
                .default_trigger = "default-on",
+ _7 e+ O' O2 N6 h        },: T, I1 B. |; r$ _) `
        {& H* s! X- m/ d& N  S$ E" C. Z
                .active_low = 0,0 |; V7 V4 m0 p- I& ~
                .gpio = DA850_USER_LED1,( L0 f5 _% z$ u" q: J) g; H
                .name = "user_led1",$ e/ m; s8 H4 ~" D1 I# h$ b1 ]
                .default_trigger = "default-on",
0 Y2 M* c7 A9 Y1 e5 B        },
% B7 b3 e! A+ W* e7 B        {4 x  W* ]- F! R
                .active_low = 0,& o1 V. _% f; z7 d
                .gpio = DA850_USER_LED2,
8 I- w' h( E" a* W3 o$ }% l                .name = "user_led2",
: Z/ ]3 v4 I$ N6 `) N                .default_trigger = "default-on",& g% d& n, Q4 t2 N- R% P' l
        },5 i& O0 p( j: ]2 k
        {
" C. o7 B, D: U                .active_low = 0,# w. S2 l7 }; f1 J) K; m# a
                .gpio = DA850_USER_LED3,/ q5 Q! ], F$ j$ b+ r1 p+ d
                .name = "user_led3",- n. ^1 N$ g& `. }0 Z: G1 n6 m
                .default_trigger = "default-on",
1 R  u& C0 \3 _1 M6 l        },% ^2 P% k3 i. h6 l6 ^, {1 |$ m' I
};( `( I# R+ l. e4 S$ S- X1 G

4 v6 H8 d0 A! h* g  hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ `. A0 o, Q$ k9 K" X        .leds = da850_evm_tl_leds,' K7 X9 i. \3 M- L9 O. ?
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ S. `# d9 ]  V# p2 b9 ^% Q) A
};* {. N; k3 s5 j% W  l, Z

- v9 N4 N1 @* R+ Lstatic void led_dev_release(struct device *dev), t+ n8 u* C6 i' X
{' H) ^# j( h+ Y' @# K7 ]
};
  V/ X  F0 C5 ?: v( o; Q2 s" E: J2 @! _; Z% R" A
static struct platform_device da850_evm_tl_leds_device = {
/ x6 A- g. Y+ T  E/ C$ U6 H$ q        .name                = "leds-gpio",
1 m/ E+ {) s6 e        .id                = 1,5 m: k: r9 K, ]( Z
        .dev = {/ V$ ?6 x3 G; ^! e! I9 h$ P, U9 C
                .platform_data = &da850_evm_tl_leds_pdata,/ Y  J% f3 N1 k1 u  Q2 @! i
                .release = led_dev_release,4 {1 p" M. B4 f9 @
        }! |3 ]2 ?  x2 b3 l( _& |9 b
};- ~7 O+ F! p, f, P: p
% ?0 N$ ?5 D, V# B
static int __init led_platform_init(void)
& f( w% N* v$ [{0 F' H0 X, v  `! Z
        int ret;9 ^/ a) F$ t( s$ S
#if 0% i$ D. j1 i7 R* ?9 w& E! F8 G
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; z* |2 \: m; c4 ?6 ]& c& i/ X
        if (ret)
; B1 [9 b2 }$ E' o$ W) ]                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ [% W6 y$ A, e
                                "%d\n", ret);" o& G  K' O/ b( K, I: G
#endif* J+ t9 L* g; W/ l
        ret = platform_device_register(&da850_evm_tl_leds_device);3 D* w( g+ ?" R" |- O( a
        if (ret)8 b+ q4 Z/ `" T% T8 j, C; x% \2 t
                pr_warning("Could not register som GPIO expander LEDS");! v0 n- M( g, M! U  j4 A" s
        else
9 H5 h% b( k7 Q; q2 ~. @' S7 @& D                printk(KERN_INFO "LED register sucessful!\n");
4 ]4 X; V) z9 S6 B/ Y2 H0 O' t0 ?, a$ ^7 `& P
        return ret;; J& [. O) L7 b, z) x- X% `
}( B. Q4 i: R8 o. i) O( i
* }# ~7 C8 q& T( T9 ?
static void __exit led_platform_exit(void)
1 y: y, f2 h- D/ B) d{
9 l* {) S$ I* o) S1 E5 W. o( v        platform_device_unregister(&da850_evm_tl_leds_device);3 L2 S% y, T4 b0 J6 E3 L% _
0 f( c7 X# V9 }, s' @+ C
        printk(KERN_INFO "LED unregister!\n");
1 g# N1 x1 w) |4 O}% F, \# T* V9 v; O& e* K( p$ M  x
* ?9 `, X7 L; S2 `6 C# R
module_init(led_platform_init);2 E) d4 S7 s) J$ Y( B3 R
module_exit(led_platform_exit);2 M! L) g8 ~' D6 [+ \

$ K$ m" Z5 {9 U! c4 sMODULE_DESCRIPTION("Led platform driver");
9 k+ c  \4 D4 q6 N" V0 iMODULE_AUTHOR("Tronlong");8 m% d0 {4 U, z: y0 Y; t
MODULE_LICENSE("GPL");& ^# G$ t* A1 ]6 X' [
2 Z( a) h. B" x( b! y
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-11-19 14:26 , Processed in 0.053080 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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