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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
" ~! ?2 M+ y: p# W4 t#include <linux/init.h>
0 {2 P* R( b/ z# Q2 n" I$ ]6 Z$ F2 _#include <linux/module.h>) h8 d: G& F8 f) ]1 R( [
#include <linux/kernel.h>
5 ]1 v, a! ]+ ?  T% Y#include <linux/types.h>
% w2 D: ~8 ?0 j: F#include <linux/gpio.h>- i6 |/ B+ O& b9 b: j
#include <linux/leds.h>
3 \) h: E( e# p#include <linux/platform_device.h>
. ^, L" ?. M3 W0 S& f! s- l6 \' t9 H
) ~) M  X4 X- s' e7 `; N#include <asm/mach-types.h>' ^, c  p5 T5 }; w$ {( w- x# s
#include <asm/mach/arch.h>
# Q4 s6 u7 \- `4 t#include <mach/da8xx.h>) F  Z  M5 g: h! f; B  }8 U" W0 h
#include <mach/mux.h>3 B( c+ h6 o/ a
( A# x% G( b9 O# t& _* L
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)2 h9 |9 M: V, u
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)- d. x6 C5 E) t
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)* R& F5 U  U+ l4 \3 J/ o8 ~
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
( ]; F3 O$ T; ?4 z7 g0 _  ^0 Q: [+ A+ T8 U1 ~
/* assign the tl som board LED-GPIOs*/
8 z% U! h# t+ o% ?6 ?9 Mstatic const short da850_evm_tl_user_led_pins[] = {
3 u2 J- ~+ z; I. |) u) z        /* These pins are definition at <mach/mux.h> file */
% E, ^' @0 z/ j        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ @4 X! A9 I" j. o4 p        -1
, D. D( V, S& {5 s- e5 c};9 j: b. N" o4 |0 y

. u% x( N% y) r! N; ^# l  Ystatic struct gpio_led da850_evm_tl_leds[] = {$ g  ^* D5 v* t1 ?9 n6 n# Y
        {, |0 z$ y0 @4 v3 V" O$ ^
                .active_low = 0,6 L! m, l$ U. e/ o- I+ i2 Q: ^
                .gpio = DA850_USER_LED0,. _& y0 z- f( |6 H
                .name = "user_led0",7 H3 ^6 Q9 L6 ^: N( G5 S
                .default_trigger = "default-on",0 r0 d' ^- [+ C& @+ F$ X( P9 \
        },; ?! z& v- l% P( v6 b
        {
+ D" o3 a. W7 T' ^- x9 ]& X                .active_low = 0,
7 Z0 c7 U  @, S3 l- i# \                .gpio = DA850_USER_LED1,5 i* q' _! X& E. P  D4 L& g
                .name = "user_led1",% [3 O) Y8 ?- \; g' K; Y
                .default_trigger = "default-on",
' Q" H0 H$ v# \        },9 j3 G6 M$ i4 ~, `4 e% x  t
        {
: P. _( _* \+ Q" T# H                .active_low = 0,3 d3 Y* u7 l9 C; a: ~4 W
                .gpio = DA850_USER_LED2,* z2 Q9 ]7 F* ?2 V- m
                .name = "user_led2",
; n/ d7 ^/ b8 T! o8 @1 z0 p                .default_trigger = "default-on",* c4 X1 e# b: b8 W: T+ r
        },
% i; H+ v- d4 G4 Z; C/ ]0 l7 M        {
9 E/ a: m: _  e) Y0 R                .active_low = 0,
) ^4 ~7 a2 b* I# \- M% p- D! J5 `                .gpio = DA850_USER_LED3,. b/ h: _  i! c/ U5 u9 B
                .name = "user_led3",, W4 Z: D. y! j4 A
                .default_trigger = "default-on",5 i$ `5 p2 h0 P7 `* X. [
        },+ N& e! B; x6 w; z5 m6 p
};/ z% ^4 _9 |; O# H

2 I3 v1 D" ?6 O4 l/ O; Xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, p3 x( p1 ~/ o1 S        .leds = da850_evm_tl_leds,
. ~3 k# \  a6 {/ y8 P9 d9 G        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ G7 W) S/ i, `, n+ p};. K  c  Q" y% V5 v. Q2 A) I' g
6 u2 D. s- z4 g  ?$ r* _
static void led_dev_release(struct device *dev). f' F, p& _5 E8 c1 D) P1 N7 i
{
$ ?$ B( k$ t& [9 u/ g" w0 S};/ i: H7 Y" V1 P4 {; v; ^& @# C& V+ G) d' S
- F  |% A6 C1 w- S$ O
static struct platform_device da850_evm_tl_leds_device = {
0 s: `8 Y$ @! `5 k; T& H; T        .name                = "leds-gpio",
0 t+ Q6 \) N% [; D5 O/ A- \3 H) T        .id                = 1,/ K  w- M! s) x, a* I, A" |
        .dev = {
# p: y8 q- L$ {0 C1 K) l( I8 U                .platform_data = &da850_evm_tl_leds_pdata,
5 g6 R+ t! ~$ n. _2 T% K7 }0 _/ n                .release = led_dev_release,
' f6 X+ q2 l2 A$ K/ W5 T9 g8 F- |        }
! V6 _% y# I; X};+ j. ]  V( M/ b5 D: s' Q$ Q7 `# {

4 d4 _" t3 R0 n2 q; ~- nstatic int __init led_platform_init(void)
8 w% `. g) ~8 [' e& b5 ]% l5 n{
5 r9 {& _8 {7 i/ Q        int ret;
; o" s7 ]9 u) ^" T. t#if 0) G- {: _0 M( A8 l  Z- Y
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 K* q, }) v7 C& t1 @; g        if (ret)
8 k3 }, E7 ~% R3 ~$ w* K7 a! m                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ F! [7 q7 f7 Q: w( M9 B
                                "%d\n", ret);
2 ?: x4 I+ O! r. I/ J/ Y#endif+ ^2 ?! }" l7 w4 S: [( ?5 I3 i
        ret = platform_device_register(&da850_evm_tl_leds_device);
* f/ I! l0 y9 }% l0 ?8 T8 @# l        if (ret); a' P9 {: X8 y0 _  d: D$ s
                pr_warning("Could not register som GPIO expander LEDS");* z+ X, C( q0 J# P+ |
        else
; U6 U3 o* l* J2 }+ d7 M                printk(KERN_INFO "LED register sucessful!\n");0 X0 ], u- k9 P  U
! x& J4 X' l' g$ S
        return ret;
+ {; n" a! {3 ^}2 a7 T+ T/ y% E: I: n7 r
1 b' Q: y3 [, C2 [
static void __exit led_platform_exit(void)
  `: M# P% d1 U' N& s. a2 C{5 ?# @5 R5 B( E; K( J# W
        platform_device_unregister(&da850_evm_tl_leds_device);) O3 v5 {; w  v( t0 j

* W  b# c4 D5 A! T        printk(KERN_INFO "LED unregister!\n");9 O( Y+ @- V9 Q3 _
}
& O. ]* P. f9 ]" U- W
1 s& T& I/ F, B  B+ A: c# [5 Smodule_init(led_platform_init);
! V* Q. a0 e6 J$ G; `+ \; Amodule_exit(led_platform_exit);. E" ]. Z- w& O, Y7 F. M. o" R, H
1 V5 a! H/ m: Y. A
MODULE_DESCRIPTION("Led platform driver");! a( J% k- ~. Y/ o* R
MODULE_AUTHOR("Tronlong");  e: d/ A0 d4 ]
MODULE_LICENSE("GPL");% y. ~1 |5 B% v( H# O- r( h) C
/ {! _% [0 }4 z& E8 [
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-15 09:27 , Processed in 0.041712 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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