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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。2 h5 V2 b$ b& a, X8 x. T! Z
#include <linux/init.h>
& a- X7 r& D" S4 M#include <linux/module.h>
" Z; y: o3 _" s3 l1 G5 D#include <linux/kernel.h>
* Z- J8 a: B% M8 b" {#include <linux/types.h>
+ p7 _( C( ~: Q#include <linux/gpio.h>
0 K) B0 p' ~5 m+ N  c: D( P! H#include <linux/leds.h>
% g0 N; y9 N! J7 A! i' f/ c#include <linux/platform_device.h>7 o: d$ r5 t) B

5 W9 f( Z3 v( ]0 x# Y0 }#include <asm/mach-types.h>: h3 ~; |+ b$ |  U" j
#include <asm/mach/arch.h>
0 ^8 w3 n1 h) t8 }#include <mach/da8xx.h>
# `* S0 K- d6 p) U4 m! \) g#include <mach/mux.h>
7 T5 p6 R! V+ N1 H$ |* D& `6 Y9 I: y- E
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)* z6 A0 S0 U: V4 j1 g/ L
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)7 w# x2 E9 a6 `* V3 T* l1 o7 i
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
! \* W! E  c3 D#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
: I& P# e# u4 H+ U, f
2 t3 U5 G# v$ P/* assign the tl som board LED-GPIOs*/
" `( u5 k" d6 y2 O- _1 V- }0 ^static const short da850_evm_tl_user_led_pins[] = {( [$ Z) C; ]% ]5 C7 J0 e
        /* These pins are definition at <mach/mux.h> file */* i! y# F* N" d  m7 l2 |
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ k$ F$ M" H0 n- I& {" t
        -1
1 o- B$ @4 q* f; B6 w};
. J9 v# k$ k+ c% V; {0 v! R# {. I) r% G0 D# s
static struct gpio_led da850_evm_tl_leds[] = {
% m7 O3 G: L, {6 r' b. f7 O* M8 I- i        {
* V* h9 ]1 S4 |1 N                .active_low = 0,( U: t4 ~: f+ e
                .gpio = DA850_USER_LED0,% x9 |9 x! D% i* ~* C. I7 R
                .name = "user_led0",
; x$ ?6 j7 U) {6 D0 w+ ?7 G                .default_trigger = "default-on",4 F" c4 j+ }7 O# j! b
        },8 |' G: k/ t8 i& x2 [" j- q
        {+ K$ h- K: H1 v9 L  D# A  Z
                .active_low = 0,' f6 ~8 g' J2 @; t# }. X
                .gpio = DA850_USER_LED1,
& |" F3 Z/ @/ n4 z. r                .name = "user_led1",6 H  U" Y! O1 s+ Q& Y' R( J
                .default_trigger = "default-on",
6 U% y- y9 M. m0 Q. ]& V$ ]        },
1 i3 h6 Z: r" o' W        {
( Z2 K: \! m, ?/ b/ G+ c                .active_low = 0,6 K' ?9 l) n3 K7 g  P  ~& ~/ z
                .gpio = DA850_USER_LED2,5 n2 e" F, u; f% P
                .name = "user_led2",
2 j9 E$ r. f! w3 O7 e1 S7 R5 ]                .default_trigger = "default-on",6 c  q1 z7 k2 |5 [* @& |+ ^
        },! |3 {( u9 d7 I" a0 u! g' Z- a( @
        {
) M% `; q) ^6 p, N/ W2 P/ O0 O5 S. [                .active_low = 0,
- x" P7 l/ {" _/ K0 g; v" O8 H8 \                .gpio = DA850_USER_LED3,
3 i/ f, b8 e0 a2 V/ X( @* m                .name = "user_led3",
; D# Y- B( W  M/ n3 r. l  i$ s                .default_trigger = "default-on",- C) ~# f; S3 z$ x
        },( r: ?- q4 n: @6 T6 E; [# z% p
};
' v# v& C( p+ ?) x* g$ c. p+ T. J% a) h$ ]
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; A6 p" g8 x5 q, S+ o
        .leds = da850_evm_tl_leds,* d$ U- q9 q' i
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# i$ p  n  C; W  B( d/ j; u+ @
};
$ A. p8 `+ F/ C6 M- v4 D/ T
2 ^0 ?5 i/ w' g) u* Xstatic void led_dev_release(struct device *dev)
6 r+ X. f4 w! B6 y{
" h/ ^1 s. F  }: r4 W) l! U1 I+ r1 _" l};
# j, H* w5 y8 O% B1 v* K2 W+ ^2 F+ d* m
static struct platform_device da850_evm_tl_leds_device = {
, ]3 ~: S& F9 m1 U7 m  f% o3 j! X2 f2 ~        .name                = "leds-gpio",
$ j# ]: _& z: u" r6 f        .id                = 1,0 J$ z9 y$ Y7 u  ^9 }# l, \% R* r' @
        .dev = {5 h$ w% {) ]* n* J" c- @
                .platform_data = &da850_evm_tl_leds_pdata,
! j" J% m3 X/ |) R3 U                .release = led_dev_release,2 C' {/ }) l% ~1 \
        }
; i- i& }8 M3 x; u7 F' P, M};
  T/ ~; ?% M7 x7 C5 v: {4 D' [$ @7 ^* N  |
static int __init led_platform_init(void)
0 G: g! r/ M. @- s( x{
7 G& Y! m# L& T+ b4 X! K9 d        int ret;
) j7 }7 q2 n. a5 D, Y3 o#if 0# I" C, C( L- c9 t3 Z
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) R* a6 M( E. U        if (ret)
2 ?8 O4 N, f5 X. T+ I) O                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; e0 C( T2 ~) p1 A  L% A7 }7 ?                                "%d\n", ret);) u( U$ E8 r# C1 g+ ?( x% s
#endif" @: r9 S# g+ W3 ~# {6 {* [+ p
        ret = platform_device_register(&da850_evm_tl_leds_device);5 a+ i; d5 w1 G* I8 I6 s9 r% i0 _9 ~
        if (ret)
% _, k: v# G3 Z, w: N7 M3 p                pr_warning("Could not register som GPIO expander LEDS");- r/ a4 f1 i6 E8 x: I7 L
        else
" Y( O+ _3 k& k! y* h0 @* C( m) ?/ ^$ r                printk(KERN_INFO "LED register sucessful!\n");
- m: D8 V; N8 x1 ~8 l
/ x4 M/ z, s7 V$ r        return ret;, {' p6 z0 e" k3 k$ ?
}
( L) f6 `  d) [) v# {4 {: k6 V3 {! X" L3 f
static void __exit led_platform_exit(void)" O% Y# X! g; Q
{( K0 Y1 s3 k, M
        platform_device_unregister(&da850_evm_tl_leds_device);, H& K( w2 ~. V+ n. u  ]
4 r5 B0 v2 Q0 g" c8 z- O8 c
        printk(KERN_INFO "LED unregister!\n");1 V9 l, A/ D" r
}" ]/ O8 B) D8 T+ v

8 Y! s6 F8 Z* ^' V6 q' T5 y. kmodule_init(led_platform_init);( O+ o/ y9 h9 J$ F" H
module_exit(led_platform_exit);$ M5 R/ P' T, R1 y& t
- N5 ?  C  O; a
MODULE_DESCRIPTION("Led platform driver");# M7 t* K1 M9 ]5 P) z& e' F
MODULE_AUTHOR("Tronlong");
/ p- D! W2 U1 y4 x! w/ aMODULE_LICENSE("GPL");
. i+ u% ?* [6 r& o. M* a0 e' X1 y! ^3 }+ M9 }
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-31 20:52 , Processed in 0.043343 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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