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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
) o- L0 K6 K0 Y7 ^8 n6 y#include <linux/init.h>' m" ]& J/ W& A4 M2 |
#include <linux/module.h>
9 k) Z2 j3 w; {" r' d#include <linux/kernel.h>5 i& T8 U( u6 q
#include <linux/types.h>5 p2 f( {% f# H$ Q# P9 i2 u
#include <linux/gpio.h>
3 A9 {, [! @' C  d% i#include <linux/leds.h># B+ m- n. h* G
#include <linux/platform_device.h>% E/ f+ N; G+ Y

, H$ w4 j9 j0 b$ z7 M" ?) E#include <asm/mach-types.h>* E, M7 Q" p0 a9 E% c
#include <asm/mach/arch.h>
! w% }$ v, e* P9 K#include <mach/da8xx.h>: j+ h+ d( f& e
#include <mach/mux.h>& M- |. D6 H) p, P) ]  m1 K
8 v  Q. X+ n2 u# |2 q" Y
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
6 u8 V( X% }( d) n0 A& d#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
2 M. |- C6 h4 N5 o1 Y#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)% m6 u; H, Z, K+ }) `' o# j6 Z5 H
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)# B7 N9 C8 _. R# [; o

& l4 ?2 F7 X7 M: G' k) z: p" v/* assign the tl som board LED-GPIOs*/
1 }3 D& d, r+ |% J7 Y" jstatic const short da850_evm_tl_user_led_pins[] = {
' w' l$ U# w7 m7 P2 N9 D- C        /* These pins are definition at <mach/mux.h> file */# f' y" r) _5 [% l) f
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 v" [1 @3 }( T        -1& @# A# q, H/ S5 }0 \- w7 V
};
7 j( r4 b7 j' K$ {4 ]6 R% S) b, I6 Q+ K2 j( W
static struct gpio_led da850_evm_tl_leds[] = {
4 w" Z. v3 {2 {0 I$ r        {
5 Q( a% y! W+ F& y/ I                .active_low = 0,* [/ J0 i8 U7 I- S" M: g7 |) S! ?
                .gpio = DA850_USER_LED0,
0 }  e' Q( o% V+ l' _                .name = "user_led0",: q8 F  E" s% z7 `" @8 x/ q
                .default_trigger = "default-on",8 m+ ?" N' n+ ~/ ~
        },# [5 z6 e$ s  j2 q2 ~$ ^, P
        {
, ^3 _: \7 y: v9 p! B6 I                .active_low = 0,/ a  O0 J+ W# O$ W% K3 {
                .gpio = DA850_USER_LED1,, F+ N' |. x& Z7 T; t
                .name = "user_led1",# o' Q, y5 s) ^
                .default_trigger = "default-on",
2 B- O$ E8 A4 d% ]        },( g  w4 v. i( `# q: O) ?9 [, Q
        {
  e/ [$ y! G1 s" h6 d                .active_low = 0,
  c, t7 f, d( |( t! Q                .gpio = DA850_USER_LED2,; ?+ Q; C% a! x  w6 |
                .name = "user_led2",% Z2 a" H4 S7 @) A, M$ {! D7 s1 |
                .default_trigger = "default-on",
3 Y7 Q8 L4 ?) {$ W        },
- E  L1 C  u( U8 n        {) G( Z$ D/ ^& C2 g, s3 F0 h
                .active_low = 0,
6 k" [4 @: c8 f                .gpio = DA850_USER_LED3,
1 _2 a' r* z8 p: O+ B  ]                .name = "user_led3",' j& x3 {1 y5 b1 U' {6 u2 y8 l
                .default_trigger = "default-on",
6 A0 d# r: Z4 x+ w6 |        },
5 B3 J) f/ ]4 f: W9 h};, g+ g  E, A+ O0 W3 K/ V
3 h/ P. e1 n7 @! w5 z+ x% x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. t5 J  B& U+ M) J% ]) i. {
        .leds = da850_evm_tl_leds,
* B- q1 z' Z" v* J: @        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ \) d) `8 v+ {
};. C7 [. v# d  ~9 {! A/ v1 C: }  Z

- h! |8 h/ \. F0 B; Zstatic void led_dev_release(struct device *dev)* D# ^3 l" O' v
{& ]. Z$ E  Y& t; X
};& N) F) D7 M% c$ f. M4 [& c. B6 x
& u# J( B: J/ n
static struct platform_device da850_evm_tl_leds_device = {
/ h5 I5 P' S. t- S        .name                = "leds-gpio",6 n" l" u2 U3 l- Z& v
        .id                = 1,+ E& ?' I" w$ X! h/ \. E6 _
        .dev = {
% `! D$ K4 j+ C* N& S                .platform_data = &da850_evm_tl_leds_pdata," d9 A( o* `9 U5 p$ m- y
                .release = led_dev_release,4 x! P* e4 \7 f/ o! @( e  v
        }
* s" _0 d7 F8 W" s  _+ g};, e" k7 M) D  l/ @) x
, S8 b! }  V  P  M
static int __init led_platform_init(void)
- s! [  @- ~& P. P9 Y4 C+ {2 Q. Q/ |{
  R; @& {+ x! K: I" [$ M5 Y: S; ?5 K        int ret;
3 I8 ]) ~/ P; V$ s; u( C$ c#if 0
. q$ X9 \- V! D$ z        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ ~; q: }& h1 u4 @
        if (ret)4 a& d1 O6 X4 F8 h
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" p9 X' ?8 |# i                                "%d\n", ret);' N1 F8 U* i5 F: m4 C- U
#endif8 S7 i  }3 N$ \$ _+ ]
        ret = platform_device_register(&da850_evm_tl_leds_device);
' z/ ^. D5 F6 o* [# }# R5 y        if (ret)
9 e, K# I  `) u                pr_warning("Could not register som GPIO expander LEDS");& F( a) y6 \! e3 h+ t4 @* W
        else
, `  Z/ \. n4 b) V$ ^8 U                printk(KERN_INFO "LED register sucessful!\n");
$ c% g  B9 J; F
; v4 o8 o+ W6 x! B5 M! k        return ret;
4 B7 z' Y( H% S  e& O0 z! l}. s% s3 V( j: O$ e' S; ^
' u9 y% e* q+ ~
static void __exit led_platform_exit(void)
2 H3 @8 f- z/ Z: I6 A5 X* R{4 ]! T' d. \5 E7 F! f
        platform_device_unregister(&da850_evm_tl_leds_device);& g. b  f) B8 p+ t
+ x( O8 M/ H! O$ F4 x
        printk(KERN_INFO "LED unregister!\n");1 e. n; k; I$ {6 [/ u- N* x4 ~( n
}
# ?3 }" O$ Y( C% K1 x0 v
0 i0 |: }; r$ k& Pmodule_init(led_platform_init);/ R7 h' y, l2 d4 Y
module_exit(led_platform_exit);) z+ w9 s  s8 A" _7 ?

8 t1 B' R) n: g; v$ K1 xMODULE_DESCRIPTION("Led platform driver");% Y5 U, k% Y1 f6 ^: W0 f  t
MODULE_AUTHOR("Tronlong");
" c0 ~4 W% P! w! x' eMODULE_LICENSE("GPL");
" Q, U) D# Y% R1 X
1 p6 q* k4 y' I3 l  ~3 R
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-14 11:35 , Processed in 0.039012 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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