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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
4 w" D* R9 N  g3 B#include <linux/init.h>
" e( F- @9 R9 }$ Z& Y% P#include <linux/module.h>5 v( U) S( K; k6 E/ y
#include <linux/kernel.h>
2 {' ~# c4 J; A8 Y6 C#include <linux/types.h>
1 {) T, U0 S% y. V$ r: y3 t$ i#include <linux/gpio.h>) g! Z) b' k' Q. Q, Z1 J, b
#include <linux/leds.h>0 b* ]2 V4 l  |) R! V6 o6 W
#include <linux/platform_device.h>
9 A' g& W/ ~* J, J7 b
5 Q& X2 P, m. y' O. t#include <asm/mach-types.h>+ M5 _0 h. z* Q8 i) H6 ?
#include <asm/mach/arch.h>. P6 X1 L9 F' d. A
#include <mach/da8xx.h>
- i) T8 h  t5 p( B1 e: z; `#include <mach/mux.h>
' d0 X1 K4 I8 o3 O  Q+ K+ d& D5 Z& @9 i0 `1 D
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
* g! F5 B4 X) X# g5 n3 e#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
6 Y, k- d% u- u) L#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)/ d' f8 y! t0 c7 q! o6 d5 M
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
4 ]8 e  j9 P) X1 r# h
" j' `* B# x. U/ }: U" E# q9 o* {/* assign the tl som board LED-GPIOs*/% i+ l( @5 V0 N& V' n' b. t! U
static const short da850_evm_tl_user_led_pins[] = {* R* S1 }" R+ C& j4 E: ?
        /* These pins are definition at <mach/mux.h> file */* ]" q" e0 Y, r1 X2 m
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 ^3 u/ d6 x" j5 U        -1
8 B; @" w1 P2 E};4 w0 s( ?' V3 U! d6 j4 K4 x* T
. D5 l: M5 Y, H# M& w- Z
static struct gpio_led da850_evm_tl_leds[] = {
, b. {8 l, x1 J0 E# h% i, W8 p        {
% E8 S" z/ c4 c4 _" V; h                .active_low = 0,% {8 F, ]8 y5 t$ u: N
                .gpio = DA850_USER_LED0,2 |1 ?7 M  `5 Y5 _: e
                .name = "user_led0",  S# T' c( Z: ^6 j: X9 A2 g
                .default_trigger = "default-on",
: F! Z& R" \: [& v6 E        },
# o' D) b1 t- p3 S        {  O% F8 V8 l# N/ l
                .active_low = 0,) m9 ]# {' J* X6 ^+ V9 a4 k  f
                .gpio = DA850_USER_LED1,. h0 h% o6 [. F8 Q
                .name = "user_led1",
$ K2 H$ V4 X! r$ g# U9 Y! v+ _/ e                .default_trigger = "default-on",
. p* ]' A" c6 t+ s. W$ d$ S        },
1 {" k9 J% U0 o5 z. J; I- z" W        {; p' n- ], d  u) ^
                .active_low = 0,
# n6 Z$ Z7 h- V5 I) y1 j                .gpio = DA850_USER_LED2,4 Y9 O& Z, G3 V0 C' C/ h
                .name = "user_led2",
. z' ~5 ?2 K+ v: _: L                .default_trigger = "default-on",& a  l( O- w& `0 @
        },0 K, G  y" j( t9 A% Z$ }3 m
        {
# s5 i2 W: u8 p$ N- i                .active_low = 0,
/ F4 w" A# r8 @* ?2 B* z                .gpio = DA850_USER_LED3,
) ^. A2 c! N9 V$ w                .name = "user_led3",
% H' _1 q* h% D9 W2 `( \                .default_trigger = "default-on",
7 ^2 q# ^% M% M        },
0 g* J$ V) e, F' l. N6 v};, B: ^& ]; |: C% j7 p3 o. M
' _, n* r. q, C- M( Y2 t4 p0 R1 x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! c# B4 {0 E( Y; x! o2 W0 l
        .leds = da850_evm_tl_leds,
0 k4 |% q8 k+ m" y! l        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 K& t$ O- U  t0 c};9 i$ M& l3 K( U4 e

8 H  y+ [1 B7 g) o1 x$ Hstatic void led_dev_release(struct device *dev)
- \7 \9 B) S2 |! }{5 Q2 U; u9 G7 c, o. N: [* x
};
" e$ T$ ?5 V. D' ~- s5 i* O0 F$ ~8 b. N% u: A7 |. M4 {& @
static struct platform_device da850_evm_tl_leds_device = {
! T3 _: z/ n) ?) l! J- N2 T) c4 |        .name                = "leds-gpio",
1 [; X7 C% K: t9 M; t7 D. Z        .id                = 1,
' m3 j/ u! u+ [0 r, P        .dev = {+ }, b( X7 n% @+ Q
                .platform_data = &da850_evm_tl_leds_pdata,
/ k5 d/ S" ^, c1 D* M" ]( @                .release = led_dev_release,  J* F3 e' x8 u2 t0 y
        }. q9 t$ s5 `2 f- K' G7 r
};0 U; g7 O$ u7 c  Y* F- Q+ D: S

1 C% ~+ H) e6 u0 O, N; v& _static int __init led_platform_init(void)9 ^; L. w/ s: `( h
{
0 _. V5 Z" f! k$ b- U8 K        int ret;
- M7 h* x- O( s% ~/ r#if 0/ X# C$ G* \, m5 U
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 q# K* e  p; @; c        if (ret)" B8 V, v# s: M2 B8 Z7 _
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 L/ j' ?% d! W
                                "%d\n", ret);
: ~+ _5 n9 X0 X# Y5 O% Z#endif- Z1 K" Y3 l( e7 }6 d
        ret = platform_device_register(&da850_evm_tl_leds_device);
+ m' j( b* A' ?# M        if (ret)1 J8 r/ x1 R' j0 j& |2 R
                pr_warning("Could not register som GPIO expander LEDS");4 J$ H$ J& M0 j& ]8 G
        else
+ H: J* L: g$ W: }0 M                printk(KERN_INFO "LED register sucessful!\n");
) E$ H2 l/ X5 q# c) [% W* j% \6 s8 w
        return ret;
; n) |1 B/ Y, `0 I( k! a6 b}
) R! A# F) j* T$ j4 Q3 M* t  |& e  y; G* r' S6 w
static void __exit led_platform_exit(void)
8 B/ r- ?; Z; u9 X; y! d, Z$ D+ j0 n{
$ b2 o# p4 L$ u# \3 t! s        platform_device_unregister(&da850_evm_tl_leds_device);
! k: M4 v% c/ v: Y6 e; O4 X! Y& n  N+ `
        printk(KERN_INFO "LED unregister!\n");
+ n/ W0 y6 I/ k" M4 H# ~3 m}9 l* `* U' {- e# n( i$ X/ h

: E( h* Y1 n. u; _8 Amodule_init(led_platform_init);  u' R! X% w, I9 C' g
module_exit(led_platform_exit);" G& U0 j- o, ?# b* w3 Z7 ]

! I' e/ W3 w9 u% V7 i( YMODULE_DESCRIPTION("Led platform driver");
- `% c- P7 w' v$ {. `MODULE_AUTHOR("Tronlong");
5 ?% \. D/ h$ uMODULE_LICENSE("GPL");& D0 Q& c4 l, n

6 T5 @, a0 p5 S
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-4 20:26 , Processed in 0.037424 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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