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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。- X1 s+ X+ {1 l' t( p4 h4 E
#include <linux/init.h>
( n+ A* z" h+ I4 H: ]#include <linux/module.h>
. w! C$ E$ ^# u& s: f+ K: I! r#include <linux/kernel.h>4 [* F0 y& u) A& W
#include <linux/types.h>
! |) z1 n5 Z; [6 a6 W# x1 i#include <linux/gpio.h>; _3 h9 i1 s: d( a9 s
#include <linux/leds.h>
' I6 L9 t6 o  Z( Z# p$ w3 d#include <linux/platform_device.h>
, i4 E: P9 F% [- j( q) v# H8 P1 V6 q% v
#include <asm/mach-types.h># R$ r: B! q3 k/ h8 t
#include <asm/mach/arch.h>
3 |' y9 U2 h* Q; |( x  y# U: g#include <mach/da8xx.h>, q/ v; i9 C  y" L& {; ^$ X
#include <mach/mux.h># d+ A) M! [) p/ {

: D/ I  @1 l# J9 _* j; q& c1 Q, F2 ~#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
" H+ a5 n( |7 f  k+ P1 R8 `* A* S, Z#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
0 W1 M. n1 r0 e2 d6 y0 {2 e- ]% @#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)5 E% D7 e. u# H/ d' R# I. `" R( x! l
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
! o5 ~1 ]9 g& p9 i- g$ j2 c. v+ Z4 ]* u9 {, n4 m* r9 S
/* assign the tl som board LED-GPIOs*/) H6 @. M# N) E. {. P1 ~# ^: y( c
static const short da850_evm_tl_user_led_pins[] = {3 e2 d" a! ?. R% _7 y' L
        /* These pins are definition at <mach/mux.h> file */
+ f, T4 W/ b/ I9 V        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) k4 z( m# D( D( g* o# T        -1
& K! W% o5 J- p3 W8 M: W* e};
' t4 ~# L' H& p  z' r* J, ~$ g# [1 R9 s3 V
static struct gpio_led da850_evm_tl_leds[] = {
" \  o* A/ m0 |. N/ U        {* v* X" R, C1 c$ e8 o  h' S
                .active_low = 0,5 d* f+ p, W7 Y1 R4 @) m  t0 s
                .gpio = DA850_USER_LED0,
3 X% W  b5 ~) o3 p                .name = "user_led0",
4 i9 u* u4 l% m! }1 F, e4 y  y                .default_trigger = "default-on",+ v$ V# f' B5 E# }1 p$ u
        },2 ~" A  e7 d1 q9 [. f+ H
        {5 v- P0 ?# ^& J7 f
                .active_low = 0,  ]! V: `( t/ F- M5 A7 d
                .gpio = DA850_USER_LED1,* J  V" w! p$ x; P0 ^
                .name = "user_led1",
$ A) s' j" [0 f( Q0 \) F! W& ^9 O                .default_trigger = "default-on",6 {" [; p! `* K/ N
        },
1 {: g9 z- k' \! G* d        {7 ^9 p' V7 o$ M  z
                .active_low = 0,# L4 t( P6 U$ q/ Y" v1 e' W; s
                .gpio = DA850_USER_LED2,, s9 w( ?! M. e! O, |  p. `
                .name = "user_led2",
9 h) J% l; E$ G: Y                .default_trigger = "default-on",# L! S( e- J- O6 j1 q
        },! o4 F, G; F& m' U4 S. w. Z
        {3 O% m! t% Y/ g) {/ E4 X
                .active_low = 0,
7 d8 ]; B1 i4 W7 X% Y, F2 b9 U                .gpio = DA850_USER_LED3," e; o% g" q5 }& p/ `
                .name = "user_led3",3 ]1 @6 T2 P' d& s3 t
                .default_trigger = "default-on",
3 j6 O  |) u  R8 B2 L        },
) ^. d+ }/ N/ @$ a};( [/ t; y( s: m- P
; X) `/ S8 D( v' |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% N' p: u* q- }2 _
        .leds = da850_evm_tl_leds,
' X; d6 g5 y! L* b" C  a9 Y        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, }6 F, _( e! P) D2 b
};  M' ^9 S! G- ]7 ~: J
' q) u% Z9 r, L4 |- b0 v6 ?
static void led_dev_release(struct device *dev)4 i. `8 ]& h# @6 B3 c; h! O* J" w( {
{# Z3 T& Q+ ~4 g1 x. a) T" _
};" S. Q: O7 L8 _; @/ N- P
9 Q9 |9 r# ^, E0 b- {0 F. T: {5 h7 `
static struct platform_device da850_evm_tl_leds_device = {  g. I% y- _  y4 o0 V5 C
        .name                = "leds-gpio",
1 I; F2 y- a5 [7 G$ s, i! W6 S        .id                = 1,
* h5 V5 O* V: K% l' O        .dev = {
9 m" D/ A& d" f; w) {1 G* Q                .platform_data = &da850_evm_tl_leds_pdata,
" k$ x2 X& t$ a6 F* X- p                .release = led_dev_release,
+ F" D( F5 }4 w3 b" @        }. i+ h; e4 M1 d* {- h
};/ J9 c; G7 X  S5 x
1 z; ]# L0 ?5 O1 ]
static int __init led_platform_init(void)
$ C5 N+ H! T& @9 U{
! ]! {' O9 Z/ o; o' P        int ret;
% ?6 [- K" S+ \; A/ |. s8 W5 f7 z#if 0/ D. S" F/ E$ ~6 N, b6 x
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, v5 m5 O) ^+ H  C+ T0 W
        if (ret)( C$ G) D: \$ w, a' ^9 _
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' C! F+ A! v% \" F4 y. N4 [
                                "%d\n", ret);1 P; t6 S- m# j/ s# [5 k9 x, d
#endif% p* \1 V9 z$ h$ k9 `6 O
        ret = platform_device_register(&da850_evm_tl_leds_device);
' j; z; Y  P* `1 R* t8 |2 `        if (ret)  F) i, p2 ^* s% W. y
                pr_warning("Could not register som GPIO expander LEDS");. u; A# }. e- T$ Q4 S
        else
& q+ J$ v" R) ~1 A* _( n9 G$ O$ {$ C) s                printk(KERN_INFO "LED register sucessful!\n");1 {+ n! L1 S  {" x
6 ?$ c6 H; r- l9 W% j8 L2 F
        return ret;# V1 A6 [! I2 {' Q4 J6 Z
}
3 r. [% S/ z6 k9 Q8 f$ }2 c& p* [6 q$ N, `9 {+ L6 H+ Z
static void __exit led_platform_exit(void)
8 t3 P0 C2 M$ E9 r6 c{$ n  D5 L' f1 Y2 V' V# p) C
        platform_device_unregister(&da850_evm_tl_leds_device);
0 D- D" ~; ]  }; k/ k4 g8 d" G/ ]  d. [6 ^0 k
        printk(KERN_INFO "LED unregister!\n");+ q8 X! O8 b* a/ N' O
}- f8 G4 E& O2 C- A& d  w" b4 \* Y; u
" B# E7 K! |* m/ V5 ^( ~/ E, [
module_init(led_platform_init);
! [" B* x; F5 nmodule_exit(led_platform_exit);  k3 `& [. A! \; ?  q
! K3 X. i' E% j  Z" `$ o
MODULE_DESCRIPTION("Led platform driver");& o* q; i0 W2 |. q! _9 f1 X
MODULE_AUTHOR("Tronlong");
, |7 W1 K  N6 c& U/ z  s3 X# yMODULE_LICENSE("GPL");
$ Z5 ^" S! c1 E, V# t# s0 J
! R" Y) l4 H) }0 O% j8 j
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-31 00:15 , Processed in 0.037798 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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