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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。; x9 G6 h7 k" v: v. r- ~; R, I7 P
#include <linux/init.h>
2 [& d7 I! ~0 p; t3 M3 {$ i- R0 p#include <linux/module.h>: A. ^7 ?  e9 Q1 ]7 V$ M2 G$ B
#include <linux/kernel.h>
9 h4 n3 {$ a, |$ T9 E  ~#include <linux/types.h>
3 h' g$ f9 k$ R. x#include <linux/gpio.h>: E" j8 E1 T! s! [
#include <linux/leds.h>' _3 i$ j# N% F( M, C
#include <linux/platform_device.h>0 m6 R4 D7 @5 L! r9 b1 Q* K: [
' k0 S1 Q4 U3 k+ \+ q( o
#include <asm/mach-types.h>
5 o4 |8 R: }  m#include <asm/mach/arch.h>
+ o# R, |& x9 D0 }3 h8 k#include <mach/da8xx.h>3 c1 g* N3 C, O1 v
#include <mach/mux.h>
( g, L# R: l" T0 \* [1 }( a* S8 f
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
3 R+ t& t3 S* @#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)! t" u$ Y' J$ O  [# H
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
6 I  `' G7 O: T6 ]4 x#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)5 ?8 k, L2 O: J5 [8 ~% b- s4 G& v
' |! m* i! f5 s! Z
/* assign the tl som board LED-GPIOs*/
5 x+ v( m/ h% {/ Hstatic const short da850_evm_tl_user_led_pins[] = {
7 q; A4 d8 Q: @) U# z5 g        /* These pins are definition at <mach/mux.h> file */: d4 n/ E: s$ t! H0 B
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 y6 N9 _$ o/ t- I  s6 o# J        -15 c$ L# q; m4 V( S; [3 R2 M
};
7 L! {' N, n6 ^& h/ I% D0 f0 C
: ~; R# u# G. W$ u6 M/ Q3 Astatic struct gpio_led da850_evm_tl_leds[] = {
1 q+ }, M/ L3 L        {
) e, {2 v- e7 A+ ^+ x! I, }                .active_low = 0," X8 C+ U7 t  B6 m
                .gpio = DA850_USER_LED0,7 v3 l5 F! F1 l3 I7 M, \
                .name = "user_led0",1 p+ x0 ?# K( A+ i9 H
                .default_trigger = "default-on",
+ q! \9 f, E, i) C- \- C        },
6 }7 k1 r/ ~8 s        {+ X" X2 b2 S/ W- [2 _8 |
                .active_low = 0,6 ~* X0 S0 F% h
                .gpio = DA850_USER_LED1,. u! h* j! g: h
                .name = "user_led1",% Y2 n4 J4 H4 [3 T7 h) `: ]
                .default_trigger = "default-on",
" j9 c2 S! s. P2 |. x7 W) R        },
$ @- A# s* g; G% Z/ R        {
- ]2 n* c8 p8 ^$ C( T# T                .active_low = 0,) z9 U* Q7 Z& y. H" H, W
                .gpio = DA850_USER_LED2,
+ B3 Q7 E0 R: @% F                .name = "user_led2"," w$ h, m0 `" U2 A* j
                .default_trigger = "default-on",. p' N# v; m" Z; H& I( S
        },0 ~' J; o3 O; Q4 J) @- Z
        {( ~9 m9 H2 Z. c$ {% l) t
                .active_low = 0,
; `  i! R, U; }* M) ?2 t. w" |                .gpio = DA850_USER_LED3,$ {' N& X7 c9 f* @$ c- M3 X! s( X
                .name = "user_led3",
8 ]% C9 j3 k: E/ B( O8 t                .default_trigger = "default-on",% x, A0 o+ i# z6 S' z
        },
! g: q# i8 @0 u6 R" }+ R0 _};
5 i+ ?' J* P* Z* n+ V
; _) T% K! i! k" ?2 kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, p* r! _$ `7 F# X9 F        .leds = da850_evm_tl_leds,
# W3 |; j; }9 a* q6 z0 q        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) p: a/ u; N$ b& P/ |0 T8 U8 b
};+ j8 W9 a1 U1 q3 X
# B" l2 G$ G0 t" @/ [. t( [
static void led_dev_release(struct device *dev)! A# g$ \7 z' U# B- T, _. n
{0 ]! b! g( ?# |$ Y
};
& k6 [, q! C7 H$ a0 k) S1 ^4 P6 s5 k# @2 E5 p
static struct platform_device da850_evm_tl_leds_device = {+ I5 |! r% I4 v; r' Y' G
        .name                = "leds-gpio",
/ {" {& [% {- G6 d        .id                = 1,
, A! Z: G, u% o1 I% ]( y        .dev = {
# E: I1 a3 K( Z9 j3 T! [+ f0 J                .platform_data = &da850_evm_tl_leds_pdata,
! d/ J9 ^7 P; b& O% i& d                .release = led_dev_release,! }. H( w  o% M% y. W" c" r- B: Y7 E
        }# R5 z# p, X4 J2 N
};
  d2 ]) e0 [9 T9 w2 B6 Q
! u" ^. L, V" n& fstatic int __init led_platform_init(void)
( n) ]7 u" s5 j/ M0 N{/ N  b, F( P8 b: @& F: @" ]
        int ret;" X; s8 f) U) A0 m' c  \
#if 0
: _, j8 J$ M8 t. }5 `        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 V$ ]( {3 y5 p( N! a* I; T        if (ret)
# l  X7 A9 H! a! F# y, H                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 k: s( T2 X6 P( f: O- D/ W                                "%d\n", ret);
0 s# Q# ]+ [' Q) `* Q* }# ~#endif7 J% u3 \( @7 Y5 Z
        ret = platform_device_register(&da850_evm_tl_leds_device);3 _% e, M0 u& g; ^6 V
        if (ret)
" q. k2 K' ^3 F- S                pr_warning("Could not register som GPIO expander LEDS");, z* l( `" A1 N/ L; X
        else6 G+ c1 d7 ]4 S% q& g
                printk(KERN_INFO "LED register sucessful!\n");! G" N* T2 {% A) R8 Z# V: d
2 \4 z" ?% l* B0 T: }
        return ret;
- x/ A2 Y- E) }) l8 k" H/ C, K}2 A$ X/ k% M) d, j& w0 L
4 |8 u- l6 Q, T+ f
static void __exit led_platform_exit(void)
4 @8 I, b( P. E4 ]8 ^{
7 N, }! W" P+ |  O. D        platform_device_unregister(&da850_evm_tl_leds_device);
3 k, U5 F' z7 [9 Z+ ?5 |/ a1 h9 j2 z) ]! W5 ^3 p
        printk(KERN_INFO "LED unregister!\n");  O) c0 `6 q4 [; L% i4 C% _& o
}
: G% d2 {# I2 ^: _! S; B% K( i
module_init(led_platform_init);
/ w/ _& \: H' h9 j( Z. w9 f( `module_exit(led_platform_exit);+ x, L# V  h/ o# l# U, Z1 F; Z7 C

' U) z4 i# @$ H$ E- D+ Y1 GMODULE_DESCRIPTION("Led platform driver");
3 H" ]1 T1 _0 \MODULE_AUTHOR("Tronlong");
" Z' R" G6 i$ l% U' O7 J2 K. o" G6 GMODULE_LICENSE("GPL");$ R, u" X+ g" ?- h) e' p( W

8 v, D1 Z" C5 f# O$ Y' F/ o& N
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-4 18:51 , Processed in 0.038880 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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