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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。% h6 u  T$ ^, |+ w5 R# S0 n1 W
#include <linux/init.h>$ i/ J6 }4 X$ Z6 `9 K* h& k
#include <linux/module.h>+ l, `4 K7 t, F% q
#include <linux/kernel.h>9 P1 t7 U* [: F4 |7 i; j
#include <linux/types.h>
9 [$ {" Z4 q( y! i( f! G#include <linux/gpio.h>9 T) M, n3 R" ^3 V- ]- |
#include <linux/leds.h>
5 s2 ~5 ?& U: ]#include <linux/platform_device.h>
, Q" ^* r3 [( h# Z' \9 N" r
1 T% c1 E) K8 z# H( X#include <asm/mach-types.h>
7 S( L8 L7 _9 Q8 \+ U#include <asm/mach/arch.h>
+ b, G3 c! K. I#include <mach/da8xx.h>
* x$ G/ ]+ b) Z( s3 k( o9 I#include <mach/mux.h>
, E2 f' G$ s: N' m" d. T7 U/ N' Q9 U+ U+ S9 U& P
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)$ P1 X- `- H5 q7 U- |. h
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
. J- R/ h! s4 t- K#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)3 r7 m( l4 ^0 _6 K! P
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)- F! Y+ Q. Q1 Y) q6 z7 i$ o
. I$ \& N' l* j: s
/* assign the tl som board LED-GPIOs*/
/ f7 W( O3 P7 P( astatic const short da850_evm_tl_user_led_pins[] = {1 S8 _; j5 q0 Y- r# k% d  U
        /* These pins are definition at <mach/mux.h> file */
; |% G, P; [0 A. ~" m& j        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" M0 ~4 ^' s/ p; |        -1
1 ?( ]* L1 l; \& \# C1 e  ^$ d2 s};: r4 ?  L8 b& Y7 h. f

) D" k1 i) O- o/ g6 Lstatic struct gpio_led da850_evm_tl_leds[] = {
) u2 o& b9 ~* w/ Q9 m: \        {: k, p2 u0 ~8 e* S# ~
                .active_low = 0,. F7 L9 |3 Q! T# W. g* P+ w$ o
                .gpio = DA850_USER_LED0,+ @6 C5 L2 t+ x% V. x2 ?1 E
                .name = "user_led0",
* |+ \% l. D8 _) [. X' h1 N                .default_trigger = "default-on",; s+ s. k4 M6 _# F' n& G; J" D
        },  |+ x6 v0 n- k, O' z& I
        {
& U2 R* @- n* E- ?* y& I' D                .active_low = 0,
) Z. V' V/ o! S$ O  z                .gpio = DA850_USER_LED1,. G; ?* q  i0 ]+ p# Y( J' L( ~
                .name = "user_led1",3 `' r9 ?, A! R/ Z# Q1 @
                .default_trigger = "default-on",3 g3 J( n$ S& R, c, x) D% p
        },8 G$ s4 }( i1 L3 }; R7 ?. ^
        {
1 W. |/ k+ d1 r5 ^                .active_low = 0,  E/ l/ @" X- O4 p2 v0 d
                .gpio = DA850_USER_LED2,
3 O' A% S7 ?6 V: t# S# u+ V! l                .name = "user_led2",( k3 `3 b1 d0 N, b8 B# a
                .default_trigger = "default-on",4 d9 ~% N6 y3 a
        },
* T6 T  L) d9 G, w2 u* r8 E        {
5 n- p6 ~. z/ x7 N) d; I6 s                .active_low = 0,
. Q& ^" Z- {; ~3 s  k( w- u                .gpio = DA850_USER_LED3,/ _  d. T8 M( z5 R  U
                .name = "user_led3",
& O6 H' _7 u$ C                .default_trigger = "default-on"," B) o0 }# a% h
        },
9 K( I! k" X% t1 P};" v9 C1 C6 A/ L0 ?+ o. {5 H& @5 U
3 e6 }4 L4 G% v( W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# n* W- T. h# G% n. t$ q- b
        .leds = da850_evm_tl_leds,4 {- z7 p& a5 p3 G' [
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 K7 a( \; J4 |  [) _' o};
! b/ |( s- C2 U/ u' O' [2 S  n/ N+ F+ i
static void led_dev_release(struct device *dev). Q0 r2 o+ V8 q$ N$ Q
{
' c1 Y9 G! u8 \8 Y$ d0 y0 z};/ `6 z0 h4 g# z( z0 s1 ^7 l

( v4 v' }. \1 c# Zstatic struct platform_device da850_evm_tl_leds_device = {* Z+ i5 v$ t: P" [4 c$ X' U! N
        .name                = "leds-gpio",) A9 ]& u4 d! d- O$ `6 {
        .id                = 1,
& A% W2 d1 W* \! |/ B& y3 p        .dev = {
$ Q3 \2 w* W3 z" S- q& w                .platform_data = &da850_evm_tl_leds_pdata,
* j" k* J' N8 j2 T                .release = led_dev_release,
* Y  T) G# Z0 n; w" T        }# j9 s& E5 S9 f8 W
};
/ l! h  n4 G4 A
9 I* \# E4 Z$ I( p& V( P) F# qstatic int __init led_platform_init(void)
7 a& N2 s. e. F$ _/ o2 y! V{! Y' E) W; B5 e& l9 d5 Z- a
        int ret;- k3 e. ~8 X8 p  D9 Z% D
#if 0
% K0 o4 l! I% V6 Q0 e* b# S        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ X- q  F  ]) P2 D        if (ret)7 \! Q; W; C9 Z* p! F  Y6 L6 p% t& M
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( x0 i7 c, w* C* ^+ [- K0 v
                                "%d\n", ret);8 V9 T1 ^* z+ u+ P) G& X/ w
#endif
  G% [, |" t& s! q1 x- z; @) X$ P3 r        ret = platform_device_register(&da850_evm_tl_leds_device);
! W' Z1 N! o; @# z+ P  z0 q0 |! P        if (ret)' s6 Z, Q* O; ?9 W; ?4 @& l+ n0 R
                pr_warning("Could not register som GPIO expander LEDS");5 z/ P! J: u; W# s- f6 g5 P
        else3 W$ R  b6 @0 f" W9 U8 a5 v
                printk(KERN_INFO "LED register sucessful!\n");7 Z7 W) m* g3 k3 u! d, n
5 c* p6 z, w. S
        return ret;
7 i, i" m- [  W6 v0 A& h- ^; ^7 v}. h2 {; f: t( s7 Z( ^6 }

2 M6 R; d5 F" _% [; ^3 `  c! J( n+ mstatic void __exit led_platform_exit(void), l7 O9 g0 U1 a; _  R5 U4 ^. v
{
7 w7 w5 F* g3 m6 j* M  D4 t        platform_device_unregister(&da850_evm_tl_leds_device);5 ^# b+ y- g6 p- I1 R1 |% K( r" {$ r
* q/ ^2 p/ k. P' C* F( J7 w' \+ ]
        printk(KERN_INFO "LED unregister!\n");
+ \8 k! I0 X. m5 S4 C+ ~}/ l0 J$ M# L1 p' Y* g

6 M! i) F2 h) W, P6 z) f# W3 nmodule_init(led_platform_init);
" z8 |8 c1 @( H6 b/ y1 x) i0 rmodule_exit(led_platform_exit);
& o: R+ \2 w# h, Z
" h! M0 u% P3 V9 G# v& J/ X2 y/ eMODULE_DESCRIPTION("Led platform driver");
, R4 s0 |' ^1 t6 s! o3 b) k% HMODULE_AUTHOR("Tronlong");
/ J7 x8 \2 [7 a! X5 nMODULE_LICENSE("GPL");/ R) R0 z% o. @, S% n; j! {
( q/ b* o$ l+ k) F  e
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-31 15:15 , Processed in 0.038004 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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