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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。, s" q: L* @. I( [7 U/ D
#include <linux/init.h>
  l  T2 u/ W( H#include <linux/module.h>
% V7 G  U4 C% X7 ^5 r8 _) u% j- d#include <linux/kernel.h>
& L( y0 T8 w4 G! k- E/ P#include <linux/types.h>
1 H6 f& ]; k" f5 V/ ~5 p#include <linux/gpio.h>. I9 b% \- v! u; _  n
#include <linux/leds.h>
6 I' K6 i' r% i% L$ K6 m#include <linux/platform_device.h>
3 y3 M, o2 K0 G) |7 N- V( B
9 V) Y; M  {4 E' N3 x' H. P' e$ O#include <asm/mach-types.h>6 U! W. f5 H9 S: ]
#include <asm/mach/arch.h>& e/ R2 X1 k4 l5 I
#include <mach/da8xx.h>
  d& f& m7 s2 _& g/ `#include <mach/mux.h>9 }6 n5 y2 x2 I' b! L6 F
4 Z  B; @* i0 J+ q$ D% a
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
- _/ d) L8 p! ]6 X( ?#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)( z1 |: i( c0 e7 q# I8 z' o
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)" B6 {. w% X& x7 S
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
0 V( M& ?, O7 L! R0 `. i  v
* E. [% M4 ?5 K- u! N% B/* assign the tl som board LED-GPIOs*/
5 G- |+ Y4 u3 kstatic const short da850_evm_tl_user_led_pins[] = {
3 K0 ?. G9 s6 D  H: D        /* These pins are definition at <mach/mux.h> file */
. |. c' I8 a1 T* w9 u" G        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 _2 _0 m! I& M" Q2 I  O; ~6 t. z
        -1
0 _' n2 e/ p% L/ {' ^- p- N};
  p# C) g' g! I7 m" X/ B  Y! y% u- g( A$ M& ~1 L' N
static struct gpio_led da850_evm_tl_leds[] = {& u% ?) K" R5 ^6 y0 T, T1 j' g
        {
  B+ [+ a  |# [                .active_low = 0,9 A& Z/ S1 t( @$ |
                .gpio = DA850_USER_LED0,
9 K3 v3 J0 k. d                .name = "user_led0",' t5 }# @/ X9 B; P: @  h+ f3 R" J
                .default_trigger = "default-on",, i& j( P; G! ~  S+ s( P% Y/ P0 z) q
        },. @! d" x' g5 `2 x6 y1 S
        {6 f7 Z% W9 D0 b( ?& L9 Q, }7 ]
                .active_low = 0,
4 q! o. T+ V8 t% x. g2 ?2 O# |                .gpio = DA850_USER_LED1,
7 C! c$ S& K  @1 b$ P; i6 a0 b                .name = "user_led1",4 Y* k3 a3 N+ N4 N' k
                .default_trigger = "default-on",
% P- D8 L6 f$ v  q* }/ x        },0 z) C& ]( C( _  D
        {# ^- w) e3 ], V8 C; e0 Q
                .active_low = 0,
9 t$ U8 t. ~# X( m                .gpio = DA850_USER_LED2,$ l4 y% \$ @$ r* A+ w: T
                .name = "user_led2",- O6 r# d8 H1 r. J+ J3 s0 a
                .default_trigger = "default-on",
; a. L3 w" |4 E9 f        },
/ y1 p* j  C% x; k        {- A% b$ p7 G) E
                .active_low = 0,1 @4 f3 E# @4 c. T
                .gpio = DA850_USER_LED3,0 }1 I* ^0 o9 w+ a* d8 \' B
                .name = "user_led3",
6 A/ @+ q6 Z% N& c0 X                .default_trigger = "default-on",3 S8 T3 G( N2 m. _& }: E# n3 S. W
        },
7 [/ ?1 {7 J) q7 {" G8 H};
% X% d' t; L. W, s  u8 r
- S. b- u( ^* zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) @' Y5 w5 z* a4 h5 W: z' |
        .leds = da850_evm_tl_leds,
9 ]7 D$ T! ^% {% G! Y2 g& d6 `  {        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% f6 K; e& y/ Q- [};
% A; p& y8 b7 V- ^) Z) ^& a5 p" c
8 B7 n  j5 X8 s2 Q- Y: D  f; R/ Istatic void led_dev_release(struct device *dev)
; O8 P7 x6 b+ ^" i9 e6 P  @3 }{, ]$ L3 m$ `6 t% j# u8 G
};
: X3 _3 A, {0 N- P) K0 R& W& }2 H' Z" g7 I
static struct platform_device da850_evm_tl_leds_device = {3 a- Q/ X* B/ H3 b4 K( j
        .name                = "leds-gpio",
7 m) J% ~: I8 s* G! F        .id                = 1,) j/ H9 Z8 G+ z! ?2 s, G
        .dev = {
) y. S8 y; P5 X8 f. F                .platform_data = &da850_evm_tl_leds_pdata,
0 g$ X/ R9 d) x) w9 D6 B% n3 f                .release = led_dev_release,) E0 y1 _1 ~5 \0 X( R, k+ ?! I6 L
        }! \5 p2 ?3 a; d8 A  p
};- ~& L( Y9 b! Z: c: l6 \+ U
& e  `7 \5 C! c- j, y  r' H
static int __init led_platform_init(void)
2 U2 i: c; a! K# ]/ q{7 U/ V/ t5 u: E( Z
        int ret;
; Z9 j. H2 B& K) @: z#if 0+ `; a2 Q0 w( V% {8 H, d
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' a) W% `8 y9 h3 M" O# ~" ~. ?
        if (ret)+ U8 _% F) g3 D2 z* B
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 T5 L, _' C3 F- K9 s" r
                                "%d\n", ret);( j0 h% N, Q$ Q% K+ f' ?
#endif1 Y- Q+ {% k  [5 r# P& l' d) [5 z
        ret = platform_device_register(&da850_evm_tl_leds_device);/ I4 ^4 ?4 F" n& u9 U
        if (ret)
# u/ N/ J4 M+ R" A                pr_warning("Could not register som GPIO expander LEDS");
  ]5 H5 F" Z8 n0 O% H  z" }        else: O5 r- K! s/ T
                printk(KERN_INFO "LED register sucessful!\n");0 |6 s$ O9 O- X( b0 v9 f
. ~, ~( D, }2 h2 y/ A
        return ret;/ j: D% G& h% n2 ^, t
}
/ T2 D9 B# y0 o
# w7 [/ D4 E% d& b3 bstatic void __exit led_platform_exit(void)
6 z" L: E& |  C4 e{
; q! B9 t4 Y* h' U3 Q% _: @        platform_device_unregister(&da850_evm_tl_leds_device);
. I6 [$ d6 C$ o8 v: P' N
/ c# I& |/ [* O4 [/ X9 j        printk(KERN_INFO "LED unregister!\n");, T" m: ?; F" j; [4 z. }
}" l" m! k8 j; z! _$ e+ @9 i

9 s5 Z8 T9 y( n, p  _module_init(led_platform_init);* T) ]% P+ K' S5 K+ ?( P
module_exit(led_platform_exit);
  l2 c  y+ ^2 y! P3 U
; R; v6 j) r3 F7 B2 `MODULE_DESCRIPTION("Led platform driver");# @1 @$ e& }, ?
MODULE_AUTHOR("Tronlong");
1 W8 I) f4 l6 t' nMODULE_LICENSE("GPL");9 F' f- b- Z, j; I

" y5 j$ X  }0 W/ j+ C) k: ^
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-31 09:53 , Processed in 0.037861 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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