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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
- o3 G: x1 c/ }#include <linux/init.h>
) S. I! q1 w, r  }" s4 P#include <linux/module.h>
/ f( w* h9 X- B& O#include <linux/kernel.h>* K1 p8 E# N5 U2 j' x$ }
#include <linux/types.h>, f  n# d# A! o' l! \
#include <linux/gpio.h>% N& o& {; C5 q* F3 n
#include <linux/leds.h>
- W1 }1 }( J4 a; f% O#include <linux/platform_device.h>
- t* Y0 b9 M9 b# |" W7 G# S5 m6 f9 h
#include <asm/mach-types.h>
4 C* l, I6 p+ q7 ]9 c#include <asm/mach/arch.h>
! I4 O7 G; x2 ]; C. h#include <mach/da8xx.h>
8 ]9 m; g" c+ K" {  c- y, J#include <mach/mux.h>
2 m' U1 i6 i) e' S6 @" S+ d& y0 [- F8 r* Y2 w# W  J
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)2 `: ^( L1 Q% r8 G" d; |
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
. X' {6 o* B2 U: H# X#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)3 B- P0 f. D8 P: K& i( X7 A
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
) F4 z' Z( ?; Y( f4 f; k
  R8 l# B+ T0 F6 m1 I/* assign the tl som board LED-GPIOs*/
' n0 m0 I7 Z& L6 U/ a4 Nstatic const short da850_evm_tl_user_led_pins[] = {  ?9 h* I) l- ~1 @% U
        /* These pins are definition at <mach/mux.h> file */
0 c% ]5 v4 k( w5 T, s8 K        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; P9 o. j1 D# t8 V
        -1
8 u" P* ^4 [% Q; b! _% t# i6 ]};5 _& {8 G$ K2 W0 u8 y7 e. `- O4 [
% i; {# C7 W+ J/ ~1 J. E
static struct gpio_led da850_evm_tl_leds[] = {) I- {0 u: B3 h' [
        {
; {+ g8 W2 o* {' _                .active_low = 0,0 i! A/ Z# l% x* ^+ X$ j
                .gpio = DA850_USER_LED0,
9 a1 ?8 h9 [$ @% @1 A; n" s* {                .name = "user_led0",
  h! e, n4 H/ N) q" c- `2 Q                .default_trigger = "default-on",) l9 ~- c: s9 a& U- p
        },
% m" I. M/ n% W/ i0 _* s2 t. j! A        {* P2 \) @4 U- A) q  F. S4 c3 I6 Z5 u
                .active_low = 0,0 B+ A, g: {7 V% e; ]+ t
                .gpio = DA850_USER_LED1,
4 `: t# d1 _+ K3 }# {( {7 t/ O                .name = "user_led1",$ b- c" y% C6 Y$ X
                .default_trigger = "default-on",
+ a- A6 o- b2 Z7 q* R        },
) `0 j, y" I0 s" T/ G0 K1 N        {
; S# C( J% \, j! s+ v' H                .active_low = 0,7 {0 K  J* \* c
                .gpio = DA850_USER_LED2,( j+ b8 l8 }) T  x4 a/ a1 @, g  @
                .name = "user_led2",
6 u- v) V$ s# K+ I                .default_trigger = "default-on",/ ~: v+ M$ K, c6 A
        },8 }. Q: E5 O  m* C, \6 y. U
        {
/ U/ o4 O: o( z( Z                .active_low = 0,* S! C! A9 D. t% `( T
                .gpio = DA850_USER_LED3,
) C) ?, H! h0 |4 b. j                .name = "user_led3",
: e( s9 @' Z3 w* C0 d; E$ m* i0 F                .default_trigger = "default-on",
$ F8 t% k0 `' V# ~        },
3 H" p; r; n" W1 z% W};
. k4 e0 b( @0 u( r( n# `6 K$ m( m% q* n3 t) W1 }
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ I: y  ~5 B6 X. P& ^  n  f/ |' d) d        .leds = da850_evm_tl_leds,, _* ]$ G* _; {
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ U9 a9 y" Q& u1 l
};
% i$ O6 D% H8 z, Q. f' ^: o2 y. U% P6 A9 T! \3 w
static void led_dev_release(struct device *dev)
) E, |6 l7 G3 t% [{  \  V6 a+ K; a3 w4 s' X1 k
};5 ~% G5 Q' E  D
+ ^6 ?# l" N7 Z9 O
static struct platform_device da850_evm_tl_leds_device = {
" G5 P& m$ g, _  v  e# ~        .name                = "leds-gpio",2 Z7 C, V0 |% x1 a: o; O
        .id                = 1,7 C& ?' ]- v$ ]/ u; z3 w
        .dev = {
6 ]5 C0 q/ v8 R                .platform_data = &da850_evm_tl_leds_pdata,
$ Q. O# Z- {8 M* w" n                .release = led_dev_release,
7 A& ~' r+ d& z" q* K        }
0 \7 C. V, J8 ~) U};0 \. ]( [0 _1 i9 f

% I$ [" n8 D; c9 j4 Xstatic int __init led_platform_init(void). i" B" |" J0 @) V2 R1 P
{  w$ j) {' N; B2 b4 l7 s# Y( Y* W
        int ret;# C; E. y; O. Q/ C& X# z
#if 0
  j" B  _. S  q. u3 I' E; r        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 u7 L$ y8 F/ n: h' Q3 Q        if (ret)3 z6 Q) R% K3 s( d! _- l
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- u) T* Z8 ~- k# t4 D1 b* Q/ H% j7 i
                                "%d\n", ret);" B8 r0 {% C4 X( i! k" H
#endif
/ p/ |5 q7 k% Y- r        ret = platform_device_register(&da850_evm_tl_leds_device);1 ~% R/ ~3 H0 V
        if (ret): Z. _! [$ s8 G. D
                pr_warning("Could not register som GPIO expander LEDS");; g0 r7 d2 N7 G# ?7 F3 u
        else4 T0 Y. ?: \0 F5 m5 F
                printk(KERN_INFO "LED register sucessful!\n");6 B& `+ r2 l( S* @) ?  Y( u  q
% S- o9 Q4 c; H
        return ret;7 P) Q, c# W! a6 A, J# Q2 u
}
8 o' y" U7 L' Q/ G7 Y" l* \4 f
+ f) l: p: Q1 \static void __exit led_platform_exit(void)% {, H! N' R+ v& n, d# h- m5 E3 j8 {
{
9 g  q; P# S4 |* S        platform_device_unregister(&da850_evm_tl_leds_device);
# f/ `+ n; n3 S' B/ q1 g
( P! L6 m* s6 U( M0 X( t3 F        printk(KERN_INFO "LED unregister!\n");
9 b. L  ^, Y1 y: ]; k  B5 ^$ w}* z: _4 h) q$ d. p& |2 M0 a
$ D! H7 L# g& y- C% F
module_init(led_platform_init);
; N+ r  y6 \% g2 ?4 l! bmodule_exit(led_platform_exit);* A1 K3 i* S' h$ H1 r& m3 ~
: L# |5 Z6 c* R- j8 @! s! _
MODULE_DESCRIPTION("Led platform driver");
4 _: W/ o! n0 MMODULE_AUTHOR("Tronlong");
/ x5 s8 P% a. i8 M; a# ]MODULE_LICENSE("GPL");
5 W& O, Y+ D* ~
) Q: g  L8 b2 ^2 f+ K6 X" @7 z& ^; L
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-10-14 06:50 , Processed in 0.041111 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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