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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。8 }7 k( X3 ~' K! o: n
#include <linux/init.h>) R) p3 Z) V. o; ?7 v  V
#include <linux/module.h>
) W9 k* q1 l; p- Q* |#include <linux/kernel.h>
, }! P; d9 Y' U% f( c#include <linux/types.h>
7 F& b* M- q, c; z#include <linux/gpio.h>2 Z: b# p' f# @, y3 X/ X
#include <linux/leds.h>* {2 d% _6 B0 a2 X
#include <linux/platform_device.h>
3 E0 E" P; G0 @) {4 p% T0 u$ H, s- N/ x, k6 J) @1 \7 F
#include <asm/mach-types.h>
+ X2 `6 {" ]2 L) |: e* n' y#include <asm/mach/arch.h>
7 K1 L4 x2 c  J% m! R, w#include <mach/da8xx.h>- o- P, h2 ~0 c4 T* q! f
#include <mach/mux.h>
: H8 K& [4 @- h
* G- Z5 `: n5 x0 _8 e% e; @: a! F, q#define DA850_USER_LED0        GPIO_TO_PIN(0, 0), A% u9 h$ g2 T6 H0 u
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
" ]4 Y) y6 @) v#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)- q5 S7 _  s" \9 i6 Z8 A8 ]/ K2 w& H
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
/ p; B% |* e# H- }
- t6 F8 N5 T0 @4 |4 Y& e) H+ C+ m. m/* assign the tl som board LED-GPIOs*/7 l5 U* f( B( A7 `% I5 C4 Q
static const short da850_evm_tl_user_led_pins[] = {0 }/ M7 j: z& g# l
        /* These pins are definition at <mach/mux.h> file */
8 L+ C# O1 ~, [) |8 H" g        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- {0 m3 B3 Z$ Y
        -1" D/ \1 k( E) }; c
};8 e3 t( B3 ?$ [

$ Z6 k" M# c7 k1 e4 }9 D5 b2 sstatic struct gpio_led da850_evm_tl_leds[] = {
  D$ S$ E: x: j' h2 R! N! @        {
$ H% r0 O0 M8 k3 e4 Q* n2 E. C1 o                .active_low = 0,
/ S, P7 k* |* s4 `                .gpio = DA850_USER_LED0,/ Z) U+ w. l- V
                .name = "user_led0",
1 Q+ o+ B8 F0 ]; D9 H2 n; p0 m                .default_trigger = "default-on",
3 q1 Q: y. K  m4 Z/ I/ n8 T/ M  |        },
0 C3 l" {) s4 e3 }        {. N5 s; E: [. @$ \4 \3 [& k! R! e6 v& |
                .active_low = 0,' U9 O2 Q2 d7 H0 h8 ~3 e7 c
                .gpio = DA850_USER_LED1,
: u- q# u9 j" E. i: ~* S; W                .name = "user_led1",% r- S5 @: s4 ^  t& O3 l6 N
                .default_trigger = "default-on",
7 R6 g( ~8 y' M        },
7 L: V) l' K' x( b+ h        {4 C- @# C7 S! Z& X( l
                .active_low = 0,* q/ T1 F, a6 _$ C2 W- f! c
                .gpio = DA850_USER_LED2,
! K5 p* y& G; t! J  y9 Y3 k                .name = "user_led2",
# C1 f+ L+ Z9 Q( Z1 N% Z" x                .default_trigger = "default-on",# s  S% G; [  ]# I1 ?4 R
        },& d( y: x4 w1 Z- y, c) l1 u% I
        {$ S$ [5 M2 W- o' R' {
                .active_low = 0,
8 Q; e, F1 \0 Y$ R' s: |! C6 e, u                .gpio = DA850_USER_LED3,
. T9 B0 L1 [% l6 E7 c# R                .name = "user_led3",
! x6 m) s/ N% p# i" N/ B4 F5 t; O4 k( v. X                .default_trigger = "default-on",
" _) C& E! c; Y( g        },
! x: v; I% j/ e% t8 I1 A};
1 }7 k4 A+ s& O% D2 H1 X( Y3 x) J6 k& {$ {% i, W8 B+ w
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {  W0 z( l3 m, ]
        .leds = da850_evm_tl_leds,
% q$ M( M) r' F$ F5 K8 K1 O" D! y6 n        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 X: K/ D5 Y' Q' x  ^+ S};" ~" x  H% @% C* ^% a- a6 Q

/ b' c3 h7 c1 J6 `# ?+ `7 Ystatic void led_dev_release(struct device *dev)
+ u/ @$ M3 u0 E: j{8 f1 {+ J. z& E# k/ S* K2 T
};
) ~! x3 A( a: D
: p; L. s+ W- V5 l8 n+ l- R. gstatic struct platform_device da850_evm_tl_leds_device = {
3 \" n3 r# w+ P- Q/ W+ x- x% g        .name                = "leds-gpio",/ a  u' I" C6 b4 t/ D
        .id                = 1,
3 X) b0 [4 h7 [$ I- W7 X        .dev = {# _! H4 p! h) S* @1 [7 g
                .platform_data = &da850_evm_tl_leds_pdata,7 {8 r/ r0 l) ~3 e8 [" j
                .release = led_dev_release,% ^- I) b- S, @: I0 v
        }
6 d* ]- z% j, Q2 V7 e+ z$ S* g7 m};2 L9 B$ t9 ?0 q& J3 H  l1 q) T

7 r! u2 L" F0 r' Q* {1 i9 `0 F0 s" _  [static int __init led_platform_init(void)
& L  ~. Z& w% q+ X( F{8 H. t- Z* @/ a: G! t) f
        int ret;
. V, V: [* V  I  l( @9 F3 V#if 0
/ i* x+ s+ X1 b" t% d        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* u7 P' ?6 l2 L1 y, W# v" Y: J; B$ w        if (ret)
' t1 U/ S2 E, t% A4 ~+ R, N                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! w9 [% r1 c8 e+ [( [+ g
                                "%d\n", ret);3 p* k! r7 \8 K$ l1 j' Z8 w
#endif
5 @: \; S7 S% P3 \        ret = platform_device_register(&da850_evm_tl_leds_device);
. @, i" c7 L5 o; T        if (ret)
! {& v$ i$ r3 a" @                pr_warning("Could not register som GPIO expander LEDS");/ \3 g" B% S! J# a) h: Y0 L# e' ^
        else0 V8 d* v! c! A- m+ M) N
                printk(KERN_INFO "LED register sucessful!\n");
$ X+ |; n$ T& Z/ J# C' b7 O& B5 E, H! J) N5 y
        return ret;! `5 u6 G! h+ K1 |
}0 [/ l1 X6 ^& O! V/ P# d
- i9 X+ p2 a: w& i
static void __exit led_platform_exit(void)
6 w+ f5 K2 t, w( A4 l$ V- f! m{1 n- e0 I2 M# V$ R5 v. R5 H
        platform_device_unregister(&da850_evm_tl_leds_device);+ ^) N- p7 k/ X& z
8 X  I! A6 \1 X0 K- b! |& w$ h
        printk(KERN_INFO "LED unregister!\n");3 z$ p; T$ C% w8 c! ?
}; {* v) i, I9 M7 Y7 U0 F7 M7 ?

: g# b6 f& g6 S5 Rmodule_init(led_platform_init);3 S$ k6 ~8 u* i: z! E
module_exit(led_platform_exit);& u$ o  Q# V7 O- `1 g

8 M/ F/ i4 A) c5 R5 R( u% rMODULE_DESCRIPTION("Led platform driver");* Q8 u8 a9 M: l5 M. i+ l
MODULE_AUTHOR("Tronlong");8 [& i/ o, {9 A& g/ O
MODULE_LICENSE("GPL");
1 o* ~& S8 O" i; A( H+ ^. ~8 P8 V2 M+ J; a* U$ Q$ A& k1 h
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-29 22:21 , Processed in 0.039334 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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