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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
% d& A4 {1 N2 E1 l' p#include <linux/init.h>, V; g; b" Y4 A, r3 Z5 S
#include <linux/module.h>4 ]! c6 x! @! k3 u6 @' S  h2 ]4 o
#include <linux/kernel.h># ]- B" J: i+ N+ ]% `! p! P
#include <linux/types.h>' A; O/ B6 o7 ~' D4 E2 M1 j, b3 v
#include <linux/gpio.h>6 C9 p+ x+ L  h/ H- s. O
#include <linux/leds.h>
( v1 M% e. ?: x, j# t6 G#include <linux/platform_device.h>
* c- P' S2 R3 s% U4 Y) X0 M! G5 E0 K# N3 M* _# h
#include <asm/mach-types.h>! a# m$ @! ~- q, s+ M# {
#include <asm/mach/arch.h>
3 q# F) M/ h) ]$ h1 r; A& O# [% L#include <mach/da8xx.h>7 T* J. _# ?" h
#include <mach/mux.h>
/ |2 P+ R$ C; ~8 d! l% u) x- [5 [
! r  z& ]0 I' F2 v, X" G#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
. @7 ]8 b$ p+ Z/ T. r( u" z( A#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
3 y) Z7 K8 j2 I2 S/ L#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
5 b8 {9 N# C3 s) b7 S$ G5 O6 Q#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
" m: s+ u0 s% g5 T" L8 B8 ~5 y) s- A7 y7 S! h8 q) ?( G! {" ~& o6 b4 w
/* assign the tl som board LED-GPIOs*/0 ?' P! U. k* C7 K5 S, Z3 ]9 d0 n: o
static const short da850_evm_tl_user_led_pins[] = {
" t8 f$ l. h9 U        /* These pins are definition at <mach/mux.h> file */6 ~5 b3 Y5 r2 z: [
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ j4 Z% Z( e% X8 I- f8 z
        -13 x. T* b+ A) C5 L
};
- `* X0 R3 Z" `9 O% N5 D) _- o- w3 I7 b! w
static struct gpio_led da850_evm_tl_leds[] = {6 {( y7 A+ B' [* c7 \
        {& b3 i) f  F6 m/ q. R
                .active_low = 0,2 {/ B- l! f5 Y( ]
                .gpio = DA850_USER_LED0,
! n2 y1 t& n5 h; {( m                .name = "user_led0",
) e9 h# h0 [( `0 z1 [- a; `                .default_trigger = "default-on",; I) \5 T/ Y* [3 a7 a% b$ C  w
        }," w4 n$ R7 w4 D4 m- t& [7 @
        {4 f6 w  Q9 p. @
                .active_low = 0,
% ?" n9 Z% ~9 ~! i9 q& W                .gpio = DA850_USER_LED1,9 g) s- {% W, }& c# o* f
                .name = "user_led1",1 k0 v) I2 q" r! ]8 [9 ^( E' w
                .default_trigger = "default-on",+ Q* Z7 c4 n# ^  c5 J2 g: R3 O. D  J
        },! O  x. {5 b- A2 Y
        {
- c4 X  E+ B% e7 t+ I                .active_low = 0,
: D1 }" E+ {& v  p$ ^                .gpio = DA850_USER_LED2,& c0 r* d* w7 U# X
                .name = "user_led2",& k8 g, x2 @% l0 x) x
                .default_trigger = "default-on",5 Y# [; f% N5 P7 U
        },1 h, F+ N. F; U6 Z. j. y) z
        {
! z& q8 B5 ^0 L8 a  F, {                .active_low = 0,, G3 [1 a: E$ u) f
                .gpio = DA850_USER_LED3,, s, X# H% W1 v4 L
                .name = "user_led3",
0 K" w6 J: _6 v" p( k. @- G                .default_trigger = "default-on",
5 {- ]0 R! F3 x! r4 `        },+ X+ c5 d. k  G$ _7 m8 O* T8 R0 u
};
9 e) x8 K3 B- j8 f* L
3 B: x) a+ T' k3 F8 cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ M5 D/ f- A9 V
        .leds = da850_evm_tl_leds,
* J5 W* N$ }- P        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 m: v' p# ?' ^9 K: J
};
- }3 P4 H# J* @" w, x; W% ~3 ]* @4 K9 y8 z( ~0 X3 b7 o4 D
static void led_dev_release(struct device *dev)
5 n% h0 C& _; p, H{( \6 w' [- F3 s( |
};
8 N, ?: X  s, X6 `9 u* z
& l, s9 U5 J5 D( z$ B6 Zstatic struct platform_device da850_evm_tl_leds_device = {3 j! _; S* y. [
        .name                = "leds-gpio",# e; P, Z. J4 L% P3 }; @9 O
        .id                = 1,
4 b; D- L( e0 r& Q        .dev = {
0 U; p( p4 f  m: j+ c                .platform_data = &da850_evm_tl_leds_pdata,5 i  U, d/ |6 ^3 B; b
                .release = led_dev_release,+ g0 M* m4 s$ F- z7 S! F
        }: H: F4 F1 X& \& J% L; s
};6 _1 s4 a# L% p
. @* a2 Z3 G; n
static int __init led_platform_init(void)6 [; Z* d5 @! ^) r
{
) O8 C; w9 w8 L# p9 E( q& s( s$ |        int ret;9 k+ i) B* t9 I0 x- L
#if 0& P' ?- h: w2 W' N
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: q6 T$ t: n8 v8 |        if (ret)
, `! _5 X1 L# H* [                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* G$ |# N+ T# B% N1 j8 f2 S5 |. m
                                "%d\n", ret);6 @* Q  P- o( ?% V8 e. n, X
#endif9 N& b8 R& c5 H) e# Q5 l( o; [
        ret = platform_device_register(&da850_evm_tl_leds_device);
( }8 ?8 \( Z3 O% J1 p        if (ret)4 S# c3 e  G% C+ W! ~
                pr_warning("Could not register som GPIO expander LEDS");2 S; O* X6 p8 g5 X
        else
% o% I  ?) y- D# X( I0 h                printk(KERN_INFO "LED register sucessful!\n");& }5 ]* I1 N* I! ~# ?3 F2 l$ w
; ]1 ~- `. N7 F- K
        return ret;
' }8 y* o. }, z}
: X* D) c  C% X* `. F
3 i1 G4 L7 j: i6 B* [; M7 q1 n6 f- mstatic void __exit led_platform_exit(void)* S1 `; ^2 h3 r$ h2 K& b
{( X$ r- I+ ~( @
        platform_device_unregister(&da850_evm_tl_leds_device);1 f& |0 r$ |% x, a  [* V7 ^# _+ Y$ Z9 k* ^
1 Y8 U% L! \: f. `
        printk(KERN_INFO "LED unregister!\n");! }9 m) @7 v0 }/ @" z" w9 N4 ~
}
& B% h+ x2 E. g- u# e, C2 d: @' G3 A( N. I! U
module_init(led_platform_init);
0 k' d4 g9 W9 v- z  umodule_exit(led_platform_exit);. e+ s1 {% j1 N" b* t- j) H- X
* J$ G5 G: t5 J, g+ e0 m8 r
MODULE_DESCRIPTION("Led platform driver");5 ~) T6 Q$ ?7 N* w2 e7 a
MODULE_AUTHOR("Tronlong");
/ h& \+ B* [6 eMODULE_LICENSE("GPL");, Y1 H+ I4 d$ d! {) G3 Z# Z

5 V* _6 P' |; t8 _
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-8 17:31 , Processed in 0.038265 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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