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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
' x! d9 x" B0 _#include <linux/init.h>
6 A1 M6 |' I* y! `9 s3 x#include <linux/module.h># q3 X6 Y  w+ s4 l& w3 j
#include <linux/kernel.h>
0 ]' R, o0 T$ q' W' W  U9 c+ F#include <linux/types.h>0 z# W; x( p( `* ?) a" I* ^9 b
#include <linux/gpio.h>! H  @# e" k: @/ I/ I
#include <linux/leds.h>
5 L0 V, w$ E9 n4 Y9 q#include <linux/platform_device.h>
+ a. L! l  S3 K! `
5 s6 `& R! s8 s- G; S* Z#include <asm/mach-types.h>
3 B4 O  d1 R" H9 M* }9 D' \* x. r+ h#include <asm/mach/arch.h>
3 p: O, W# g8 Y#include <mach/da8xx.h>0 g5 y: {" l% ~6 w4 I
#include <mach/mux.h>
5 Z  a; v, q% m; d& [
' ^7 r/ c9 ]% I! q- v0 d# B# D#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
/ U0 H7 w: C6 a" F* W#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)  x' A: {1 `2 d
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
/ ?! x$ \: g) B8 f; y#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
7 n; A8 E4 S3 X. C4 G# Y( i5 q2 p0 S( S, R8 {: a. u
/* assign the tl som board LED-GPIOs*/5 T; Y, b+ k+ y/ d0 R
static const short da850_evm_tl_user_led_pins[] = {
8 z) i+ Z1 B* p9 m        /* These pins are definition at <mach/mux.h> file */! p  l6 I; R( S3 X7 T
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. }  W4 ^$ ]2 i: `1 B5 `
        -1
; S- Q) d9 j) r  p6 d* a0 R};
* S/ O% j. B- _' y( h# _8 D/ e& c4 v& x( I7 a$ X( S6 f8 N2 y# ?6 P
static struct gpio_led da850_evm_tl_leds[] = {
$ B: L* z9 {& N, p/ o, J7 q        {
% x9 |( d; |+ w& s! m! w                .active_low = 0,
4 M+ R! p' l( S7 k( n- q                .gpio = DA850_USER_LED0,
* y& w( q8 Y3 ]1 U                .name = "user_led0",- f3 {$ e5 b; I; |. w) i3 @
                .default_trigger = "default-on",
5 H, S# Q: q% P7 \+ ^" x        },+ w2 ~: Q# o% m1 m; s
        {
( {" \* c0 l+ I. E                .active_low = 0,
2 w4 {+ a  `! y7 r  a# ^                .gpio = DA850_USER_LED1,
3 n6 Y9 e! D: j4 W. T9 a                .name = "user_led1",, u8 X" E4 R' p: p- J" Z5 `- n! b- ]
                .default_trigger = "default-on",2 H) M! l- W/ e3 U: D8 Y) y. n; k
        },
8 O1 e3 u, y5 M# ?9 o% M' I        {5 m: V6 j1 H/ [: i1 ]; m
                .active_low = 0,5 ~5 R8 W6 _9 S3 n7 `$ ~3 n0 W+ _
                .gpio = DA850_USER_LED2,: q$ `& i3 S- O' c8 e
                .name = "user_led2",& K7 ?9 V+ T& g, V5 F6 K
                .default_trigger = "default-on",
" ?" ]6 Z& s/ ?# J+ o4 u* `        },( H" o! a: {+ P' j
        {
* A/ k( H# z) v2 P                .active_low = 0,
, U: F6 H7 t: M7 H, @" M5 U                .gpio = DA850_USER_LED3,
& u4 r. {/ U5 V# @0 C                .name = "user_led3",% B' v/ q- o! G. ~- p& W& d
                .default_trigger = "default-on",1 @) E8 j5 L* y* h- a7 d
        },
$ O+ Q# m  w: ?7 l0 c4 T4 J};
/ ~, V5 I0 D: j; o1 H
4 l; r1 [6 ~2 G+ T; K5 Tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! f" u5 I* Z4 R        .leds = da850_evm_tl_leds,% w% A& n5 P3 Y
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 J) d9 |6 o) w# t. N. O. g- P};
/ x4 A  f" f0 R4 {% V1 }4 N( y: Q. b* r' _1 e* ?
static void led_dev_release(struct device *dev)
4 u9 k! q& p8 `5 e/ r7 ~7 f/ N{
1 W4 R! A2 r. E/ N};
# ~, p  i! J. t) K3 T6 H
% A( x% @' h2 N( z; s# k- Fstatic struct platform_device da850_evm_tl_leds_device = {! ]5 V/ z# u9 d: R+ N- c
        .name                = "leds-gpio",! R1 R# G' ~6 v9 o9 W. q
        .id                = 1,. g, v! C! ^) @% _3 x5 S
        .dev = {
8 d% k3 G2 w6 N                .platform_data = &da850_evm_tl_leds_pdata,
8 ~* D$ l1 W) S' n' I                .release = led_dev_release,3 q) [. J6 a. p/ T
        }8 f+ G- _0 Q) i) U0 s9 W& C
};
* g! S( b: A9 x" Z4 H( r8 ~( s# {- i% O
static int __init led_platform_init(void)
; j0 n" c" a" }{0 }0 W  \& d5 B6 f7 B
        int ret;3 X5 Z7 d7 m% m( c/ ^& |. F) H
#if 0: ~7 m! m+ I9 I, D
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) T/ l7 y( |# i# O
        if (ret)5 Q1 Z: I: J$ |" M
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 m) M: h  A" i: n+ A: Q8 B
                                "%d\n", ret);
7 Y: m; G6 m0 X* |; x/ |, ?$ D#endif
0 V, r4 B" S, \        ret = platform_device_register(&da850_evm_tl_leds_device);9 d0 X( u3 L$ Z
        if (ret), o& }5 d3 B! n' {# C' ]1 A0 O
                pr_warning("Could not register som GPIO expander LEDS");9 ^0 z+ R- f1 }* e+ ]
        else
. {) U% k6 C! K: ~                printk(KERN_INFO "LED register sucessful!\n");
; F; n7 L0 c% }2 x
) [% _/ b# p( L' O        return ret;5 t" g$ u  D& p6 f1 D" a
}
- ]) u% ~& Z* T4 r- U; m* u: _7 `4 t! S4 l+ o7 }
static void __exit led_platform_exit(void); E. N* M# X0 l7 ^; ^5 \% R
{) L7 n& G; G: {9 b% O4 F
        platform_device_unregister(&da850_evm_tl_leds_device);
9 {+ D" M7 T7 ]+ Y8 q4 j' X6 ?# r! w+ G* \  @9 V' H
        printk(KERN_INFO "LED unregister!\n");3 A1 b+ f# B. b' p& t
}0 K  g' b% \- l" J' w# f: I0 U" T1 W
  f* |  g. j! a) t( p6 S$ d
module_init(led_platform_init);3 x0 {; F- T$ \$ L3 r
module_exit(led_platform_exit);& x) l4 g9 @- ^# C

. b2 F2 }2 ~3 M5 c# [6 I6 vMODULE_DESCRIPTION("Led platform driver");; E% p2 l, z& X/ B
MODULE_AUTHOR("Tronlong");8 D5 L+ }  @0 |
MODULE_LICENSE("GPL");
9 {5 R8 i  q% T0 M* F
' c' ^/ n1 n0 b7 p+ o4 f7 n1 D
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-26 07:29 , Processed in 0.061336 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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