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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
. {4 s  T/ x( ^8 M1 _  E#include <linux/init.h>
9 O2 R* J, ^. f" Q$ @% J: h#include <linux/module.h>9 a. ^3 s5 o% X  c: X
#include <linux/kernel.h>
0 F+ r, ]! a2 S3 l: {% L#include <linux/types.h>
/ {3 K* H; E6 a+ r#include <linux/gpio.h>7 I8 w9 k. r) A
#include <linux/leds.h>
% j; t' u( X$ j# R- @2 K#include <linux/platform_device.h>
) h1 F8 D3 `4 W* s) b1 v. T, v  T9 h
1 E+ R, t: e8 q; z! @2 x#include <asm/mach-types.h>+ E  [1 j1 |; d
#include <asm/mach/arch.h>; y2 T8 E, v* G7 c+ b/ d8 T
#include <mach/da8xx.h>
8 Z* X, t# a0 I" g, v$ o; T8 N#include <mach/mux.h>/ H) I( M0 [3 q( \$ Z4 I

( M' H0 H& V) ]+ z#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)9 }! Y6 q+ i( k9 U6 e
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)7 R. Q+ U3 ?: i
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
" m: ~$ m  M7 y8 w8 |7 Q* ^% [; S#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)! h% e5 v' V1 m9 G, z

5 ]+ L( w0 S- h: i. i  L/* assign the tl som board LED-GPIOs*/
8 f/ Q: |% y, p/ Pstatic const short da850_evm_tl_user_led_pins[] = {
* M, h; S! G+ P) ?2 ^        /* These pins are definition at <mach/mux.h> file */5 {( ]; Q  Z& H
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 _- r# K& x+ R0 ^) Z
        -1
9 I2 m  e8 h7 x, N+ J- l};, T- J, Y) h, x4 F3 @6 T
1 c! w1 R- @& h( g& O/ s, X
static struct gpio_led da850_evm_tl_leds[] = {
# Q/ ^0 Y4 T9 P        {" ?) _4 l+ W+ [4 P% w8 N! b
                .active_low = 0,
% }0 |3 q, i& X3 z                .gpio = DA850_USER_LED0,
( ^8 N" B5 U# J                .name = "user_led0",
7 `# b3 B' }  H5 P+ C$ z' X                .default_trigger = "default-on",! ?' H9 n3 ^5 D0 P* Z5 t+ ]
        },  k) A0 A2 ^) ^# F! G
        {
* x, n; b) G9 T/ r                .active_low = 0,! [- Y: ^- l) [6 x* s
                .gpio = DA850_USER_LED1,' d0 t. N7 C1 N  u3 s3 ]
                .name = "user_led1",
3 a6 x. b5 j: s0 F% Z                .default_trigger = "default-on",8 w" ]: t- H; _5 A# B
        },
+ o6 [$ p' I5 @6 i        {
6 S9 S, O6 M- Q, d                .active_low = 0,9 B8 D; k9 p" C6 ]" s  C, D' s
                .gpio = DA850_USER_LED2,
* c; W- A6 Y- @7 m! o. |                .name = "user_led2",. A7 ~6 t4 D( _0 k  r2 s
                .default_trigger = "default-on",6 X& `3 ?6 M& Q7 f* J* }; h$ u
        },2 _$ C# T" U, S" n: o
        {  S: j6 N0 A; l- o0 s
                .active_low = 0," h: q5 x& O4 j  Y! u. }' N
                .gpio = DA850_USER_LED3,9 k" R( ^9 q% T) L
                .name = "user_led3",
# t3 Y3 J( {) n; n" F5 N                .default_trigger = "default-on",
6 `4 @  k/ ^3 Y' F        },
+ i! n! P/ i" C0 Q1 g- O4 H};$ ~1 _5 ]+ a. K2 {8 k7 x" ~: P. i! G

+ y& m$ ~) G4 X9 ]  ^6 Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ L1 A' b# g3 s1 Q% p        .leds = da850_evm_tl_leds,8 j3 F6 I7 B! j
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! y& A) I+ B. I2 l};9 N' v8 X  W7 n3 U( ]  n" F
. T- X. a' B- V4 M
static void led_dev_release(struct device *dev)' _+ P; K. I. l" n7 g
{8 W( l7 j% g/ B' T4 g" N
};1 s9 v. I+ y! X3 f: e; N
# V3 Y( W2 G- t7 d3 B/ X% M
static struct platform_device da850_evm_tl_leds_device = {
1 _/ o' r+ e0 Z8 a" C$ A        .name                = "leds-gpio",6 F, j# |6 G) B! ^8 T
        .id                = 1,- a' {7 c( Y/ b1 @: H
        .dev = {
5 c/ E4 D/ e9 P, X. u                .platform_data = &da850_evm_tl_leds_pdata,$ r) ?. L# t: f& S  K5 d' Y
                .release = led_dev_release,' E, P) c% r: |5 T. |/ }/ Y4 _
        }; Q# o& Q$ G' I4 B' X
};" `7 ]8 h+ ~& H' z
  e+ j6 E. ]7 D, o
static int __init led_platform_init(void)
9 s' ~5 R% q8 c. U5 V9 q$ \" }& e2 ]$ h{+ I1 n7 u, X% d  b
        int ret;
% R8 {1 H4 S2 ~4 g#if 07 \3 T/ ]! x9 c) X
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ X/ I9 l- U% c( M
        if (ret)6 D4 P0 D$ L8 V* H, ], G# ?
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ S  t; I" L1 m! g! y. I( X4 |                                "%d\n", ret);2 V" M. {, ]& B
#endif
' A  ?2 g- J3 \        ret = platform_device_register(&da850_evm_tl_leds_device);9 {, o0 m/ D% m* V; O# d, k
        if (ret), \! u4 ]0 Z0 b- O! @, P! ^
                pr_warning("Could not register som GPIO expander LEDS");% r/ q, F" j: t; e8 W6 N
        else
$ N5 U3 o: Y3 q( O9 C9 f. C# C2 j                printk(KERN_INFO "LED register sucessful!\n");
. O  R3 ~4 z) S9 T# q6 l- {
( {! K/ j' ~) i- {( D6 W' i8 F        return ret;; r/ v5 c. d. `6 a0 u' a0 p
}8 o5 L" Z, M+ W  q
) x! l4 r0 p4 P' A$ v8 H
static void __exit led_platform_exit(void): t6 p, J. D) H9 C
{
# l/ }) }8 U( A/ w3 I        platform_device_unregister(&da850_evm_tl_leds_device);
2 C! {# `. Z( K' w% ~& s
+ t% I$ h* `7 K+ g. `% j- Y        printk(KERN_INFO "LED unregister!\n");  P  b( s2 @. }1 W; U; I
}9 K5 a. a9 `: w8 R% e

& G4 W/ m( V: @: qmodule_init(led_platform_init);# n7 G) J% R% R* j& M
module_exit(led_platform_exit);
% l$ Y) `$ Y7 n( _$ y$ Y1 {
1 ]$ ?3 O. X* O0 VMODULE_DESCRIPTION("Led platform driver");
- S* C6 u5 f0 F: O# [MODULE_AUTHOR("Tronlong");, R8 i  ?6 ^0 w; X/ I' X% R7 c1 n
MODULE_LICENSE("GPL");8 h4 Z& s+ r. M5 M* p5 e' y

  W. ?$ ?2 ~# Y! n( }; o# W
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-9 16:39 , Processed in 0.039644 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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