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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。% T! u* N* m3 t( P) D
#include <linux/init.h>! l( r% m8 J' R2 k' k$ N9 v
#include <linux/module.h>7 P: R. g1 u5 X& G
#include <linux/kernel.h>
% ^$ u3 J5 u0 L0 V/ X  v, t* H  o/ Z#include <linux/types.h>3 s/ [0 ^3 W9 B
#include <linux/gpio.h>7 |/ J/ j  g5 |# h1 G. v* G
#include <linux/leds.h>" l9 b$ z6 p1 Z
#include <linux/platform_device.h>
) g4 r3 G9 c6 M  `1 G; s9 O
2 ~) J1 s( l$ v$ x' O#include <asm/mach-types.h>
. W5 ^( l/ }7 ]' e#include <asm/mach/arch.h>! }- ~1 T/ P5 T5 ~
#include <mach/da8xx.h>
, S4 o4 ^& [- |! B" W  g#include <mach/mux.h>
! A& D* w( V3 D2 h  s0 |/ Y" H- X  m
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0). p: ]/ f- L- _* X" t! ?
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)8 O9 J0 ?# B, T4 w
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)! ^7 T$ s7 ]6 _$ E/ u- `
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)9 @8 I0 I+ a+ m  I6 U4 P# ^

, b1 k+ _2 E9 g" w# F/* assign the tl som board LED-GPIOs*/* U% v+ @0 s/ D
static const short da850_evm_tl_user_led_pins[] = {* F. i: O' W" w5 r. T
        /* These pins are definition at <mach/mux.h> file */0 [% I9 n$ ?$ \. N6 P& k
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ U! r1 J. m& Z. R        -1
" |! v& E) U3 Q};
3 L) H* B4 I4 Q8 A' ]8 q9 V# d1 b
$ T9 N  G6 q2 |/ m! v# l! Hstatic struct gpio_led da850_evm_tl_leds[] = {: @& i- I& n$ t( K0 \
        {
2 j" f% Z8 V# ^                .active_low = 0,
5 f( [" N, C7 @. J                .gpio = DA850_USER_LED0,
+ m3 e6 b% c( k# H) _3 E                .name = "user_led0",( I0 S( d3 W8 z1 R9 y
                .default_trigger = "default-on",: d! c5 Z0 x- u6 n+ s
        },1 a/ M, ~$ G" G; F
        {
8 K  {* J( P; ^; x( l6 I$ r; P                .active_low = 0,' w/ p7 D/ ]0 `! j# }& I- J! a
                .gpio = DA850_USER_LED1,
  t2 s" Q% S5 j8 ?                .name = "user_led1",
1 I% `3 @, Y/ t! J4 X* x                .default_trigger = "default-on",& E& C$ b1 U9 J! K# u
        },3 W# s/ c/ r$ L% {
        {1 Q, W+ h" P" }) j! C9 q
                .active_low = 0,: v* H% r& A# [) g0 [" [9 Y; y% b* H
                .gpio = DA850_USER_LED2,
/ {: N( k, X8 R- }' i' X2 B                .name = "user_led2",
( t( o% }* \# }/ |# O                .default_trigger = "default-on",0 F: A5 p, q; m. H, m  Z. \$ P; q
        },3 Z8 S# Z# t. L  B" U
        {* K7 F& o1 P  t' v( U! _% m3 O
                .active_low = 0,1 F4 A+ G# K# N! \2 i
                .gpio = DA850_USER_LED3,
7 @% T, G) T+ O) j; W                .name = "user_led3",( v$ p- I) T( o& m' M8 a
                .default_trigger = "default-on",
5 G# [' m1 c, o- P5 ^        },  G! W4 N/ I0 |! L9 E. V& ^7 `
};
% u3 J( E- p2 _+ K6 q7 [. ?  S8 m
1 r$ R9 S9 e( W! lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ N- t$ V9 c( S  L8 \8 t# c        .leds = da850_evm_tl_leds,. U/ L1 v8 j4 c- Q6 u
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, A8 K0 G  P9 k7 ?6 i
};
/ {  ?$ Z% j' F7 o$ F. W4 G: N4 b0 n* K& @, U) f- r5 Y
static void led_dev_release(struct device *dev)+ [3 u. B/ S9 u, |. O' t
{* J. U' v+ I# U8 y$ w0 N
};
- @2 }/ G2 f, o9 g
/ f9 G5 M! y( y- Z' Jstatic struct platform_device da850_evm_tl_leds_device = {5 B& t7 D$ j5 j5 M
        .name                = "leds-gpio",! M- C2 R# Z( l" |3 c3 M8 Q
        .id                = 1,
. H7 U# F0 y. ], v0 P        .dev = {
9 N* P$ r! s, J* M                .platform_data = &da850_evm_tl_leds_pdata,
5 J+ G5 F8 m( V9 a8 @+ Z: t2 U                .release = led_dev_release,# ]4 R% \% i& T0 V/ a$ g- y5 \
        }; E/ e, ?% R$ y9 \& L( k6 @4 h" ~
};
4 k* d0 ^" f* H4 Z$ T" ^! Y( w3 ^: D5 ~* M" f8 X: W, V
static int __init led_platform_init(void)
7 @2 i# K/ ]/ f) C$ V% I$ F% s9 C{2 D# E6 s" v# ?6 V- O  ?  [& M
        int ret;
6 T8 w7 i, E' D#if 0
; X8 `) _7 [9 m) a        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) I8 z- H' Z! W/ L+ E        if (ret)
% ]8 C' {6 E, h4 n1 V1 X8 b/ a# D: S2 F. `                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
  J3 d" H  I. x1 S8 @8 M& r                                "%d\n", ret);* |, S3 m+ s' m# f2 C6 |
#endif
7 Y4 d7 D. Q+ b" O6 S. P& p/ c        ret = platform_device_register(&da850_evm_tl_leds_device);
! _$ C' _" G- W7 m/ ?3 o! w        if (ret)8 D. U. c4 d. i% A- ?
                pr_warning("Could not register som GPIO expander LEDS");8 p' M4 w% A, @- ?# Y% T! `
        else* _# O% h2 M4 f, A6 s
                printk(KERN_INFO "LED register sucessful!\n");0 ]; e1 A) [. a0 e6 O7 V
/ q7 S% |# ?9 e5 B2 g
        return ret;
: A+ M% P  }5 u$ z0 W* T0 v$ a}
- E# e9 x4 Q3 N7 N9 j) g( t$ E$ A2 Y0 u+ l: c) y7 ?* U7 S
static void __exit led_platform_exit(void)( K* l  O0 m7 A6 p3 h
{+ F1 n: Q( @6 d7 W& \* H" m/ S+ s
        platform_device_unregister(&da850_evm_tl_leds_device);- ]4 F' B$ |6 }2 ^; n& p0 g
5 }4 |2 C- T. r9 P' [: \) ^
        printk(KERN_INFO "LED unregister!\n");3 [0 S% H% ]$ v- I# [
}
4 e& L( o( S0 t4 G" Y, d( O$ q- a: r
module_init(led_platform_init);
9 W; p/ b  u6 }+ m9 n2 H0 g0 }0 C4 Kmodule_exit(led_platform_exit);
! t  I. W: ?4 |( z' N* b0 J7 W; M+ P6 I2 ?; d7 \/ o# M# F
MODULE_DESCRIPTION("Led platform driver");
- S) P* S; [" O, TMODULE_AUTHOR("Tronlong");
  P/ L. Q1 S* u" l8 y8 vMODULE_LICENSE("GPL");) I+ V' ~9 R* i, W! c( V
' ^& ?' F& a7 l
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-4 09:30 , Processed in 0.048144 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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