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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。4 B3 c: ^  D2 f4 y5 w
#include <linux/init.h>- \3 |, n, B6 j$ q
#include <linux/module.h>6 l/ k, j. F: Y9 p6 g
#include <linux/kernel.h>$ f, y  G; Y6 W, [$ W* ^
#include <linux/types.h>9 u6 z+ }7 Q6 `8 _" |: [9 E
#include <linux/gpio.h>
5 D5 ]* s& n+ k6 E4 N! ]0 ?#include <linux/leds.h>- f, Z2 f/ [4 t" K, L1 [
#include <linux/platform_device.h>
1 f2 m* ^' j) M$ p( u  M) G8 p1 e/ R7 r
#include <asm/mach-types.h>3 M* E; R4 z8 E5 A% V/ ^
#include <asm/mach/arch.h>
4 e% ^8 S3 F& \#include <mach/da8xx.h>
% P! k+ Y# g9 k5 |; x#include <mach/mux.h>
) f3 e) t; h# h* R$ [; F7 x" ~, p! z; I# w0 A( \
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)2 ?3 o* e# ?* B5 k2 C
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
, m, O/ s  J0 B3 W#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)3 }- R2 E0 H0 j+ h- |
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
* i, s7 \- M2 ?1 e& E
- T: h. [0 e' a' y, ^: o. O/* assign the tl som board LED-GPIOs*/
; B5 U! V2 x# {5 Z. J3 m1 i$ ?( ~static const short da850_evm_tl_user_led_pins[] = {
6 c5 ]8 @) r4 t, A4 [0 [5 d. c0 Z2 V        /* These pins are definition at <mach/mux.h> file */. _$ K; }0 R9 P( `% P6 p) V
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( n, a( g) D- y+ J
        -1
* t3 ?: U- P2 A# G# \/ `3 a};
$ {/ {. b- m- G4 K/ V$ l& s+ K; i' E1 r7 F$ e) t4 l
static struct gpio_led da850_evm_tl_leds[] = {' r* n$ B1 {6 A7 K+ ]6 a) J, ?; p
        {
3 L. m6 D/ _$ y, p6 Z9 o( [                .active_low = 0,
1 }8 j; b) R$ e7 B                .gpio = DA850_USER_LED0,
; i# D7 s, ~# j. U% ^( u9 W                .name = "user_led0",! n& i1 Q, |! n2 @5 Z
                .default_trigger = "default-on",$ w) m7 e0 d: \" ~1 p4 g
        },% k, W0 Z; M# c5 A( s: h6 m! E
        {/ W& D( Z% N  D) d/ m& Q
                .active_low = 0,
7 q6 \- X$ }, v+ m; A                .gpio = DA850_USER_LED1,
/ C$ g2 w2 p! Q, h. x                .name = "user_led1",
! _7 \5 r1 _2 Z+ G2 [$ F                .default_trigger = "default-on",
6 `: X: R, Z9 M2 W% G! u. r        },
; P8 F! D4 J4 \, L$ ]1 Z# z        {
: o/ S! q! t: f4 V& t; D+ e4 {                .active_low = 0,
. g! \, G  x5 {                .gpio = DA850_USER_LED2,( r& S9 I& Q( l  O6 ~! {+ S( |
                .name = "user_led2",+ ?6 a* g" A1 p6 N9 D
                .default_trigger = "default-on",+ e% K4 ], k$ t( |% Z& `' K
        },9 n- f( D( D) P6 R% K
        {  S8 G3 X% q1 U7 s
                .active_low = 0,# @; ~6 V4 d% X. ^3 G! b1 c5 C0 v+ V
                .gpio = DA850_USER_LED3,
$ @" W4 V- c* E: j4 h                .name = "user_led3",
& p" L8 J6 Q; T/ ~                .default_trigger = "default-on",
# w9 W3 ]! s3 W- E( ]" E" I+ J        },# S; ~; j8 P% I. X( [
};
6 f( @+ }# G& `* ?+ f( i2 [2 V! R4 h! N' |' e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' _- M2 x( ]* p( A% Q2 R( O6 p6 E) S, p        .leds = da850_evm_tl_leds,7 l& \: p# z0 Y3 R# q8 ?
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 X2 n0 n! v) t( E" t6 M
};
8 i0 b3 B7 n: Y' _$ o2 M& ~6 H. d/ O& w- W
static void led_dev_release(struct device *dev)& U2 U. H2 y9 z: _
{
4 H2 j: h; Q0 A# m$ f2 L};0 S' f4 s2 x8 T5 h7 a# U

3 r# a1 c, e0 ~. ^static struct platform_device da850_evm_tl_leds_device = {2 u  e3 j, X4 Z4 R* S; }
        .name                = "leds-gpio",
% M1 M. |9 t. M        .id                = 1,
  u! q0 h2 }4 ]# c! f$ N2 q( j        .dev = {6 _+ y' u* }8 L, t) m; Z7 s/ ?
                .platform_data = &da850_evm_tl_leds_pdata,& |( S  O. O. j4 \
                .release = led_dev_release,5 s, y, R$ N4 `6 E9 A# L9 R
        }
# m, i$ A: T! I};
# p$ D$ }* Q- r6 W- E: C$ i7 R. F8 {+ H1 m. e3 c
static int __init led_platform_init(void)
  J- |5 R! C2 h. ?: }* z, ~+ N: n{: D9 |4 `1 T6 P! _$ \% H
        int ret;
. F9 t6 j: l/ R5 |' @/ K#if 0* C- x- M7 ?8 U6 A- G5 \) _5 V
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* G9 ]4 B7 }) ?$ b' Y" q" z, }
        if (ret)
! k1 Q9 g/ g3 @) @( j8 F                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 j" Y3 R$ k+ S- R                                "%d\n", ret);9 W6 M8 m5 e: a0 z
#endif8 l, c; G; v# H$ K* B% G  q
        ret = platform_device_register(&da850_evm_tl_leds_device);! ^8 |0 `2 P3 S0 F  K( h9 J2 H
        if (ret)
. Y1 f' N  p; j# r                pr_warning("Could not register som GPIO expander LEDS");
- @2 D$ p0 N( S& L9 J$ r" b9 i! J        else
  @$ ^& J# }  T2 k                printk(KERN_INFO "LED register sucessful!\n");( }/ J* L7 {& Y9 @/ `4 c: Z
# P: N6 V4 ^- t" |, Y! N9 t- x& h
        return ret;+ p7 W/ x' `$ a# Y4 Z. A$ `) `
}
7 ~+ z, @: V& x1 L& ^3 o+ G% M+ J% ~" ?3 D" ]. N
static void __exit led_platform_exit(void)
: \6 B: e+ v5 I$ E9 ?9 b{* {3 F9 A& {! H: O8 X- W
        platform_device_unregister(&da850_evm_tl_leds_device);
& u2 S  f( x! Z: p
9 o+ |( c8 o& R- @& l# |        printk(KERN_INFO "LED unregister!\n");
' x8 L  E5 _$ q) P2 B}) {. F, }2 s0 Q( n2 q

) @6 ]1 ~  h& w/ E: `8 Y; ~& ^7 Omodule_init(led_platform_init);
+ v, h4 g5 S' H. {. d  f! A- {module_exit(led_platform_exit);
# h, d# p* j& R) g6 M  I! C$ \( }" j! x: i, R
MODULE_DESCRIPTION("Led platform driver");" m+ K5 C4 N2 m
MODULE_AUTHOR("Tronlong");2 B( r( S# ^2 L
MODULE_LICENSE("GPL");
; B  k, s  V( I; k7 `: N
' t6 l4 G5 t5 x$ ?5 C. U- T  C
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-9 20:53 , Processed in 0.043781 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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