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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。: h9 c5 v% x5 i/ g4 E% N
#include <linux/init.h>
* M  w% o, i5 e7 Z% U1 G#include <linux/module.h>- ~5 h  ]. ^' F' s; B: ^
#include <linux/kernel.h>
: m# U$ o' H% T#include <linux/types.h>
2 U: K5 O+ x" J! l% q; t#include <linux/gpio.h>
1 M' S9 n. W1 I; A( b0 u' l#include <linux/leds.h>, D2 H) A3 V3 V) G& a2 V# S
#include <linux/platform_device.h>- o+ {$ B& S# M. E$ Q
! T/ X" S) f* |
#include <asm/mach-types.h>
, \# I# ?/ I$ m8 ?#include <asm/mach/arch.h>
8 ^/ D& o8 Z! k: N& t#include <mach/da8xx.h>! I4 G8 s) c1 ~  E4 `+ l
#include <mach/mux.h>
4 i: |# c" Y# ^- K
) F5 k5 \/ l! o9 a2 p#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
% |1 ^* ^8 R: @" k4 d5 q6 P) a#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)# L' f& G5 b3 {0 A! y
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
; S0 y: q2 ?& x#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)* I  Z1 P$ S" ]& p* F" Q+ u; Z

! F9 E' G, m# k+ n* ?/* assign the tl som board LED-GPIOs*/% H  B2 u6 `. n3 ^& n" f
static const short da850_evm_tl_user_led_pins[] = {
( c6 Y' T5 @* H        /* These pins are definition at <mach/mux.h> file */
6 r$ W- c6 L' T% R        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' e( q7 ?- f; x+ o3 |        -1
  D8 b7 ~/ @9 f7 L};) V% Y2 {6 K# ~5 d% b1 Y

" b, P) W5 e2 q/ U+ M  I2 a- M6 Cstatic struct gpio_led da850_evm_tl_leds[] = {
+ V1 {0 Y$ a& J, e5 w        {: O; k2 w2 Z" D- u5 B8 `
                .active_low = 0,
! K" V& }6 F) X$ h                .gpio = DA850_USER_LED0,( [$ Z( {% A; h/ N& {" h  u1 n7 \* H
                .name = "user_led0",
% |& |8 p. U8 n  G% p                .default_trigger = "default-on",
1 \" K3 e+ V) u3 a$ e5 s$ a        },
+ w$ o6 Y: X, Q8 R6 `2 b, N        {# ?* G+ e- T4 l! f& z
                .active_low = 0,
  m# z8 X" A/ z# H9 ]8 T. r                .gpio = DA850_USER_LED1,
1 v. W. d* w0 {; U0 u                .name = "user_led1",
2 s+ A4 K. E! P1 [0 \, ^( n' c                .default_trigger = "default-on",
- \: b9 h: f) r& t- S' z& q" Y7 q        },
/ I7 f" ?$ T8 Z, v; C$ t- d7 s( }! E        {) i: U2 ]) k7 `0 ?5 S/ u8 T
                .active_low = 0,) Y1 ?* m& J1 ^( d1 E- x
                .gpio = DA850_USER_LED2,
, P  a6 B9 _) K$ {                .name = "user_led2",
1 j# h5 ^- k6 e# {+ Y                .default_trigger = "default-on",! O& D: c8 ?. F2 w8 l# G/ {
        },
4 v9 B! B  Z& h" o$ H        {
; C1 g4 \* i2 [8 ]' p* B7 b                .active_low = 0,
3 N6 t# j0 n- Q" e                .gpio = DA850_USER_LED3,
! W3 s4 s# Z1 e                .name = "user_led3",# E2 N/ q, I: T9 M" w
                .default_trigger = "default-on",
8 P5 ?) n) Y# ]+ c. i; M        },
0 p6 ~6 s+ |) y5 O, P1 W% A};
9 B- Q: a! J; G7 r9 X) r: {6 z  C% x' u1 r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 P( Y& k/ J2 |5 f
        .leds = da850_evm_tl_leds,
0 |. b0 f( m: }1 @        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. i9 r# X% l1 b2 U" g
};( @! @* V( l8 ~

6 K! L% Q! {7 f0 W- h3 Pstatic void led_dev_release(struct device *dev)1 z3 {) I4 \. d, c& W
{
& I' e1 j% p: o# G};
& l5 A$ ], G8 @( R6 ~6 l# x
6 `/ h: C3 T' z- Istatic struct platform_device da850_evm_tl_leds_device = {5 L) Q9 [4 f( u! m% P5 u4 u6 v6 y
        .name                = "leds-gpio",
; v% r7 X+ {& y4 x0 R        .id                = 1,5 v2 A! [0 e; Z/ H$ f
        .dev = {
7 E; w( ]8 k) U8 ]; q                .platform_data = &da850_evm_tl_leds_pdata,
# S% f9 P. A: r, M4 _; x8 g                .release = led_dev_release,6 D' ?% f4 y9 A1 c
        }
+ B! y0 B- x# Q};8 ?. l( m) g; T% |- t& y% _7 i+ B
6 Q+ t, C( a( K( h$ f
static int __init led_platform_init(void)/ b7 _) i4 I- `0 N% N
{
' {, V: g# j% j3 D3 Z" K1 m        int ret;
  ?2 ~# h- M3 G" f! n# a#if 0% ^! x, C8 g; I& O
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# w6 i$ a$ C5 ~" i0 Q
        if (ret)
: d7 e/ H; C1 r2 Y                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& q7 C. f' p5 C                                "%d\n", ret);  s% C  a' o5 u: X+ S
#endif
9 o: p% D# A! q- t- i4 M- y        ret = platform_device_register(&da850_evm_tl_leds_device);
) [8 t$ |; h1 S. M) s8 y0 c1 x        if (ret)
- f9 e& T, @  W" m                pr_warning("Could not register som GPIO expander LEDS");, Q% S! |: @" H+ G' n
        else* \9 U& a8 n) J2 s
                printk(KERN_INFO "LED register sucessful!\n");, Z/ J; y3 E$ ?. I# h) ~
; x/ a1 u# j: u7 F
        return ret;
" f5 b) d# T( g" S/ r}) I; \& @+ e& H' X
  i6 M, z. D/ p5 k+ x1 k4 @
static void __exit led_platform_exit(void)# t3 z' Q, j# J
{2 ], s! a! y3 X  F' l
        platform_device_unregister(&da850_evm_tl_leds_device);' Y/ e2 t4 l% V3 j0 M' u
" d/ \& {- Z( p+ D% R9 }0 V
        printk(KERN_INFO "LED unregister!\n");+ D7 a! R/ o! f) y( @4 O
}! N& D3 f4 O1 q' y
" n2 k; w  _  d. z9 z2 `) [, F* l# k2 C
module_init(led_platform_init);6 S" O, s% ^! r
module_exit(led_platform_exit);2 K2 {1 W8 M: Z6 b. V) Z* ^
. g$ c$ u1 U8 r" O0 Q. R
MODULE_DESCRIPTION("Led platform driver");7 o5 t9 |! }! Q3 l! Y- I
MODULE_AUTHOR("Tronlong");9 K- r5 A6 B7 z+ d6 w& x1 H7 [! }/ g: @
MODULE_LICENSE("GPL");
) y( A5 q8 ~+ r4 l) A9 w( e
8 h' ?) k" r7 t
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-29 13:11 , Processed in 0.042979 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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