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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
7 L" ?8 ~+ G$ x% @' {* c9 i+ [#include <linux/init.h>
# X; ?( V( [+ r0 k  N#include <linux/module.h>
( D: a8 ]2 x9 K) F  y#include <linux/kernel.h>  P8 g2 H0 Y' v
#include <linux/types.h>
1 o" P6 w# V6 w8 h. V7 o" B#include <linux/gpio.h>
, v5 N" X, b" y. E- \: z#include <linux/leds.h>
3 x, g. E) ]% e7 G4 ~#include <linux/platform_device.h>
3 S3 P3 D) @, T! v6 J+ K3 E* w4 Q/ V1 ~& x
#include <asm/mach-types.h>
* {2 |. W; V) G#include <asm/mach/arch.h>
/ i8 ~3 V% ^2 V#include <mach/da8xx.h>
3 o, M+ X" `0 p8 \6 r3 E% R& A, R#include <mach/mux.h>0 @" q* O7 N3 o, M  b
  d; z. y. m( s+ E1 Y  t  ^
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0); |% {9 M# X, F3 O& R
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
/ {: K, r9 @4 L$ o5 j#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
# b6 j  p  e9 Z6 n- ]' ~0 W#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)6 _3 J2 A% \7 t! X* O- r4 m& z

$ s# s  m0 T/ M; e, [/* assign the tl som board LED-GPIOs*// C/ y7 R& a6 f0 O( [( n5 [" `
static const short da850_evm_tl_user_led_pins[] = {
! H& {; l; ^$ ^3 q, G( g+ g        /* These pins are definition at <mach/mux.h> file */
  G% c) ~7 M" T/ m1 E        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! j* v+ U# N3 N6 R; R        -1
3 r5 g4 F9 n5 y  ]! K$ b};- D# ?- O8 Z, `6 c

: p1 c$ o9 V' ?+ A# S1 Mstatic struct gpio_led da850_evm_tl_leds[] = {7 f0 H0 u: a" G- B
        {- S* F/ \, I4 }6 {& X
                .active_low = 0,, N7 V/ n- Z/ U
                .gpio = DA850_USER_LED0,1 w$ _& d7 {& X2 Q- m* y1 P( M% g  L
                .name = "user_led0",
* ]' s+ ?1 M9 I1 V' l. _                .default_trigger = "default-on",) m. G* E, j4 ~& N5 E! o: D# r
        },
6 C7 M* D- P. I; W+ H3 }. q- f        {- `, c2 ?) j1 F
                .active_low = 0,
5 J% U7 H- k1 C2 o7 A                .gpio = DA850_USER_LED1,
- f' J. a/ O% V5 d7 U                .name = "user_led1",
+ ]+ u4 i9 [/ P: N                .default_trigger = "default-on",
  g; i# j2 ?! r6 T2 H  I        },5 Z" r$ C& L9 k* O8 Z- x4 [
        {
$ [5 Q" Y4 `! L4 S' S' ^  q                .active_low = 0,
" I' |5 [5 K$ s                .gpio = DA850_USER_LED2,
1 j8 ]( r9 b# x5 C0 s                .name = "user_led2",( Z, r  L2 {' A* T3 |- m" T
                .default_trigger = "default-on",. u3 W" E5 |! d# s* g. k2 K
        },
( I1 E7 S* T6 u) {; V" p5 a: z        {
1 `" G, H3 |, _& y5 O; f$ @                .active_low = 0,
1 s4 W9 x9 y$ a( Y                .gpio = DA850_USER_LED3,
5 C! S8 T3 L  e$ Z& r. n% {                .name = "user_led3",
& Z4 e. ?# r9 J- r+ f                .default_trigger = "default-on",
  y# ^0 }- I, j; [6 d# J; y% s        },- e: M- C4 ^/ g+ ~8 N; |
};
8 G7 L3 ~: h3 w6 R) {* ~4 O6 |6 M0 I4 x; [
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) ?+ D9 S5 F. X3 h$ Z4 G, _5 V        .leds = da850_evm_tl_leds,9 j! f9 I4 C; V2 Q2 k; l) N
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) t2 Z! Z& {' \* K};
; ~0 ~, j" `! I4 J/ t, [' M( g4 B- [; c3 w* ~
static void led_dev_release(struct device *dev)' s+ W1 l1 @5 Y8 y4 }. X* }! T
{3 v8 e; p/ l3 M9 I& ~! n4 b
};) U; x3 o) |6 v. H% V& w5 x# t7 v
- R' M; }& a6 Z- K
static struct platform_device da850_evm_tl_leds_device = {/ c8 J& K+ ^! _1 I$ v4 R
        .name                = "leds-gpio",
5 i5 m9 x- y4 m7 w2 X        .id                = 1,: r- v5 \; h% e2 W2 z& m5 b
        .dev = {4 o/ q0 j( g! X* e
                .platform_data = &da850_evm_tl_leds_pdata,! r: m; ]2 A+ g/ Y, k" M& V% a
                .release = led_dev_release,  o, |1 H% s; \6 a! ]
        }  ^) A' j; o# a- C' }0 B; l' l; s
};$ T% Z3 \# \& R, F
( A* l. T& `3 q' u! R) m
static int __init led_platform_init(void)0 w- a7 |* M+ b; A
{
6 _. F' s3 r5 c: m; t( I        int ret;
+ X1 }, d9 d5 H#if 0" i: N9 ]1 R" q, w2 R9 e4 p- l
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 x1 W3 b* E$ u( n  O9 d        if (ret)
2 B! n; Y0 e$ ^- _                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) d  l; Z  z. v# M) T) |  g                                "%d\n", ret);8 b' z# y0 W# Q' F
#endif; p5 w; y8 X) P0 o$ v
        ret = platform_device_register(&da850_evm_tl_leds_device);4 H0 y9 P) s% c6 s' x
        if (ret), c+ }/ V2 w; C; v# C
                pr_warning("Could not register som GPIO expander LEDS");
( \; C' O! B5 d) Y! D# J$ s7 d1 P: K        else
' ?( w+ i3 D6 h+ H                printk(KERN_INFO "LED register sucessful!\n");
) ?! l% S  I' D4 P
& t; n1 _* ~% e; `- b        return ret;: P( K$ j9 n% r! N2 S4 Z
}& u% Q1 m$ ]4 `) n
8 Z- \+ I( J6 g8 t2 ]( C! K. t
static void __exit led_platform_exit(void)
1 n' n- ?' B5 D) V2 Z6 ]: P{% Y1 X# `2 A; O* Q3 w* m6 O# s* T
        platform_device_unregister(&da850_evm_tl_leds_device);7 X( T: T. `$ e/ n$ d' _. N& M# Q% G) Y" b
0 I' [7 y2 s5 T3 p% j2 r6 t
        printk(KERN_INFO "LED unregister!\n");8 ?7 Q' D0 L, D7 q% G( |
}& X0 @+ Q% J3 z" I
* l4 u8 s  g/ M+ U1 H1 _
module_init(led_platform_init);8 {+ l/ }0 U3 O* R* t1 Q
module_exit(led_platform_exit);
! g$ e& L" L0 j
- p# ^. L3 N/ B* N! K/ d( o7 BMODULE_DESCRIPTION("Led platform driver");
4 h- M0 x) m- J$ [8 C. i9 iMODULE_AUTHOR("Tronlong");) I+ I) F& r$ a4 r8 I3 z
MODULE_LICENSE("GPL");
) K8 g6 ?/ a6 K' A; {; f& ?) _' P" J. H+ ~2 M3 Z
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-10-21 09:23 , Processed in 0.041920 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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