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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。1 x! v  ^" \6 t+ G6 I5 v3 U% i
#include <linux/init.h>/ |+ r, g' s3 a' h7 e
#include <linux/module.h>
9 A/ n; p; z* L* \#include <linux/kernel.h>% c  m4 I7 ?+ W, o& V4 a4 j# V3 W
#include <linux/types.h>
, G& p2 c5 o% g) C: }6 Z#include <linux/gpio.h>! v3 ?# |# W: M  ]; o# C6 c" j
#include <linux/leds.h>
1 ^7 j$ b3 ?$ q/ M#include <linux/platform_device.h>
: H' K) i% Z  ^! r
1 p+ f# P0 p/ p3 d' r$ H0 Y! U#include <asm/mach-types.h>
. S! p, O3 u+ r! K* J& }#include <asm/mach/arch.h>
. L- {0 O" A8 m- r. @9 ~#include <mach/da8xx.h>
. q  t7 M/ n# V& y#include <mach/mux.h>9 W8 W; Q# ~1 q( y1 E

2 C* X! p5 }4 O) z- l#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
" ?, [, @) A- [#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)4 Q2 q7 v% q2 i
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
" h' |- t2 E6 e1 u" J4 y& T7 s#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ |8 f, x$ ^) L2 X/ Q( l9 M
1 M4 S1 f+ k3 g* {: I$ u- A
/* assign the tl som board LED-GPIOs*/
5 c- R; @! {* R: G7 D! cstatic const short da850_evm_tl_user_led_pins[] = {+ N& Y1 f) |6 T' |: {3 d3 P
        /* These pins are definition at <mach/mux.h> file */
. K, E6 B5 b4 d' W% w        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ u1 Y6 y) a) Y8 Z& K. D
        -1) F$ y  s& {7 E+ [. ^
};$ p2 e( n1 w5 A( [8 x

. I# u& m- q6 E  ~' |* s4 ^static struct gpio_led da850_evm_tl_leds[] = {- ?3 L- x+ ~: V, `, ?5 [
        {
$ _  G0 w6 Q1 @  c                .active_low = 0,4 J, t9 a$ }5 A6 C
                .gpio = DA850_USER_LED0,
; B" K- p/ w: a+ f# k" n) |- z% `                .name = "user_led0",8 c$ g; `9 ]3 {
                .default_trigger = "default-on",1 g: C4 x) g( m% c4 E/ ^8 S
        },9 S* q0 v5 ]+ U' _* m) S
        {. ~8 {7 B4 @6 m' b/ q0 L! L% @3 j9 t
                .active_low = 0,
8 g0 @; \1 m% X( B1 p                .gpio = DA850_USER_LED1,
3 e6 B( R$ B- Z3 B9 T                .name = "user_led1"," k1 J& g2 R8 ~1 R! Y5 `6 ?) Z
                .default_trigger = "default-on",! C; r4 Q4 ]9 X* U9 }
        },
: g' j) e- W' o% t( @        {
3 K# d; b, C6 k& P                .active_low = 0,' P# q$ [! e) x$ W: z" j. t
                .gpio = DA850_USER_LED2,
, j" u6 `* s" b7 Z2 O                .name = "user_led2",2 D$ e, q  @- A) J
                .default_trigger = "default-on",- w: D) X# i$ f# Z
        },: m& p$ I) k  d# `
        {, q) X3 d) b* ]" {6 X( D, ^7 d  B
                .active_low = 0,5 d4 B7 f& S7 o
                .gpio = DA850_USER_LED3,
5 t8 B$ O, o" r  y  T; C' k                .name = "user_led3",
$ @+ y: `# Q7 t5 v                .default_trigger = "default-on",
' ~$ U$ G& G: B& s1 b" r  G2 u        },
4 N& w) a/ ^. i& {5 z( [};; s" ^/ U- \: Y' h1 J1 U( G
3 `0 |' x  D' }3 |4 t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) N$ K1 k) p2 a        .leds = da850_evm_tl_leds,
3 G! P5 Z3 X9 M        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% J# U6 ^0 ?( Z3 y# D+ ]$ d
};
/ W/ c7 m- R4 Q) u. B# C8 D" Y4 {
3 X5 T! t) M; I/ p: l3 i' q7 F4 estatic void led_dev_release(struct device *dev)$ L, J+ ~/ [8 @
{
6 c) t9 a9 C0 j5 ?6 m};6 J& ~. L+ t3 S& Q' k
7 O) J) C+ W# z. C
static struct platform_device da850_evm_tl_leds_device = {
1 k* d% S* o  H, J" Z2 Z        .name                = "leds-gpio"," q6 z- D3 t' H% d  @$ a
        .id                = 1,
2 Q3 j) |* }/ e  M2 ~  G! T( o' p        .dev = {+ C2 o- I% L* v1 h2 `+ ^5 K
                .platform_data = &da850_evm_tl_leds_pdata,
) n. H0 H  p$ A. N  r                .release = led_dev_release,% U. Y9 B2 A5 H- O0 O
        }) y; ~7 c; d2 i" J: j. T. d  N
};
) |2 g8 }9 x" z/ `. b/ S  B) Q1 a
2 [9 U- i# T' _9 Estatic int __init led_platform_init(void)
' m7 m: U  h8 j8 q4 T& j{% a: X4 ?  @: X
        int ret;
" P/ O/ ~" `$ p! |- k#if 07 g  X! ]0 P5 w: `1 \8 o/ t
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ v7 z9 T# F2 p  s: l        if (ret)
5 S; d  _" K) B5 u& i+ r- s                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 T( Z& h( ?+ F: @# F8 |                                "%d\n", ret);
$ s& `# L) M* y4 q# u4 X#endif' ]- J0 B  V9 F! C' J( S( D
        ret = platform_device_register(&da850_evm_tl_leds_device);
; W5 H3 e% C. Q' |' v        if (ret)
5 B( h/ ~4 n" i! T) M8 ]                pr_warning("Could not register som GPIO expander LEDS");1 J4 o& w6 `) Y' o" Z' S: h7 s
        else
& H  r4 R3 o7 S  ]: G- a/ ?                printk(KERN_INFO "LED register sucessful!\n");4 j+ H. h! s; x, ~+ m7 \7 x+ W7 U: W
* w1 U* R' @5 ^9 O) n
        return ret;$ \; [. D6 a! w/ Q; d! C7 j+ p$ i
}$ U. `# Z8 Y6 _* g) q
( L0 L6 Z) E9 Z0 J
static void __exit led_platform_exit(void)) e* x$ w5 ]( V) z( B4 v1 h
{
" P3 D0 N5 [' y5 l        platform_device_unregister(&da850_evm_tl_leds_device);
7 S# _' F: x" d  B% k+ {, Z) t( L% v/ R& Z0 y/ A1 H
        printk(KERN_INFO "LED unregister!\n");& W2 X1 }+ O6 _, `
}1 i: G5 p8 M# i" H7 ]3 F4 x7 ~

* a: g1 I. p# u- F; Z/ Dmodule_init(led_platform_init);
: q, y2 p) Y: P2 n% i% c" Y2 fmodule_exit(led_platform_exit);( Y3 d* w3 c/ n" ~5 f, k/ k+ p5 B
( D9 N' |5 y! E4 Z8 j! h
MODULE_DESCRIPTION("Led platform driver");- H$ R/ T+ a) @3 O
MODULE_AUTHOR("Tronlong");
6 @* ~1 i) D" E( X$ \3 C6 q# T2 VMODULE_LICENSE("GPL");6 c6 n+ s% u" Q1 R

+ D# E* E/ ]& v7 X
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-2 09:37 , Processed in 0.038707 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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