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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。( J) z* k7 s" D" h
#include <linux/init.h>
/ d4 |3 Y3 t: d/ }7 |$ p. n#include <linux/module.h>5 r/ `' K# U7 _$ x% V
#include <linux/kernel.h>
! P  N; x% O: D  X8 p#include <linux/types.h>8 K  [  B" J, `' ~, c
#include <linux/gpio.h>
2 |. S: F( j6 c6 N- K#include <linux/leds.h>
/ @1 Z- H8 V/ o' z#include <linux/platform_device.h>
# e9 l. d" W! N6 j! }* i; u/ P/ d% k- g% I
#include <asm/mach-types.h>
' z& j( [- }5 z! ^& `  h6 j#include <asm/mach/arch.h>
, f" c# F# F$ k9 X- t" H1 Z1 _" C#include <mach/da8xx.h>0 T4 P' R# z8 t; E
#include <mach/mux.h>/ M0 I; V" A1 h: b: w( q/ N- A

5 T, }  m- P2 t& C& [: s#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)& ^6 M4 c: A$ t8 R6 l
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)% `6 k. u" H4 x" D
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
; A& s7 {9 _" F' X. {9 P: |#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)  O- z7 q3 c8 r5 |3 _
# j5 a7 U, o* K, g; I& S2 v" Q- H
/* assign the tl som board LED-GPIOs*/
+ S' j/ ]& ~# w& c/ q5 Istatic const short da850_evm_tl_user_led_pins[] = {
. _3 h! X2 Y  t- K1 j/ J, n        /* These pins are definition at <mach/mux.h> file */
* s! _! J4 w, A& Z        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, G$ V4 _6 M" E7 k9 @        -1
& w" N$ Z4 e$ x2 u- c" `};
0 S+ W8 j  C# j, P6 M* J" Y
: t+ q- }. V1 F) ustatic struct gpio_led da850_evm_tl_leds[] = {$ r+ X( l" H- f1 y3 v
        {
! {" v, O  U+ T3 E* p+ S                .active_low = 0,3 i2 }& U, y" _- J
                .gpio = DA850_USER_LED0,
# {1 N& z, E+ V. M* C* q                .name = "user_led0",
$ m, U, O3 F, ]7 T% s                .default_trigger = "default-on",
% u; \0 N* Y2 Y) H( p+ U/ L/ |        },2 p! m$ i( T. w
        {
- b- {* ]0 T2 Q4 A$ u7 ?                .active_low = 0,: c* q. m- l; t! o3 n4 q( k  g
                .gpio = DA850_USER_LED1,& H( q( P/ f8 L) q' M0 g  d
                .name = "user_led1",
' ^5 B. g& T: s                .default_trigger = "default-on",
8 q- L6 C. j2 \' `        },- j+ E' m+ Q& }( M# M+ @6 `
        {1 B* P# B3 k& a4 l. s- M) N, r
                .active_low = 0,: B! [, R5 q! q6 e0 u% v+ q$ g
                .gpio = DA850_USER_LED2,' G6 D4 Q# E+ k# k% c. p$ o
                .name = "user_led2",$ n5 ~% Q# @+ E+ |
                .default_trigger = "default-on",, [3 _6 H/ K1 g" H- g* t
        },
! w' K. Q% A7 {" ?* Z* M8 L3 \        {; @* T# n6 |) X( i4 n
                .active_low = 0,
) V. @+ Z7 b+ |0 r- b( s: u                .gpio = DA850_USER_LED3,; n' ?9 S  t) [
                .name = "user_led3",
" H# F" K! z- t1 G6 J2 m/ e                .default_trigger = "default-on",3 z+ r% M$ y2 e- u8 y+ z
        },/ f! o* X* R  s' y0 {8 N% w( o4 f
};
/ e3 F' P# |$ i
  D9 y. V( l# A# t: n9 I) {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 h, c. y) C* z$ C
        .leds = da850_evm_tl_leds,  J8 D: D" O$ D8 }, v
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! G8 W: E( w6 a$ T9 U/ C' v};0 Q- X& A. Y8 Z: I) F! A6 d
& r' Z9 l; _" F' ~, ~8 E( r$ ^
static void led_dev_release(struct device *dev)# G) x( ]  x! D# C
{' T. X1 m5 y( k: F1 ^7 I5 A; ?8 l
};" L2 U& j7 @# _6 ]* w. e

( g# P5 @; C. L6 tstatic struct platform_device da850_evm_tl_leds_device = {
! Q' ]# x& k" M$ s( m: s% R- Z        .name                = "leds-gpio",' _; }7 n/ |( G% A; G* L, _
        .id                = 1,9 ]( q# w9 o* ^* ~9 ]* e6 r4 N
        .dev = {
4 J* V/ N/ \9 s/ _% V                .platform_data = &da850_evm_tl_leds_pdata,
9 x6 j4 ?- @4 ~; D  {                .release = led_dev_release,6 _2 J2 _  A3 }( h( L2 l% L: D1 w
        }$ R% O; m& T& z, D: {2 E
};. R3 t! `3 Z. d. s! ~
) t  w% w/ R% A- d
static int __init led_platform_init(void)- l8 f+ H( Z9 W
{& j! D5 V: {9 T
        int ret;
& _% P/ ?2 ~  L3 c  ^* s8 G3 s# K#if 0. p/ Z/ H5 {8 b" b0 P
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 w! h2 V7 n9 e7 n$ F! u( M4 P) L& {; g0 m
        if (ret)
0 F2 N) I8 W3 s  ?                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" Z6 a* P; K( @* W
                                "%d\n", ret);
! T& J$ n" B$ c% Y" `#endif1 [. p" ]+ L2 a
        ret = platform_device_register(&da850_evm_tl_leds_device);$ m" _0 t3 i7 p' b- \! m+ b
        if (ret)
# P1 Y' Y; m- o5 V8 {                pr_warning("Could not register som GPIO expander LEDS");; L7 |# @9 k7 w0 u, Q% u: H$ n
        else1 s' n/ T- z- u" j* W
                printk(KERN_INFO "LED register sucessful!\n");( }# K5 D3 T' J+ I: v
1 ?0 _3 b* Z% o, X& d$ \% x
        return ret;7 S6 y8 o0 A) {0 S7 K
}
: w8 J: _! R* w; t4 |+ e! k. f. u# ]3 s4 w
static void __exit led_platform_exit(void)2 j& t8 l$ l' R3 [, F9 b* \: D+ Q
{8 Z! ?) [$ M+ @5 G
        platform_device_unregister(&da850_evm_tl_leds_device);
0 p2 O) `6 V0 T; l/ S8 C1 |) O! q3 Z: w4 q+ M% O% V
        printk(KERN_INFO "LED unregister!\n");/ G2 v1 n' g7 T7 A& x, f
}( t3 x1 U5 U% t  n* @
# g& @( e  S" o4 m0 H
module_init(led_platform_init);" k7 K( b! @1 H, t9 w
module_exit(led_platform_exit);
( p7 L( i0 b/ U: J% k/ e) f2 s
' L2 E% ]3 T) u( yMODULE_DESCRIPTION("Led platform driver");6 Q$ s4 G9 w# ^7 P% l* l$ F& N
MODULE_AUTHOR("Tronlong");$ S7 _' ^5 |$ u8 s! R/ X4 {2 D
MODULE_LICENSE("GPL");7 z; i, i% L4 G

: J0 q( P" g( l; v7 P. O$ e) f
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-9-25 03:31 , Processed in 0.049199 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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