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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
' h8 C5 a+ ?# P: ^- X6 `/ g#include <linux/init.h>
- }# U- `" E, {9 B' X#include <linux/module.h>; u7 @7 ?+ W7 |) Z( c' c2 f
#include <linux/kernel.h>' G% l+ u* r9 J% H
#include <linux/types.h>
' {7 @( ^3 Y8 q( y# M; u+ _) e#include <linux/gpio.h>& t7 r5 H& ~  S7 Z9 ^
#include <linux/leds.h>  S8 ?$ b* @- f$ N- J
#include <linux/platform_device.h>; ~( u. z+ A( e; G% u

3 T( a! K1 H# @" O, O* H#include <asm/mach-types.h>/ n% m2 A- y& _9 Z8 X
#include <asm/mach/arch.h>
5 K5 W, e$ I& Y0 S" t$ u#include <mach/da8xx.h>
6 L* ]) P2 i: v& @+ o6 |, c#include <mach/mux.h>1 M* @; M" V1 J6 A1 s7 z# a% `8 G
' N& D  a6 B/ h
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
$ z% w$ i2 J1 X9 d( \+ Y  P#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
5 m0 u9 E' n7 J' C6 I#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
  V! s  F* U1 e, }1 W#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)5 w2 W( W" F$ {

  [; S  v) Y" M8 w- k+ q/ Y/* assign the tl som board LED-GPIOs*/+ T% T" F( b3 S) k
static const short da850_evm_tl_user_led_pins[] = {, m' T" ?9 a2 Z( B9 B* |( v) k! S$ l
        /* These pins are definition at <mach/mux.h> file */
# }2 h# x0 k9 W        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: C. F" a. W6 T: w4 Q' Y5 ?        -1
0 f; `$ u! D# D/ n. h, |};0 F" R8 h6 o/ _9 i
6 t' c3 X( z. a+ F
static struct gpio_led da850_evm_tl_leds[] = {
1 k+ H& [% Z: P4 v        {
% ^7 U1 c2 o! V( p# [  I                .active_low = 0,
# i4 J0 P" Y. j                .gpio = DA850_USER_LED0,
* J# C1 L) R  s  H, x2 c0 r7 b                .name = "user_led0",) B* V( `# f( ~. t/ @
                .default_trigger = "default-on",/ U5 V- |+ f2 ~# I) g. c/ \7 [
        },. t. q. i) d7 r0 g4 E" Z
        {# R. v# O. H# i/ Y- Z. \4 Z
                .active_low = 0,, I; {) R; F( _
                .gpio = DA850_USER_LED1,$ X, R# ^  s8 G
                .name = "user_led1",
4 P( n' K& H/ _                .default_trigger = "default-on",3 K% Z8 U+ e& _
        },( O0 ^! i' E/ t. ]6 s
        {4 p: B8 _5 e! N' @
                .active_low = 0,) H' i. l; o+ b1 p( e( A
                .gpio = DA850_USER_LED2,2 q9 a3 R+ I, w, e
                .name = "user_led2",
2 i) `. H* U. V                .default_trigger = "default-on",
8 B# ]) l7 t: ~) O- O3 l% z+ D1 J2 ~        },
8 m" E) u; a! m) A2 ^4 c% p        {6 P" j/ }$ q% j# E: F8 E5 C- B
                .active_low = 0,
. Z6 F2 {, [5 {! |8 S                .gpio = DA850_USER_LED3,
( j& U, `( G9 E- V+ _  e                .name = "user_led3",
" t- v9 j- J  R( U' y8 ?& O# i$ L                .default_trigger = "default-on",# T/ P7 I5 {0 M5 c" K+ N
        },. p  r# i& N: ], h9 V
};
, Z* w2 B9 E! b" P7 V
! X1 g8 _6 Y4 Q* k' Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; D* F3 s' G$ }0 d  s: q8 }        .leds = da850_evm_tl_leds,
0 L1 b- Q/ `( o# O        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. M) i( n9 o" \3 ^; i: B% H3 Y
};7 }- Q% V/ Y5 s, t( {! P
1 t" z2 ?$ w4 i- s0 ~- b& C
static void led_dev_release(struct device *dev)
# b$ q  C" v' h6 w{3 _* n. N! l) I3 `  L$ O& G
};
& S& Z  S# U  d  A+ v/ _
" B- I2 V! {6 T1 N, t0 e: Lstatic struct platform_device da850_evm_tl_leds_device = {) ]! Z1 X* P, z8 X9 K/ a" O0 k
        .name                = "leds-gpio",
7 `' l/ Q5 g2 S! H# q        .id                = 1,
1 S" A5 K: _7 z( h, t        .dev = {* B3 e# _& T0 C: O/ z
                .platform_data = &da850_evm_tl_leds_pdata,
! [% _# ]( L% U6 P5 R/ e+ [' h                .release = led_dev_release,# [5 v$ l" I& i9 H" v. T  g
        }
8 l: y8 I) g: \! \# v};; \9 ^2 g* X8 }) ]5 |! r
% w" E; \% M, O0 H! Y# z
static int __init led_platform_init(void)5 H6 h2 S3 s3 r, W, A3 s( O
{
6 s$ t) h3 Z9 V3 i6 }        int ret;+ ~! c; D  k+ j3 R
#if 0
3 ]. P2 V. e. F; Q' M7 a        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ }6 H& y8 ?& `9 u1 A) `        if (ret)
9 b9 L' \( L8 }" k" `* A3 ?+ f                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- J- k9 W2 f- G
                                "%d\n", ret);
$ G- E4 |- X5 m+ U; C6 P2 j1 ?) ^#endif
" T, b& Y- X% @) o        ret = platform_device_register(&da850_evm_tl_leds_device);9 Z2 `/ d5 r$ g9 t% J5 W, |, A
        if (ret)) C' n6 v* ]( |$ s& d- g
                pr_warning("Could not register som GPIO expander LEDS");- i, R, n3 r- |, _. {% z
        else
9 s% b: f+ K$ _) U" j2 _! K                printk(KERN_INFO "LED register sucessful!\n");& q( g  [: ]! W! U' s+ d6 m

  c. {1 i( t2 R! L        return ret;
. B: }: B" B" n" _}2 J4 z* r/ M0 s

- `5 l% J! g& G# ^* \6 Zstatic void __exit led_platform_exit(void)/ V- n7 I, n7 w1 a  H; Q: u* @
{
5 L+ S4 B+ [( J3 A7 y3 _4 P+ N        platform_device_unregister(&da850_evm_tl_leds_device);6 U9 Q. U/ o5 A* Y9 t$ o4 e0 j
) N; |  h- K3 d! }
        printk(KERN_INFO "LED unregister!\n");
  ~3 C, Q8 V7 ?- \}1 ^+ h! W% Q+ }5 b) d5 ?( {
% i# a- A+ ~/ J. q4 S
module_init(led_platform_init);! a) J" z5 U5 b" j; t
module_exit(led_platform_exit);2 B$ y2 x* i+ A9 a% l

2 \7 s" \" v& g) n1 o0 p' gMODULE_DESCRIPTION("Led platform driver");
- t* a: h0 a3 T4 f+ p0 J9 w. HMODULE_AUTHOR("Tronlong");: |0 H  {' D5 T9 Z
MODULE_LICENSE("GPL");# V! y3 t4 i' u2 ?

- H4 n, w( J, ~8 {8 i6 E5 H
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-6 05:22 , Processed in 0.043401 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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