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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。$ J4 N/ E7 O6 U) G2 K+ O# T( Z* Q
#include <linux/init.h>
7 t+ }6 s/ K1 Q8 l1 a0 w#include <linux/module.h>" ~9 t1 s0 L  J: I) D
#include <linux/kernel.h>
/ R# [3 j6 P" s- ?# o7 ^#include <linux/types.h>5 n4 b/ p2 ^4 w. [" W" h
#include <linux/gpio.h>
$ F; X1 H7 @/ [#include <linux/leds.h>7 T! m1 v: r! x$ P2 T1 Q( X
#include <linux/platform_device.h>
/ c/ r' g5 j# {; i5 |- k' I
% l& I9 m  t8 N! |( z& q6 {#include <asm/mach-types.h>
; i/ y( u- A9 j3 X3 b; u#include <asm/mach/arch.h>; q1 b+ V9 L; b3 ^2 U
#include <mach/da8xx.h>: m$ b9 K5 _# g& k, g: t/ P
#include <mach/mux.h>7 T2 U0 ?6 N) Z  C% r7 a: F. e

4 A/ Q6 ]. L3 |# E& o1 M#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)! s. T, i. z7 K2 L$ v1 X
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
- M2 G' z" Y9 Y. l& Y# S#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
  Z! S+ q& {- h% a  r#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)2 d6 w, x& B5 O+ w

( S) I1 f, Z4 I7 O1 P8 w% i/* assign the tl som board LED-GPIOs*/* d, n8 {' |$ u0 ^+ S, ?" H* |* x
static const short da850_evm_tl_user_led_pins[] = {
. k& g% i/ O9 G5 D) M9 H2 D0 v        /* These pins are definition at <mach/mux.h> file */: ~% z# _. A0 t4 i  R
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 E% X9 }6 G8 J+ t' c% e3 a
        -1
" o  t) y5 J! z3 `};
# ?$ S0 V8 Y9 s4 B! s, \
, H. }, s0 u9 E8 ?4 I; s' G6 m1 fstatic struct gpio_led da850_evm_tl_leds[] = {
. r4 X6 A, x- s( j" t/ {        {
( l6 i* ]+ r/ A' z& z                .active_low = 0,
$ _2 T+ W0 R  f$ q4 @) R$ a- d7 U                .gpio = DA850_USER_LED0,; F6 h8 |4 [9 k2 T7 y9 d+ \) g6 q: I5 g
                .name = "user_led0",
  o  {4 y2 @) M  D0 A% I                .default_trigger = "default-on",
- J. }" \; Z2 m( ^: g* N9 G* H        },
5 f' z5 }' Y$ j2 ^) X# G  m        {" r, z0 S( A/ j
                .active_low = 0,( d) F7 N# ?: |, ?) p/ I
                .gpio = DA850_USER_LED1,
/ W% P: B5 q8 n! J* _- |                .name = "user_led1",; `  E$ }- s: R9 l
                .default_trigger = "default-on",* r4 ^7 ]% a' |9 f+ w" B1 b
        },! M: h: u5 A- n9 T
        {
: _: \/ x  F- h0 x4 |" }                .active_low = 0,
1 B* S; R0 E  X                .gpio = DA850_USER_LED2,
9 v5 w6 `& x% ?1 A                .name = "user_led2",9 b) h1 J% r& f, K) l. s
                .default_trigger = "default-on",& B: c4 ?- i3 h
        },- [. j5 i# |9 b1 X
        {
! f1 H. T+ R- Y. q2 x7 D5 Y% I                .active_low = 0,
: t2 W9 O: z8 v8 _! {& ~                .gpio = DA850_USER_LED3,; b4 Z+ i: {, y1 v
                .name = "user_led3",6 l1 H5 h# R% K8 H  G( Y
                .default_trigger = "default-on",
0 I4 p% @5 }6 V, T; Q! I% J1 ^0 `        },
0 W, ~2 ?) Z7 Q8 h9 q3 R* N& G};
7 K/ q: n. R! A3 J) J* v  M, V5 ^- Q3 y' W( D! B, Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) {7 S; |0 e& q2 s# p! W4 s  x        .leds = da850_evm_tl_leds,. E+ O' p3 m% t( S- z5 }, T
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% o6 V! \& q" _7 X* E; ?. g1 m
};
( N1 {* ]6 y0 U, S7 O2 _/ r8 t% q2 L6 b1 ?# w
static void led_dev_release(struct device *dev)
& \1 U; m- y3 l{5 L) y5 o; |7 M/ R
};
6 s$ @' G  T9 D2 q2 i* l2 b
; F3 N- s0 T, ?- Pstatic struct platform_device da850_evm_tl_leds_device = {' {  m5 n& A. O, W' l# i( F- T
        .name                = "leds-gpio",& G' _; H8 s: m( B7 u7 [/ t
        .id                = 1,
& r/ O7 W& ~$ n: Z; T) w        .dev = {
- W7 h6 T! W+ [) O. m+ v8 j4 a                .platform_data = &da850_evm_tl_leds_pdata,( D1 H! z/ k+ {7 i
                .release = led_dev_release,! x( g; ~$ x  |- {, |5 U: i# b( w
        }! g$ F9 {3 a/ W; H& a! K
};
: l7 i7 @2 v* b
  o0 o2 w/ U/ w( S& c9 cstatic int __init led_platform_init(void)
( H" l0 r0 u  o/ S$ L{
5 a- K/ k' M: m( X7 @9 Z        int ret;
4 K3 V, R' Z+ J5 D9 y- M#if 0' s+ N( I% _/ p+ Q: q. `9 _2 `
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; @! g+ f+ E( J- K+ p, n        if (ret)
# w9 p5 i% ?& I5 g- o                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 {, F) F5 \, Z, j                                "%d\n", ret);
0 X5 l( [$ z# L' _7 v; h( w* u#endif
( ?. C0 l5 {6 A        ret = platform_device_register(&da850_evm_tl_leds_device);2 T2 N  ~+ L" q! _6 G
        if (ret)9 c$ I" F% d5 f$ S' a
                pr_warning("Could not register som GPIO expander LEDS");9 J2 R# f! K  [2 c' ^
        else0 j6 R% S+ X: E
                printk(KERN_INFO "LED register sucessful!\n");
2 q+ _. F, ?  i
- u; K$ _& L- u, t3 d, J        return ret;# r  m9 W* i/ F( j2 r/ F/ b- w
}" v* x' E8 n1 S5 F# k- c$ p' N
) L* |( J& }9 f' C3 I1 Z* y* Q
static void __exit led_platform_exit(void)$ x2 `  D/ |+ [* I
{
2 p. g1 S$ V4 y1 W  ]! w        platform_device_unregister(&da850_evm_tl_leds_device);
5 v" q: r; a) \8 S8 r) `* y
" l( S! j: l/ W: Z+ f  d% D' j        printk(KERN_INFO "LED unregister!\n");
/ N* h$ o: E  N# l- b  R0 X7 W8 O}3 D% h7 D8 T1 z0 l( p
& O- T4 @; }4 a6 U" r
module_init(led_platform_init);
' A3 L! F9 B3 t2 u) s1 p0 Imodule_exit(led_platform_exit);
; J* b1 W0 X; }, ~0 T+ e# Q4 |. r/ x$ p( b( m( Y) j5 t' c/ c) q
MODULE_DESCRIPTION("Led platform driver");2 `) O) d$ I# G+ i  e$ ]
MODULE_AUTHOR("Tronlong");0 F9 R3 D9 ?4 Z1 s* N& e/ c, I
MODULE_LICENSE("GPL");1 ~. _& Z- s% o

- L1 q, Y8 \& T  P6 o
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-10-4 19:55 , Processed in 0.032019 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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