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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。4 ^8 g- e0 o; m0 ?5 P: t7 X
#include <linux/init.h>! x9 M: d3 L: X
#include <linux/module.h>! t8 D) W, m, a  ^
#include <linux/kernel.h>" i+ q$ ~; f: ]5 O7 n+ Z+ L
#include <linux/types.h>, [! G! e3 P$ @! V
#include <linux/gpio.h>
9 @' R- Y* w4 j#include <linux/leds.h>
7 t8 ~/ P! u( W#include <linux/platform_device.h>8 z$ y$ ^" t1 T  Z$ R* @- P
0 m* M4 g5 ]( X( A) @% s# m
#include <asm/mach-types.h>
7 ?9 v% i/ D& |8 B; I7 S% R#include <asm/mach/arch.h>
+ q( j4 I6 s( L# [5 y' _#include <mach/da8xx.h># _! F, v& s) A5 Q1 N8 V; f
#include <mach/mux.h>. k. X* m. b# K  q4 d5 G
3 Z4 H. _. i' W& B- K7 `; Z% \
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0). n; g7 U. A- D1 {
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
' c) `# P# U' ]* X#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)6 q) |. t  q$ U- p+ f1 h/ V  }
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)' i1 p# T: B2 z% q6 w$ f" w
5 s) i8 }/ j+ U3 o. Y; o+ V2 A5 [; W2 d
/* assign the tl som board LED-GPIOs*/
" P' q" N) \2 Z2 d, H0 f6 Cstatic const short da850_evm_tl_user_led_pins[] = {
% k. M* I5 a/ p( a% z+ q        /* These pins are definition at <mach/mux.h> file *// d3 n$ N, x! X* B
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% D& q/ T: k3 L        -1
* g1 `8 d5 X- j! k+ q' \9 {* j6 R- y};
& G% R4 ^) ^# ~. @1 U
8 h5 r+ M) ?% p- V% |! wstatic struct gpio_led da850_evm_tl_leds[] = {
! y& G1 V1 P/ H2 \, j- f; @, a, o6 w* n        {9 e2 x+ D6 c9 s2 J; ?1 k* F# M& l
                .active_low = 0,. F3 ?: q! \/ o
                .gpio = DA850_USER_LED0,$ B8 O" l) B& y; v+ E8 A
                .name = "user_led0",2 C4 W5 L7 q+ p& t0 s1 }
                .default_trigger = "default-on",4 h: E* p; q& f
        },1 r- D  R) ^+ n. y& H8 _
        {
7 J# _; E4 ?6 e# r3 y) t; H' L                .active_low = 0,8 T3 |# @2 }6 Y8 [9 r" \
                .gpio = DA850_USER_LED1,
9 Z5 u) o( ]6 D  t6 P" m                .name = "user_led1",
6 l+ n8 h+ I" f                .default_trigger = "default-on",
3 F! w, |8 H( a! W        },
' f6 d! f3 _, b3 T( G        {5 }$ |4 L8 A- ^; \3 u6 O$ t
                .active_low = 0,! B7 Y' J& L) [3 A4 N% v
                .gpio = DA850_USER_LED2,
  C; v" q' ?: q% \5 c                .name = "user_led2",
- W" O7 o2 W  Y9 i( p: c                .default_trigger = "default-on",
# ]3 m$ e) u6 {/ Q) e        },
" E, N: N9 Q! h' F2 R- w6 b0 J        {, G1 k+ P% @: K: y
                .active_low = 0,
5 t, K$ P. }' f                .gpio = DA850_USER_LED3,; x  l7 Z9 |: q" y
                .name = "user_led3",
7 \' Z/ `$ ?; Y                .default_trigger = "default-on",9 I; q6 k' c6 e3 C$ k
        },$ o9 _, \5 ^! ]( A4 K
};
8 F! a- l: R" }" k
5 U' ]! V: a  A# J5 b! C3 h% Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. ]& T( w! |$ x( F' u1 Q) V        .leds = da850_evm_tl_leds,. X2 E, w. F3 R! ^1 Y7 H+ q2 i
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# d/ S; E( @& O6 l6 C. u};
5 i4 U7 s" b- N, A
1 y: i) O& i! w$ y2 ?# c: v' |' Nstatic void led_dev_release(struct device *dev)
- R" A$ b; \" e  k( B{
# z/ `) I6 P5 H};
4 \- R, i1 A+ w+ ?) d$ o3 h# k' h* K8 ]8 B( b
static struct platform_device da850_evm_tl_leds_device = {
/ X0 M3 A8 H8 [( _/ R        .name                = "leds-gpio",
& M5 j; d0 c, q& E+ Q- u        .id                = 1,& V: [9 S& [5 R1 }5 u7 s$ S- x: L0 P" t
        .dev = {
+ K( U1 ~+ d2 G3 Y" E                .platform_data = &da850_evm_tl_leds_pdata,; O/ U' U, ]- c
                .release = led_dev_release,! S( [1 Q) q0 d( T. U
        }, `# q: [$ f7 V  |; l! ~1 i6 M
};
; J* h8 E  P9 c6 w# Z% z3 l8 [7 t  f& V6 ~% L2 O& S0 Y# Q: O
static int __init led_platform_init(void)2 {7 F; \+ c. o1 [) L- s8 M: @
{) y3 q4 R! @5 p7 q
        int ret;) W+ p: H7 n' t. v3 E% K4 R
#if 04 P8 `# I, `. S0 N% G! ~! H
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; X6 J4 f" A2 O: a7 u' b9 x
        if (ret)' F5 w8 X/ i* x' l9 d
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :") R- X% q# o, Y' M
                                "%d\n", ret);) p& w& x# F7 |) V! x% K+ J
#endif% ^4 i% [/ Y# D- ]
        ret = platform_device_register(&da850_evm_tl_leds_device);. u1 n- B6 Y4 n, {% S2 o7 I% z
        if (ret)6 u8 T7 M' Z5 D0 l! ]+ Q
                pr_warning("Could not register som GPIO expander LEDS");& x9 _' |* w1 I% ]7 [5 _2 n8 m
        else
+ p8 _0 c, l% E1 s+ `% x& q                printk(KERN_INFO "LED register sucessful!\n");8 F8 S2 P5 M* L9 n
/ a' p2 E/ C! a
        return ret;
0 E0 i6 u% w9 z) s% V2 b9 \, i}
4 `: X3 a$ X$ t% w# ~! t$ W+ y: a
& a6 u) z! ^/ @! G3 ?! t. o+ [% nstatic void __exit led_platform_exit(void)0 B3 ]( i, k% ^2 j
{
, f; U$ y) d8 m" I8 y- O2 [- f        platform_device_unregister(&da850_evm_tl_leds_device);4 q3 P- v$ k, c  z1 q

/ E+ X5 v5 y* b: O        printk(KERN_INFO "LED unregister!\n");7 F+ ?% g+ F. P
}5 l: e" z2 C6 n2 b
% N3 b2 q! U) `) _  K. O/ R
module_init(led_platform_init);* C0 `. L. R6 c  Y" c
module_exit(led_platform_exit);- |3 ?' c/ G4 n8 f1 d  A8 A

3 S! P/ z& ?2 @8 ]- p( gMODULE_DESCRIPTION("Led platform driver");7 u9 t( ^; r; P5 R7 g7 w' E  s( ?
MODULE_AUTHOR("Tronlong");4 X& H& d; B3 Z+ q# A5 f
MODULE_LICENSE("GPL");
* `3 |1 U7 {0 v/ L( G3 g1 f5 W( [: i- D% s
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-3 05:57 , Processed in 0.037581 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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