程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。9 I  {* q& i/ R# P
#include <linux/init.h>
3 [+ M  X7 w# @. e0 c* [#include <linux/module.h>
2 }) i6 x# b+ l; T5 z#include <linux/kernel.h>
' D4 y/ {3 `3 E6 {! A* a4 s* x2 e, r#include <linux/types.h>* o1 }2 q" w* n3 T: x
#include <linux/gpio.h>7 Y6 d" a& |" ^1 c) s5 o: x
#include <linux/leds.h>: t% U- q- y  X0 o: N6 p
#include <linux/platform_device.h>
' c) X5 a, O- E/ F* m
3 ~! \  n8 v7 r: ?& y7 i#include <asm/mach-types.h>, j& ]# d$ z6 y3 h
#include <asm/mach/arch.h>) j4 b$ {/ @' D1 a3 d1 h/ D
#include <mach/da8xx.h>
0 Z0 A6 O( I3 N' e! o* i* ?' w: B& {#include <mach/mux.h>% y) w! L3 K0 F2 A) p/ n
; \# M7 U8 `4 N6 e! h& ]2 S
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)3 J4 \: V; [7 L0 {* x  n. C& L0 ?) [
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5), f& s5 u4 ?6 F, w$ q
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)$ l$ [$ i/ S) J) _; I2 O
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
/ ~9 D' p' A- m; z- y: s) e# A# D6 J: k* B
/* assign the tl som board LED-GPIOs*/
$ M$ e% v' E5 a( b! A& t4 jstatic const short da850_evm_tl_user_led_pins[] = {: V1 q) @+ N8 m# J7 ^. J+ s
        /* These pins are definition at <mach/mux.h> file */% ?! R+ T2 w: q8 ^' h, a
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 H+ f; u: s3 Z. n/ Y5 C5 `, D        -1" @/ D  w' w: |  H# S
};
( G* q+ P; Y' _
8 y" M0 K, h" W" `static struct gpio_led da850_evm_tl_leds[] = {
2 E, w  S# [+ R& `4 P9 A' P+ Z        {
* E1 ~9 d) [/ ]% V/ `* F) F- S  B: G                .active_low = 0,8 k! `$ e1 p& c6 O
                .gpio = DA850_USER_LED0,& \8 r4 \3 N! n  k- t5 T
                .name = "user_led0",
) X) B; z- _7 |$ r* ?, j$ y2 J                .default_trigger = "default-on",/ m+ R! ^8 B1 s; {5 d0 |9 H+ J2 [) O
        },+ `7 N: U7 k3 u1 C2 c6 L$ x
        {
4 G. ~. B  D4 A7 z                .active_low = 0,9 F/ X0 v$ p3 P
                .gpio = DA850_USER_LED1,- K9 X+ m( z& {0 C2 P: W
                .name = "user_led1",: w3 A  Y& v) \3 u
                .default_trigger = "default-on",
/ F4 v* F$ l7 v( B        },
! k6 h; i( j2 R! ?: C- B# E        {$ q* x3 Q1 O, g
                .active_low = 0,3 f5 _# a' B5 Y* ~
                .gpio = DA850_USER_LED2,5 e- G7 s' S8 n' v
                .name = "user_led2",
3 N: w# V3 v$ y) D                .default_trigger = "default-on",3 n; K2 w# z5 u) X0 J2 x0 Q' e
        },
9 O6 L, I- A9 m0 ]* \% e        {/ o+ x: J8 m& `3 g4 c8 p
                .active_low = 0,9 w+ t0 \/ g% T* e
                .gpio = DA850_USER_LED3,; H1 k2 a6 \0 B# `/ K6 E
                .name = "user_led3",; h3 K4 Y& O( A
                .default_trigger = "default-on",
' J1 e3 H: A) W4 I        },
. Z4 V- l2 [( S% N/ t# r};( Q9 O  S9 Z0 |% G; V# P

7 e* m2 ~2 [- e% Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. Q. \! X; E7 v3 Z6 G1 q        .leds = da850_evm_tl_leds,
' d( C7 S9 o4 \! c  n3 A+ M        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: P; a: C0 p; Z! S};
! p: I5 l) T  S* [! @' Y
( B; j" i7 J4 Y$ Cstatic void led_dev_release(struct device *dev)
0 w8 F% X- S0 q{, C, d! D' m0 x
};
% `' S: `0 i5 q6 d
- h/ [4 L5 K9 F  D* E' @* istatic struct platform_device da850_evm_tl_leds_device = {+ a5 R4 A! G1 K4 K) {
        .name                = "leds-gpio",
% M2 m) n, Y9 \8 I0 ^2 K; v        .id                = 1,+ _5 D- ~  @: @8 k7 s3 c
        .dev = {# q; c( Z* X  Z% ^
                .platform_data = &da850_evm_tl_leds_pdata,7 G/ s4 L9 R- v$ P* b
                .release = led_dev_release,
7 R3 {3 e8 U! H4 V" X' Z        }
* Y% i* L* O5 l( T- U};0 I- \" n* N) ^' ]6 f6 \

: H" g6 \6 A, t0 q: g8 A6 s2 Qstatic int __init led_platform_init(void)
1 n0 \6 X! W$ g$ ?1 g) D+ D4 Y+ _{
: f/ f0 Q2 P% g6 g        int ret;
" r! f- x4 V) m$ ?, o#if 0
; f1 G" w/ g# V        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% n- H8 ^) `7 c" G) y$ e$ `
        if (ret)! X! W0 w# P+ u8 Y, T) }5 Z& {
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 s9 o, [! o# q; ~4 D
                                "%d\n", ret);
, S% c( U1 }  o1 L2 E3 e& U#endif
/ J' q: x3 T) B6 ~* l5 [& \        ret = platform_device_register(&da850_evm_tl_leds_device);$ G3 O" t. |) m: _
        if (ret)
- M' v; U, Y+ D" c8 S                pr_warning("Could not register som GPIO expander LEDS");
) t! r5 o* ~. v. O        else6 l# s$ [: n+ q. g2 R1 X. s
                printk(KERN_INFO "LED register sucessful!\n");
3 d. d9 G4 M/ K4 G0 ^( Z; H* m$ P
3 i- ~9 [4 j  p# \, e8 ]        return ret;
' z% l" _0 M5 p}
3 J; g8 Y% ?; {' B% J  g+ c8 F1 ]5 z$ l& l2 U0 z; u
static void __exit led_platform_exit(void)
" n; R% D& z+ m( \{
+ A2 @" g5 r% i5 V1 w5 _$ r8 ]3 H, R        platform_device_unregister(&da850_evm_tl_leds_device);
  Q" j( x; b, A( }% E& g. [3 y8 m
9 U7 S2 U' z7 y3 B7 O        printk(KERN_INFO "LED unregister!\n");$ M0 R# \; _6 u7 x0 R; b8 }/ M- c
}# H( G4 Q1 d& C2 D. D/ V

6 V) X9 a) `' C+ K- W/ kmodule_init(led_platform_init);( X) G) e# @$ L& N* u
module_exit(led_platform_exit);
  ]" J/ E! d; f# L" D: _" F
5 P0 ~6 o: c: ^+ L  ~MODULE_DESCRIPTION("Led platform driver");
6 U; ]! E, t4 W7 `# d0 wMODULE_AUTHOR("Tronlong");
9 R1 R6 K- \, N* ~MODULE_LICENSE("GPL");
3 c: p+ r( r8 d% }# m6 T4 @! @* {
, \) O, k# y, T* G. W, Z
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-11 15:05 , Processed in 0.044957 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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