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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。$ J' s/ p2 Q6 M* d' P/ a
#include <linux/init.h>
7 B7 i" W# E# P6 n; Y) Q3 ]7 O#include <linux/module.h>* d, l$ M; F. ^5 A
#include <linux/kernel.h>
3 r9 h1 C* b0 T- G#include <linux/types.h>
8 v6 T4 f! H1 J! R' S0 e6 {/ d8 a#include <linux/gpio.h>2 T7 N$ k2 G6 c# p7 N
#include <linux/leds.h>
, }  G9 ?* R7 Q/ t#include <linux/platform_device.h>" u* z* B( L) O1 f9 ^

3 W: X* T- t0 V9 v0 G) a) g#include <asm/mach-types.h>
- T3 O0 n! c( |9 a; L' W#include <asm/mach/arch.h>
$ W1 O: B$ j3 o8 o- ~4 u#include <mach/da8xx.h>
( c& S3 {/ T1 y% e# D9 N% d! g6 i1 M#include <mach/mux.h>: \2 F: M  Z: w5 N2 x* K

- I# ]+ c$ u2 E+ @* D6 N- Z. \& [; ^#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
' i" T, w7 l. }" Z) W& t' r1 Q- e#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
- k0 q0 m$ H1 |5 N* `0 z$ ?: h3 l#define DA850_USER_LED2        GPIO_TO_PIN(0, 1); e. C9 M9 z! z* J( s. [: X7 _
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2). ], X6 n* g6 n9 h8 O

( F/ A" M9 b, f  [  M5 y: ?- S( i* F7 ?/* assign the tl som board LED-GPIOs*/
3 a) ?. H! i$ h3 R# ]* B  d- M" hstatic const short da850_evm_tl_user_led_pins[] = {* k$ z9 v/ w  U! t: N- I
        /* These pins are definition at <mach/mux.h> file *// L2 q4 z, k$ }" x+ G
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 x+ u6 O; R7 g& q. ?        -19 {9 N0 P' T/ x- Q
};! Y$ l0 b4 Y: j6 r
  {1 q! S; H* t
static struct gpio_led da850_evm_tl_leds[] = {3 R, q, @( z) ^( e8 |# P
        {
1 ]" J! D) s( p& l( T, F  a                .active_low = 0,! x4 A2 j; a- ~& v3 C" r
                .gpio = DA850_USER_LED0,
, O8 z1 c, O. I8 h; E                .name = "user_led0",
) N6 G; ~/ h" w9 Q                .default_trigger = "default-on",
9 U& G/ P1 I, e' {        },1 |- }6 V3 V& t. p6 l" x
        {
& ?" J& C( J, {3 N' K                .active_low = 0,4 a# i1 m- ~1 U0 G9 P& Y8 n
                .gpio = DA850_USER_LED1,5 O& @- T4 e2 t) K& I4 b
                .name = "user_led1",0 T, j& M# E- h( Q  F1 M( \7 Q
                .default_trigger = "default-on",
5 W- D3 c+ Q& c        },
) Q1 r5 |/ J6 V/ E9 T. T2 G) U        {4 a4 N2 g$ @& T  O& q/ G8 L
                .active_low = 0,
6 G, U" o0 V, y  Y3 n! \' l/ ?" a8 l                .gpio = DA850_USER_LED2,; E( G' ^" R  i5 Y7 n
                .name = "user_led2",
- _3 Y4 i3 e% E+ D* t                .default_trigger = "default-on",
! O; Y. S$ N# S( X# A        },; Y) m9 ~- u; o3 ?# D
        {7 c4 _; a; f4 }6 e9 V% O9 |
                .active_low = 0,
" W( Y3 N) ]' {* D$ s5 _) l7 e                .gpio = DA850_USER_LED3,
& M4 g# q- Q( k8 v, K5 g                .name = "user_led3",' Z+ s: e4 y# q6 L9 w8 S8 G6 z9 v
                .default_trigger = "default-on",1 t  }. Q9 X5 G3 b% b2 F
        },  H6 _+ d! I" [/ B( c5 e( L$ n
};
$ c0 w0 J9 W5 T5 V3 o0 U  u( @5 ~
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 R( e* P- g; [/ ^. w# f* b  `        .leds = da850_evm_tl_leds,
: _8 i, a4 X, w        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; R- p2 S& ?- e};
" Q0 R' M0 r( M  V! w  O3 m! Y$ V( l& k
static void led_dev_release(struct device *dev)
+ ]3 b& h2 Y* t" N! L# W* R{
5 |4 J3 z) o5 E; J  v- S};/ l- a6 Q- B, B0 P+ `

2 ~( S, F$ |4 Z5 p9 Z0 D" J: ^( }static struct platform_device da850_evm_tl_leds_device = {
* Q( B; v& t6 v3 t" C" m        .name                = "leds-gpio",
* w1 Q# Z9 c* a0 k5 B3 T        .id                = 1,
1 V+ D  S/ f1 E- S7 U  o  W% g        .dev = {- P- b4 r  v; o4 Y: D$ w
                .platform_data = &da850_evm_tl_leds_pdata," K3 H* L) ?) h. F2 g, v* B& @9 S
                .release = led_dev_release,  V  a# `4 y* e9 ?8 T9 ]& U
        }
0 s) z7 F5 B3 q# o};+ v! A6 Z, w+ U: s
8 f: z% c/ }3 g* f' _" }  g
static int __init led_platform_init(void)+ e* U9 i* [9 a/ |6 o- t3 i
{
7 r( {0 D% q0 p: `# I        int ret;7 D! E" S7 f1 J' ?7 c
#if 09 X: r8 V) K& c$ S1 j$ C
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: i. S+ z* O+ Y$ Q2 D
        if (ret)
$ U/ ~5 a0 c2 y/ @8 U; H                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 b9 v0 B% b+ a5 [' O9 M
                                "%d\n", ret);* y8 L  V* a' g8 ]5 O) p
#endif2 D6 @  ?2 ?+ v, M2 [
        ret = platform_device_register(&da850_evm_tl_leds_device);# L3 g7 ~6 W8 s
        if (ret)0 h2 h' n- a: a9 v+ Y2 a
                pr_warning("Could not register som GPIO expander LEDS");) X" g  S; c; v
        else
  V7 ]) f! m$ ?5 W/ o" n. M4 F5 W                printk(KERN_INFO "LED register sucessful!\n");
& A! U, d3 G8 P) S! p
7 c* K+ v0 [' J        return ret;& n) y- F8 e3 ?) ]2 m1 T! K3 ?, M
}
, b+ }' J9 v. @& N* I: w
9 @+ @4 Z& @1 T/ b8 tstatic void __exit led_platform_exit(void)9 g# n! o; w- m9 v
{+ \. O$ m; ~, G' V) ]% ^8 A$ x
        platform_device_unregister(&da850_evm_tl_leds_device);9 G, N+ X# V; Z- c  I: c4 m4 [7 i

# [- o$ ?; l6 ~0 q- k        printk(KERN_INFO "LED unregister!\n");
0 F% h$ Y  `  L) c- P( T5 @}4 H/ Z/ ]- a3 j! ]

9 n& s! u; o9 t/ o& N4 H5 O& k, q5 amodule_init(led_platform_init);' L, _/ }6 D! J0 r5 J
module_exit(led_platform_exit);
+ k! K  `7 u- B( U2 x3 I) _% G& B4 f3 ]# f. ~8 n
MODULE_DESCRIPTION("Led platform driver");
$ u1 u4 s) h3 s: r  T, YMODULE_AUTHOR("Tronlong");
6 R5 ~4 P8 |4 r, p! |" TMODULE_LICENSE("GPL");
" f+ H9 W* D6 U8 e$ |' k/ p4 J( C1 s2 D0 f- u" z
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-16 04:50 , Processed in 0.043405 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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