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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
0 J$ H5 L/ C1 Q7 H: D5 a#include <linux/init.h>0 N( X- ?$ U+ W( d
#include <linux/module.h>; \& S" I0 W( K
#include <linux/kernel.h>
; {! g9 y2 P  m, q4 V* q+ h3 X#include <linux/types.h>" w/ [7 z4 M7 p% m5 k, V3 f
#include <linux/gpio.h>
/ Z& ?7 H) l7 f, t#include <linux/leds.h>
: D8 a" q0 |; H0 t: ^; {#include <linux/platform_device.h>. K0 D! _4 c1 }  X. u: L! k6 t
' E9 T/ m: r, @# t. }6 R
#include <asm/mach-types.h>1 p& d8 w0 l( o* A* e& X
#include <asm/mach/arch.h>0 a# I& e9 i. J9 Q# J( N  y& u
#include <mach/da8xx.h>
, R" |/ O1 G# T6 C9 T, t2 l#include <mach/mux.h>3 W0 n5 Q. H1 \% g% c5 o

$ V  ?" E0 d. `! x6 M- c5 [#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)% L* D& e/ @, ?
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)& ]7 Q0 F2 H) u8 L* ]. u$ G, W
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)0 g" y7 N0 ?& B& Z9 g9 z" }3 P! ^
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
- Q; `0 {; v4 b! x( c5 j- Y
6 }, |* {4 B! F) A) \* q1 ?& B/* assign the tl som board LED-GPIOs*/2 `# T' `5 F3 k3 M
static const short da850_evm_tl_user_led_pins[] = {
6 s3 J( M8 {8 C        /* These pins are definition at <mach/mux.h> file */' D3 ?' b- v/ u5 i7 [/ t3 c
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* _/ h: L3 ?5 g  q. E* u
        -1+ z- }0 E2 n1 r$ ~+ i& m* g6 j+ F
};- l' r; w& o, h, J

, l1 o1 w" r! P/ j8 ^( ]static struct gpio_led da850_evm_tl_leds[] = {
& C5 }, P, V1 }: Y' N- q$ a0 g        {$ ]) Y4 P' J: b* E
                .active_low = 0,9 ~9 V7 Q0 J1 R$ D! t* m' p
                .gpio = DA850_USER_LED0,
3 X, b. K* p( ~                .name = "user_led0",4 ~5 [0 Q! N0 T, Q7 d( K
                .default_trigger = "default-on",
; j# S2 [) v6 s- \2 _        },$ u, ^" H' G  B5 D+ E6 O' n
        {, u: I/ r/ Y7 e) L  G
                .active_low = 0,; S+ G0 t& c; A9 m
                .gpio = DA850_USER_LED1,' f  ~' G7 U  |8 }: |0 b+ |
                .name = "user_led1",8 }! ?- c5 E% ?) Y0 F
                .default_trigger = "default-on",
) p6 R0 l! J2 t4 x: a        },
3 N% P" Y. G. J% E: v2 P        {8 v' Z% g) r% A9 Y4 V0 c
                .active_low = 0,5 Q) X" q$ t: ]; `
                .gpio = DA850_USER_LED2,; Y( [6 ^1 b- p9 m% L7 H% p4 z0 T
                .name = "user_led2",7 J8 H. F! ~: Q6 s, a% {9 |1 ^  t
                .default_trigger = "default-on",9 y" m2 T$ ^0 t8 d/ A6 }
        },& h( K( m; y0 P
        {% ?/ k* `0 n! n. y6 j9 D7 @6 E
                .active_low = 0,
; N% m, \; r/ l3 _; E' {7 J  T                .gpio = DA850_USER_LED3,
/ ^, K/ o& a' F4 ~; x% g                .name = "user_led3",9 j8 _* r* w$ K. g' T: D
                .default_trigger = "default-on",1 \4 h" S+ @- o3 c' l4 J( H7 I! C5 f( d
        },
$ u- @) Z; M% I+ E. O# Z};
( R! K; t) h# X. S4 k
! m1 n3 z9 M; z/ z0 y9 y( Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: ~( ]4 G* V8 X8 B1 h        .leds = da850_evm_tl_leds,0 f# O# u4 \- J( |( g; a3 J
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, \+ W% l/ i( j5 K
};
3 f4 p- ?( w2 p7 Z1 G2 s6 B
0 u2 Y) U# w* P) Z1 W3 r3 Nstatic void led_dev_release(struct device *dev)
% g3 T" M& y; |/ }5 E/ \2 x{
' \/ G1 w. E/ V# h! q};# `9 E. O8 t) Q. W- ?

* T# L6 K# u0 v3 A& M8 I; H5 Istatic struct platform_device da850_evm_tl_leds_device = {! S! n$ g3 u1 \0 J' |- P
        .name                = "leds-gpio",# ^0 }; g5 R$ m
        .id                = 1,2 s. X  ^, Z# I) M" f& Z
        .dev = {
: `: `' U. t0 a1 t! Q) ?                .platform_data = &da850_evm_tl_leds_pdata,
5 m$ X* W- u  ]                .release = led_dev_release,
! z+ S2 }% d; z/ C- \; {        }
& V& _) P- r+ q! P) v7 m};, ]. Q" D/ L9 I9 |/ t- s4 j/ W
! r1 b) U, X- q( N  ]! D, ~: ?/ W
static int __init led_platform_init(void)/ ~& R9 H5 M6 v# V- p
{
: W1 \! d0 q& H0 N        int ret;& j% {; M& w& O2 j1 u
#if 0
# r& z) O; B1 g8 o7 q. [  ]* P3 O2 v        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, w( I3 o: m; C9 \2 ]) i. @
        if (ret)8 q' ]& e* }% m8 z4 J$ w
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( x3 i, b8 L. v3 ~
                                "%d\n", ret);- d$ n6 @$ J1 O" B+ ^0 t
#endif
& i( Z: z9 X, d" E3 I- |- F        ret = platform_device_register(&da850_evm_tl_leds_device);
$ ^3 q* W: f6 R, D, f        if (ret)8 P5 e3 U4 K' _1 e$ D1 t
                pr_warning("Could not register som GPIO expander LEDS");0 ?: e; q. q6 [; M1 r8 h; r
        else
4 [! w7 x) j2 E6 a+ Y* }& o                printk(KERN_INFO "LED register sucessful!\n");
" i/ S$ G3 ^3 F& S! y
9 Z8 O$ J) ]. _        return ret;8 \3 u& h( Q4 Y7 s% y5 I9 z! P
}& C( a4 c: v' }: Z- x- R* y
' l: E1 M3 A* `: `
static void __exit led_platform_exit(void)
' d, f# l$ d7 F9 B( W{
) [& S' k! O: B1 w0 `. E1 g3 Z( C        platform_device_unregister(&da850_evm_tl_leds_device);
( w, H0 M; Q& R, H9 l
. v% m, j3 }2 r8 g7 n        printk(KERN_INFO "LED unregister!\n");
6 l8 L. P- T# I. l}
* P# f% y  j* J, x
- y; Z1 `. F+ J( `5 ~0 Z$ }: [/ Amodule_init(led_platform_init);8 b5 e; P2 O. k$ n7 e/ Z
module_exit(led_platform_exit);4 N5 B7 S, H6 u) S! @9 W0 `

+ [; h+ i- H, r! {0 p9 L( G2 iMODULE_DESCRIPTION("Led platform driver");8 i2 \, U! t$ w+ \" O8 G
MODULE_AUTHOR("Tronlong");- N7 A3 \' \0 e6 V3 F' N1 [
MODULE_LICENSE("GPL");  P6 y! u: |' B5 }% h
' H) s" u$ [% {, N
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-1 10:27 , Processed in 0.055193 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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