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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。' Z! K$ ~" T2 T) J$ B
#include <linux/init.h>
$ F8 n% P4 g4 T#include <linux/module.h>
  o6 E( d8 Z3 R#include <linux/kernel.h>
6 J8 D" @( e$ J: |; p1 o5 r#include <linux/types.h>
/ g: t/ X8 ~7 G+ y+ [#include <linux/gpio.h>
! f3 q6 M# f. _8 E% {#include <linux/leds.h>
0 M0 H$ {1 _( h, r#include <linux/platform_device.h>
8 n8 P% P0 ~' Y) K5 H" Y1 Y8 J$ ]- Z0 }1 p6 }5 h/ V
#include <asm/mach-types.h>* A* P; V, w7 }5 h/ i" u8 A6 p/ Z9 M
#include <asm/mach/arch.h>
% }; b8 L: F. P, O" O9 Z#include <mach/da8xx.h>% Y, j5 D4 s$ V7 j
#include <mach/mux.h>! I) i0 p0 ]) w+ l% I( R1 @

. t2 n5 Y3 X& Y7 }; V& F3 v#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
2 O. D' j- c9 n( n  ], M+ K4 n#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)2 T9 o) i  z. ?& R
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)7 g; s' a% G5 i" ]
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)$ T9 ~3 T0 Y* M2 d- {4 S; ]
" B( G9 u% d: f0 m; g0 {: \
/* assign the tl som board LED-GPIOs*/
2 I3 Q  t6 z' J# b( x+ r4 ~3 j( Dstatic const short da850_evm_tl_user_led_pins[] = {( q+ C& Z0 Q8 S7 ?  V* F
        /* These pins are definition at <mach/mux.h> file */
- G& g4 R; c# r! n! G        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; R9 B2 p* Z/ P9 p: O        -17 j. p# {- Y- z. v. G- Q4 v. q  [
};; h1 l' w. L' W$ r
2 \, g3 U/ r- G; ^: i' k* {% |
static struct gpio_led da850_evm_tl_leds[] = {
8 i1 R9 [# M2 i8 T        {9 o& i# B, u8 Z
                .active_low = 0,1 O  K9 L# I" e# B0 w1 k$ E
                .gpio = DA850_USER_LED0,& m1 C( F! v/ F5 d1 u% `
                .name = "user_led0",
. @$ p# V3 e  }$ l1 X* n                .default_trigger = "default-on",
' C1 ^1 h. m9 @8 m; S4 j        },
6 f5 P# D) E* S3 u3 [        {& w+ V* |1 E+ |2 ~% ?4 S) x+ B# x
                .active_low = 0,
6 q+ X, i. A3 `3 M* X0 R                .gpio = DA850_USER_LED1,
: q% N1 I- J7 \1 l, @                .name = "user_led1",8 v4 v. g3 ^8 U: n
                .default_trigger = "default-on",
; i0 H/ T( R% ^! i# _, L4 w        },$ A! m( K  d0 ?5 s2 m& k" R
        {. n; Q' O8 \0 `$ Z% U1 [& V
                .active_low = 0,1 z  _* g3 g6 T( s: O& ]
                .gpio = DA850_USER_LED2,4 s* P. K8 Y6 @  w
                .name = "user_led2",
+ O! q; M, v, K' k1 Y' _& O3 V* ^                .default_trigger = "default-on",4 |2 h5 I2 f' Z  X. K4 C+ K" B
        },, i; l2 I$ ~+ V8 U9 `7 f' N
        {
# O0 r8 ]* f6 H                .active_low = 0,
! x4 z# I, s$ R9 D: E) o                .gpio = DA850_USER_LED3,6 F. m7 L1 J) i2 r: h7 G& m
                .name = "user_led3",
( o* D% n, U4 l1 a2 A/ M  {                .default_trigger = "default-on",* Z! l: H5 i0 r
        },
. G5 v9 z" n9 y0 E5 _};2 `! T  S+ g3 A% K
0 Z4 p' c' i% d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" I" [0 J5 d3 H        .leds = da850_evm_tl_leds,
% C" s* \, u! B2 z        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. r$ n8 H1 t3 e9 n% t};
: l; L" e; V, I* W# ~
; y1 b8 s+ E  x0 C/ mstatic void led_dev_release(struct device *dev)
6 J7 E' [6 v- ]1 o; E8 I: a0 D{! ~6 S' o0 c- N1 [$ |
};  g: B, p" |( ^' D  [
3 A$ {2 Z7 w0 r' I" U% {3 K
static struct platform_device da850_evm_tl_leds_device = {! F' O) Z) R% P: ]; H1 Z
        .name                = "leds-gpio",# ~/ x  f. x* c! i  M
        .id                = 1," l' J9 Y" g( F! r
        .dev = {
2 `0 s* i3 V- P# n6 I( z' t                .platform_data = &da850_evm_tl_leds_pdata,% |( d  P- h7 q2 I
                .release = led_dev_release,& E; o8 a/ `; n. f4 U4 c
        }
! ]  G/ d% l, H};
: L& l8 ^$ G+ }1 f8 W- U8 c, t7 m# I$ Y
static int __init led_platform_init(void)) P  {& z' a7 P# t
{
# Y# P6 ]5 I( V$ b' X  N        int ret;
; W3 w+ Y* R; M( j* Q#if 09 L$ y. I* P9 o& a  [
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" X7 T4 r3 G7 c$ Q* `
        if (ret)
1 a8 o& S6 R- r0 H- F                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 Y, u5 H1 ^. j/ R% B3 Y
                                "%d\n", ret);5 ~3 Y/ i& W  k6 d. G3 p$ d! g2 f
#endif2 {! J3 Y4 G! y7 J
        ret = platform_device_register(&da850_evm_tl_leds_device);
% \8 b4 H1 f: e, q9 z4 }6 f        if (ret)
; C& B  G. f$ ~                pr_warning("Could not register som GPIO expander LEDS");+ T4 j4 y) ]8 I! P
        else" t. g0 l4 M" E7 n' ~0 s: i
                printk(KERN_INFO "LED register sucessful!\n");
) w6 p7 O8 Q$ S5 n- T- i) _0 R0 w% \0 _/ X
        return ret;
$ y; U: p/ [6 @# g+ r4 k1 Y}
0 X& l! S* D% Y3 N5 ^4 _/ M9 q, C
- ~) [$ U7 @5 O  R: i- c  t4 vstatic void __exit led_platform_exit(void)( V7 U: Z! I" Q2 I" r9 o
{& z) z( h5 I! w9 ^) A2 v7 H: y
        platform_device_unregister(&da850_evm_tl_leds_device);- x' w, `7 d2 D, u% m( ^
+ i- l5 v0 l4 G! F8 J. [7 V# ?
        printk(KERN_INFO "LED unregister!\n");
/ Z8 y3 H: Z+ F& y- t3 ~5 u}% u3 y: E! W: ~. I

  ~- H# x# D7 M) Amodule_init(led_platform_init);
: X: P  W* v1 n* d6 m9 f; {- wmodule_exit(led_platform_exit);
6 K& A- {$ y& W+ \6 L
! B& N1 J! j: w0 ]8 ^MODULE_DESCRIPTION("Led platform driver");
- U* p& [: a( y- _. O- xMODULE_AUTHOR("Tronlong");& M! r0 A( W! k) b( J" D& @5 |4 L2 Y
MODULE_LICENSE("GPL");
. r$ B1 ^6 V6 G0 q% O, z/ n4 d" _" y
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-22 05:49 , Processed in 0.039232 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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