程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
, M, D' t* b5 {) U9 C. ]4 E#include <linux/init.h>. V2 {4 V8 j* ?! b% P+ }
#include <linux/module.h>! I- n8 \7 H+ n2 u) X: O8 T
#include <linux/kernel.h>) m1 \6 v: n9 ]0 z- K0 p
#include <linux/types.h>& y; \: y. H' K
#include <linux/gpio.h>
3 A; ~  a( d5 C, d: ^9 n#include <linux/leds.h>
! e: A6 x/ l- _#include <linux/platform_device.h>
4 ]3 A) H& \1 j* r+ F1 F. W5 v: R+ f3 e* ^; \4 }
#include <asm/mach-types.h>
7 P) M  C7 S& q1 Q# z#include <asm/mach/arch.h>
9 s! q" m7 y* ~8 t( R# b" `5 E9 T- p#include <mach/da8xx.h>
3 G/ C  s* Y& ?4 f#include <mach/mux.h>% R1 y6 `" z* `  E! b3 ~7 |  }
+ |% h. ?% ^$ G7 B2 Z% @
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)# J9 I# M5 x+ N  y8 ~# a& s7 }
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)3 J3 K+ z. D* Q' z
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)) `: q! R; `* t( X  e2 E0 N2 M
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
3 ]6 D5 q  ?5 `; }; ]
& n+ {8 O3 E* E! ~2 H7 d/* assign the tl som board LED-GPIOs*/
7 b9 V: Y$ `. ~static const short da850_evm_tl_user_led_pins[] = {
9 ^% p7 e. S3 w4 N( ?% ]2 g        /* These pins are definition at <mach/mux.h> file */5 x0 E) \: ]7 \# N5 e; @- v
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 f9 B8 q$ }/ Q& d+ b: s) c2 ~. L
        -1
2 l* }- W& o- G: G$ ]' S9 g};
- S; m) Z2 ~& C! w  w- B3 f4 u! ^  w; B% s' n
static struct gpio_led da850_evm_tl_leds[] = {
: _; B+ J% |0 r+ }1 C$ ?        {
7 C" V9 ~3 N4 M. ~6 ?                .active_low = 0,' _, S( a' a1 E# G% }, ~- C
                .gpio = DA850_USER_LED0,) |# }6 ~$ s0 _5 ]" w, |9 q$ {5 b( @9 t
                .name = "user_led0",
( a1 E( h9 M& r  m& A( Q                .default_trigger = "default-on",' @( h$ J  o: X* t- w# k' p1 |
        },
, `( \1 f5 u" k4 h: v9 ~        {4 ]3 I3 {: i. G+ r3 j  U% ~
                .active_low = 0,  n8 @2 Y' h- f- b) P
                .gpio = DA850_USER_LED1,
& V* `; v8 c+ p0 n3 }' S+ h                .name = "user_led1",+ Q8 ~* [3 z$ [: r2 v$ ~& y# u
                .default_trigger = "default-on",
1 g5 H! r$ ]9 F9 r        },
) X8 {- q7 l. K& v; x2 u2 m        {
  J6 B- R5 M5 N                .active_low = 0,9 l  \5 B# [$ I' X$ V7 ~
                .gpio = DA850_USER_LED2,5 j' z2 I4 J1 r! h* ?2 N: Q( ^
                .name = "user_led2",
5 D4 s8 v/ @1 s7 |                .default_trigger = "default-on",& U: G8 ~5 S6 _: i; r: Y
        },# k( Z, v- [9 u5 q* f$ v
        {  [' ?% w& i; J& p+ ]
                .active_low = 0,! E  `! e- z6 ?% o
                .gpio = DA850_USER_LED3,( k- k7 [' C: \# O* _0 Z
                .name = "user_led3",* r2 }6 R$ w- ^5 \9 i% B( ?
                .default_trigger = "default-on",
$ n" E* o6 Y8 s% b& y( z        },
$ Y+ v% e. o) K- ]};
  _" }" U. X) {: N- Q" T* ~% |
& |; e0 M8 q* \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ Z; e! f  _  Q: T5 ]        .leds = da850_evm_tl_leds,/ B, z0 b3 Z, q
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 a; z% L) O5 k% \2 q1 H% e
};) i0 u9 f; O0 U
: I/ _% w' @0 z5 I6 L# E4 E( G
static void led_dev_release(struct device *dev)( u( Q( E! J$ s0 o( b; W
{1 c* R0 s1 W1 l! w
};3 ~) N; m- |8 U- t1 K
. s$ v& X& r3 N* I
static struct platform_device da850_evm_tl_leds_device = {
7 ~8 m) d( R2 m. Q5 ~/ a+ ^        .name                = "leds-gpio",6 S/ h8 [. x- i& S# i0 o! h
        .id                = 1,7 g+ x% t, E  f; g/ X, k$ M
        .dev = {+ P+ H, ?+ T% U/ V
                .platform_data = &da850_evm_tl_leds_pdata,
/ J) ]" J( R' D4 B- u' J5 G8 u                .release = led_dev_release,
  K- W- Y7 U7 l1 n        }
  y- Z! Z: ~1 V2 o/ k};, R# m0 t7 o7 ]6 S& F
- X4 k$ E" I  T* E$ }7 q1 ~
static int __init led_platform_init(void)
- j, O6 A3 m$ ?9 s6 O' w' ]{
4 P! B; }) }' g3 `$ S        int ret;* \5 x4 H  Y4 t4 Q) R. M
#if 0' g7 v! s' h* _* l
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& p; S$ J$ ?/ O: ~4 J! |
        if (ret)
  [: g( m4 I1 E9 b$ ~                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! a5 L2 o# s# Y& c2 B                                "%d\n", ret);( F: H& g) j  c5 [8 |; e
#endif" J6 f% o: s$ ^1 f8 I& }& e% b
        ret = platform_device_register(&da850_evm_tl_leds_device);. B- U- J: w6 Z/ y( b
        if (ret)
+ x: {, P7 ^8 V7 N3 @! T                pr_warning("Could not register som GPIO expander LEDS");* q& R; i& U4 b7 r% P' b
        else
9 K$ q) h5 R# r4 U" f                printk(KERN_INFO "LED register sucessful!\n");5 ]+ i7 I3 p8 w0 K( Q& j/ Y

" x0 a' o! j  K/ D7 n) P: i        return ret;
8 @4 E* \6 A: x) H( i' h}
5 b3 W$ n6 G% `' a2 X# _, U5 g. D' \. x) Q
static void __exit led_platform_exit(void)
- \& O' {# L- I: @; Q{# z" q0 B4 j% d( Z# G
        platform_device_unregister(&da850_evm_tl_leds_device);2 J- ~2 o8 j- |2 y4 B

( C3 C) }) g% Y! M        printk(KERN_INFO "LED unregister!\n");9 n3 h' a  j8 i! n0 e
}, V& i+ N' R+ L% k3 ?
; M. l: E/ |  j  Z6 L8 J" }$ S3 k
module_init(led_platform_init);
' y5 O$ L, v" I, R% d8 Mmodule_exit(led_platform_exit);
6 L% R1 b7 t( ]. |
0 Z, C7 w9 ~& w) iMODULE_DESCRIPTION("Led platform driver");
, n' H% g  c2 i7 q2 I  ?MODULE_AUTHOR("Tronlong");( d+ ?5 C: I1 Q: h; \2 s% H
MODULE_LICENSE("GPL");$ T7 K( @5 A* s" K& O7 ?6 G
$ h% O: s$ o# {
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-1 19:36 , Processed in 0.035978 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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