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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。$ ^4 R$ _5 ]/ B. d% t
#include <linux/init.h>
9 c. R# W- D% K- z1 S2 L7 T#include <linux/module.h>& Y( B0 h- w: L
#include <linux/kernel.h>0 C8 p/ @. H: [/ g) N
#include <linux/types.h>! C8 [+ W! @" Q  h3 r
#include <linux/gpio.h>! ?' i& g/ w' A" @; y
#include <linux/leds.h>8 w: m1 q1 M  y7 I" I
#include <linux/platform_device.h>; X* G" p/ s; @+ |1 {

1 B/ f9 K8 r' q% a9 I#include <asm/mach-types.h>" ^' I8 x8 J/ C# ?, k1 F# e
#include <asm/mach/arch.h>2 x  V% i/ v$ Z/ E5 B) ]
#include <mach/da8xx.h>4 q1 I+ [5 Q; i( h& ?9 T! x
#include <mach/mux.h>
& _4 _3 |! u! j5 }# A9 Z  x3 d4 M2 f) T
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)  Z9 k9 M! s' q  p: L+ Z* C$ T2 X
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)7 l3 s; L7 B) D8 o; Q7 j0 ~8 I
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
3 d( ~. D9 ^+ l& U; A#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
" S* ^3 s0 [9 v( i
+ G' e& R/ K& |$ I/* assign the tl som board LED-GPIOs*/  A% v* O/ z- V* o; G- ^
static const short da850_evm_tl_user_led_pins[] = {" A$ H' X8 T3 h7 A2 \! i+ I
        /* These pins are definition at <mach/mux.h> file */0 l7 ^9 j3 _. N  Y' K3 X$ ~8 h( m
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, k" A  Z2 g  E$ t+ f% `8 z2 j        -1! ^* q$ e( m& |1 w' ^  L5 s
};6 V) L6 x1 V; Z7 H5 ?
$ e: e2 x. C1 W0 v
static struct gpio_led da850_evm_tl_leds[] = {& W7 V+ [# r: b2 K% ?3 N  F) i: m  X1 I
        {3 F6 k: [' T6 a  ]3 A" Z2 u
                .active_low = 0,
- r" }% [& Q4 @0 Q* b- D                .gpio = DA850_USER_LED0,
/ u$ U- P' H" @1 A# P& f7 e" i                .name = "user_led0",) Q5 Z( a6 s8 a
                .default_trigger = "default-on",
& a6 S/ ~: w; c+ W- F+ a$ {* [        },
; M6 f- i! i$ T. ^9 Z3 ?, w; u        {
- ^! {5 e; ?/ n                .active_low = 0,
# Y) q: a, W  c* L9 V! L                .gpio = DA850_USER_LED1,
/ c3 h; V0 q: i' t                .name = "user_led1",
: r& D: a; m+ j                .default_trigger = "default-on",
; M! Z* {8 v7 C, ~1 w! N( G& P% b        },
+ c8 w2 @7 r& Z; A. Y; S        {
2 x! p6 N8 J' {* @0 ]                .active_low = 0,
: g  Y+ L& r7 d) @3 k0 Q- W                .gpio = DA850_USER_LED2,; M; \/ \' W: ^! W8 d  i
                .name = "user_led2",
2 K! r4 l6 K, r3 j6 c                .default_trigger = "default-on",) j: p0 H$ a% x/ o5 h, M
        },
/ T4 ?1 i6 r7 w3 ?/ a# n        {" X5 j( Y* G. a0 w, {3 ^
                .active_low = 0,5 K% d0 R  ?7 S# H+ x
                .gpio = DA850_USER_LED3,3 Q; ~' z# m$ n7 H7 D% |) s
                .name = "user_led3",
3 i; \2 V/ h9 E: J8 a0 F7 _                .default_trigger = "default-on",, e$ d  ]0 I* `) A0 k
        },' \* b6 v9 K' @  @. x
};6 _' N- [4 v8 D( S! e& D8 Z
' d9 o3 N8 \0 K& [; A2 h
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. s8 E! q' @$ S4 o  q) V0 y5 q/ y
        .leds = da850_evm_tl_leds,
. @% y- |5 e# ^/ H5 R5 Y        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. \* z2 h, q! V& r$ F" G( @};8 W$ i+ Y2 O1 b5 _5 h

' a2 o8 G* N$ G/ M) I& C$ ^' {# wstatic void led_dev_release(struct device *dev). }" S9 o3 y* t# A' o4 A# w0 m7 w$ }
{
5 v0 ~3 ]4 `4 n4 ^% q7 S6 [( G' H};/ K9 ?- o+ p* l  ?8 b5 g% D3 b0 v7 \4 b; `
3 c* Z; D% C! N) Y: f9 H9 g# t
static struct platform_device da850_evm_tl_leds_device = {
" ~/ P  n, W+ d" ~' h/ M9 S        .name                = "leds-gpio",
3 W' l( Z1 l3 }. ~        .id                = 1,
! ]8 F5 E3 G! M8 |; H+ x% z/ A, U        .dev = {
( i0 h# [0 M. j9 e" [; ]2 ^                .platform_data = &da850_evm_tl_leds_pdata,
- ^: f) F0 m. ?                .release = led_dev_release,; n* g1 F1 _( {7 `2 M
        }3 }& h2 B" s, t7 [3 a' e
};- `1 b! O7 \! P1 {' z& W
# s3 S5 R8 ]" X) q; X
static int __init led_platform_init(void)8 w1 w6 {  B/ y- p# c
{3 I! o5 S' F5 p2 {8 q/ o2 i
        int ret;
0 ^. C# j" K$ E9 k1 |#if 0
7 P! b- X+ C& Z2 _. S! Z        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 x% a7 r1 ^, h
        if (ret)
& i1 t3 K: ?; x7 M$ I4 Z                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 H$ R( e: G9 G/ e: i* V6 k                                "%d\n", ret);
% g6 ?( y. X% @4 k" p9 u. m" W#endif
# }7 O6 J  P* d3 d# a        ret = platform_device_register(&da850_evm_tl_leds_device);
$ M2 Y. G: D" U2 E5 ?( ^4 J        if (ret)
1 ~+ i1 u8 O4 i# v2 X                pr_warning("Could not register som GPIO expander LEDS");
( s/ y% i2 i" Z  H2 t' c2 @$ D        else$ T" H1 {( O2 O7 g# @: o
                printk(KERN_INFO "LED register sucessful!\n");
) n$ c- @( C1 \+ F
: @  K8 g, ~& x% V        return ret;# w& Y: u2 `  W$ X4 s- x6 ~
}
! a! q9 s2 s$ A7 H: L: w
1 M! S+ I) E0 }static void __exit led_platform_exit(void)
) C! y) @% o' p( j) B$ V5 f: s; _{  x2 b2 ]. B4 e# }3 t- ~
        platform_device_unregister(&da850_evm_tl_leds_device);$ D& h: w' \+ j5 F5 o8 }

( q. K( @5 g6 l& a! p2 J" x        printk(KERN_INFO "LED unregister!\n");- ?8 C; J: b  O+ _$ n. p
}
7 o" c* Y1 F' [- v
5 i) l5 H1 E6 ~9 Y0 hmodule_init(led_platform_init);
4 b, L- r! ?: vmodule_exit(led_platform_exit);' v  k1 Y* X6 }7 c' S

  S3 I; O+ v5 S# U6 N9 m5 EMODULE_DESCRIPTION("Led platform driver");
  n; M+ V/ \% c' r: O' |MODULE_AUTHOR("Tronlong");
! C+ R5 e9 r+ R9 _3 h; _/ M, e1 DMODULE_LICENSE("GPL");( ?( [, f# D- u2 L3 {4 q
. r- V& ?% g. A9 M
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-6 14:22 , Processed in 0.039226 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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