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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。# F7 E; ~" `* Q1 |3 D5 }- U! Y+ n
#include <linux/init.h>
) m* X% k  e$ o5 _. L#include <linux/module.h>; W- x) s5 R. r8 Y3 G) @8 Z/ f
#include <linux/kernel.h>
' \" U  H' k9 R  t, N#include <linux/types.h>! F: I1 X! e$ |5 j, ], k
#include <linux/gpio.h>' [* I' l  l; C. g8 n4 t
#include <linux/leds.h>1 k4 Z1 r4 S; A
#include <linux/platform_device.h>
  T- G3 f/ t) e( R7 w: N4 l! l5 M2 l7 D) V: I
#include <asm/mach-types.h>
9 |! O: ]. x1 B3 w1 M#include <asm/mach/arch.h># o8 d% R3 B, P
#include <mach/da8xx.h>
. t4 I) z* L' A; K7 K( a- I  p#include <mach/mux.h>3 q  ?, l6 h$ ]4 K
/ N  |) x! S3 l# W
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)3 n, x% t( S  u  V
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)& z, W. K9 K/ n! ~7 H( o
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)( o: c. A0 i) Y: f. T
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
6 n+ c) R. R( e# ~7 A2 ]& N7 o& N& t2 c/ K$ d9 @+ x; i
/* assign the tl som board LED-GPIOs*/: L0 Z7 b" Q1 ~  g2 I" W
static const short da850_evm_tl_user_led_pins[] = {) B/ B: L- W. |
        /* These pins are definition at <mach/mux.h> file */! V2 {: H( r6 J$ Z: _1 n
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 u8 u' K3 u$ L. T# ^& E; s7 Y1 D        -1& |+ F6 T! E) y
};3 \$ s0 s- ?% d% X- q
$ |- F7 i2 f* v( Y
static struct gpio_led da850_evm_tl_leds[] = {
4 }: M3 R" j; T# t        {
5 r* w/ a) ?' H/ o/ A6 ~                .active_low = 0,
+ C2 e1 Y' T' [; I- {& |                .gpio = DA850_USER_LED0,5 t0 X6 ~, [4 v! b& y
                .name = "user_led0",: Y9 B2 R7 F# J7 C
                .default_trigger = "default-on",8 P; ~; M2 u: D- ^9 o; c
        },
: W. U3 [1 }6 U6 q' b1 w        {! g+ K+ e7 n- s& P
                .active_low = 0,
1 A' k9 P; ~! ~* |$ v                .gpio = DA850_USER_LED1,
* z  _2 I9 N! H  t' M                .name = "user_led1",
4 z4 ]. u" i# S* P                .default_trigger = "default-on",
+ F( `9 T, n1 O( i        }," Q, d& p/ J# ^. z6 W
        {
8 i4 g. x! O3 b2 U6 [                .active_low = 0,8 f+ i4 j2 v, |5 g& a9 O' s
                .gpio = DA850_USER_LED2,
, S8 o, G$ `0 Y4 E( t5 Q8 o3 m                .name = "user_led2",' M6 M' [! v* Q9 `
                .default_trigger = "default-on",' f1 }6 I( N* M! |
        },. ?, m" ?: D- p/ f
        {
2 n9 k# d1 t7 c2 u# `6 v                .active_low = 0,
( q& Z& Y; u$ \" I                .gpio = DA850_USER_LED3,
9 C3 `& y, s3 z$ Z) k                .name = "user_led3",0 b/ X/ V! j+ l& a" Z! i; ~
                .default_trigger = "default-on",) `* Q: a: H4 H/ n
        },) O  k4 t; ^0 l# ?' J+ |
};
0 V1 G  L5 r3 `2 Y0 Y  e
+ `! w. W* m% ]0 o" Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 `6 O, u8 z: ~  p& l        .leds = da850_evm_tl_leds,
" V- _) x2 ~( f; Y1 E        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 t9 b% g/ x! b( f7 k; J. \2 z
};
7 b9 m" |+ u: n( A6 Y* T* M; ]& y+ n% m8 d  ?6 X
static void led_dev_release(struct device *dev)- Y2 }5 n3 D; m3 \$ Q  G" v1 b, f& Z
{! f% E2 |0 s) n9 f: k: s
};
9 ~( Q! ]& g! S3 t" S% F# W) \4 L& d4 {) l& R  {5 S+ g
static struct platform_device da850_evm_tl_leds_device = {* |" W9 v- N' t; i; H
        .name                = "leds-gpio",
) h$ _) V0 K+ P- R; M        .id                = 1,4 n; r. V) Y7 Z& f( U
        .dev = {& x+ E% r9 N! H& k7 _4 x, E& H
                .platform_data = &da850_evm_tl_leds_pdata,% z: j9 o) l5 S! k/ z2 q( Z; X
                .release = led_dev_release,9 u  Z# l2 c+ _7 t
        }
' m: T) \$ G3 Y6 X- ~$ ?' ]};( J9 q; Q  K8 }% L3 x; E: d3 z

: ~  a+ ]1 f. c. Fstatic int __init led_platform_init(void). I. e6 S, v2 G1 j2 n; R4 |
{- G* B  b; x+ O+ F, H+ m
        int ret;
1 v/ @. P9 t8 E$ f5 K#if 0
# e- K- f8 J9 o. \, k2 X# e# r& N3 `        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, h7 }  F: U' {; ]# E8 S# f$ J
        if (ret)- f6 b* u: U( Z) Z4 m
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* \5 y+ ~# I9 s! l, R9 \, @' G                                "%d\n", ret);
2 ]8 G+ a4 w( }: P* O#endif
1 _8 v' C; P$ h" v4 ]1 u7 {% d        ret = platform_device_register(&da850_evm_tl_leds_device);
6 \/ u$ I6 H7 y1 a0 D        if (ret)* A: Q8 R4 U; ?
                pr_warning("Could not register som GPIO expander LEDS");
0 k0 E5 Q& F% U# W) K' Y* b        else6 I& m& r+ o, i1 V7 F/ e
                printk(KERN_INFO "LED register sucessful!\n");
  ~3 q+ A& I. `$ h
3 K  V$ b* n2 a        return ret;
+ s( [! G* {8 {1 c4 g% E( b}
! f5 Z" I% u) I
' {9 u# ]( R* l1 L6 @2 o- jstatic void __exit led_platform_exit(void)7 I# W/ o9 `8 m( N
{
5 a" E, I7 U; b7 j& s8 D2 K        platform_device_unregister(&da850_evm_tl_leds_device);; \$ h. `3 y' D) ^4 b. ~

, T6 n/ V& W/ s        printk(KERN_INFO "LED unregister!\n");: U% D7 Z$ }- a  }3 Z
}' h- I8 u$ v+ ?. g
# `7 Y9 ~, R. m8 }
module_init(led_platform_init);
% e, j& h, Q: o% ~7 D. B9 amodule_exit(led_platform_exit);* x- z1 @" ?) p* ^. R1 O- s" a* A

( y3 Z& e3 n* T# g' WMODULE_DESCRIPTION("Led platform driver");* V. K( c# ]. _5 f, n2 r7 a
MODULE_AUTHOR("Tronlong");
$ I6 a1 p' x2 ?# k  ]6 n3 mMODULE_LICENSE("GPL");% y3 M/ Q1 Y/ o
6 A& n$ A8 e- ?
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-22 22:02 , Processed in 0.037068 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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