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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。- k/ F3 W3 l% e. M* l+ u
#include <linux/init.h>1 K3 g, O! G) Y. m
#include <linux/module.h>* s/ h+ V; m4 c& v# o( X
#include <linux/kernel.h>
! o' J  Y% _% a( z) S#include <linux/types.h>/ @) g7 v1 U4 y& H
#include <linux/gpio.h>8 S+ X, r# |. c( N+ y! f
#include <linux/leds.h>
, t& l* Q2 X9 H# w& g4 G#include <linux/platform_device.h>
4 w0 V' ]# r! _$ p+ L0 q, D  Q" h3 l+ O! m4 X
#include <asm/mach-types.h>
# O$ e. m$ `( n; P5 v. W#include <asm/mach/arch.h>
1 U; m9 h1 c$ P2 \3 g#include <mach/da8xx.h>( ~7 W4 ]. B: F3 T. U0 v
#include <mach/mux.h>
. T3 \' M4 J4 M- _* n; s- M9 h
" z: |; F2 e6 o" U) ]#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
7 j4 _) q3 n4 S# k4 z8 p$ U+ e#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)+ P8 q& V% @% a; D; N
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)+ u7 x% q3 T5 W8 s7 q2 k3 y
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
9 Y  f5 Y  S; f0 a
" d$ ~# s  a+ P" y/* assign the tl som board LED-GPIOs*/
7 P, D1 F5 G# b, f1 Fstatic const short da850_evm_tl_user_led_pins[] = {5 t! [! u) j1 V; N
        /* These pins are definition at <mach/mux.h> file */, J2 w- i2 h. _" A1 G
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 m1 r; n8 Y7 ~: j, T5 a        -1, n8 D) `, a- J+ Z+ a9 K/ A
};6 d$ R: i( v9 m5 `; G

8 h2 j$ A* I, H7 T, y: r# Vstatic struct gpio_led da850_evm_tl_leds[] = {" f2 P: ?; c, n
        {
: O+ W8 e: |9 X! }: f' `6 @                .active_low = 0,' e; f* h: @5 B" F" z! n
                .gpio = DA850_USER_LED0,
% M: A" ^% h+ h* j* z% o  y3 }                .name = "user_led0",
9 E5 G3 L1 e, F  p* ?5 `                .default_trigger = "default-on",
, [0 H) b0 d) k' e: x% I% H$ x        }," |* u7 k  r1 N- a
        {: L% v0 `% ]. S2 E; T
                .active_low = 0,% ?9 j( K: P. o  c( w$ q1 S  O- L
                .gpio = DA850_USER_LED1,
. X: N0 @" r, n7 s                .name = "user_led1"," @( V8 y, P/ t2 w' R
                .default_trigger = "default-on",
4 M, d+ X. U8 `8 X9 X9 D5 ~0 l5 C: _        },4 _3 S# b( I- R! r5 T$ t
        {
. d! Z* e: s: [! W! Y/ X- f                .active_low = 0,
8 ~/ Z- i  x* F+ U$ q- ?6 m4 J                .gpio = DA850_USER_LED2,0 j0 t( k. ?$ J* U, X( Y. \
                .name = "user_led2",% p4 e5 b$ U% A& @  j' f
                .default_trigger = "default-on",
7 b9 q. n* i! d5 N% C' j        },
! u, y& F. {0 W; b+ H9 ?        {7 L  K9 z2 }& d0 D
                .active_low = 0,$ e0 Q9 K& x* Z1 K5 ?! }) y
                .gpio = DA850_USER_LED3,! l- X7 k4 s3 A/ r  a
                .name = "user_led3",
) g4 E' Y4 H  Z/ B/ e                .default_trigger = "default-on",! ]. B! d2 E% h5 A7 ^& s7 Q3 ^+ R
        },
; D) {2 Y% E+ ?- Z3 {& S8 T! Z};
& d9 `7 ~+ o. @4 }7 D2 y! d! @
4 h0 [. R: g& ^/ G) C( r: ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 E1 @: F! V. `$ }' @/ T3 Y  J6 p% O
        .leds = da850_evm_tl_leds,1 M$ b, U3 `4 B, j8 o0 T2 A! ^
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 R* E! E  i6 B* D& z" ^% g4 I+ U! f
};8 A! x: }+ D. [- b  V2 S3 q- V9 y' x
. S  B8 E, V2 k9 S& v% R3 t
static void led_dev_release(struct device *dev)
7 Q1 W5 M4 P, W9 R1 w! X{- \, E# [; h/ R' A
};3 o- N5 b) i4 U

+ w, \! ~+ H( o7 |9 P/ astatic struct platform_device da850_evm_tl_leds_device = {
0 M% ^/ E3 c8 m1 q3 W1 B        .name                = "leds-gpio",
/ C/ U+ D3 E% [  _2 x7 b8 U        .id                = 1,
% Y) s. c6 G% e$ }        .dev = {' [6 N8 d; K2 ^
                .platform_data = &da850_evm_tl_leds_pdata,6 w: B9 g& i4 X. \+ k% E: b$ p% y
                .release = led_dev_release,
% e- G! K" _+ e# S0 x5 @  }/ b# A        }
: D  N, o9 \0 N5 v: D* `};" p+ H0 }& Q7 z+ V, _$ f
/ r2 H$ C% M0 g% i0 u
static int __init led_platform_init(void)# T! F, _0 `9 h1 i# S" R, A
{
* F# q5 Q' ]! {* c' W        int ret;
) I( M; M% [6 Z: f9 k, f& D#if 0
9 e7 [& E) H& S1 c4 G: g8 a        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 c0 a" `0 H' T& |% D. K        if (ret). I: E5 b. q2 @2 v. c( H. Q: s
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ `, {& Y' N* J/ b% M+ m2 y
                                "%d\n", ret);2 I" T0 y' P% b7 J7 z7 v0 g: m
#endif
( b1 ~: i2 K2 l+ |  ~! d8 h! V        ret = platform_device_register(&da850_evm_tl_leds_device);" Z9 c: G! E, Y
        if (ret)
* y# g; S* O1 q& i9 L                pr_warning("Could not register som GPIO expander LEDS");4 h* X/ k' m  Z, A. K+ F
        else
1 t% R; q+ n1 C8 C. W  l                printk(KERN_INFO "LED register sucessful!\n");
7 `) v: p. e& f6 j* i+ `
: F( L) ^* d: n( u8 C" C# C        return ret;$ |, ]  `4 a; F$ K8 f
}  x1 }2 Q" K0 u" [

7 [" I9 F# D# k: i4 C3 Lstatic void __exit led_platform_exit(void)
4 w6 _2 X0 f& m: X% g: M/ h{
1 F5 v4 g+ I$ _7 k  m6 R% E6 r, n        platform_device_unregister(&da850_evm_tl_leds_device);
9 H8 Z( l+ z/ w9 P0 `. D0 C) Q8 b5 R( y+ C+ j0 Y
        printk(KERN_INFO "LED unregister!\n");
; u; w: n3 N+ V$ v1 @}2 X/ |3 t& q$ b/ l/ R: k( n

$ D3 g( [! C) f) bmodule_init(led_platform_init);* E" {6 D$ e$ B
module_exit(led_platform_exit);, g) |+ L8 a7 h3 J8 ?
* ~! s4 E5 M5 r+ k
MODULE_DESCRIPTION("Led platform driver");
2 l  V( v' A$ Z" h, FMODULE_AUTHOR("Tronlong");, `- a, Y; @3 T* n: M$ A6 R! x  ~
MODULE_LICENSE("GPL");9 g( b( l6 H( N/ J$ i) O/ a1 ~; y" q

5 q% _& I/ _0 s/ I: x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-10 06:23 , Processed in 0.048735 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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