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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。2 l) m& f8 x0 ]* L. S) O
#include <linux/init.h>
+ l$ q( r$ G3 j  L#include <linux/module.h>. N2 c; e2 e4 v( x0 d- e
#include <linux/kernel.h>. i$ w: U; u- b/ P2 Y
#include <linux/types.h>
6 ~) a. K5 J+ R  T4 _7 R3 n' y: {8 Y#include <linux/gpio.h>
6 r% v$ i4 o1 ^2 j7 X; s#include <linux/leds.h>
6 ?3 q; w' S# H: W7 A& V# T0 E- K#include <linux/platform_device.h>
  |9 V0 |; A0 V# W1 V9 B1 F4 O' F6 _/ O+ @+ f1 v4 {  |* I
#include <asm/mach-types.h>! T* k( u( p' p( f1 Y% ^8 ^! a
#include <asm/mach/arch.h>
+ z9 l, D+ k$ K& Z#include <mach/da8xx.h>! Q5 m* t2 H. h5 d- I7 L5 u
#include <mach/mux.h>
0 M2 G6 T" O, c0 k3 E+ F3 L8 Q0 A) C% p& O5 d7 w" I
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
5 ~4 ~! D; v1 a/ _6 R3 l#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
3 |1 ~7 f* o* k#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
0 h* }9 e2 F  Z5 u' G#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)3 E5 O7 F  M7 O- T1 L  R) A  h

2 @6 _4 p$ N% w0 t5 K/* assign the tl som board LED-GPIOs*/
: V' L& a" S( Q$ t8 u+ p, t0 X* Jstatic const short da850_evm_tl_user_led_pins[] = {( C+ \* R8 v% r& C  {. `
        /* These pins are definition at <mach/mux.h> file */
5 P8 ^( D1 q: V) G0 X        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ }4 S: E" ~' s4 u: ^9 `: g
        -1/ ]/ S& L! G' v0 ^; Y
};/ F, N, I9 B( [
- F, x9 ]$ c5 p# S1 A2 C+ c
static struct gpio_led da850_evm_tl_leds[] = {4 U: p# \% y6 q' J( E+ Q. k/ h' e) J
        {
! o* C# V1 a6 ]6 b  \2 H2 S                .active_low = 0,
( X4 A4 u5 B: X6 b3 Q                .gpio = DA850_USER_LED0,% }" r0 S( ]" n& ]0 Y: b  ^
                .name = "user_led0",2 J# e1 F; s# M/ _1 n4 `5 ?
                .default_trigger = "default-on",
$ o8 U. U' s$ ^) u        },
1 P8 s. E* I" E) u: ^        {
/ ?* s& |" Q8 m% T) {1 _; x  [1 I                .active_low = 0,: B4 z* G$ L% \0 q0 \' ]5 [
                .gpio = DA850_USER_LED1,
5 ]( F: q# G& @/ L% Y! B/ x                .name = "user_led1",, [. c3 s7 c% C0 S) v& e
                .default_trigger = "default-on",  d( o$ r: @1 H3 X# P
        },
6 l8 v4 T+ z% m! P6 |        {
( J( O$ v- u- r                .active_low = 0,
5 Q& y5 J5 V8 P5 M% n! c+ t3 ^                .gpio = DA850_USER_LED2,
8 V" l: N7 l3 L- j' G, R; X2 k                .name = "user_led2",
! ~) x7 }: ?& k5 \- U                .default_trigger = "default-on",9 T6 A! Z% Z: D0 G
        },
7 x9 U" k% s2 y' S- H) B( Y        {0 `/ f; V+ }7 u
                .active_low = 0,
% Q! U- N2 Y( w3 ]/ O) }  X                .gpio = DA850_USER_LED3,
  S+ l. m- J. Q& c                .name = "user_led3",9 w2 D6 K1 W  i) g
                .default_trigger = "default-on",! K  z6 z  I* u6 u0 v' N* e: k2 L: n
        },# l2 g' v2 A9 i2 h
};
/ @# S# c0 W5 T4 w% Z
& q" O( b- k: C9 Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( r6 P% q- v4 p. H" a* v        .leds = da850_evm_tl_leds,
3 o$ P. ~, W( B. Q. ^/ R# H        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 A3 D+ H$ Q+ I/ M/ e  K( P5 t
};
' H9 w7 J. |: t/ C* l, o3 _- E) V" e
static void led_dev_release(struct device *dev)
9 C1 A9 M' X. q3 B8 Q* X- o& v4 ~{2 n7 N5 [3 P: @7 M- x9 Z: I; x
};! `7 g" o2 V) x. g% l. S- C4 f+ \

; a  V* c/ u% C/ \5 W9 H' estatic struct platform_device da850_evm_tl_leds_device = {; E% M( {( K( U& s
        .name                = "leds-gpio",
/ |7 R* G6 N/ S  W3 ?        .id                = 1,2 d1 O( s1 q# d, l& `
        .dev = {
6 t6 h$ w9 ^: A, M" {2 Q                .platform_data = &da850_evm_tl_leds_pdata,
" \( F( K/ d7 N/ C# C8 a  p                .release = led_dev_release,* w$ K% P4 @. O- z2 w9 N
        }# O( m% s0 D$ p, O) n
};
: j4 o0 W( _$ H7 U. x& Z3 W3 ~
; V( y4 X, E& y0 d) wstatic int __init led_platform_init(void)
  R( _" B5 R  I6 s8 m6 z( i{; j) d" r& j  @! ?. C( Z
        int ret;. u) F6 s- R- C  R) M% ]- v8 x
#if 0
! u' x* f6 w; T$ ?        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, i& s  ]5 D7 u        if (ret)8 z- }2 g" l* N) t
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 d9 f3 X5 g6 g% ]                                "%d\n", ret);# V! F; u. P; v9 E, _" @& R% c6 F' T
#endif3 g4 S2 ~3 b- n
        ret = platform_device_register(&da850_evm_tl_leds_device);
3 P; C$ s) K  w* e        if (ret)
& u1 ?7 d" l6 g9 R' x, P5 X) d                pr_warning("Could not register som GPIO expander LEDS");: s5 }- t% y2 U
        else' q$ Y/ Y7 N$ k3 ~, ^1 [6 L. @! q
                printk(KERN_INFO "LED register sucessful!\n");+ T$ l8 i3 f. b; P  ^3 m

* y) D3 @9 H/ b* j% V% m        return ret;- T: w& G( C2 V. H3 P
}
6 A6 K$ |) x' t0 ^( p  e3 T, w* G5 L* Z
static void __exit led_platform_exit(void)% Z* |7 E. f1 P$ b3 x: ]2 r* l
{
7 D6 `3 N1 D# j( x& \1 W4 e        platform_device_unregister(&da850_evm_tl_leds_device);* S: _" q0 W# B/ P/ z
3 `" @# k3 S, m
        printk(KERN_INFO "LED unregister!\n");0 g0 R  D, q( B) Z
}8 i2 v/ e; }8 l; }) r$ @
# K0 X. p  Q  S. w
module_init(led_platform_init);3 @  l- z9 T# |, t
module_exit(led_platform_exit);
& F9 ~& G' D! A1 Y. y; P2 r3 [
( l4 r0 J" p" `  b# c4 C9 v8 }MODULE_DESCRIPTION("Led platform driver");) F/ T2 X6 g7 c* L3 }" r# F6 j
MODULE_AUTHOR("Tronlong");
* E  S" t  i' P; \- X. M1 lMODULE_LICENSE("GPL");* E7 O  A  ^+ E: T' P# T) g  S
6 ~% {6 f4 j! v0 {: |' q7 k' ^
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-4 14:36 , Processed in 0.044448 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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