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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。% t& g* f8 o. ]  Y" |- K& a: p
#include <linux/init.h>% P) L( [; i1 c! W9 K' w5 l4 t2 s
#include <linux/module.h>
# W8 w$ o: J# y  g! f( J- ?* _#include <linux/kernel.h>
! h) {! k6 e, J2 C8 U1 D9 F/ l& q#include <linux/types.h>
3 I& J+ \' a& a#include <linux/gpio.h>' ]6 F- R. Z9 V% W
#include <linux/leds.h>, e3 s9 Z* ?; b6 D$ z
#include <linux/platform_device.h>
6 `. [; `. a1 L' [8 ], ?
8 }) ^' U2 N. f( ?0 q2 n#include <asm/mach-types.h>8 A: A* ]+ w; s! z! I8 {* q# T
#include <asm/mach/arch.h>
% O% J' m: v, T3 f2 v1 j. Q/ N#include <mach/da8xx.h>
9 D0 {2 Z, `; I#include <mach/mux.h>
( r9 _7 K% T: p5 j+ X6 s; H. r
& Q. }+ f/ n) J7 f  w  U" J#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
1 S6 n8 g& T5 p#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
9 S9 g% u: B4 q* x#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
5 X1 }/ a  S. S! x#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
  `* [7 c5 g- _  f4 R4 T- @1 @5 i
! G# e$ g- y: A2 O3 z* m6 L! Y, k/* assign the tl som board LED-GPIOs*/
2 e; m7 ]% i3 g+ W. G/ h% s, vstatic const short da850_evm_tl_user_led_pins[] = {- I- N( b+ K  F5 R
        /* These pins are definition at <mach/mux.h> file */( ^$ Y2 {2 S3 p7 b
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ |  ^& ~/ O9 f$ r& \        -1
7 q* T3 s! H! x: @0 e3 t* H7 b4 L};
; e& j" w1 z! y) c% n6 h
- ]9 N2 q1 T8 }: q6 b- rstatic struct gpio_led da850_evm_tl_leds[] = {' w0 n  g( f1 w' x% l
        {
% d9 n! O9 _, x2 ~# b5 O* Z8 w                .active_low = 0,
! e  U0 v. X- \                .gpio = DA850_USER_LED0,
1 A" a0 k4 p: P3 m- i                .name = "user_led0",$ v; O. }- x( X/ b
                .default_trigger = "default-on",6 F# ~" l9 k. L2 i1 C
        },& Z1 t3 S2 q3 A9 A3 W
        {( @% x( e" c( f8 ]" V
                .active_low = 0,
) b, @$ L. S9 x                .gpio = DA850_USER_LED1,
. |, E  |, W6 E& y8 x/ h% o                .name = "user_led1",. ]' W$ D  ^* ~% t9 K
                .default_trigger = "default-on",
  V. G; ~" F8 L, q        },% `! H+ }  K- k
        {
- c, _5 H$ o: h4 X  X* ^                .active_low = 0,2 T* M3 l7 E- M9 _! t
                .gpio = DA850_USER_LED2,: @' G9 ?# ]; j+ l
                .name = "user_led2",* g' l$ d, d5 k& l$ ~4 @
                .default_trigger = "default-on",. C) n- s. y( Y1 H% s
        },2 _) n9 m( Q5 R) K2 U" N" J
        {0 ?) j% S9 h7 Y7 G: u! X, _: Z; N
                .active_low = 0,
- H% c6 I! f/ r                .gpio = DA850_USER_LED3,( S" c# D- Z' K! K  u3 A9 t
                .name = "user_led3",
$ b& g# j  Z# a: a- U9 j+ @                .default_trigger = "default-on",
! x( t4 I. {0 @        },
% [, z! U- ^' [% k};5 s! c4 ^- ^0 }' ?" \8 s# q

8 S2 ?3 m7 t: ~0 s0 Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, T2 e" {! K9 V. ]6 N) F3 d
        .leds = da850_evm_tl_leds,, v/ R) B6 R% t+ K3 Q! h
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 R* G9 o5 \4 x8 |+ G};
; {! h& }. Q. i' J0 D* e5 s* G* m* W# ~, Y  [4 ^
static void led_dev_release(struct device *dev)' e6 b2 x' i; o
{
4 i" v; U; @9 U; f& Y};
4 l/ O3 t3 u+ e0 F: m* d' H% G  P1 t. e& G
static struct platform_device da850_evm_tl_leds_device = {, o5 K5 w( d  M) s: r/ D
        .name                = "leds-gpio",9 r- O$ F' u) j. e# s
        .id                = 1,
. k6 a) g  k- a3 J        .dev = {
; s7 D* [, W, y/ S0 d& T                .platform_data = &da850_evm_tl_leds_pdata,
, r7 I2 p$ P8 Y# R# K! [+ K- ]/ q                .release = led_dev_release,
$ g3 l/ U8 _  s9 ?        }
9 N" b* K& I# u6 Z+ E3 i: W};
2 z' p; a( O, ]% t( ^2 ^
. v4 w" N5 ~: m) O( b0 E+ g3 astatic int __init led_platform_init(void)
0 S* e5 b& Z: s2 _{
$ ^' I0 u- a% D0 {$ U  S        int ret;& B4 ~% R0 E2 p! {" e5 m3 u' v" Y
#if 0
4 k% r6 \( R" |5 @  ?% W7 n- v        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 P4 h5 h: n# T+ o; n$ ?
        if (ret)) s1 O0 r! q7 z
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& U6 A! C6 }- O9 O  K
                                "%d\n", ret);
9 I) B6 R7 f4 {' X. c) k#endif/ a9 e: y7 Q  z8 \, j
        ret = platform_device_register(&da850_evm_tl_leds_device);
1 K3 F( n/ j: Q  i1 S1 ^        if (ret)) y5 Q# C0 }1 H7 l0 ], g* ^
                pr_warning("Could not register som GPIO expander LEDS");; X4 \3 n. ]8 B7 W. I- R4 o
        else
: ?2 K. t* a7 _$ B! @" e+ R8 I                printk(KERN_INFO "LED register sucessful!\n");
& S  B: U8 c) {3 l! A) o2 ?. m. L) e
        return ret;; C8 q0 w% G" p& {; b/ l$ T! u
}6 s/ h% w: H+ s4 @4 ^8 p+ s) Y
) r6 C4 d8 d4 C% K
static void __exit led_platform_exit(void)* K  p% h% }0 I) g# R* A
{# O- T* \/ u! n5 G- s% ^- [
        platform_device_unregister(&da850_evm_tl_leds_device);
( s5 s) @9 f7 m7 r& n6 r6 r
. e; R+ |" G* D        printk(KERN_INFO "LED unregister!\n");
) G* ^! k- s0 J: c+ \. b9 f}' W2 D0 m1 Z& ^: c( T' t
  A4 ^% y6 \2 \+ m% D8 l
module_init(led_platform_init);( e( b" `: H' m
module_exit(led_platform_exit);
0 V* m+ N5 }* n: G/ [% g' b% U
$ }  O3 `# x# w" ]MODULE_DESCRIPTION("Led platform driver");
% O. ?& z; T# H0 ?MODULE_AUTHOR("Tronlong");! S$ g! @- Z9 S/ o& G
MODULE_LICENSE("GPL");
! E$ V1 w# ~: n$ n' [( ~7 u# w6 \0 z9 a* S. q6 g
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-29 22:02 , Processed in 0.041548 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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