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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
7 r  ^9 i3 q9 v- I* r#include <linux/init.h>
& c# A$ Y+ R1 {9 E, H( B- V% L#include <linux/module.h>! K' J+ F* X1 O
#include <linux/kernel.h>! L! Z( g8 c$ W
#include <linux/types.h>
8 j8 o  m* h0 d#include <linux/gpio.h>" T9 s% d0 j: k" j: M$ Z
#include <linux/leds.h>1 y: o8 p& t0 v* M
#include <linux/platform_device.h>
3 T  E: _% c; l5 H" ]
. b0 h# Z% G; ?8 E  O#include <asm/mach-types.h>. c3 [+ A# w- Y" N
#include <asm/mach/arch.h>
# h1 Z& U2 a0 x  p$ E4 ^#include <mach/da8xx.h>- d9 J- u. H% \2 I; s3 c
#include <mach/mux.h>7 t$ B0 \4 d; [, L5 g) }0 e

7 x( a4 ?# M$ Q! f* T( E#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
; J, g% J! M' E3 q#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
3 C# t7 w* r7 {- R# j#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)8 C9 _% u! S* V& I% m5 L
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
" q7 }9 h9 L" G# M0 V  o7 E: r& g( i; f& a7 @2 _
/* assign the tl som board LED-GPIOs*/. H( b) V9 ?$ Z1 q" T: k$ a' k3 U
static const short da850_evm_tl_user_led_pins[] = {
% ^7 P, D8 X$ K& `" x        /* These pins are definition at <mach/mux.h> file */5 Z- O3 v* z: m1 o6 s$ Y8 W! d+ _
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# O3 Y' @* X' U
        -13 Y+ H: G8 u9 O9 |5 g) e
};, P5 E- U# p2 ]2 T2 j
. g9 ]5 C& ]2 Y% B( D, A) A9 f
static struct gpio_led da850_evm_tl_leds[] = {5 S7 {$ I; z9 O7 J& \6 |
        {0 A, ^! c& |6 A
                .active_low = 0,' x0 I8 `+ I7 E# P+ p) |8 g8 F6 I- C5 a
                .gpio = DA850_USER_LED0,3 i4 A$ |6 x  E! `
                .name = "user_led0",
* v. h; N* \' b8 Z7 G                .default_trigger = "default-on",' ~6 N) {' Y' ]1 f
        },
( E( I) _% [- T. l! f7 l3 u        {
$ T* s- H) g. S9 L7 d/ ^0 ~7 V9 f% r                .active_low = 0,
5 }  T# k! D5 `4 ]" c                .gpio = DA850_USER_LED1,
* ~7 K) F1 f* _! i( G                .name = "user_led1",2 g3 U, g; D3 k: U" O" M
                .default_trigger = "default-on",
3 N7 W( [" e9 U) b" z        },$ l5 r) h1 k; k. h: M) i
        {
9 K/ m' D1 s6 f2 P# X) I4 [                .active_low = 0,
# X( Y- V& e, ?( y$ V                .gpio = DA850_USER_LED2,: ?2 g6 V, o; i- `' V$ ^
                .name = "user_led2",
# U/ h' o8 a! C( M( b( ?  J2 h                .default_trigger = "default-on",- ^+ n9 H6 C: K0 U/ V6 B+ q
        },- U, q- D6 p$ j7 {+ T
        {: b) p3 [! k# i8 ]0 g4 j
                .active_low = 0,$ M+ ~9 ~0 J# `* N
                .gpio = DA850_USER_LED3,
$ [3 S9 t5 Z: C; Q4 c$ c                .name = "user_led3",3 @. q' y5 Z% H
                .default_trigger = "default-on",5 V* H1 }$ q$ T; _3 q
        },
5 v' \$ g* j- E8 o};/ Q* C0 w% p  S

, B) R+ H5 E; p0 V& z6 }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ ?7 V) H$ C3 P6 [4 |6 A        .leds = da850_evm_tl_leds,
8 Y; {1 T9 C' E( z) L6 c' O! ?& C        .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," ^; U9 |! m* s7 L& t' Z
};' ~. w; R8 e# O* C' B% M
4 \, W" m. R1 z/ `3 e
static void led_dev_release(struct device *dev)4 _2 _5 o. ?9 _3 W+ \
{5 i* E' R  e- U- E! k; c
};1 @2 R( ~' E/ |. x5 Z

$ F3 C2 _: q3 b$ {0 B; V! a$ ustatic struct platform_device da850_evm_tl_leds_device = {  E* b4 ~) O. x+ s+ x# V" P
        .name                = "leds-gpio",
: Y6 m/ a2 ]3 u( [& u6 {        .id                = 1,3 a" g5 q% E; R* [
        .dev = {
. Z$ b) D7 f1 _  c9 N6 J8 W/ I4 l: o                .platform_data = &da850_evm_tl_leds_pdata,( ^0 v1 x& d: @) |
                .release = led_dev_release,
% G9 F+ G  X3 W/ k5 x        }' x# }) t$ k$ d. J& q' U9 h
};/ F+ R# A+ k; h. U. w: ^
) L7 H2 w! c! b2 q' a9 w( \
static int __init led_platform_init(void). E5 a% a$ c: `9 J3 q& O
{( s# b  i) A" S1 S' g
        int ret;
& G/ C4 d# J) o0 l. g#if 0
" g) {2 v7 V6 m0 n" o        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& w/ k- ~4 U1 D3 `. {
        if (ret). f1 `$ I) M% z- E/ a
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) e/ K( w0 L& f$ j2 V                                "%d\n", ret);
5 J4 g" B. K, a5 m; N! F#endif
8 L8 s8 c; A) J4 ?% q/ V. Q; h7 [9 I        ret = platform_device_register(&da850_evm_tl_leds_device);, R* d" m( ^! {* G
        if (ret)% `$ o0 o4 d% m- W+ B
                pr_warning("Could not register som GPIO expander LEDS");
' V* |! h, B  p  E/ t# Q        else
) I/ X7 ?: x# ]8 N                printk(KERN_INFO "LED register sucessful!\n");6 a" E7 U) ]. j( b* j+ W) ?

  ~6 [3 ~3 H  J  E3 _1 G; Y        return ret;
  }7 X* `9 G0 W, T, K4 V7 K}
4 k* e/ U, a( b/ m0 d" J$ a1 ^8 k0 c, |) b. y: E
static void __exit led_platform_exit(void)
$ D9 Z) F! B" u: _$ [+ U2 {( G{; i" C* R/ k) B1 ^$ c+ [
        platform_device_unregister(&da850_evm_tl_leds_device);% o/ U7 u# b4 w

- I8 ]& j7 K. x5 Z( P5 Z        printk(KERN_INFO "LED unregister!\n");
1 ^( F" z( p2 u4 t2 U( ?7 \% E0 t) J- v}2 j3 R6 ~" q/ W' ]% A6 \

; Y% O4 m2 z$ Bmodule_init(led_platform_init);
1 s# t6 D4 i3 e" i1 Smodule_exit(led_platform_exit);
0 ], l' x7 E% e1 Q6 s) p' N8 f2 S7 `: M; C9 F; S$ e( @
MODULE_DESCRIPTION("Led platform driver");2 q4 Z5 v$ k$ `# t  W: D
MODULE_AUTHOR("Tronlong");
; ^( J+ k# q# D: y( ~MODULE_LICENSE("GPL");. a7 j$ W2 r# F$ E( X

5 l- s  ~( k$ t$ p7 X) _+ C1 Y+ G( @# V
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-11 08:41 , Processed in 0.036988 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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