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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。( V$ Z3 r) w9 I/ d5 d4 ^$ w- O
#include <linux/init.h>
/ U6 F0 I2 b" D1 J  R3 j8 R; W0 t#include <linux/module.h>% ~7 k# m! E1 g9 ]4 q* D2 W9 _
#include <linux/kernel.h>% h4 m# i1 e$ i) O/ k
#include <linux/types.h>" {( L' O! ~. S1 U  q
#include <linux/gpio.h>
0 t* C  Z  i& Q; r: Q+ T) r#include <linux/leds.h>. \/ q1 D! y( T2 R1 `
#include <linux/platform_device.h>
0 a' K8 P5 n! s9 b& G, `' |$ V4 Y) v# N/ y; @5 h; Q$ k- Y
#include <asm/mach-types.h>
4 |  m+ a- e7 [% l0 Y2 y9 o#include <asm/mach/arch.h># v0 W" b/ a% c9 v
#include <mach/da8xx.h>7 g) R; b0 p" p+ W7 \8 F
#include <mach/mux.h>
# q- x$ O7 z5 w
: G6 N  X0 M: @* Z#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
* s' q+ z& G, k#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)- \2 |5 g% c" S* Z7 J0 W
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1): P0 T  p8 U' m" v3 k
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)( t4 a# p4 E: V' k- B, n
4 ~+ X; \. \. }0 G* @/ X
/* assign the tl som board LED-GPIOs*/0 t. c8 k! z% m
static const short da850_evm_tl_user_led_pins[] = {
0 I( O6 ~* ^7 m6 x# G9 G6 t8 {4 T        /* These pins are definition at <mach/mux.h> file */) W! `! A7 N" f5 V- v9 D
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; T! M3 b# m, l# Y        -1- i7 V* L. S4 E9 d% B! M
};) J& N& K4 a% e  A5 i

5 ^  D  [/ t6 i- P, jstatic struct gpio_led da850_evm_tl_leds[] = {
5 }8 a- }2 o* J* @        {) R! ]7 n2 \! x1 M# Y( L( I! P
                .active_low = 0,$ a5 v/ T5 h4 Z
                .gpio = DA850_USER_LED0,& F) r% d, B' m) F- ]. M% T" S* Q
                .name = "user_led0",4 H7 T$ G1 @6 O, S
                .default_trigger = "default-on",5 M( x/ `2 \% K3 w1 W6 h
        },; n& `  Q: z, Y: C( A0 |2 D  _% D8 ]
        {6 d3 ~, `: c( B5 h
                .active_low = 0,
. P. {" M0 P+ U! ]5 O! ?( m                .gpio = DA850_USER_LED1,
% e+ t/ T: p' z, T& q% a' b6 n                .name = "user_led1",
1 V* E; A" Y. O4 l, I( l4 H                .default_trigger = "default-on",
9 l, y6 N8 V  h. I6 o3 J& j/ `        },- {) X' X/ U7 f4 N! k
        {
, u! m  ?% ~( M) @- l                .active_low = 0,
$ p# ~! K' @9 b* s                .gpio = DA850_USER_LED2,/ k7 f2 O5 y! y6 l
                .name = "user_led2",6 K0 P7 }. f, s! G- o" ?7 `
                .default_trigger = "default-on",
$ l* R! ]& [; g( G        },2 q. a0 ~( Q# D; p' t1 S
        {
7 l6 w# ~! F. x" `$ y4 d) T                .active_low = 0,! C! p. e1 b( l7 X0 q; r
                .gpio = DA850_USER_LED3," P& `: b% j; k* i1 c" a
                .name = "user_led3",
4 O! S5 t# _( c  w+ z1 a                .default_trigger = "default-on"," G+ _. x0 r- ^7 C
        },
3 V2 j8 N/ d6 \: C1 _( ?};
" q1 P( P+ F' u, C
5 F5 X: E! ~: B9 xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' E8 u2 {6 I7 X$ L0 t- \9 |
        .leds = da850_evm_tl_leds," n' E/ ~6 f0 g" K- h5 X& Y
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- H$ [. s# @! d5 e};7 [* m" k. i* G! |
; g: a0 k; i8 E) a/ ~
static void led_dev_release(struct device *dev)* t4 a' @4 [* C5 ^5 G+ r
{
! h+ P3 D, ]1 {. s# b1 [};6 ^, N+ s! E9 [$ w) |# K4 b

% C6 W. u* P1 v  a' y- hstatic struct platform_device da850_evm_tl_leds_device = {9 N* H: U! B2 A
        .name                = "leds-gpio",
8 k5 t) I6 j% c. c1 c( W! s2 w/ e        .id                = 1,
# v- d$ u3 u3 I4 m  D        .dev = {* L0 L3 m3 n- J7 U1 Q
                .platform_data = &da850_evm_tl_leds_pdata,3 G$ P& G) H( x, ]4 E' s$ {
                .release = led_dev_release,! {' x; f5 t7 \4 u
        }) m" K- h! X3 ]$ C# r
};1 q" c# v! c. H- V5 _% a. f
4 q: x" d7 }* w$ d7 A' ?
static int __init led_platform_init(void)
6 `/ @* `+ g* ~9 W: g  V{
- f7 ~+ H$ W" o# V, V: r! L8 P        int ret;
. U( Q9 I1 K' m4 U/ G; Y. S#if 0' s% v; Y$ T1 ~+ i
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& `8 I' i* h: p1 u; }
        if (ret)
5 G4 b& J9 [1 D9 Q% W- A3 U                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 r% J$ [8 r& p5 x1 h, {6 f
                                "%d\n", ret);
) G2 U  h/ M2 [: w! o; S2 O/ s: Q#endif5 y; C& k4 r. I; B2 C& k% t
        ret = platform_device_register(&da850_evm_tl_leds_device);
% J; n% z4 S8 }( `0 p        if (ret)
! D+ X! S- n& F+ N/ l7 D/ {                pr_warning("Could not register som GPIO expander LEDS");
/ j: w9 f5 [; P# W: O6 K        else
$ X4 z& c' _: _  J, n3 s                printk(KERN_INFO "LED register sucessful!\n");/ L9 ~/ Z! Q4 l
4 }$ Y, n. c% a
        return ret;
' D7 N! ?4 F" J+ @) y: ~7 d  G5 M6 n}$ L: V" N3 V; F0 r5 O

" ]4 _# e  {( P! @+ estatic void __exit led_platform_exit(void)) ^: y/ v# S3 c" ^9 j
{% ^" d+ n2 t' s" w& z
        platform_device_unregister(&da850_evm_tl_leds_device);# ?+ e( V/ W1 b2 R$ ^; x. o- P

$ J, t! ^9 n1 {6 |& r6 q        printk(KERN_INFO "LED unregister!\n");
9 s4 K+ u- B6 Z% B- n, x0 o. m}
1 J# [/ a: r# {& \9 g* N
0 K6 X8 {6 x) M2 }. W5 kmodule_init(led_platform_init);: a8 p0 d4 H5 K4 b$ O
module_exit(led_platform_exit);
* S7 x) `9 b" y9 ]* U  H9 }7 e5 x( z9 A5 I) m6 t6 O
MODULE_DESCRIPTION("Led platform driver");
; _$ Q( _4 g2 `; ~MODULE_AUTHOR("Tronlong");
  {% ^+ Z8 f, W5 _: sMODULE_LICENSE("GPL");
) I1 d2 s3 ]" F4 |; B7 o8 b: ~# a0 r, G& G7 ]- H
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-9 13:40 , Processed in 0.040853 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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