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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
  ]1 T4 h9 }" J6 @, k- }+ x#include <linux/init.h>8 D$ B4 N# ]' F! m
#include <linux/module.h>
- u( w8 a  b5 ]5 V- Q' s# y/ \#include <linux/kernel.h>
) Y( [! L3 M6 ^; `% y#include <linux/types.h>
6 u1 _3 p' {4 @& X$ U% s#include <linux/gpio.h>* u# x: k; p+ S6 r
#include <linux/leds.h>- I- k0 H. J, d: i; h
#include <linux/platform_device.h>2 O0 g# E% F& }" p, N" q

8 H( G' u2 f8 @0 |$ U. L1 q; Q#include <asm/mach-types.h>
% |5 J4 Y9 L" s' I# u#include <asm/mach/arch.h>
/ r! S3 l# V8 C9 i' U#include <mach/da8xx.h>
4 a$ `4 }5 N8 ]#include <mach/mux.h># [2 U: d: J( B+ C  g

. c1 x" i7 y7 _3 r& V4 R5 h#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
2 s9 i0 F% w& D8 \, A#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
! m; V; M# q4 h8 h4 s7 ?9 e#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)1 @6 z: e& d- m4 }6 t6 g
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ P9 f* E" R5 `  H! ^& ]) x/ x5 s
! D$ i# }# r: M
/* assign the tl som board LED-GPIOs*/# [! K* g, A$ ], N
static const short da850_evm_tl_user_led_pins[] = {
! C3 N; t8 I6 _& b$ k: M        /* These pins are definition at <mach/mux.h> file */
, q+ K& |0 S) z9 I& y        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' I+ u  I4 N/ s        -1
$ n% x. @: n3 j; g, \0 J) s6 Y};
$ r! C- p. B+ L& W
/ e$ _$ B8 Y: Bstatic struct gpio_led da850_evm_tl_leds[] = {1 X( D7 x# U" F1 t0 }7 j! ^
        {) N% b& Y4 m7 u+ ^' l
                .active_low = 0,
# Y$ y, y$ Y" H$ y8 Q# A                .gpio = DA850_USER_LED0,$ `# |; f6 }" `, z8 T) i, C4 ?6 F
                .name = "user_led0",6 L: s- a: I! _0 \
                .default_trigger = "default-on",
, y4 L- f! N2 j4 a0 ^        },
3 X( e! i) ^' o3 F6 F+ z        {4 Z' j0 n5 _8 e4 y) m; h  }7 k
                .active_low = 0,
5 m" f. L7 W* v: X" \                .gpio = DA850_USER_LED1,: L7 a! Q  T7 p; j& r) r) d
                .name = "user_led1",( P* {! L. ^  V* _
                .default_trigger = "default-on",+ Q% M0 k- H6 E) z  u( H9 H+ S
        },! Y+ p$ I  d) g( T+ ?' c* |
        {% f' F8 K3 U! T8 L
                .active_low = 0,
5 N1 P% z6 z: N% i0 @. p                .gpio = DA850_USER_LED2,2 g7 y/ ]3 b7 E" Y
                .name = "user_led2",0 ~' Q$ a# T9 O. C) L
                .default_trigger = "default-on",
! @! Y2 {# x4 g: A) k7 l0 W        },
& x% [. O1 v; E$ [' m* E        {
6 V7 v8 F+ w& B  G. v. f6 j8 P                .active_low = 0,/ T4 g( V' y. b
                .gpio = DA850_USER_LED3,3 `. ^- L; D5 O- ^
                .name = "user_led3",
) M7 u: Y7 `2 H2 B                .default_trigger = "default-on",) m3 u8 H# N1 ^) m% l( ?
        },
$ y8 k- i  K+ H( g3 V. ^};" K! }1 W8 P/ G; M7 e/ G' e. v" o

+ ^/ X4 [9 X3 w! I# |2 Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. O2 j, R3 h( v5 O5 h  Z9 I        .leds = da850_evm_tl_leds,
% [* m9 F% b" s, s        .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," a+ k# j$ n) B
};
+ Z+ R' U$ \" I& c6 L  \7 n: n) z: D$ h( {
static void led_dev_release(struct device *dev)
7 E% Q* m' c1 }4 w9 Q# s{
" F5 L$ x7 a, c" }3 P$ b/ K};
5 X7 G8 U6 S; T" k0 g8 ?  y+ N/ l
+ M8 D( {( t' Z9 ~7 T: N# ~1 a3 R8 ustatic struct platform_device da850_evm_tl_leds_device = {/ U( w  {3 v& o# Y
        .name                = "leds-gpio",
( f9 _' l4 I, P; F' K0 }% o        .id                = 1,' P+ M9 o$ q1 U$ Q
        .dev = {7 Z) S8 H; n8 Z. W0 C
                .platform_data = &da850_evm_tl_leds_pdata,
: B3 r; o" ]9 K, Y5 C& Y                .release = led_dev_release,
# {8 d7 p- l* L4 ?. q" S+ _        }) e6 N; s7 S! |* R4 w# W
};
$ G1 n8 E- _. L/ F8 i
6 @8 C# |  W9 j- w8 vstatic int __init led_platform_init(void)
( o% ?# C/ o0 \' e$ s{
2 _, f0 g) J) x% M/ W  Q0 g, C        int ret;3 I  \9 [+ ^& d
#if 03 x* ]5 l- e7 `
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 l  w/ ?! ^0 ~  a
        if (ret)
( T% g/ d: o1 T# j8 a( r                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: T5 ?7 w  ~# A" R; ]- R+ p                                "%d\n", ret);' I, J, _4 P3 D3 r, ^4 O9 `
#endif2 c" P9 d; G5 \6 ]$ B) g2 c
        ret = platform_device_register(&da850_evm_tl_leds_device);$ @/ ]/ b. @1 ~( g+ r& `/ ]/ g
        if (ret)
; t, h9 V6 Q3 z" j# P; h; A                pr_warning("Could not register som GPIO expander LEDS");
5 G) D2 k4 m8 E# r' D/ k  q        else
1 s! h' n, c4 X8 z                printk(KERN_INFO "LED register sucessful!\n");: x6 O2 h9 e( y0 F" z' N

( p% ?* c* f# ~9 G8 `        return ret;7 o5 t4 F' E# @# k
}- x" `- H" F& l3 p* y

9 r9 T5 F* o0 K+ a; Z% {static void __exit led_platform_exit(void)
# B( y! Z' Q5 e1 V9 Z{' `  ]# I8 s9 b* d: q2 K
        platform_device_unregister(&da850_evm_tl_leds_device);
$ W/ _( U; m" s" A% `1 L
, r9 X' Q( \9 G# [2 L: m  ~/ p        printk(KERN_INFO "LED unregister!\n");
, v7 t2 u6 o9 `9 ?1 I}
( b+ g' Y% O) m! p5 p  h* F( G8 l# a; i! S
module_init(led_platform_init);& m# `! f/ K3 a  J6 T8 b
module_exit(led_platform_exit);$ e8 H% J* A" J8 N: |
1 T; H1 m; Q: V1 P5 W" a
MODULE_DESCRIPTION("Led platform driver");% S) g1 i. t# X! ^8 C
MODULE_AUTHOR("Tronlong");
; R( p: Q2 ^7 O& e3 G3 c, qMODULE_LICENSE("GPL");& P7 p# G* z3 m6 c7 G8 h
: m8 Q9 c" ]! O1 l5 e
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-16 06:58 , Processed in 0.039937 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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