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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
1 q; H" n5 B) |& @4 e/ B#include <linux/init.h>
0 a" W& _0 }1 K#include <linux/module.h>
# m' B5 K. y0 w4 B0 n" {#include <linux/kernel.h>
% j( D/ r. y5 ^6 C  I#include <linux/types.h>
9 c# s6 ~# L& E: ^; u#include <linux/gpio.h>- Y6 T% j- v2 @- T" l+ S
#include <linux/leds.h>
' b" t8 L3 _+ P& l#include <linux/platform_device.h>8 n& |0 W+ g- R# R  w4 c% M
$ u% ]: N& U2 p( A
#include <asm/mach-types.h>3 Q1 ]  V( H+ Z" t3 G% }3 \
#include <asm/mach/arch.h>
& [8 j- v! E) ?# c, J; f#include <mach/da8xx.h>
& c$ R6 U7 S/ K" e5 [#include <mach/mux.h>
1 x- k6 F9 b: ^0 [$ ^& F+ }+ U& {
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
3 i% s8 }$ p) C, a8 q' `2 X1 T' K#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)8 S" Z2 ^0 Q! p; N8 E
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
( `" Q6 P& Q7 t5 {#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
' m/ }5 P) z$ A$ [! r
2 J$ I; s6 H9 O7 [' N* L/* assign the tl som board LED-GPIOs*/
% F/ J; \1 V! |6 G8 qstatic const short da850_evm_tl_user_led_pins[] = {
0 C4 n5 z8 Z$ e5 |  W6 h        /* These pins are definition at <mach/mux.h> file */+ X+ U1 ]7 ~3 s( q' a
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# F6 q4 t% w0 y( p. N- L0 r6 j  |$ [
        -1# g9 c5 Q5 C) x$ e: l1 l+ N
};
0 ]% l9 w; a# ^' o5 R9 j+ }( }  K3 _& ~5 O: ^4 g/ u
static struct gpio_led da850_evm_tl_leds[] = {
; i5 y& c$ D- T  r        {
0 f. i  b' y8 r  ^                .active_low = 0,3 c# b9 g2 J* P% l
                .gpio = DA850_USER_LED0,
) O( A, |. D7 x; k2 G                .name = "user_led0",6 M: d" M8 A( c# y5 r- M
                .default_trigger = "default-on",$ `2 g4 j; ~5 E
        },+ [0 `) A2 }7 R( h
        {
1 E2 A) @" _/ Q9 _( Q                .active_low = 0,6 q- I' l) N% j+ O6 m
                .gpio = DA850_USER_LED1,+ c: e4 `; j/ u' _+ |
                .name = "user_led1",  U- L9 ^& E  X8 F' d
                .default_trigger = "default-on"," A/ V8 g( h5 o& h" z) h
        },4 y5 Y- p/ Y" N7 J9 ?
        {
2 C" Z, ?( o: T1 I                .active_low = 0,$ i5 C* f$ P: L* i7 o% I
                .gpio = DA850_USER_LED2,, h5 R: x7 C! T- I' a- A  }# w
                .name = "user_led2",
2 C' l8 @2 W1 W) r8 N+ y& t, A                .default_trigger = "default-on",
2 R* t, p) R, [& {$ }        },
8 Z) ]/ j7 [5 k* b8 U  [0 J        {
* ]8 u- L, a9 M8 |  f" @5 x                .active_low = 0,
7 K; \& J$ W8 H: t5 R                .gpio = DA850_USER_LED3,3 X5 A% y) v) k) C8 b
                .name = "user_led3",) l6 N3 S6 b4 R4 P$ ]0 f/ S
                .default_trigger = "default-on",0 Z* C  R3 _/ c0 m, b( j; p0 S
        },+ A. V1 h% i% T% w. Z9 g
};# Y& h3 J. [2 f) ~6 b* n
+ z4 [' a+ e4 C3 x; ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 w" a" d0 T- J& ^6 ^
        .leds = da850_evm_tl_leds,& T  x( e! a  V
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 @; n8 c* }+ y  g) P};3 a. w! E( d# l
8 `' b2 ?; z3 u- E4 f( s" n! M
static void led_dev_release(struct device *dev)1 Q0 i4 j, o% j4 T) x! K
{1 A( _- ^% ^$ a  I* H* Y9 ?
};* |% Q- H* C, ^/ l" U

5 Y( E. t9 Q- Z( @0 Y& P2 rstatic struct platform_device da850_evm_tl_leds_device = {
  P* F+ |  q9 Q6 h# S% o+ E        .name                = "leds-gpio",
! C1 K. u# q' Q3 P( E        .id                = 1,  d2 a1 O+ h, `; {
        .dev = {
. c1 O: G9 l: U% ?9 J& ~4 a9 }( _                .platform_data = &da850_evm_tl_leds_pdata,
; R8 _1 S1 c7 O5 M# Y                .release = led_dev_release,* j- v1 O' l4 R3 j# b5 v. N
        }
2 w6 h8 i. o' s3 \. g3 R1 f9 i};, B& v$ p" G( p/ {; ^

2 f( g$ G" i/ P, A2 ustatic int __init led_platform_init(void); B3 J' E# M9 |, B
{& Z9 _4 B! v: Q+ c4 P/ d* ^( s
        int ret;
% A* Y  a) V( s3 J1 C#if 00 y' ?; L( Z# h7 S. Y0 c5 M
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ X( h; i4 K' h" h' f" V  R' e5 X: }        if (ret)  F! e/ x0 A% u1 v1 G- _
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; j$ h5 V9 k/ Y                                "%d\n", ret);8 E0 `8 K( M4 |' i. x
#endif6 m5 C5 j8 A  B( t; N7 D
        ret = platform_device_register(&da850_evm_tl_leds_device);, S# ~9 S- _' R- R3 w
        if (ret)* ]% i& t3 J+ x3 R; G
                pr_warning("Could not register som GPIO expander LEDS");3 K) ~- {  p% P& P) G; n
        else
1 V' s+ ]+ I! x) u( _- {* c                printk(KERN_INFO "LED register sucessful!\n");! }- \) q6 \5 [' C* a9 z
$ I/ q7 V* ]1 I& a
        return ret;. z( b1 G$ {3 J: F
}
! w) X2 G9 E$ Q6 T
) S5 B8 H- s9 c1 ~+ a1 ?static void __exit led_platform_exit(void)
: z% V$ w3 r5 ]2 H/ e0 Y2 i8 k{0 X# G; d* o% a" m: [3 t: c/ R
        platform_device_unregister(&da850_evm_tl_leds_device);2 S" V* Q) R  h, x
% ]) R- y2 Y3 c! w
        printk(KERN_INFO "LED unregister!\n");
) R/ r, z/ \  C  U0 L5 G' C}1 S9 ]3 A1 ?) u8 i; r4 G

, R0 L/ ]" G0 N, ^. smodule_init(led_platform_init);
. ^5 v8 X, m# w1 y: I& ?module_exit(led_platform_exit);
% g* k* v6 m* Z! ?9 C1 O$ W8 B3 Y  I: `5 ^1 Q* H1 X
MODULE_DESCRIPTION("Led platform driver");
/ G: ]. o' P: A0 G0 LMODULE_AUTHOR("Tronlong");* f) c1 V  h. I4 O) j/ c
MODULE_LICENSE("GPL");
+ c, }7 m4 v8 w7 }$ o% h/ W$ p) l; l
# G0 G+ y1 v/ L* L4 y
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-2 15:56 , Processed in 0.036453 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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