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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。3 \/ _( k0 g8 F; a7 f; r
#include <linux/init.h>
, L- e- r+ c2 g$ {* `0 o#include <linux/module.h>
0 W0 W2 B( B/ g! {# X5 R& x/ g#include <linux/kernel.h>6 y/ L/ l4 j3 m+ i3 l
#include <linux/types.h>
  D! E0 i% y5 A8 M8 ?#include <linux/gpio.h>
2 O" b) F. j8 r4 ~: M( S5 @#include <linux/leds.h>
0 h$ g+ I# Q1 h, }) O; y9 W#include <linux/platform_device.h>
& ~+ o8 G, s5 D1 T6 S- x0 n3 `( X
#include <asm/mach-types.h>
, J( B5 f3 |$ A$ p+ M#include <asm/mach/arch.h>
" `8 y5 O; y" }' ?) `0 q, ]. _#include <mach/da8xx.h>& i3 L  C8 j1 h) ]$ Q( p9 v
#include <mach/mux.h>
' ~* r- k( ]% y* K7 X4 h
4 N. {* F4 S% U, y$ i#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
  f) E# @, j- q% L* B# ^5 v#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)0 N9 {3 ?* T! ]. B* R2 c
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
% f1 b1 ^, e3 I6 Z- {: G( W#define DA850_USER_LED3        GPIO_TO_PIN(0, 2), y2 N# [, F. k: S
6 N6 ~4 @" e& J& \$ l& O0 @, v
/* assign the tl som board LED-GPIOs*/
8 A& l) X( K0 R# Tstatic const short da850_evm_tl_user_led_pins[] = {
$ p6 E/ {  C& I) q5 r0 y" I2 Z        /* These pins are definition at <mach/mux.h> file */
- y" Q! t% }6 ^& l) a7 W" |        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 c- R& u( y! J/ i$ ~* f1 }
        -1, B" S2 x  m" L1 @7 @
};- P5 E' w& _  ]' Z

, B* A" p$ O. Q* qstatic struct gpio_led da850_evm_tl_leds[] = {
$ ~! u: z9 W  p6 W        {
; [6 U3 S+ |: t- O                .active_low = 0,& ^# H3 O: @2 g0 K: k, R
                .gpio = DA850_USER_LED0,
. U2 N! G7 G( ^9 C$ k# w                .name = "user_led0",
3 j$ P) n$ d) P) X/ b$ ^, T9 l6 a                .default_trigger = "default-on",2 F4 d4 N9 P( o7 h5 `1 S. N6 z
        },& V- k1 k& t: g. z0 R
        {
+ V- K8 p% Z3 A8 l0 w                .active_low = 0,
" _7 T& c9 {9 S5 j% j$ I/ C                .gpio = DA850_USER_LED1,3 ^  z0 R7 Z/ p0 h
                .name = "user_led1",; o% V- S. [  b0 g
                .default_trigger = "default-on",
# ?; U# R) }" c; U' b        },
6 c/ i$ p3 t. _4 I        {
. w: C3 j3 ?- f6 f' q+ m. o+ p                .active_low = 0,% W- U, U# J; u# d5 o- @# o1 o: {
                .gpio = DA850_USER_LED2,: n6 R8 L8 b# f6 B7 k+ r$ v6 d
                .name = "user_led2",
1 u$ a) M# ~) @4 T+ i                .default_trigger = "default-on",
. y' J; O( O' \+ W* Y        }," h& q) m2 _- X8 j& e) q
        {
; P9 a5 }2 L4 M4 r5 i+ M                .active_low = 0,
$ S, U# n1 F6 E1 _, K3 ?2 A# n                .gpio = DA850_USER_LED3,$ W- C0 m  u- ~; ?# K8 s. G: ?; u/ }
                .name = "user_led3"," D0 ~. S( u& X( ?8 a4 ~; [- H' t
                .default_trigger = "default-on",& _/ b+ q+ J1 R: ?& r- W0 I
        },
/ p+ T9 O! |8 R: n* A& G- o6 O" Z};
1 }& n/ @- w; c  l+ |5 R. S0 ?2 }3 D; n/ V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 I/ [: J  A: P, E2 a
        .leds = da850_evm_tl_leds,) n+ T3 Q: B& K* b
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( [3 j, j0 Y2 O/ j+ j- Y0 s
};
3 }0 }5 T' n% a) Y, Y) D! Z8 D8 R9 ~: E# a& C7 d+ G2 m& o  _# d
static void led_dev_release(struct device *dev)
% \2 D4 l* K8 b- x$ w% d* a1 e. Z{
* Q) o# l6 a9 q: A+ Y};% G4 c! ~0 @9 I3 h
6 b* o- W4 U$ p  g9 A7 F( c; |
static struct platform_device da850_evm_tl_leds_device = {
9 ~* I) @: \# u0 G$ s        .name                = "leds-gpio",+ I6 F) p: y, U# ^( J! s1 p
        .id                = 1,
/ t' [2 `$ Z2 g4 u, x        .dev = {
. a& \  L- Y; h* {1 R( N4 V                .platform_data = &da850_evm_tl_leds_pdata,
1 P5 X% N# d" a                .release = led_dev_release,
, R# H' `/ a% j" H* S0 S; ]1 i        }& u/ r; t2 x! @* r7 Z9 v
};# O( D* X' ^" o2 y1 S9 R8 I. g. X+ ^
  ^" U% N- K2 G/ s; F1 Z
static int __init led_platform_init(void)
, ~7 I4 ?% ^( o{# g+ {7 `7 b5 t+ }
        int ret;& x; p6 H9 {& Q, w9 C6 V6 S- G7 U
#if 0' ]( X: M0 ]# k) _5 b
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 a$ H8 X1 H" R& U# A7 h& X0 D        if (ret)
% V8 U% ~; j! e' l6 y                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 a; T3 s+ \7 J, q$ g$ C) R                                "%d\n", ret);
3 O7 ~' o- _6 A, A$ l3 r# p#endif- k0 M+ A+ ^) k
        ret = platform_device_register(&da850_evm_tl_leds_device);
( Q% c+ }& W7 Q1 |1 G        if (ret)
" T0 F  Y3 u1 E8 e3 s9 F/ L                pr_warning("Could not register som GPIO expander LEDS");3 j( D& i, D" k
        else
9 z8 o+ |& A6 ~, U4 V  u) q8 [                printk(KERN_INFO "LED register sucessful!\n");
$ R0 P2 \  ]# b3 x
2 v! {. _  e* @- v$ m        return ret;
" W8 m& C4 b2 X# c4 @3 J}- h% K0 w8 t$ @9 w) q3 g, @
, i2 H( \. ]( A8 v) V' J3 n& O
static void __exit led_platform_exit(void)
) M- g3 K. D) w{+ o0 h9 C9 |1 o9 E
        platform_device_unregister(&da850_evm_tl_leds_device);
! ^! M5 k5 \9 P8 U
3 \; f4 z$ D# D2 ^        printk(KERN_INFO "LED unregister!\n");
6 f4 }& p6 U8 p  x0 i}+ t4 n' e" E! P9 i5 l

9 O! K3 w' u. Cmodule_init(led_platform_init);
  T& @+ S+ {2 Q9 m2 gmodule_exit(led_platform_exit);( c' [& g9 \6 u1 z! X( I3 }: Y- J: z5 V9 f

- _6 G! b. B: q  F+ GMODULE_DESCRIPTION("Led platform driver");
% D% o' g0 U- H$ j' QMODULE_AUTHOR("Tronlong");1 h8 Z& |4 Y# |8 M% [; N
MODULE_LICENSE("GPL");/ N! M2 e* D$ x1 X
$ k. A! y% F6 y1 a& S6 Z7 c
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-8 23:14 , Processed in 0.040056 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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