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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
$ {0 G$ i$ r0 |# w( }1 M#include <linux/init.h>
1 l* x+ ]0 W/ [- [! l#include <linux/module.h>( q" N3 [8 P) Z8 V
#include <linux/kernel.h>8 y2 n8 E* A6 G3 i$ G
#include <linux/types.h>
" |& T8 Q: [$ G0 Y- D#include <linux/gpio.h>
$ K) N" B% D! r9 s) o#include <linux/leds.h>
( r$ E" }6 l! L# h( }8 m#include <linux/platform_device.h>
, N% k$ o# V1 n& s6 K; R! w$ C
/ ?/ O" u4 C+ b) k% {#include <asm/mach-types.h>; t: y/ f: y- {4 |
#include <asm/mach/arch.h>$ {: C" p) K9 k3 x, g6 ]
#include <mach/da8xx.h>1 ~# |, Q; i; E0 L6 ~  t, }! K
#include <mach/mux.h>
0 z( @. J* b7 m# |
7 D, u- P- r1 ?, N2 I8 h! O" T% [#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)" ]5 d8 J7 s& U3 L2 {7 h  ^3 E
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
* \8 h. S- P3 J- N  A* ?" Y#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
& Z' m! I3 f" S9 t* P#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ t* t9 Z4 k  w' T% ]

# O0 i. H& V: ^% F+ V7 g7 H1 E  ^9 a/* assign the tl som board LED-GPIOs*/
, L  B) i& z; o4 L8 Pstatic const short da850_evm_tl_user_led_pins[] = {5 ~* x$ C5 P$ K% c2 X
        /* These pins are definition at <mach/mux.h> file */
- I3 @" K5 g1 N3 o; n- h! w        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 V6 f+ P* ]# \9 G
        -15 I) e- Z2 ^6 u4 o) z! W* |
};
5 i1 n" M% l% ]1 b9 G/ R
, t- d4 Q/ c+ N$ Lstatic struct gpio_led da850_evm_tl_leds[] = {  G+ r( r8 \6 K; e' B
        {; a5 d! I& c, g1 a# g: L" v, ^
                .active_low = 0,) h& N* S9 E' O4 d' O: `0 |% Z
                .gpio = DA850_USER_LED0,
0 ~% _- M0 u, f8 g( G/ e/ V1 Q                .name = "user_led0",, R2 f- k1 z- g1 m0 v0 r
                .default_trigger = "default-on",
. u5 O4 m% ^7 w! [        },+ k5 e# o! _8 Y* ]; T% D
        {% _. j) l' K8 z) V3 H( _; c! J7 l+ H
                .active_low = 0,3 ?! P, Z/ J  j' F! J- O" e. ^
                .gpio = DA850_USER_LED1,& r; b  a3 U0 _7 v
                .name = "user_led1",( y( e6 b4 {' \$ h& I! u' l! q' w
                .default_trigger = "default-on",
9 p; A+ }' b( j; V' G5 L: s        },3 S- g1 D2 [/ x1 F
        {, t' j2 r# `+ H/ p3 f; e( Y
                .active_low = 0,; O2 n! |$ L8 J/ N  c' f7 O0 X  Q
                .gpio = DA850_USER_LED2,# {, P7 o, F" F& l, k  L, u0 n( \
                .name = "user_led2",5 `/ b: H4 l+ X2 _7 }5 J% J  ~7 q1 v
                .default_trigger = "default-on",1 _: s! d' b* {1 O% U
        },+ ]# m( W- r9 c$ o) `/ ?" k4 Z
        {3 E3 F  Q5 B7 ?9 ]; W2 N" U! H
                .active_low = 0,4 k7 o' Y* E9 y; V
                .gpio = DA850_USER_LED3,% M, X  V1 v: B! Z3 I* D
                .name = "user_led3",; X0 B  E" _1 x$ N( `
                .default_trigger = "default-on",
! Z: q$ w* F7 r0 T* ^3 G- p& w- h5 A        },8 }2 {; ^* q+ R0 |8 L. A# d) Y
};
$ b4 D2 |6 Q; t2 z6 J$ E9 n0 b8 i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
  M( @- L# R/ `$ g        .leds = da850_evm_tl_leds,
$ Z4 b: C% ?& g9 V3 W        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 A  A6 {# j' m6 r* h4 L- E
};: Z9 O/ b) S; J1 i$ M
: z. V" m- ~& y- e
static void led_dev_release(struct device *dev)& f- z0 e2 o. e  x# v: _
{
3 I) B' \8 R! x0 ^8 X  M! D* u};" i) |' U( ~; t* a; r( c- Z! P

4 c1 T. _+ o& P5 c  y6 i2 nstatic struct platform_device da850_evm_tl_leds_device = {) z- O0 h; a. v8 w
        .name                = "leds-gpio",
3 S6 Z+ G- @) P( t1 j7 w        .id                = 1,
. |& U7 a5 l- I$ W4 j: K* j        .dev = {
7 N+ j& i' L4 d4 W                .platform_data = &da850_evm_tl_leds_pdata,$ D- f- k7 A3 F7 O% r# x
                .release = led_dev_release,* A7 L9 k4 @. G" ~
        }6 Q6 h9 t& k! C' c
};
/ b; Q! i& g& N& k
4 p/ P. k; i! wstatic int __init led_platform_init(void)9 P( w6 K6 ~& T2 m8 f  U7 u7 z8 O
{5 N, _7 x; }, c; y$ N3 x
        int ret;( m- \, g0 {& g; X5 r& n
#if 0" X+ Z$ @9 Q+ C( h
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% S4 O; I, y  M
        if (ret)
8 U/ B. R5 r$ F- z8 p/ a& D- V& S6 z                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ V* {' W9 E3 o$ O0 L+ P2 |# ^                                "%d\n", ret);
# p  q. U( Q4 s5 V& A* X#endif
; T1 E, k' n( ]        ret = platform_device_register(&da850_evm_tl_leds_device);$ f% T  f$ R1 c
        if (ret)
& @' t4 @* ]; i2 O- k% j                pr_warning("Could not register som GPIO expander LEDS");
; z( E* p# ]" P9 e2 m        else# T; B. F, \6 K
                printk(KERN_INFO "LED register sucessful!\n");
3 j' b$ W; s% k. c- H+ [1 o2 F+ P
        return ret;
" l: j# M4 n8 v1 m}% h. @6 h3 d8 b  {
/ z8 E8 v+ L; \, O% |$ c2 v
static void __exit led_platform_exit(void), v# X' b3 ~: D  X$ f
{9 c' c( y* g8 {: g7 y
        platform_device_unregister(&da850_evm_tl_leds_device);
. o8 e7 o; Y) U( c: M) |% o* e2 u5 p0 {1 q
        printk(KERN_INFO "LED unregister!\n");$ W; Z) B& h. y  i5 [
}& c$ K( N/ F, `9 u- q3 O
+ ~! n0 Y) b, Y
module_init(led_platform_init);
5 s% ]7 d( k2 ^: S$ U$ \module_exit(led_platform_exit);
& q1 V( W) H9 A; }
( X" l/ `" F$ q% N' BMODULE_DESCRIPTION("Led platform driver");
: y' T! v$ J$ i/ V  v2 n% ~1 f6 RMODULE_AUTHOR("Tronlong");
0 J- s4 f5 y9 v& rMODULE_LICENSE("GPL");1 _" T2 x6 `* E/ T4 c

- D6 J4 S) E' K' Z2 d
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-30 21:22 , Processed in 0.039598 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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