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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
* E# e& @  u' v+ I8 l. [#include <linux/init.h>
  E& F8 x' p( O$ I1 t( N* O#include <linux/module.h>$ {% J5 }; |) M2 @2 s
#include <linux/kernel.h># U) G5 S0 s# `) L7 X: o
#include <linux/types.h>5 M( r$ l' |1 E/ I
#include <linux/gpio.h>
8 V1 a+ H+ V; f5 H' E0 c#include <linux/leds.h>
, |8 Q' Y4 n8 s& ^- K#include <linux/platform_device.h>
) r1 Z* T6 p# c0 a7 R7 h" _1 T* x( C
#include <asm/mach-types.h>" S' t( |5 q7 ?+ W% X' {
#include <asm/mach/arch.h>1 s! {3 x, A0 `" F1 j; T( e; q
#include <mach/da8xx.h># J- j- P& e2 ]  J7 D, j7 N& u
#include <mach/mux.h>, r6 K1 |  i  h$ R" @5 p

. j! m+ z4 V$ W7 f( J#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)$ W' s0 h% d+ j/ r0 R" X
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)2 m  E+ j  G' y4 E: ~% {
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
2 [) L8 `) @; E1 ?2 g/ Z+ y#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)! C- Y* M* _7 M  m; k# M9 O  S

; T/ {/ ]- W' q1 Z: m+ |/* assign the tl som board LED-GPIOs*/
' `3 |9 |; B3 mstatic const short da850_evm_tl_user_led_pins[] = {
& {# j* i4 C- B, G- d        /* These pins are definition at <mach/mux.h> file */5 d. t* c! e) a" |$ h4 G0 d8 @
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* y7 A. s4 P! t
        -1
6 h9 y( k  ^5 c1 o; @6 U! C};
- Y3 A- w0 ?3 V
& s, T9 n7 e& X! {static struct gpio_led da850_evm_tl_leds[] = {
& o' c0 |6 v& S: _# g3 M5 D        {
- P: M9 K, |' K( z                .active_low = 0,# w2 l; e) W; j: O
                .gpio = DA850_USER_LED0,# D% m- L$ |: k
                .name = "user_led0",
& S, X3 s+ }' [( h$ q                .default_trigger = "default-on",
* m9 c3 {% F7 ?& e8 @        },6 j# g) w: o) _6 a' U1 c3 H
        {
( _5 H" e  s9 A4 i                .active_low = 0,
- r+ l' ~! ]' V3 o" z                .gpio = DA850_USER_LED1,- {! A/ F5 T: _( c' N% }% J/ U
                .name = "user_led1",5 t' H: p7 q7 s- R, R
                .default_trigger = "default-on",+ |* R2 x* f; ~3 `: w7 \2 S
        },
) k  w7 L, [( B0 j        {  {9 o' S% s! ~0 ?$ {
                .active_low = 0,
' S/ q' H; G  a                .gpio = DA850_USER_LED2,8 a; c+ k3 j6 v: B! D. b& d
                .name = "user_led2",8 r% q  [2 y% Y; s- g
                .default_trigger = "default-on",3 R# y( W- U: q7 l4 k
        },
5 d; O! u0 ]8 B        {
$ \" Y$ c" _& N. r  p2 v                .active_low = 0,- T8 R5 W6 j& h% |! g/ h6 g1 G# @
                .gpio = DA850_USER_LED3,- t6 d" K' @  c2 m5 t
                .name = "user_led3",& }2 `( D) `3 T6 A+ U
                .default_trigger = "default-on",0 Q- Q1 J3 V; r/ ]% V, Y
        },# h6 x% t. q* v2 {8 x7 N
};- o2 j5 ?5 X) S) j

$ y' T. [& O0 X4 Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 g+ q/ a" x- j% l- |/ ]        .leds = da850_evm_tl_leds,7 _. t1 ]! e3 _; J% K
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. \) d1 M! c( u( g5 X3 O9 ^+ U};1 o& W! v% j/ h7 M$ ^- u& o/ [
3 w3 M! t7 N* _; Y
static void led_dev_release(struct device *dev)$ `6 ^: P1 v* Z" c* ?# B( c
{9 j; H* }, }0 U/ e* R  |
};
- R; W$ U8 j6 g6 u7 R* [9 V! G+ K
+ y5 a# \5 w$ l3 i2 I) istatic struct platform_device da850_evm_tl_leds_device = {
+ A* }( R# K- E% l8 V! N        .name                = "leds-gpio",) N' L; T! v) a
        .id                = 1,5 S1 A" \7 ^  U( P! Q2 e
        .dev = {
4 C4 V+ I+ A. o                .platform_data = &da850_evm_tl_leds_pdata,7 g  Z4 M2 f' L* H" k: \. z
                .release = led_dev_release,2 x; k2 b) D# O* i$ h$ b# A* S0 H
        }$ r. N4 e: ]2 `4 ]  e& |; r; i
};
8 V+ w$ @4 i; H1 j
' B. p! q$ {. P7 Rstatic int __init led_platform_init(void)8 M% v! r( F  I$ [
{
; O, w2 }2 q* h0 m; p        int ret;
. b( R- w6 H: |+ c; \#if 0
, A2 V2 i0 R2 n" X        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! i& p* N0 ~0 [, I        if (ret)) |' ~7 O0 {' E! v- z
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' L9 e7 D1 E0 X% J  n                                "%d\n", ret);1 t7 v: A# L4 ^' P
#endif; v4 ^; Q/ t' i9 L
        ret = platform_device_register(&da850_evm_tl_leds_device);
, k. n0 D& _# N1 w: c; Y8 X8 z        if (ret)
1 M/ Z% c$ u% J$ L                pr_warning("Could not register som GPIO expander LEDS");# _0 O' |& I. A- {$ ?) k+ d* o% A7 `
        else
# j1 s2 d5 V+ s- C6 ?4 C# X                printk(KERN_INFO "LED register sucessful!\n");
7 b7 W. D  @0 D, c( N( D2 [8 \
% J1 J  e9 S+ a9 a        return ret;) ]& f* ^( M' S& Z+ e
}8 K6 Z/ p  ^2 y2 m& b& v* `+ }

% v% S  _. k9 u& zstatic void __exit led_platform_exit(void)
0 Q' o& [2 d; X7 D! L$ w{
0 z6 o) O6 o; r) ]+ }$ s$ V& K# w- |        platform_device_unregister(&da850_evm_tl_leds_device);
" ]- t+ t; N& J' m; ]6 D7 q8 S/ ?- H9 [% h8 E& O% E& c
        printk(KERN_INFO "LED unregister!\n");8 a4 o. R2 R& K3 Q
}9 p% @1 o; d6 M7 R" B, z7 U# h6 W+ v

" [+ A1 o/ r* M9 Z6 s) N& d  F2 gmodule_init(led_platform_init);7 x' J" {1 k% A
module_exit(led_platform_exit);
. `: ^7 S. E+ L3 i
! ^( W* S6 g# `% o  @7 QMODULE_DESCRIPTION("Led platform driver");! ~" ]- i- T# m% B2 V
MODULE_AUTHOR("Tronlong");# i4 \9 J$ g! f# @) a
MODULE_LICENSE("GPL");
5 k: }: ?, U0 ^  ]
+ _" N& q5 H( q( h7 |6 m& W9 `
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-4 10:41 , Processed in 0.037534 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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