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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
) T4 m2 h" K, h) \#include <linux/init.h>
$ k- N" W0 z8 R1 ?0 Y#include <linux/module.h>
9 W: v& \1 |# T4 a1 H) z8 S. f#include <linux/kernel.h>
0 q# a; p5 K/ ?, E#include <linux/types.h>3 R) [. G- X8 _/ P
#include <linux/gpio.h>
6 F0 D, F0 E* k% w0 G#include <linux/leds.h>8 T5 c2 V6 F2 T" o4 r
#include <linux/platform_device.h>& t2 ~$ c" P/ i( B7 q" s/ Z
: d) h$ h& }0 P
#include <asm/mach-types.h>: [# g7 @/ Y" e' |! x7 Y: M/ O) C
#include <asm/mach/arch.h>
6 k) l( ~( L$ X" d" n% j#include <mach/da8xx.h>. [  w4 J' d, T) c- d2 T9 L. r' x
#include <mach/mux.h>2 p5 n7 i9 w/ y& r# [. @: h/ r
8 n. |/ s- @: y+ Z2 c4 O
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0), A7 [7 u  @  K9 G
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)$ O6 ^: A7 E# O  `( \2 U
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
2 x! d9 {- Z0 `2 h) G#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)0 G$ [& ?8 r1 ]) ?
1 J2 s' }& }' r) \& a7 ^7 k5 l
/* assign the tl som board LED-GPIOs*// w" O+ _& H: X+ L% C% ~+ Y& ]
static const short da850_evm_tl_user_led_pins[] = {
/ G( J/ j2 i( n7 ]; L        /* These pins are definition at <mach/mux.h> file */
4 k2 R  n5 ]. a6 {1 M' w8 [+ v        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& G; A2 X' [1 A2 h
        -1( C! i6 |  z4 `* O7 X
};  W' [( C- i5 p( j

1 L  K8 e9 b: l% ~, S' I5 Astatic struct gpio_led da850_evm_tl_leds[] = {
$ V& u* i% A2 l% {) B8 d9 a        {, r+ T' S( |  E' M2 U8 @' @
                .active_low = 0,
8 V) g( l5 k% S4 O: G& c; g0 k                .gpio = DA850_USER_LED0,, @* G0 R- d7 s9 X2 |
                .name = "user_led0",
$ H- l6 n) x" ~                .default_trigger = "default-on",. a6 L9 X. ^4 J* e
        },
6 ~7 o* s) M$ K        {
2 r% N, \2 b/ n- z+ |" C* l                .active_low = 0,) G& n. ?5 y! H! v7 d
                .gpio = DA850_USER_LED1,- Y, D/ F9 c6 n' d4 d" {) W8 J+ ?
                .name = "user_led1",
% Q" B8 w6 u, j2 T) a+ ~                .default_trigger = "default-on",
& k; q, ]$ t/ {1 I. ]        },
, u( @4 b, J5 t0 d: u+ o        {4 u( k. Z7 H" `' M0 [+ ~1 k+ V( C
                .active_low = 0,
) x9 w8 }& P% C                .gpio = DA850_USER_LED2,
/ I; `1 H! g8 r; m( ?4 f                .name = "user_led2",$ y* c& L. Q8 C$ J3 Y! y
                .default_trigger = "default-on",/ P" F" w# ~) ^8 K9 z4 G0 S
        },( e3 y5 w- R) H0 t. h& w
        {# |8 n/ `" F2 J/ i8 Z. R: P+ Y
                .active_low = 0,
6 w4 s0 F$ R% C3 ]* }( C2 I                .gpio = DA850_USER_LED3,! o3 e9 T0 w+ c, ~% ^2 ]
                .name = "user_led3",
; W; e' c; a7 Y9 U3 E                .default_trigger = "default-on",
$ U1 I1 a& i. `) n% p/ N        },) M, t8 c( s8 T% V! g4 i5 _) F
};
, m6 i" e+ R3 T4 z6 u& k
  Y: P/ E% p% K& I' Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 O) u! o% ]: v! y
        .leds = da850_evm_tl_leds,
1 i7 I* b' h/ E+ r7 f- n9 Z- w6 L$ n        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ a" \" Z2 T3 n: Z
};
8 _7 V0 z1 s4 g" |9 \! m; j" J) M& b2 ?; t' G
static void led_dev_release(struct device *dev)* M. N) P" a3 q( g, c6 ]
{8 D1 U. R. [8 u* K6 o* j, V
};
  d: @; I( {$ b) K$ M& A
* s2 V/ n1 Y* W9 Nstatic struct platform_device da850_evm_tl_leds_device = {
/ N) _0 E' P8 Z% X. k6 A, O+ ?5 {        .name                = "leds-gpio",' Z5 Z) h1 u0 i0 _) j3 y/ p
        .id                = 1,; F" J# u; x* k: L$ N
        .dev = {
9 Q2 \+ S0 s6 j- U                .platform_data = &da850_evm_tl_leds_pdata,
3 F& i+ w/ M8 V. ?" r! K$ {                .release = led_dev_release,4 Z7 E, f# }) O
        }& t0 a, U' {/ w, p6 L. i! ~
};
4 F  a$ Y8 F5 B7 |; I) V$ w: V/ u7 l* C5 Q& R* s
static int __init led_platform_init(void)
, s4 v1 P; G+ ?  q6 {; ?1 l{
+ I) ]+ b3 f5 ]        int ret;
" K0 \- C/ q" ~. m#if 0+ E  H' n% p' |
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ _6 Z/ L) I1 K; z# f/ }- q
        if (ret). j' c4 e, G( f4 v6 u
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# n& {! `2 ^% ]* k$ S                                "%d\n", ret);
( J8 C" Q, g" m; E" t#endif
7 f6 g  Q: ?9 u- Y4 [        ret = platform_device_register(&da850_evm_tl_leds_device);+ {) _9 S) \& f
        if (ret)
4 a+ J) z8 W( S  y+ C& @4 S$ t' Z                pr_warning("Could not register som GPIO expander LEDS");
3 Z7 a5 `1 M: _0 K# t* F/ R4 h        else
5 u% M3 P7 o% a2 Y  h                printk(KERN_INFO "LED register sucessful!\n");# Y0 H% {# T% A; v" {
5 a) {& J9 z) \8 h2 s
        return ret;, V0 j! ?: M) _9 [* k2 N, x
}9 R) b# e2 W  X5 i2 C3 J3 |

" J' [/ u$ l  E! K- Q$ @- Wstatic void __exit led_platform_exit(void)
' w$ K  m- l! p. r0 ^{
; ~, k+ `3 e  N        platform_device_unregister(&da850_evm_tl_leds_device);
' a4 \6 }' F) |' U- s/ P0 s6 c! o1 ^2 g7 z& l  n! m' e4 d
        printk(KERN_INFO "LED unregister!\n");
! `0 O: S- I. W6 B}
) Z. C& s/ b& w% J  ]  I
- C' y9 \0 U: ]% amodule_init(led_platform_init);
% E7 I! S7 s7 i. mmodule_exit(led_platform_exit);8 @: V3 L- A% m' L' s$ t( _$ b

( M3 n2 B- h7 y0 R/ [" H: O- P' ^MODULE_DESCRIPTION("Led platform driver");3 H7 s4 F" i5 i. l4 N+ j0 j9 |
MODULE_AUTHOR("Tronlong");  V; A1 ?1 @2 l# P7 n9 Z: s/ J$ N
MODULE_LICENSE("GPL");6 ^3 c! T5 c# f3 g$ y

/ S) g2 p8 ]6 b, t' P( L# b
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-26 09:07 , Processed in 0.037261 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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