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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。5 |* r. i& k0 t9 q2 @
#include <linux/init.h>
7 j% ?) f. P; m- S#include <linux/module.h>/ ~; n% T5 B' R6 Q  ^3 S+ H
#include <linux/kernel.h>- D) N- \8 Q/ |" S( o6 U
#include <linux/types.h>9 I2 h# A+ ^2 }4 t* o5 C1 }
#include <linux/gpio.h>0 X# R7 g3 B2 J' L* J
#include <linux/leds.h>7 K7 W/ p7 z" i6 P6 Q
#include <linux/platform_device.h>
3 P4 T$ N! X: R; W; ?3 i9 F: s, P( p' W$ H
#include <asm/mach-types.h>
9 {( f# f6 q: d" ~#include <asm/mach/arch.h>5 z) X5 }+ b& `) l9 z' D
#include <mach/da8xx.h>
/ v/ k& e9 A+ w  e( `#include <mach/mux.h>/ }0 W! W) C2 X

+ l& z+ ]+ t9 j  v9 u1 l5 _: F0 U#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)" \, U: [- p) W; _" u- E& L
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)/ [& Z( q: Q2 L) v1 Z0 G
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
; a" F, i3 n' J, a# d& ]#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
& |+ y: s/ z& y! Y( w5 c$ Y% J1 M2 ~* w- A3 Q0 l
/* assign the tl som board LED-GPIOs*/+ K% ^0 m$ b4 p
static const short da850_evm_tl_user_led_pins[] = {% `; Z6 |7 F. G) y# H
        /* These pins are definition at <mach/mux.h> file */5 t# G% M& E/ r+ D* w' @" f8 J
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 ?5 X4 i  D; Y! P7 c3 \$ M
        -1
2 m7 {9 _" Z9 W};+ F9 J' E1 h3 R2 H/ [

) l2 M6 p! b( f% Bstatic struct gpio_led da850_evm_tl_leds[] = {, y# {+ Z9 B$ C3 r8 |3 B! K
        {0 d1 G( O4 ?3 z/ l) i& A( ?
                .active_low = 0,$ V" Y  T, ^8 O4 D' w
                .gpio = DA850_USER_LED0,9 E$ u" A7 u- M! ~, _7 r% ?- `3 r
                .name = "user_led0",
/ v5 O) H' l3 V( I                .default_trigger = "default-on",
0 a( W  U+ d4 f+ s# }2 w: ^  g( Y; e        },
1 K8 Z! S) E; y- q. x        {
- k5 ?/ W2 d( {; s2 o                .active_low = 0,) h6 \, K0 y* ^  g/ {6 P
                .gpio = DA850_USER_LED1,
1 Q" o, f/ ^3 ^8 s                .name = "user_led1",% ?  \) O6 T6 Q" W
                .default_trigger = "default-on",$ h" A; l: b0 H# w
        },0 _4 r; B+ t. r9 F1 ~* Z7 h
        {/ h+ `: K, o( t6 b
                .active_low = 0,' y: Y" F* A6 R  t6 N
                .gpio = DA850_USER_LED2,
' B% t* n; m4 a0 e: @                .name = "user_led2",  G/ k9 G4 S# M* h
                .default_trigger = "default-on",
/ V. i% r& J% o( j8 l6 ?0 Z% d        },; D8 m  M: B( E' @+ e" t
        {
! A5 s) w- P9 _: i5 r                .active_low = 0,: [3 M: F: Y& {' a% h  u4 O- A
                .gpio = DA850_USER_LED3,
/ |! K6 W- G- _                .name = "user_led3",
) z& ^( U0 e% c. P                .default_trigger = "default-on",& N/ Y+ r1 D: ?* B# @1 }* q
        },
$ ^4 R* T0 y; c) ?  }! @2 R};
5 b! M& j9 N9 r4 Q
* ]7 S  u1 A' h% @: ]8 z9 S0 s9 mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 m$ u' q3 @0 }8 t: n, [9 v8 E        .leds = da850_evm_tl_leds,
  r* H/ P$ V1 g4 s        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) N9 N& ?0 Z. o& k8 U
};4 D% Q4 T5 E4 q
& \4 t: u2 X: J! Y# i
static void led_dev_release(struct device *dev)
. Q: C/ f' l/ r5 F: H# O" e{# J& L( y2 q4 {" s9 L: x
};7 V0 C5 Z& P/ D9 l: q
" E8 v; N% \5 k4 @: c1 {7 F
static struct platform_device da850_evm_tl_leds_device = {, T( c' ^5 ~! t) _7 Q- Z$ B, @
        .name                = "leds-gpio",: r7 V6 B' R& ]
        .id                = 1,
5 Q* j* U! N& K9 b        .dev = {( M2 k. t+ D, }$ L
                .platform_data = &da850_evm_tl_leds_pdata,
; M8 K" q% y* D+ {' `% O- e" ^                .release = led_dev_release,
  \' Z, `& B& I9 H- W        }) S, j5 }/ P- L& D: I8 H
};
1 T+ C" k8 b0 F: c: E4 P' k7 x, e: T9 b( v, F* S
static int __init led_platform_init(void)
8 {4 W9 l9 ]. W0 I3 R5 E; r# T2 ?/ z{
( t1 u& L' @, j5 x: D6 a        int ret;
" J6 x$ _1 s# g# J#if 0! N% j) r* C' [- x! V
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);  z  `0 v$ z) C8 z- p$ J
        if (ret)
! F% U8 D- z- b3 h                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; ^5 C0 ~2 m3 X# J6 \
                                "%d\n", ret);  N7 Q9 a2 t4 h- [
#endif8 h! l+ S# S7 @& ~( U/ _
        ret = platform_device_register(&da850_evm_tl_leds_device);2 _8 }0 [9 y0 k) u4 f6 l
        if (ret)( w( E- x% g, E5 e
                pr_warning("Could not register som GPIO expander LEDS");$ f/ u7 s) K5 f0 y7 k1 J+ @
        else
2 ?  J2 p& i+ {" a1 Z* i                printk(KERN_INFO "LED register sucessful!\n");. k8 `( Q( A( m4 ?
( d% ?5 {) f, T% S
        return ret;
# V) n* d% u% O6 J4 y; X- _: t}
7 M. v# m: k% z5 N+ t
* B0 Q( X( l) t1 X, istatic void __exit led_platform_exit(void)
+ ?6 n7 B, G! x; v6 w) B{
# N9 X4 p; u$ g6 m2 s- P( b        platform_device_unregister(&da850_evm_tl_leds_device);
: z9 A- N; p2 f$ a( p( g& \1 x8 p
( W5 S! X! X4 @        printk(KERN_INFO "LED unregister!\n");
+ a- U6 E; F$ B# b8 O- _0 D}
1 f5 J" M0 j' I; L
; j1 G) h6 `1 B7 U9 Vmodule_init(led_platform_init);; p9 U7 O0 B/ {' C2 G6 C( i
module_exit(led_platform_exit);2 i6 y- y4 V! f% W: I, W
. l: @6 l( R& Y/ g6 B
MODULE_DESCRIPTION("Led platform driver");6 }( i" E) q% Z+ Q3 \3 y$ F2 |
MODULE_AUTHOR("Tronlong");3 |7 a+ Z! m) X7 t
MODULE_LICENSE("GPL");  j5 Z" O, F- q2 M7 o
) p: a+ x& L" J3 k; z7 ^* B, F% ^5 y  x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-3 17:44 , Processed in 0.038966 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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