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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。6 F/ n) g/ H& ~6 q- j/ o5 O3 k0 v* c
#include <linux/init.h>
! Q# h$ d( }( d#include <linux/module.h>
" g6 j" n1 y" N#include <linux/kernel.h>. P1 G( @8 o- g8 S
#include <linux/types.h>0 W0 p& J2 x. P$ U1 V
#include <linux/gpio.h>: D; Y# e+ z, T- t8 y
#include <linux/leds.h>
, n) |- N0 |9 S3 J' ^#include <linux/platform_device.h>
3 f9 S1 j# C, l/ z( c: w; @4 {. l0 ^5 t0 S$ ^
#include <asm/mach-types.h>
7 _3 P* M, L# q" B) \#include <asm/mach/arch.h>6 b- x' r: ~& \0 k; z2 d7 K# ?
#include <mach/da8xx.h>! ]8 E( k: F9 P1 R$ i0 j3 o8 h9 D
#include <mach/mux.h>9 O; A5 X4 `& C# H4 E
" i: _$ I( c  M  Q  \
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)# O+ |5 q; W3 e
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
) i& a+ v1 Y2 S. f7 x: Q0 m. X1 c#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
9 X) Q( X8 [7 w, `: s#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
- R2 w6 o( Q, \5 y
% [5 t' G! b4 I- K! S/* assign the tl som board LED-GPIOs*/! u% A5 @8 N) s* S* P8 y' f
static const short da850_evm_tl_user_led_pins[] = {: m, z7 s! v: P* K: }
        /* These pins are definition at <mach/mux.h> file */
1 q0 |, K% i# B        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 k/ i% f( K" H' Z0 A# N        -17 A% ]4 e9 G  p1 Y
};: V! \9 E2 [  B$ t

- V9 X' y+ I1 r  P& pstatic struct gpio_led da850_evm_tl_leds[] = {3 T" n0 K: X0 h+ |
        {( X' I4 ~2 m+ E
                .active_low = 0,/ S2 j( y) g' t2 H5 v$ b4 l
                .gpio = DA850_USER_LED0,
9 P5 w- w* u* P* Y* t! s$ R( S                .name = "user_led0",; y3 ^- o- \, w2 R/ K/ L- N
                .default_trigger = "default-on",. @5 T+ W/ ~' h# C1 _
        },
7 L" N+ S8 Q9 D        {2 W7 K# L7 j9 z: g  M' q1 q1 z1 [
                .active_low = 0,
/ E* T% X; l" {  W. }, a2 B                .gpio = DA850_USER_LED1,
" ^  x, ]9 E9 {, p- V                .name = "user_led1",
9 h) `/ n# I8 A9 Q; g                .default_trigger = "default-on",
: T9 w% m6 N7 [% @        },- T% L- ?) X: c/ F
        {( \6 C' f; I4 f0 s, R& k' Q/ B0 D! O5 H
                .active_low = 0,5 m# o( z7 f; s- U/ s- \6 o+ J: \
                .gpio = DA850_USER_LED2,/ |5 v( C+ u$ s$ Q# [. A
                .name = "user_led2",
4 ^4 ]; C4 A- T. d$ j# D                .default_trigger = "default-on",
$ P8 Z% @& L% h        },; B8 I9 j4 o! S! f
        {+ I" C* J( g7 a6 W9 {
                .active_low = 0,
7 R6 v3 Q* B( J                .gpio = DA850_USER_LED3,/ }5 e3 m5 P* d( ]7 ^
                .name = "user_led3",0 ]# D! g# F9 w# Q
                .default_trigger = "default-on",
  V: N; t5 m9 t* s: ?5 T' h        },7 `9 a6 [, L* g: s) C$ H* q
};
/ S& J6 i2 B" _  k) q5 n) O2 `; U+ m0 t6 O$ F4 G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 P2 @7 ~4 O; \4 u        .leds = da850_evm_tl_leds,( A. q- {. H) Z1 T
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 f. V+ A5 L: A% @
};
8 t7 _( a9 ]0 ~1 e5 B. _7 P% w% f. M' K. h
static void led_dev_release(struct device *dev)
5 V% _1 |; J& [) m. E3 d{
2 D  b! R3 A4 j9 q  u9 f$ H};
, g% f0 T( ^' \- t6 H, k
. Y& g- D3 ^" M7 y( ]0 i" x3 Fstatic struct platform_device da850_evm_tl_leds_device = {
! N7 K7 O% o* d; ^+ \; C" Y: b        .name                = "leds-gpio",
3 n" k( g4 i; l; b+ y( s/ I, a        .id                = 1,
* A- g( x1 f8 k+ R1 f( O5 q        .dev = {/ d! ^/ Q0 D0 P- ^
                .platform_data = &da850_evm_tl_leds_pdata,3 p0 [- y# k  ^9 ]( ?7 h# e+ C6 [3 Q1 h
                .release = led_dev_release,
0 u, K8 T) p3 m. a        }9 n3 a$ G! _: {3 A$ b3 Q! A
};+ O$ u0 h- ^  V9 w: A
8 L- G& w* T0 a% L4 Z
static int __init led_platform_init(void)/ A1 C) e- Q6 N
{# p5 B% i5 F2 `) _+ ^
        int ret;
" w* L3 h' p+ X1 @# g#if 0
: e7 }/ V' k1 |: k5 w        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* K4 o4 g4 q1 L0 g        if (ret)7 W# n: f6 n/ |8 P7 h* c
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- C1 Z5 S: x! h: C5 P) V- ^% _                                "%d\n", ret);
3 Q8 A; W5 z9 p9 N$ Q#endif
4 k$ t; Q" d1 R4 x- O* Q/ L& Y        ret = platform_device_register(&da850_evm_tl_leds_device);
8 K! u: v' b% ]9 I0 X        if (ret)
" Y9 O) K+ Y+ x% A( b1 K% C                pr_warning("Could not register som GPIO expander LEDS");
4 d: B2 m7 g( u1 c7 v7 A. Z7 p# J        else
) `- h+ C% r$ Z4 A2 Q                printk(KERN_INFO "LED register sucessful!\n");
( Q3 E$ T3 p1 ]  t$ h" E$ a0 m5 H7 _3 j3 d- v5 }/ H, e/ I- V. K% W- x& |9 J
        return ret;- Q2 l5 p, s) O3 l7 k4 c
}
) j0 T/ I/ ?8 `; g1 `* L# i" m& G/ i5 D
static void __exit led_platform_exit(void)- G8 W# A6 O+ N  e
{9 U  T* t6 g( \6 R% t' [
        platform_device_unregister(&da850_evm_tl_leds_device);
) D6 ^' z* x8 g- J2 S& [7 P* K9 G# j( N& m
        printk(KERN_INFO "LED unregister!\n");- S" L& U! J2 _  G2 j( i- r; D
}
6 v7 Y4 I' }4 ^2 j/ P3 D# ]
( d" x4 a) p8 X3 J) t4 H) m2 nmodule_init(led_platform_init);
' f" `  J& R6 t# n) Fmodule_exit(led_platform_exit);: ^* B: U5 p! |6 @- n; U7 l; M

/ [" ]* l" @9 Y. P; g. r" ]MODULE_DESCRIPTION("Led platform driver");/ t5 S1 U9 E- M7 ^$ I- o- b' s, g
MODULE_AUTHOR("Tronlong");
, S% g; Y8 ?: |1 ]* |) E6 XMODULE_LICENSE("GPL");
8 G" m1 d; h0 o% y0 |& l6 f# L
5 t2 i/ K. l# f1 w4 R# n9 v! m2 I; D8 G
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-11 18:59 , Processed in 0.052416 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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