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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
* i+ d& p8 S1 r" [  W: B8 c# }#include <linux/init.h>
  b8 T9 f& R  P; ~# l#include <linux/module.h>
9 z: H: n+ b1 q/ A1 X#include <linux/kernel.h>
, T* L+ |( A2 t" m7 m0 H#include <linux/types.h>9 d6 t$ u/ E  [
#include <linux/gpio.h>: j6 ?0 a; x( l3 V. ^" e0 J
#include <linux/leds.h>
8 P) _3 s' f. M* Q#include <linux/platform_device.h>, {7 q# U  N9 l8 c1 q9 B

6 u* m0 A+ ]/ z+ p( J#include <asm/mach-types.h>
5 U/ Q# B: z+ i; c( l5 ^6 H, f& l#include <asm/mach/arch.h>
; U$ W( c; `, Z% H: x! n#include <mach/da8xx.h>( f. A$ T6 D+ C( P' C9 Y& k
#include <mach/mux.h>
  r8 d. c. m9 \% ?0 S6 q
  |* b" {0 a. b2 X0 u#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)$ Y, I* |4 n, t1 q2 _! O7 Y/ {1 \/ v
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)) o9 s6 D% N8 a5 q5 R8 J
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
$ k, a; A: D: m# n. a#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)9 ~6 @3 w; \3 y  J+ F

, I+ u. h* v8 |5 O2 I3 ]8 B/* assign the tl som board LED-GPIOs*/
$ m, H: x9 N$ ?/ e& zstatic const short da850_evm_tl_user_led_pins[] = {/ w+ q7 V4 N6 o7 s' j- c4 m$ R$ Q" c
        /* These pins are definition at <mach/mux.h> file */
6 z0 ^- ^0 l+ m  C( _, c% U        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 _6 `' A8 f3 ~; q) ^
        -1
) f/ b5 _$ n$ d" J};
" H( S# e$ d8 J* E+ `7 Z3 y( `# o  V' {+ @7 Q/ z7 I
static struct gpio_led da850_evm_tl_leds[] = {
9 E8 o- D- m3 @- H+ b% f        {
  n0 d4 K) e& y2 F* f                .active_low = 0,$ O3 x5 ?7 m0 v2 t6 ?' c0 ~
                .gpio = DA850_USER_LED0,4 G# X! L- ]6 r* w% a
                .name = "user_led0",; Q% \. X# ^5 ~0 R" I% z! g
                .default_trigger = "default-on",
/ J3 }# x' I3 \4 ]( w        },9 `/ l$ e0 F) _3 h# J1 c' D
        {  Q7 I1 \. P0 B0 h4 N9 d( c
                .active_low = 0,7 @" N& X5 b# q: e, J6 K9 d
                .gpio = DA850_USER_LED1,6 w9 ]+ c7 p4 ^  j  f
                .name = "user_led1",8 o* f- P7 X  X0 Z- s
                .default_trigger = "default-on",6 L. A) P; T& Y& T
        },
) S+ Z: }* Z# k' M0 v        {6 \" B9 F4 {) h  A5 n
                .active_low = 0,
0 i! i# Q3 v( |  T2 s                .gpio = DA850_USER_LED2,
" n! S! O8 P0 C7 H! I                .name = "user_led2",
1 u. ?" s7 R/ W# R! s                .default_trigger = "default-on",
4 L) d5 y' x4 c/ s( r        },
( s0 X; L' W8 ~8 R  u        {% a3 w3 f2 e3 ]. A5 ]
                .active_low = 0,. G6 m8 n* n5 Q8 @% Y( `* n7 B
                .gpio = DA850_USER_LED3,
& [5 D; d9 b5 V- ~) h* |, r                .name = "user_led3",
( L0 \6 c% \: P  O' f                .default_trigger = "default-on",
7 b" X* f4 J+ \        },$ i2 D6 B# r- F: i& w
};8 k. P. y1 I: p* i

/ Z) T2 _+ \2 L; D0 P9 a8 e. z; ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 p) c! x: A+ c8 L" y
        .leds = da850_evm_tl_leds,
7 m% V( G/ {+ o6 w3 u6 B+ a        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( u: {6 _  w' n6 r/ K: Z
};
5 X2 {; }6 ~3 i. l9 Q0 ^! s& F) t- x& ?  ]8 Q4 ^1 O! |6 l
static void led_dev_release(struct device *dev)
# r8 Y6 P# e" T+ b% P/ z{: A# d: B" w+ h7 r$ b
};
- ~5 V3 ]# [3 q7 i
5 c. k9 F" y& W9 p) zstatic struct platform_device da850_evm_tl_leds_device = {) K3 @2 T' S/ d$ p2 M, }4 e) L/ b
        .name                = "leds-gpio",( N8 w8 ?4 q9 ]: P5 R
        .id                = 1,2 G0 ]9 @/ d7 Z1 `
        .dev = {
/ ]8 n% j% D, q7 J                .platform_data = &da850_evm_tl_leds_pdata,' s3 F) u+ \: z
                .release = led_dev_release,
7 U+ O  [! K/ y9 {3 a& H+ ?4 ~$ W        }
/ \" g8 W* t3 O2 D0 l};: C: {* e! I+ m
2 }* ?! m& k% @& l. l5 ]% ?0 w
static int __init led_platform_init(void)
1 n: B$ Z' A3 f{
0 A  Q" y- c) G/ i        int ret;9 R) L* X" T& [! `8 J# A
#if 03 Q1 N# Q3 O7 R$ a7 u
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 Q: ]# b' X+ K        if (ret)
  y* T- R; O$ [3 m. z                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- b" T! T7 f- h& ^8 ^/ V                                "%d\n", ret);
" {' p1 v0 K5 Y5 d2 \1 z#endif: ]1 Z0 ?7 Z) ^) X# t. x" B" c7 e
        ret = platform_device_register(&da850_evm_tl_leds_device);
# B4 l6 _5 z0 J0 Y( r0 H        if (ret)
9 E! B  \( i$ O) Y9 W4 M3 c6 q                pr_warning("Could not register som GPIO expander LEDS");& s$ d7 J  F4 x+ X/ E
        else) m2 d, V" c. i1 O& k( ^+ ~
                printk(KERN_INFO "LED register sucessful!\n");
* _/ [; c, E6 H! W4 _$ ^1 P7 O! @8 x" U6 f
        return ret;" U3 V6 T3 g2 v4 W* @
}3 J6 h/ |9 k3 Z) q

& v3 |: G: `/ \7 _2 ~static void __exit led_platform_exit(void)/ w) q. E! L  x. q* ~  X: E
{/ P% e( f- R1 a3 f( j0 y
        platform_device_unregister(&da850_evm_tl_leds_device);
. v. M4 M$ k! c' `& ^
( I/ {) |4 ^5 x8 p9 w9 k7 }        printk(KERN_INFO "LED unregister!\n");
) ?! G4 V, ^5 e' h, f}9 g3 L: f# U! a  [1 G

: w7 ]) Q0 r" Z3 a. W2 J0 o: \' h1 umodule_init(led_platform_init);
/ g5 }7 V% d9 c$ |1 f) h) v" jmodule_exit(led_platform_exit);) N" S7 _6 K4 J8 g

- D7 q% j! D, T$ z7 pMODULE_DESCRIPTION("Led platform driver");
8 f* v( \$ m/ T# zMODULE_AUTHOR("Tronlong");
/ Q% g6 u  D& J* |8 C& MMODULE_LICENSE("GPL");
  H4 T8 R, c" V3 x+ d2 ~. I+ Q4 H
1 K0 k; |8 t1 J! K
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-1 15:10 , Processed in 0.039532 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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