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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。! G9 i% |, H4 f1 Z5 K" G
#include <linux/init.h>
1 _+ u: X- c8 J% Y$ N+ H3 `3 A#include <linux/module.h>1 \) f3 i) b/ b3 w! G  _
#include <linux/kernel.h>
2 h- b% G+ J  @- A- Q+ c#include <linux/types.h>' ~+ h* \8 F5 O  N1 B8 z2 l
#include <linux/gpio.h>
" I9 z/ X# e. k. O) H#include <linux/leds.h># I) Y0 v6 c( ^6 z/ b) k
#include <linux/platform_device.h>" D+ i9 q4 |0 q

2 P  G! G6 n: G, N+ j" [" O#include <asm/mach-types.h>
( s% x% n: u1 b2 c; ?# E#include <asm/mach/arch.h>
, Z. |  D* ~. J, d7 }4 N; p#include <mach/da8xx.h>3 j9 F2 b/ A' S; [
#include <mach/mux.h># m9 H( ~2 T1 p3 u9 V; `9 S# J# u

3 D! F2 R2 _- Q5 r4 l#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)0 }7 q. m% R4 ], t
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)7 ~4 N" k0 k; N8 v; W
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
  _3 v, `7 ~% b" e! i- P#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)' r3 O9 s/ u  n

7 u  g) ?6 S* I/* assign the tl som board LED-GPIOs*/' i0 a  ?! f. n1 k+ Z8 S" ^
static const short da850_evm_tl_user_led_pins[] = {( F9 f. L) Z! v! d3 U7 L
        /* These pins are definition at <mach/mux.h> file */- e* x3 ^( p; J% y& u
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ i6 K* ^1 I, d8 I- S
        -17 j' s& ~7 }0 c8 p/ F1 E/ d
};8 p8 u" N$ ^5 S' Y
1 E2 k2 t3 M! Y) m
static struct gpio_led da850_evm_tl_leds[] = {
( R& y4 m6 }  L, A/ H7 a+ s+ A, i; N        {
% C$ T1 K/ O; ^                .active_low = 0,
1 L; p3 Y$ D# g                .gpio = DA850_USER_LED0,3 O% K  [0 P3 V
                .name = "user_led0",) f2 y) K: H& O. ?( E
                .default_trigger = "default-on",
% {1 Z% |( _- ]" Z! t' ^( Z        },
9 ^7 b( S+ X2 V& Y+ s0 j: [        {( @# x1 T4 k, R$ f" y
                .active_low = 0,1 s% T0 y, ^- m7 b  t
                .gpio = DA850_USER_LED1,
3 R% W, H1 A% @4 S5 b5 r8 J/ a                .name = "user_led1",; J% s9 h: A% D9 F' B, I
                .default_trigger = "default-on",
7 e0 i+ R6 t0 t7 c3 Y! S        },: x8 J4 Q9 J; r3 ~8 u
        {4 z7 o; V* p7 \4 m* {0 b
                .active_low = 0,
% c0 Y. a5 p( M0 F. ?; R                .gpio = DA850_USER_LED2,+ w  m  h, P! L5 g
                .name = "user_led2",; U) K2 B& O/ u8 N% _, N! X+ N: x
                .default_trigger = "default-on",
9 K! v/ o7 R2 I3 X2 w. \- m4 b        },
4 a8 R5 Z6 t4 F* h# f, @) y+ L        {9 |1 C" R" x9 Q# ~% Q
                .active_low = 0,
: X5 N0 l% S: Y& x6 N4 ^$ W                .gpio = DA850_USER_LED3,
* y7 E1 \/ X) f5 m                .name = "user_led3",9 F) @3 J/ Y' y
                .default_trigger = "default-on",: o9 E- \: l  s+ P
        },
- z- F* _9 Z: \5 I};3 x3 ~: I! w; e" i

) o( g5 w& C0 S2 T9 ]! B0 k* Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' _3 a# u- m$ A/ e( h        .leds = da850_evm_tl_leds,
% J; q5 ?6 S7 a6 C4 @2 I        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
  ?9 a8 y! b+ [3 Q% q1 H1 H$ J0 q4 p};
4 |9 T% W+ N0 L) B: @9 X- q8 G# c0 I% T3 ^
static void led_dev_release(struct device *dev)1 N8 {# i8 ]6 y  \$ d! }
{+ M# w  s5 P% E4 M8 t* P6 I
};
7 h0 X7 B( O; t0 o0 L3 L- U2 I- F. V& H. m
static struct platform_device da850_evm_tl_leds_device = {$ t) @0 m( W" s" L1 B
        .name                = "leds-gpio",
( f! n# l8 [7 y4 E8 Z; k        .id                = 1,4 Z1 D3 m6 [! G; F
        .dev = {* Z  \3 u: r0 T
                .platform_data = &da850_evm_tl_leds_pdata,7 `# j) d* ]7 B: {/ s9 W0 q" w
                .release = led_dev_release,
9 f  X2 R* ?5 L7 k. I        }
0 \* a' `* \  R6 F8 ]- P, F};
$ S( j& K5 A- f1 A  q* T0 u& n8 g; p0 Y) c& o
static int __init led_platform_init(void)7 N+ x  j9 m( j: o, o' a3 y% {
{
) J9 o* T/ n% z3 N7 z& m9 k        int ret;+ S+ ]+ G( i2 O4 T$ {+ \* Q; ?
#if 0
0 E" v# D; {& O  r8 E        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# o/ r( h2 e  m3 f: H* V' M% J        if (ret)0 V, Z5 U. m6 ^$ g! g9 Z7 F
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ @& O. _, i% `+ U* M  Z$ q                                "%d\n", ret);1 K6 q; k! u5 x7 r6 e- A- r( @
#endif
2 r0 R9 T7 k& |. t, l% H        ret = platform_device_register(&da850_evm_tl_leds_device);. d( H( E+ L& L& R
        if (ret)' _7 C4 t: W0 m- _. d8 {8 z3 o1 ^
                pr_warning("Could not register som GPIO expander LEDS");* V$ g% K1 R  X5 h/ H/ |5 c
        else( O+ _) a7 \% Z5 ~+ b
                printk(KERN_INFO "LED register sucessful!\n");
! {* E  d. q4 v9 o* f( X. q: H/ A: _2 [  m
        return ret;% Q' x  p) ~3 i; j# X
}
" q' B1 e, n; v: c8 W4 S5 r
  g4 O8 u2 n8 K- [6 F9 Tstatic void __exit led_platform_exit(void)5 s9 g0 n( r# e! M. L6 q7 I; V6 V
{: k( G; i# m+ t. R
        platform_device_unregister(&da850_evm_tl_leds_device);
  d0 ~$ S& C+ \3 n2 W8 W/ z6 y) b- }" Q/ j/ `
        printk(KERN_INFO "LED unregister!\n");
5 K3 y1 G% M3 q2 }, V1 m( V$ @7 ?}
3 N4 \1 L; W7 p
0 F% [, M2 }. |7 y0 B5 I$ {module_init(led_platform_init);' j, ^( [0 P1 b, D0 u: W3 W7 Z
module_exit(led_platform_exit);6 R% Q9 U9 V- F
5 k4 k) D+ @! ^
MODULE_DESCRIPTION("Led platform driver");6 Q! Z. h# w- X3 O! L  W' H
MODULE_AUTHOR("Tronlong");& E+ s! w% E" Y. I* i
MODULE_LICENSE("GPL");! h  H! @! R2 _+ o) q6 {3 ?0 m" s
# |3 \2 Q& W5 ?: J
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-17 12:11 , Processed in 0.042213 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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