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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。) }" [. C2 v$ j
#include <linux/init.h>
& F9 {8 x7 u* ^#include <linux/module.h>
$ O& d3 K) v2 s2 n#include <linux/kernel.h>
7 A$ s, Z- [. Z3 r" U" d  P6 v#include <linux/types.h>8 V5 N. o" T7 ^2 J! n" T: k/ Q& _
#include <linux/gpio.h>: n, Z9 C6 _1 |! s. M
#include <linux/leds.h>7 }. Y( L4 }# y0 y. ?0 O2 K
#include <linux/platform_device.h>
# d# ^' z  _& R  ~" Q1 S/ F3 f3 r' Y% U5 e8 V3 m1 X
#include <asm/mach-types.h>7 O# r: p' I' s
#include <asm/mach/arch.h>* n9 J& G0 a* A1 m; ?7 G5 q) Y4 ^& G
#include <mach/da8xx.h>
) F$ x+ w3 T' ~) Y  |2 C7 B3 F+ X#include <mach/mux.h>4 g$ I8 S# K3 m3 @- b9 z/ B2 H

0 `1 @' n: s3 w, n2 }& ~#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
) k, T; E3 }3 k6 q' ~# U, J2 K#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
5 @" n/ _5 `" e* |, @8 x: f#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
! N2 c( k3 R" k$ T+ q4 w! U#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
$ I# V3 B( y5 [9 A
" M. e# e/ C& @( m( V6 C& a/* assign the tl som board LED-GPIOs*/
8 p: ]) V' s! f/ y+ bstatic const short da850_evm_tl_user_led_pins[] = {
( Z- k6 ?' l1 _- O) s        /* These pins are definition at <mach/mux.h> file */
, [6 |0 Q/ Q' O6 a& ]. n        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," G- f3 j4 ]" k0 Y
        -1
) b7 A( r8 y9 K- B' m};* X% Q0 ~; m7 T  n% t! ~

+ O# i7 `$ ^, M& R+ Zstatic struct gpio_led da850_evm_tl_leds[] = {  o( T' |* K+ ~# |" M" U, b
        {
$ y% e' `6 \4 K& {8 n                .active_low = 0,
$ I; t/ k0 ~; i- S! w! ]                .gpio = DA850_USER_LED0,0 [0 p6 L6 r/ f" U* f# m
                .name = "user_led0",
- x4 O: V8 m8 l" h0 D                .default_trigger = "default-on",% n) R" L# t7 u$ J" ~
        },
: C$ o4 [5 M* p$ E' b2 u8 B        {
% `/ T  P# X8 g2 y: k                .active_low = 0,
* Z. x( R0 f) ?5 v8 S3 p                .gpio = DA850_USER_LED1,
% ^" q) @# Y7 Y                .name = "user_led1"," I6 G& u; m. c2 S; y8 {; J* w' Q  p) ~
                .default_trigger = "default-on",
# S' J+ O$ E- ?# P( P. D+ d        },! w1 i8 h+ I4 w. s
        {
; z) N' x1 A( ~4 [$ a! w; Z                .active_low = 0,
2 K' J( T0 c* X  Q6 Q                .gpio = DA850_USER_LED2,
. N. K5 E4 }  W% {% F                .name = "user_led2",# ~1 U7 @1 z8 h( c1 h% b
                .default_trigger = "default-on",
8 `" E: h( p/ T  `6 p- Q8 L" M        },
4 N) k" s+ A# \3 Z! E' X        {
% k: F0 S% N3 U8 D# ]$ c" n                .active_low = 0,
- i* i$ ^: s! M- Q2 I5 U" I4 R$ f3 b. S                .gpio = DA850_USER_LED3,
( m* G3 f+ @) e( {& d                .name = "user_led3",
$ y& L+ e+ g* v0 U- J" U                .default_trigger = "default-on",
! }7 h$ |9 |/ {8 s  k" d        },
+ B/ U- l; T. y/ i  C2 {; J4 n};
9 b& m5 ~5 q8 R! ]# d/ {# h1 Y0 b' k2 \+ v, J2 D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: A/ `2 N$ f4 e. k  Y/ ~8 ^! |7 x
        .leds = da850_evm_tl_leds,
6 v' w/ M8 P2 t* u0 e        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 p# W6 c3 _9 M" g6 R$ ^' k; u
};4 Z, T! G  G" a! S- ]7 m

2 A% h! Z! O/ \, Z( P6 O8 Hstatic void led_dev_release(struct device *dev)
+ V# y; U, _; _8 b: ?' P# }{
9 b. W: C( N5 R1 q7 r};
$ i6 i. i/ ~6 K  x# C# ?! {6 I7 R3 f6 Y3 @" S5 }; R3 F
static struct platform_device da850_evm_tl_leds_device = {
# e/ i5 q% ~) j2 S) z6 _- V# R        .name                = "leds-gpio",7 r( @, {9 _4 W5 @: C. `! {* u* M( f
        .id                = 1,
2 N2 F6 W5 q. m        .dev = {
  F$ ?/ Q% X3 S: A2 r                .platform_data = &da850_evm_tl_leds_pdata,, ]# c  B/ Y5 q) [$ T8 J7 ~- R+ `
                .release = led_dev_release,8 R8 x+ _$ L& H. s; {2 O/ V
        }
4 ^' G; Y, H1 H};. \5 Q& p/ N4 ]2 h! @# X

) ~+ b1 ^* c9 _5 istatic int __init led_platform_init(void)
! j& K  Q4 E. T  w1 _2 B{, G- q! v' n8 {5 o3 S3 P, ]
        int ret;3 t" U$ z7 ]' F2 t3 i. s8 {
#if 0
7 o6 c0 s  u# f        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 i% E% D; M4 i" C' {: d, |        if (ret)) h, r6 `* E1 ~  C
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, `5 `, a, [8 o8 U                                "%d\n", ret);
) U# i; ^# K4 c2 ?#endif& e  O# c  u$ a# Z" {' W! I0 `/ M
        ret = platform_device_register(&da850_evm_tl_leds_device);: r: u+ ~; p4 F5 Q
        if (ret)
8 G8 l0 n* F& X* z! J, ]2 m                pr_warning("Could not register som GPIO expander LEDS");8 H! m' g! J/ g; ?3 |
        else1 M  H; S3 A3 X' `* r* k- r
                printk(KERN_INFO "LED register sucessful!\n");
4 v' J' _" z( ]4 W( }) q7 k: T& o, g- @6 D& o2 }! S
        return ret;, q1 i3 R- k. K6 R
}
9 w- K' D2 g! A5 O+ N9 ~0 C& A5 G: h3 a6 C4 V- b
static void __exit led_platform_exit(void)* t* e3 {! v3 S4 F
{7 [6 g: [  O- N5 z2 d3 j) |
        platform_device_unregister(&da850_evm_tl_leds_device);/ g1 K: \5 h% y4 y  E$ B

0 Z4 G6 r& d# z; c- Y& R        printk(KERN_INFO "LED unregister!\n");' q, M1 Y* p% Y+ W' Q
}
7 q5 X4 o6 @8 x, T# u# [! e& W- ~8 Q$ s9 f5 Q
module_init(led_platform_init);
, a* b* l: G" i, L  E9 ^5 e6 |module_exit(led_platform_exit);; C4 F6 w( T2 u0 n

. _, _- `) l, L" RMODULE_DESCRIPTION("Led platform driver");; q: \( O; {8 {9 V- Z% Z
MODULE_AUTHOR("Tronlong");& p9 O8 h! N9 Q; u8 T; @
MODULE_LICENSE("GPL");
0 t$ `) }; A5 H8 S3 X" D0 A. K. ^9 m7 r4 s: y/ R/ D
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-22 02:00 , Processed in 0.079772 second(s), 33 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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