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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
1 U) Z/ b2 b8 n$ Z2 K3 m/ k% y#include <linux/init.h>2 h& y- E& n1 _' H- B
#include <linux/module.h>: c+ n* I5 x7 K# u+ U$ s# t% `
#include <linux/kernel.h>& J1 M* O% z# R$ a1 [" k, ^6 H
#include <linux/types.h>
, M* n, C  h- _; j  f: _  N#include <linux/gpio.h>/ ]5 z% c% r) q' q) {; P
#include <linux/leds.h>' q2 N8 p1 D: G( F# i7 p5 N, A+ ~
#include <linux/platform_device.h>
8 U( W+ Q4 N* \3 p* t, B1 ?, I" k6 v0 d! ]8 I* [9 g" J; h
#include <asm/mach-types.h>
- G5 Z6 a4 v. J& I9 U/ B: H#include <asm/mach/arch.h>
: O3 ?: O6 d; U9 ?" ?#include <mach/da8xx.h>
* c. O" m9 @6 h7 N, ]% Y#include <mach/mux.h>; I0 B5 a1 j0 G! F  T) W

9 Q: q) l3 s: p$ ^; ]2 R+ }#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
; T- b8 k& H+ c7 _# W) Y' W5 [7 a# l1 l#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)3 L* ?. \$ L& v+ L
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)# @& B) e1 B& r7 V# `, @( s/ u
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)% l( I" ?3 k2 Z( D1 I# f

6 }7 i) n# W& @! x' t/* assign the tl som board LED-GPIOs*/: [( P6 n" I/ ^1 K, |
static const short da850_evm_tl_user_led_pins[] = {% A' i% I! S& Z) a2 I; o$ X. w3 ^) A
        /* These pins are definition at <mach/mux.h> file */
5 b- ~1 ^( p8 A* X8 G2 Y! T; J, l3 L        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ k6 d9 G" J2 ]8 W
        -15 `( `! Y! E( @* Y; D% p
};$ f. f4 G9 G& s
9 d" T1 H# I: U/ s% v
static struct gpio_led da850_evm_tl_leds[] = {+ A1 c, G4 s% {7 y& p5 e/ B
        {
# E# ?5 T3 K: I                .active_low = 0,
- O6 o) B; g/ _) `! E4 i                .gpio = DA850_USER_LED0,6 W3 E0 Y6 Z/ d0 x( |
                .name = "user_led0",
0 [" k8 u  d) i7 k                .default_trigger = "default-on",
- h" A1 g! B- o+ w& f        },
. s& y/ r5 b0 `, _        {
. }( @5 i; q7 C' `' ?                .active_low = 0,
: f. _4 X( E8 l4 b  `  \3 n                .gpio = DA850_USER_LED1,1 d% X$ D# h. T% ^
                .name = "user_led1",
8 l$ H5 E0 C  h* ~# T                .default_trigger = "default-on",' ?% J* k  B- h. B" k* B$ W1 H
        },
* B$ k% S& N* Z- \' E        {# {: i8 l$ _2 e9 J7 [2 }" h! {8 `
                .active_low = 0,
7 b+ l# v8 f8 d& _                .gpio = DA850_USER_LED2,- U3 u4 O1 Z# h& W( w( a5 y
                .name = "user_led2",5 b; }; [! w$ O' q+ F9 D
                .default_trigger = "default-on",6 _6 Z( o, I. y/ S' l9 {
        },
5 \2 j% |- l6 K8 I4 S        {# G3 A% ~7 O$ W( `: T7 J$ c
                .active_low = 0,0 @2 L2 P* H/ s! l8 U
                .gpio = DA850_USER_LED3,  U8 u- D% }5 `1 |4 g9 {
                .name = "user_led3",2 d  Y8 y+ o1 k% e2 [1 v6 a
                .default_trigger = "default-on",% l* D6 f8 K5 t- \+ z7 Q8 c
        },4 J2 i( u( k/ l4 F; h* y
};) R9 K, c8 Q. V& a5 ^( f7 M& g, R
3 Q  k# Q; o1 o1 t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' u2 X' `0 Z" h% L: l        .leds = da850_evm_tl_leds,
- T3 w* F" h( K( h" A/ {        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 r9 ~* N, \) W  a; S2 G
};
' v0 j$ G+ n6 ?* t! R) |' r) Y8 u) B  I# w8 s* ?
static void led_dev_release(struct device *dev)6 X% L; U8 Q: w
{: X7 m/ l( g7 G1 Z
};
9 B0 U( G. w" k5 x, T& `7 h- {" v" X$ X. A5 S4 K9 h  a6 o
static struct platform_device da850_evm_tl_leds_device = {: B" h0 \% ]+ X% l
        .name                = "leds-gpio",: K4 s, k" [5 m4 f
        .id                = 1,7 V- k7 K; {" f+ q$ {
        .dev = {$ G" K. [. I9 G" f) _
                .platform_data = &da850_evm_tl_leds_pdata,
" W9 m# c# K- A                .release = led_dev_release,
! H" F* K  }' t' i        }
+ U2 ?. ?6 C8 W};
1 T" W5 W+ L  g$ F8 F, `5 _' y$ U2 k. N% Y8 m' D. m7 o
static int __init led_platform_init(void)' f8 c( _" s3 V; T
{7 _$ ?0 R. D# E  f
        int ret;
7 }! ~: D* l+ y' ]; [! J, K#if 0
1 K0 T' t  y6 `2 W: _- N$ L! j4 t        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 k6 z$ I5 ^" \8 Y6 x        if (ret)$ Z8 o6 x; H) U: E' A5 W% ^
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& V( h  e$ d) O# r; `# L$ J8 G                                "%d\n", ret);" n0 x- _! j, g
#endif. g! e1 P2 C9 y) Q1 c. Z
        ret = platform_device_register(&da850_evm_tl_leds_device);" Y" y- r3 Z; D4 L& `
        if (ret)' D' K1 N" m  `1 @8 S0 P
                pr_warning("Could not register som GPIO expander LEDS");
$ b1 t% k) D' |  K; _9 O0 T        else
. |" Y7 @" j/ ]: ]  ?6 i) l) p                printk(KERN_INFO "LED register sucessful!\n");. D; Y$ Y6 c# K' x3 c8 H& B* _9 o0 U

! \, E7 ?, r. j        return ret;% ^- U) l# a# g/ o2 R
}/ H3 B/ n6 I, q: q

/ z4 N: c# A. o; J6 Wstatic void __exit led_platform_exit(void); B2 I' I2 b, j" e0 A7 C" [
{
5 @+ c& S+ k6 g+ @; x, Y1 R        platform_device_unregister(&da850_evm_tl_leds_device);
' N3 C2 ]7 G+ G7 |& K
8 X+ r) f; F7 ^) E. m3 w6 n% t        printk(KERN_INFO "LED unregister!\n");" r5 u0 q1 y% w6 P0 b9 n+ g$ A8 l
}  l0 p: F  h4 a0 l$ A, d
) B; R( h0 y2 o, {+ A
module_init(led_platform_init);* b% k& e8 d! K- z7 k2 `
module_exit(led_platform_exit);
$ _5 |+ J. T6 o( H) O* i. l& J' |5 U# Z, m1 P, ~( ^
MODULE_DESCRIPTION("Led platform driver");
. Q! G+ H3 S# W+ v0 jMODULE_AUTHOR("Tronlong");$ g5 @" @% e0 |
MODULE_LICENSE("GPL");! _3 ]8 Q* x5 ?" c6 L; M; r
+ O- L4 O' H6 a- Y- l: K+ U% x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-30 01:30 , Processed in 0.047082 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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