程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。: G; r' l* F5 N  p/ y0 b
#include <linux/init.h>
5 p2 o) m7 C( X5 l$ p( u#include <linux/module.h>- y8 q' W  B* D8 y: y  \. B9 C
#include <linux/kernel.h>8 [* D  _( N& {: P0 T* Q, A
#include <linux/types.h>
( ~0 @, s( \/ |& G/ {0 h#include <linux/gpio.h>+ B; U" u1 z" K
#include <linux/leds.h>
6 h* c3 u- ]! g" `$ M/ w#include <linux/platform_device.h>
/ n  d* h+ [$ ~! Z/ z' k
8 s' {) }/ W! t- p$ p- |#include <asm/mach-types.h>3 L5 g  l! C9 V1 z, w
#include <asm/mach/arch.h>
* I5 m% S! s: F/ g; B8 _4 G9 [9 B#include <mach/da8xx.h>& @  V' s3 V  I4 C
#include <mach/mux.h>
* y0 M. a7 ?4 x1 d0 y& I8 [8 r
) X8 e  i* J% Z#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)* J4 U" ~  p; V$ O% }# P
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
( T" ~: @% S# e4 U$ U#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)2 b9 B* w2 [1 e/ y# d: `  _
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)/ \6 O9 w1 j1 l; y# c: }( ]

; n! L; n) i. f8 O- m% c( \/* assign the tl som board LED-GPIOs*/
) w4 {0 T% U! r. K! N3 fstatic const short da850_evm_tl_user_led_pins[] = {
  F+ Z. x0 k  z1 y9 s! C+ n/ p        /* These pins are definition at <mach/mux.h> file */7 r- Z9 m! \7 W- |* i" H; h
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; B* e8 }8 G+ t+ ^( h        -1
8 T2 l# Z* S) N};
3 N7 I7 a/ a4 C8 ^: X
& p7 f) x9 Q" Z+ c, B$ t' Ustatic struct gpio_led da850_evm_tl_leds[] = {
4 I1 y* t' }) s/ y! X' k% ~        {
$ s$ w8 v) \5 k7 A: q                .active_low = 0,
- r1 p$ R2 p7 M/ G                .gpio = DA850_USER_LED0,
' m( _! v, T. }; M" ~                .name = "user_led0",
! ~, S5 {( r! J7 n  z                .default_trigger = "default-on",
5 M; K: ^, t: Z2 w$ P        },
3 I5 F4 s* y# o6 N6 H$ G) d        {
5 |- l% t6 P( q% `" X  B) B, k                .active_low = 0,8 q/ i+ S+ y3 f# q
                .gpio = DA850_USER_LED1,
; @0 ~3 \/ C+ X) p! X                .name = "user_led1",# p+ L! n7 G: q5 e/ e  y8 @
                .default_trigger = "default-on",
; ~/ A: J) i$ C7 s- w1 j+ H        },6 _! d2 }0 d  i5 H  h# L
        {
6 w# ~' ?5 S* t6 C* y" q: u9 L                .active_low = 0,, D& w- E3 U8 d! j  E
                .gpio = DA850_USER_LED2,* t0 m+ B7 C1 J- o8 V
                .name = "user_led2",
  k; X2 j/ G% P6 ?1 d+ N, @8 {; j                .default_trigger = "default-on"," D: o# R! z" u2 t; ?% g
        },
8 U1 {0 g1 w$ z" ?& ?* @1 K- l        {
3 |5 h) S7 i" i7 Z* t                .active_low = 0,
: W: M& p; i8 X+ I  k                .gpio = DA850_USER_LED3,3 {- P# \' d/ b3 o
                .name = "user_led3",' Y( l: D3 Q+ _! ]
                .default_trigger = "default-on",' z* t: C3 p1 {+ J) W% o
        },
1 z& S1 m) x* p  X; k$ j};
( i% m$ t# d! u8 p" V0 q& f7 X$ U
, ^6 m& q1 Z# V6 h6 p: Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 C) E- _. K3 u6 ]
        .leds = da850_evm_tl_leds,
( j5 {; I; u8 U8 Q: e, s' O0 X        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! d! g* q$ ?) H8 O/ t  }" `};
) [2 L! D1 _; G2 [. ?( ^# O; [& p. e
static void led_dev_release(struct device *dev)7 A1 O+ _- ?# B$ q: o2 U) T; c6 \
{( Z( \" t( U! ^& \6 [
};
/ D9 x+ Z' J( ?
7 Z# [5 t  {7 I$ A+ Xstatic struct platform_device da850_evm_tl_leds_device = {
: U8 U$ b4 ]" g        .name                = "leds-gpio",0 b9 J. r# z: @; i) ^3 A7 l
        .id                = 1,
+ m3 ?8 ~: Y$ J- h        .dev = {2 \! _" l# Z. ?: q8 N$ Z
                .platform_data = &da850_evm_tl_leds_pdata,; }$ s) `" w, ^' V, _8 R
                .release = led_dev_release,
8 Y& j( t5 Q4 F7 l. P. u        }
0 t" ?& m1 f+ U% V- o};+ V7 x2 Q) C  n7 `4 w

% ~$ l# m  g2 `9 T2 Xstatic int __init led_platform_init(void)* {6 A! f; B, u! t
{  f: `* G6 g$ T! ^' O9 H
        int ret;4 V% ?! Z$ h# T0 M  F
#if 0
- g1 a, S% `1 S$ }        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 ^' D5 S5 _/ v5 x        if (ret)
: Z( U" b& E* }& }8 s. r* a9 S' {                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* F' o' u5 d7 A) L% @6 W
                                "%d\n", ret);1 O2 {" Y3 z9 A6 B9 d: V! I
#endif
( h0 O# I0 q* k" ~/ Y! A        ret = platform_device_register(&da850_evm_tl_leds_device);9 v- _# p# \4 u
        if (ret)
9 w/ U( m: Q" W2 R7 l2 B7 Z                pr_warning("Could not register som GPIO expander LEDS");, P3 }8 `, c  V
        else
! K) _" Q+ K* a7 B& {% {" X                printk(KERN_INFO "LED register sucessful!\n");' p  I; i" A" X6 W; z* u' f
/ `, A! y1 Q) {% p* o
        return ret;
! h# k8 P% J- m0 @; W2 D}; O6 l2 f3 N' I/ u# w

6 v7 q+ `# d5 h  m- z# Mstatic void __exit led_platform_exit(void)5 @! A8 M/ w7 n: P
{2 ^! y) |2 D" N6 c
        platform_device_unregister(&da850_evm_tl_leds_device);0 u7 m; w) X* I( C6 N4 N0 Z: ?4 v

2 J0 v  W, ]! t        printk(KERN_INFO "LED unregister!\n");# Q5 j# K$ {+ I
}7 |/ e4 ^; y% X6 n; n7 X

" O  i  }( K. P% Tmodule_init(led_platform_init);
" c3 f! X% C; Qmodule_exit(led_platform_exit);
0 p8 s# k( e" {/ m
$ f2 S2 E6 x: M7 j* ~, B7 L7 uMODULE_DESCRIPTION("Led platform driver");, v# I. v, k8 j& \* q7 c4 L
MODULE_AUTHOR("Tronlong");
/ |5 I: \: l7 L3 vMODULE_LICENSE("GPL");; g8 P3 p. S- ~% |) o: c
+ E1 x$ m' B7 @& _7 m! Q2 B- o# l
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则


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

GMT+8, 2026-1-10 08:14 , Processed in 0.039048 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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