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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。# j1 O  m; J8 d. m7 _, K2 X
#include <linux/init.h>  W' D* V& c6 i9 d
#include <linux/module.h>* ?2 O( s* `2 j: }1 i
#include <linux/kernel.h>  ?9 B9 Y3 K3 d: Q7 }# O' x
#include <linux/types.h>
( E8 {& S$ |$ ]#include <linux/gpio.h>
% {$ M: M" J4 X: q+ O  L. C. C#include <linux/leds.h>
0 w( {' Z8 F- L3 h. x$ t#include <linux/platform_device.h>
9 }# E" y& z# c1 Q  M- s+ L7 w6 p% Y% T( K# i4 J8 b
#include <asm/mach-types.h>2 y2 ~6 ^  o) |5 Q
#include <asm/mach/arch.h>
4 u, k! Y; H" u! `/ u' @1 |  Q#include <mach/da8xx.h>
' b8 q, @# }% E+ c#include <mach/mux.h>3 t! i- D# b+ @+ H) r# D3 e

  V$ E0 T5 R6 {' }#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)' s8 c0 V( X, ?  K# s. P
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
# i. O9 p, G1 _  h7 r#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)5 v* m" }& W/ I) n. y( U5 ^
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
/ e9 ^' j, Z9 B. }: q( s( r5 L1 d2 s- j3 t
/* assign the tl som board LED-GPIOs*/
2 v6 ]. I0 O8 }0 @+ pstatic const short da850_evm_tl_user_led_pins[] = {
1 X$ r- K- L: d8 g+ f' z3 b: s        /* These pins are definition at <mach/mux.h> file */& d1 U0 q! ^& X' h; y5 [
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; m& n; e- v8 n3 h8 d! |
        -1" l3 p, U6 a+ U& z
};
9 c: f" m3 r# |2 H2 C
" {5 \1 j; v  H. E; lstatic struct gpio_led da850_evm_tl_leds[] = {
0 p) D0 d) ?4 H8 [        {* n% S2 V+ J/ g7 P5 v
                .active_low = 0,
) W8 j* w9 r. t* E0 Q+ r4 \" m                .gpio = DA850_USER_LED0,
7 I' u# F6 o; {1 j9 f$ t& E                .name = "user_led0",- L0 w6 N+ R* m
                .default_trigger = "default-on",
2 V% j! {, f7 D' Q( c' t        },+ @" t3 J; k, ^- X: I- B9 |
        {
$ z- o1 i: Q, i% G                .active_low = 0,
+ f% `3 w8 \  V                .gpio = DA850_USER_LED1,
1 B5 Z! |( `+ I1 i) ]6 P                .name = "user_led1",6 @" a! |  Y' C7 d/ n) Q, f/ M6 B
                .default_trigger = "default-on",9 R7 g# f8 Q7 g' ~% l+ x. A& l" [
        },, x/ b* t6 f% C
        {! J4 {0 i! e6 w" i3 g5 R
                .active_low = 0,
/ a) n. x7 Y2 V/ y: [) e: \                .gpio = DA850_USER_LED2,2 o- m2 O) r9 J6 R
                .name = "user_led2",
8 d- U) t: p! v                .default_trigger = "default-on",
0 e( |0 y5 p( j" y- w! L' m        },
6 I4 w2 U: m- b; a6 d        {- x; g3 R3 d7 o7 a
                .active_low = 0,
- F3 G- u1 w, H4 r                .gpio = DA850_USER_LED3,
& Q3 o4 l% s4 r% U: ]                .name = "user_led3",0 E% P" p$ A4 ?
                .default_trigger = "default-on",
3 ?) |! T5 T2 P& N        },
) v0 U# H; s' S+ s};
) K, Y' @1 A5 ~, ^' k; f9 ]5 _, ?/ z3 B' e0 k1 i; O+ ^! f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, b6 _. h  c) {8 o$ F4 @+ {0 W; Z8 o
        .leds = da850_evm_tl_leds,$ i# b* [( }- V# X$ A1 [0 _1 a
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& f# R# g$ l' f  k+ v
};
- D; [7 @2 {, _( P5 Y+ Z  w# U: O- `
static void led_dev_release(struct device *dev)3 w, o) y# s/ k
{
9 L! x1 A; f3 @& b8 E};5 P: v- u2 }. B2 M. q
3 G1 [" F6 {9 x, W! e  k1 I
static struct platform_device da850_evm_tl_leds_device = {6 P+ r, l3 A. k# X( g$ K
        .name                = "leds-gpio",6 Y/ \2 e8 x: p: x* y% G
        .id                = 1,
. B- Z8 S* O% g6 K* Z% N' v        .dev = {( G% a0 H' t$ S# h* ^
                .platform_data = &da850_evm_tl_leds_pdata,# Q  O! a* S# `3 b) s: T
                .release = led_dev_release,
# Q4 N0 [: d0 f/ y) d3 B3 W' H        }
5 M( c% Y! w% c3 I' N/ s};
$ W  v4 m; W7 m' q7 v& U7 h! c; x+ _5 U& o% h  M* V! O
static int __init led_platform_init(void)
+ b5 F. r, H  h) I1 C1 i{& A$ d' |" `5 B! C4 Y0 A2 j# x
        int ret;/ \) A% s0 l* ^; v3 ?9 j: j
#if 0* _) }6 ~) _- k# e
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 w. p8 V0 R0 q7 T
        if (ret)
! l6 O) I8 i0 C/ f                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 K3 T/ z  b" c6 L) C- X$ ]                                "%d\n", ret);
+ w9 R( h  {% S( S6 ]( N2 q#endif! W9 Q1 j1 p2 e5 N0 q3 Q
        ret = platform_device_register(&da850_evm_tl_leds_device);; a" Q. o( W& c$ S: E" ^
        if (ret)8 a' M. r1 @  n1 Q# D" |8 E9 y" O4 R
                pr_warning("Could not register som GPIO expander LEDS");
# e4 i: |9 Y" Z( Y4 s        else0 R- ~; \6 ~# `5 `' j2 G
                printk(KERN_INFO "LED register sucessful!\n");
8 @: L4 H* R, M
+ V/ T: ?( m3 I8 v        return ret;  I9 ^/ O) U3 z; U% Y* @! Z
}
+ B  X( C; [5 o" t3 y) ]
% z2 d  Q# D( N1 ~static void __exit led_platform_exit(void)
9 _5 o. W3 b6 m8 v/ W{. @8 v: a& U6 r* M# l) j; L: B9 Y
        platform_device_unregister(&da850_evm_tl_leds_device);+ s& G( t- q6 q

/ q9 L; _1 H6 B8 G        printk(KERN_INFO "LED unregister!\n");; {, t9 [# ?2 J9 z4 L
}
( N; n0 A4 E8 F" g; ?  p0 v
" P1 g! m: L) q. T$ _- Wmodule_init(led_platform_init);5 r( s* z# @3 @  w# N
module_exit(led_platform_exit);
# h) K1 E- W3 c0 I. ~
1 p! `5 [! Q4 U7 u  J" W2 \MODULE_DESCRIPTION("Led platform driver");$ J9 C( y$ z- \5 k" Y+ l
MODULE_AUTHOR("Tronlong");  t% [0 h" M3 V
MODULE_LICENSE("GPL");3 c4 ]: j2 q# L( H) J

" y. a6 i# x$ B8 ~( h4 J
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-5-23 23:30 , Processed in 0.038742 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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