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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。: |9 Q, Z- q; j! M
#include <linux/init.h>
, H/ P! I+ ~9 ^* ~#include <linux/module.h>
; M8 k) s5 o  u: j' K! \#include <linux/kernel.h>
  I; _. D/ @' s" f#include <linux/types.h>1 K; F4 e* G3 o$ G) e' K" m; `" O
#include <linux/gpio.h>
* T+ B6 J+ H9 _/ v8 l. T0 K#include <linux/leds.h>
1 A: _3 U* D  }' C#include <linux/platform_device.h>
% A) u7 v5 j: [+ f: h% D6 j# M6 {3 c# x% A5 X: z$ f  c$ |
#include <asm/mach-types.h>, X3 b, o& q& m3 ~7 U- W$ ?+ n
#include <asm/mach/arch.h>
6 N3 p% x% p8 S9 v5 K, {4 ~#include <mach/da8xx.h>8 I$ X4 U( l# w9 t: d, a
#include <mach/mux.h>+ e6 x2 _5 ^) ^2 m

. A) E8 l: K, B#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)& D" W0 C$ U" g2 t1 o* G& M1 R
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5); ?3 N% W4 A: {1 Z; q) o; P! v
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
( f/ Y7 A/ I+ @#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)4 g/ v# p1 ^: z; M

" S& n! s& v' R* V/* assign the tl som board LED-GPIOs*/( ]9 Q3 V& F. B6 H. a
static const short da850_evm_tl_user_led_pins[] = {
: f  {; H! ?7 \/ I) F2 ~5 D* x        /* These pins are definition at <mach/mux.h> file */
  K: P' s4 b: ^7 M5 P. }% J- X        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, S6 q: O2 l$ e2 L0 _) U  O4 G
        -1* a3 L3 ]; _% _
};% q- r: ?+ p0 e! S
& I5 H6 r3 Q6 K' `  q7 M
static struct gpio_led da850_evm_tl_leds[] = {2 Q% X5 q3 u& t. z: ~* J
        {, R) k9 P% ]8 t  b' C& l# b' w
                .active_low = 0," [+ O. d  R( x% d
                .gpio = DA850_USER_LED0,/ T- M( }7 A. _% C6 X
                .name = "user_led0",
7 M1 r, @8 c$ Z" I                .default_trigger = "default-on",
; q% G, P+ }( `- ?" E; Q' ]: U        },- v: d! ?7 L8 k* q
        {
* v0 V& Y7 q& p% {) l: e                .active_low = 0,$ a) N5 c2 y0 S( g: W2 f+ g  B
                .gpio = DA850_USER_LED1,9 D. k5 a1 C4 M5 n0 D
                .name = "user_led1",7 v1 M# Z, R/ u# @' S+ Q' \
                .default_trigger = "default-on",
: N% I3 Q2 t5 c* f        },
; B9 x8 w8 J0 G. g3 g9 |/ p        {4 R4 M% e  W% S
                .active_low = 0,) v7 e* u8 \. a4 ^. T! C
                .gpio = DA850_USER_LED2,7 o2 d' Q0 _& f2 P
                .name = "user_led2",# a0 U1 z9 H2 T* q5 W
                .default_trigger = "default-on",
6 `3 e6 f8 d- F  c        },# z: O* j  \2 N1 J
        {
$ {# J, X$ N  a! d1 p" G                .active_low = 0,
1 `8 T7 F  W1 Z3 U' t: F                .gpio = DA850_USER_LED3,
9 o) n0 ]' D/ E! o                .name = "user_led3",
- ]& K& ?: v& ~9 g+ B                .default_trigger = "default-on",
' j7 Y3 ]/ U3 Z: U' ~2 a        },
6 o. W( O9 t% w& [9 ?};
/ g* L+ e$ x' C" ?0 e& o+ ]( a! s2 x% P: ?* O0 ]; [8 n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" e* I5 u5 B% {7 g
        .leds = da850_evm_tl_leds,
/ ^3 a2 g2 @# ~1 Z        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, v% S1 K" m  X5 T0 |  m6 R2 D, V1 }
};
0 [# ]" n2 i1 i8 Z% B) d& O" Z! a
% X6 h+ w( @. f4 ~) Z/ sstatic void led_dev_release(struct device *dev)
4 w  p; r' U8 `{* z7 V1 Q3 g! P& G5 Y
};
4 ^# {! S* z; ?* g: f, u5 m" G  Z& Q4 m. s1 }  H
static struct platform_device da850_evm_tl_leds_device = {2 s/ i2 H( O$ Y( N5 }
        .name                = "leds-gpio",' ~; M9 _& Q# k" J+ j4 Z4 B
        .id                = 1,
, w) ?& [6 Y2 A' k- ^/ n  K        .dev = {
: E/ X( A2 J- ?5 \9 \; q$ Z                .platform_data = &da850_evm_tl_leds_pdata," `( X) {  g# _# L- r7 F! X
                .release = led_dev_release,1 S4 o. U, z/ C7 H- y& Q  G' l
        }( u; i) N0 @  \/ R  [1 |
};& r) P& A0 P6 U, [9 K. x1 ?

" `7 L( s* b+ s! ?& dstatic int __init led_platform_init(void)
" [3 F+ i# T4 F) u' n2 i{+ v8 a* Q1 R' g
        int ret;
9 y" R2 N, c8 [6 h7 B& t- i#if 00 }, c5 N* \) N
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ B3 _( i" X: X! t+ X- G  ]" I( S
        if (ret)
# X. F1 |4 C2 V8 Y* s, h9 b2 t                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! N$ |. g: W4 F  @2 e& D                                "%d\n", ret);
* n' ^  g9 T/ b5 {9 r! p3 S#endif
2 ~) M4 R6 E  q' p1 I% g" C        ret = platform_device_register(&da850_evm_tl_leds_device);4 W' @( K: U' ~9 d7 R
        if (ret)# b. k! L7 w, X# r8 S0 {& Z, A- b
                pr_warning("Could not register som GPIO expander LEDS");
% v: V2 V0 G3 w" ?        else
* x; z: \% p8 a: n) ~                printk(KERN_INFO "LED register sucessful!\n");
( P& o/ y: b1 {2 i
2 s1 }2 K  Y$ U        return ret;
8 u/ I- E& t2 ^1 \}
7 K, V: ?8 q2 D
" H0 t9 f+ o1 [% t( i! Rstatic void __exit led_platform_exit(void)6 q% j9 \8 }. ?2 `
{" V1 D8 V/ N5 ~/ H. T+ o+ {
        platform_device_unregister(&da850_evm_tl_leds_device);
) ?0 o/ p, Y% H
# F; V! Q- o2 r( R1 }        printk(KERN_INFO "LED unregister!\n");
5 V9 u6 D1 C, a; L}4 A7 N  b' c( r+ K
9 K  I& M: L& ?( X: j9 V* k
module_init(led_platform_init);7 w- a' B1 C& H, w9 b( x
module_exit(led_platform_exit);. X1 Q& \0 H8 j7 u

# n" j7 ~3 f: P9 s# nMODULE_DESCRIPTION("Led platform driver");* z8 _0 b0 n) O4 O; e9 V! W3 u
MODULE_AUTHOR("Tronlong");+ Z2 P& i3 F/ L+ n
MODULE_LICENSE("GPL");8 Q7 @- x6 Y( q. X% D0 Z( y& `2 r

; ?' f) _: i* d0 y) O6 I
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-22 04:10 , Processed in 0.041885 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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