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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。1 X- M9 Q& {+ Q: @0 R
#include <linux/init.h>
. g# W4 p1 y. g0 E1 d#include <linux/module.h>' C( g0 S7 p1 f4 }1 w. v- S* V
#include <linux/kernel.h>
) G; d, _' B3 g' }8 q5 U% p#include <linux/types.h>% i! X# M* u" Z  g! e/ x3 t! x( R
#include <linux/gpio.h>3 b, W! W/ M- [, |9 c$ r7 D
#include <linux/leds.h>+ T  ~  g; f* u6 g2 s1 J# a5 m
#include <linux/platform_device.h>9 `! t9 ~1 N. c% k# m. J: k3 S8 z
( m4 K8 G. k6 j6 Z7 }( S# q
#include <asm/mach-types.h>
6 [6 C: d3 j# N: N7 d7 {, u5 h#include <asm/mach/arch.h>
  t/ O$ N6 S% {2 D* j1 S' P( B6 I#include <mach/da8xx.h>
* {! v& ?3 r9 y% {#include <mach/mux.h>
' x/ |2 s. u9 T; Z5 F' A: {$ w$ f3 L4 L6 x; x
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
/ f0 d. R+ W* |6 z#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
% ]. G0 R6 K& p* t6 }! U% U#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)/ V# P% X8 D6 p
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
9 A$ A9 v# d: e; Q! e4 V) t! r) |, u
/* assign the tl som board LED-GPIOs*/
' a. F% E$ r* X1 Z7 X; ?; o6 V) Fstatic const short da850_evm_tl_user_led_pins[] = {
: X) x! o8 y8 `0 d" ]+ Z        /* These pins are definition at <mach/mux.h> file */) f0 c* y4 W8 ?/ s6 H, B
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, W, ]( z) [) G' Q  }) L        -15 {- c* y" X6 [: V
};+ q1 j% P/ G6 B# I

% {; W' {- [& ~, M3 x1 Z2 h( R! Mstatic struct gpio_led da850_evm_tl_leds[] = {# R8 ^5 ~" C+ s/ c6 I
        {
# g' t# v% d; v- [5 c# t                .active_low = 0,% q( u5 X# b# s/ N4 Q) i
                .gpio = DA850_USER_LED0,2 o9 ]  I( D' @
                .name = "user_led0",
3 J/ H4 I- @: X                .default_trigger = "default-on",: U' X+ J/ N' _+ G- D" Q
        },
9 E: E6 M- }# G9 x- m" Q& S3 A        {& j2 G" p" e$ H8 t
                .active_low = 0,
# `0 \, v8 }2 f                .gpio = DA850_USER_LED1,7 D1 \5 i4 y' M; @8 P6 x
                .name = "user_led1",: U5 T/ l; w9 e) ]3 @5 a4 V/ u
                .default_trigger = "default-on",& ~1 m& \& L- i$ H
        },- @$ x# Z6 V6 ]9 b
        {
$ m  ^1 y) {/ E% H% N                .active_low = 0,2 q6 a% p9 u6 s$ C4 U/ M9 [) Z
                .gpio = DA850_USER_LED2,/ y+ o4 ~/ i" V9 }$ h, P
                .name = "user_led2",' T7 E+ k2 S9 N0 E
                .default_trigger = "default-on",
; F& @4 |! v2 |* l5 L        },/ g& ]: m5 C! T( K
        {6 ]: p0 E7 Z0 \6 K5 D+ @2 [
                .active_low = 0,8 n* G! q5 p5 T- X  I/ ~2 J
                .gpio = DA850_USER_LED3,
  W' i( ]+ k+ A0 X" J/ f                .name = "user_led3",; C2 \$ t1 l8 P& {& D0 u
                .default_trigger = "default-on",
$ `/ {2 @; k$ w, V6 C        },- w0 _! W; l# w  q
};; I& o$ V) o. {; Z) K2 U
. Y5 S+ ]! A  y2 Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* L7 O* z& C, c        .leds = da850_evm_tl_leds,
; S$ U, k+ o( e' Y& k; L1 R        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),  L& \9 A* H3 |2 F  \* ^" B
};7 W$ I* }( B  v, L/ j2 D: ^
8 c: ?) t5 q# l; U. O3 k
static void led_dev_release(struct device *dev)  [3 t$ e2 x) b+ p/ X' J
{
+ e4 o1 ~8 L4 H};
7 F% n9 V& I0 s( @# _2 O4 ^
7 t' p: T/ i5 {static struct platform_device da850_evm_tl_leds_device = {
8 p& ^* p; [! O- P        .name                = "leds-gpio",4 A/ Y: b# f; T+ @  _( X
        .id                = 1,! [- d6 C# u. ]9 O
        .dev = {
/ J# a! P9 D: C                .platform_data = &da850_evm_tl_leds_pdata,  w9 r4 z$ u& J$ r1 |# s3 J* z
                .release = led_dev_release,  A. \  i( W+ ]5 l
        }. i' _8 o5 B7 N9 R1 B
};
! R6 X* O; p, x7 n* ]" ]9 T# n7 ^
static int __init led_platform_init(void)" g( R" u0 D% c; B4 w) [
{
$ ~+ l3 j' \: ?; O- d# v4 i+ _        int ret;
/ Z4 X) f8 ~& H, u' {, P( H#if 06 k3 e  K$ V" T$ j# ]3 W
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 {  f$ q. Z0 c1 r
        if (ret)1 ^$ S! C' J! A4 N
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. v. j" v0 @& Y/ d2 i" a+ m0 g                                "%d\n", ret);/ K, @1 q- l. v0 U
#endif
* e- p. w2 W1 Z+ c* Q        ret = platform_device_register(&da850_evm_tl_leds_device);* b" f, w, y! W& H& l/ j* f: r
        if (ret)
. c/ e( `' H/ j1 W                pr_warning("Could not register som GPIO expander LEDS");
9 s, s* ~  g4 f# u4 F        else1 P- ?+ a& n! Z
                printk(KERN_INFO "LED register sucessful!\n");' D! S  q: [& g7 `( q3 V- `% G$ W

4 t. Z' G* Y" h. M  t. G- u/ x! _        return ret;6 g( C1 l5 P' t; W+ e
}0 d1 p4 y+ b  U, i9 y% t2 ^# ^0 e" {

$ M+ u& s" S. r/ gstatic void __exit led_platform_exit(void)
9 {" t0 r- p8 ]{7 n% w" N! \1 m( f, ^
        platform_device_unregister(&da850_evm_tl_leds_device);4 `3 Y+ Z. e; s8 |$ T0 t: W

8 U% \; N! b% M" n# K        printk(KERN_INFO "LED unregister!\n");
0 Y2 g& x# x( x8 B6 |}" H$ g( M) l9 U! I3 C

' x* r0 _" ~" b; }; o* w" L. t, umodule_init(led_platform_init);
: E* o. g& x! zmodule_exit(led_platform_exit);& W/ |/ v& }5 D" K! w, Q" Y
, ?" c. F/ n+ ]  }4 I
MODULE_DESCRIPTION("Led platform driver");
: v3 Y/ S# I2 j+ AMODULE_AUTHOR("Tronlong");
3 J/ Q6 R( q2 B' g! jMODULE_LICENSE("GPL");
2 B2 M" \8 ^* r/ h. L% K. n8 U! T' M  P5 Z# P" T  E. J
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-13 12:07 , Processed in 0.053746 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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