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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
( k6 h; ?! w# ?! q& y#include <linux/init.h>+ z3 k# [' d0 G5 [
#include <linux/module.h>' `- j0 B- C$ ^  G) w. Q% K6 t
#include <linux/kernel.h>6 k" C9 {) K2 E' \/ D
#include <linux/types.h>
6 |# J3 N, N# m5 V, R& d, _#include <linux/gpio.h>
5 ]$ i! s% D* b5 i- {  b- @#include <linux/leds.h>
+ S# a* q1 c) K+ c. V# I#include <linux/platform_device.h>$ |$ K  w& K4 E! X* A

$ s6 T# \$ M! G% X6 g9 m#include <asm/mach-types.h>
: O/ \: @/ n! y# a#include <asm/mach/arch.h>% W4 x1 I( H0 ]* ]  p0 ^4 _% k: z6 |
#include <mach/da8xx.h>
8 E+ L- r+ y. K: g, E#include <mach/mux.h>
( O: f/ u) c6 u; C
& {0 X5 \# m- E#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)7 C2 M- X; D& e! h8 Z( S: _
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
& a  E: K5 a0 F- V8 G#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)( I8 e! j2 Z9 F% }
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)1 q* r. T% d8 t2 x6 \: u

- E2 i2 |- k$ d* d/* assign the tl som board LED-GPIOs*/
) n' v: v! f! ]static const short da850_evm_tl_user_led_pins[] = {- j5 o# W! C6 S" r4 x& Y% b
        /* These pins are definition at <mach/mux.h> file */
6 M0 }4 r! @5 h9 B: [! S9 f& H        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; Y# O9 W" [% R+ ?; E4 A
        -1
) g  }6 N; {+ }( e9 M};2 |; ~6 Z& z( c& L0 f) p
2 f" w: U/ Y2 y4 S8 x8 P5 j) |3 g
static struct gpio_led da850_evm_tl_leds[] = {3 e6 E1 h6 E, I# A. H
        {
7 a" Q! V5 P# e$ A( U2 j                .active_low = 0,
- I$ _% Y& `. N( q& S4 A7 c                .gpio = DA850_USER_LED0,
( A( k9 h3 d0 Q' A8 {1 @; [, Q                .name = "user_led0",
6 N9 V# F' F$ e0 [4 ^1 U1 L" S                .default_trigger = "default-on",& W% m' K8 z3 M7 F$ b* G
        },
6 P+ D+ {+ D' @        {' H+ K4 Q4 D. b
                .active_low = 0,
" m6 p' u$ v6 [1 w                .gpio = DA850_USER_LED1,7 J! o- R7 W+ Z, E
                .name = "user_led1",4 @0 A) [- d# S
                .default_trigger = "default-on",! @! G, g5 U5 B2 l1 ?( G0 n3 a
        },. s; Y4 J: ^3 U. p  Q
        {
) T1 O" c# K! }" q" y9 J& M: A' K% O                .active_low = 0,
: B* H3 _# `1 d* w5 G                .gpio = DA850_USER_LED2,
$ f; o/ u% M* Q; w& F0 i8 b" X  S                .name = "user_led2",& [# R5 Y" J0 E. q' d5 \% n5 Q5 a
                .default_trigger = "default-on",7 h) {  X' @$ v: A$ Z
        },
& S) X' O; U) F* _1 e        {1 ]& }5 h, [, B0 D3 X' X# g
                .active_low = 0,: @6 x5 ~* C% G+ ~# b5 s
                .gpio = DA850_USER_LED3,
1 F% h  P8 U) k1 m9 G3 O                .name = "user_led3"," h8 \, Z) R$ h' D) _, I) s
                .default_trigger = "default-on",/ A5 i0 \5 B: k+ s. {" d( e" S
        },
' c/ c2 }; `) [/ V" [$ S$ [# A+ q% O7 o# S};
- ~' A. M5 O! B7 ^3 {2 n7 W. k# t! s& G& L  W6 F
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- S: c* ?' i. s% V7 B! c
        .leds = da850_evm_tl_leds,( o3 M0 x& r1 f8 n: l+ s# D  P- }( f4 f
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),  f" _: A0 u) m
};
/ M! K0 G7 u/ p4 N& x, u" D9 r+ n  m: ?+ |' |
static void led_dev_release(struct device *dev)+ z  D+ S" {( @/ i+ @3 c, v
{
0 I# d1 b, j' a0 u};
; l0 Y( U* c! ]. S0 V
' x' w! m5 V6 X& ^; x0 {0 astatic struct platform_device da850_evm_tl_leds_device = {6 E0 b7 Z0 I  |2 p
        .name                = "leds-gpio",
" s7 a" I' w4 {        .id                = 1,/ U/ e, h. u1 F- y$ C' b4 u
        .dev = {  m1 @/ J/ W3 @7 S( z( x! T" _
                .platform_data = &da850_evm_tl_leds_pdata,) ^' H' b% d8 G' E7 C5 z
                .release = led_dev_release,3 v- ]5 l' \; }. S
        }
- [7 y. p/ c- s2 m};* m3 c: H. ^/ P! [

7 j" B) |2 J' R- H( ~9 m, @9 H6 ?static int __init led_platform_init(void)
+ q/ ]; P2 r$ w& ~. ~/ D8 k{5 a- e. v" n) {$ j
        int ret;
/ |- Q" u* D) M1 [# t+ M. F" J#if 03 a0 C3 M& R4 U$ I% D3 x) O% ~
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 ]0 s+ i- G6 E8 d0 K
        if (ret)
" u" j  a% L7 d8 L9 i0 c( }+ o                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 W7 ?, V2 P4 b. R                                "%d\n", ret);. p$ @% |! p1 E1 \& _3 ?
#endif
  v, s7 f  [1 E/ G7 c$ j5 y6 r        ret = platform_device_register(&da850_evm_tl_leds_device);
  ~2 G" P  U+ \* h0 _9 t/ c        if (ret)
6 z  ~2 ~: ^  x: U  R                pr_warning("Could not register som GPIO expander LEDS");6 c! l" v& Y" O7 o  z2 V1 c5 }
        else0 |- h5 P* x3 U7 d; \" K1 H
                printk(KERN_INFO "LED register sucessful!\n");
$ M! @$ o& {. @7 s1 x7 R$ ~4 w" ?
: Z: u) e+ `  N5 G& V* @( T        return ret;
6 ?# H3 R2 M3 ?8 ]* E3 \* S( _}5 U2 X9 @* d2 D9 J

6 r, U" }' F  O0 S" L" hstatic void __exit led_platform_exit(void)
+ s" I' v  A3 H0 }& v7 e' m{
. p5 j8 |+ q7 K! K7 L5 N        platform_device_unregister(&da850_evm_tl_leds_device);7 H$ t* ~' D. p( L4 I" ~" m
1 V5 V6 g$ n2 d( S; {. J4 R
        printk(KERN_INFO "LED unregister!\n");
3 o) C, x& [) ~* I( f* g}! L$ u1 K/ r2 C% \) b
' V. ~9 L, x* q, u& {, V- W
module_init(led_platform_init);
/ B  ?  T4 S6 Y" W" G0 Q& dmodule_exit(led_platform_exit);
( g8 C3 v* ^4 U
/ H2 f$ Q; k  OMODULE_DESCRIPTION("Led platform driver");, I0 f5 O) S# m+ [# p; {
MODULE_AUTHOR("Tronlong");
1 h$ o& f% a( l( w, Q7 K% |MODULE_LICENSE("GPL");; o$ P* s' @: E* a& O
7 s( [8 c) W: v% u" B
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-2 16:40 , Processed in 0.058075 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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