程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站
点击跳转“创龙科技服务通”

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
( F4 i- C* E$ t1 k# f; l#include <linux/init.h>- y$ T5 _1 V' g* x
#include <linux/module.h>7 ~& c3 O7 E& I& J  O3 R9 p% W
#include <linux/kernel.h>
$ Y6 r4 p; l+ R: b. H#include <linux/types.h># q1 Z3 B8 @' A6 Z) t" f% W
#include <linux/gpio.h>
( b8 v! A: \/ e/ }9 u7 X: n#include <linux/leds.h>/ h4 V) O& v% I; ~6 P1 M
#include <linux/platform_device.h>
* V  }4 f) y/ M8 [. x4 U6 E" Y2 B$ K2 C! v/ J
#include <asm/mach-types.h>( Z5 V1 U7 Q- j' Q
#include <asm/mach/arch.h>  r; I8 g; y, l* q5 h  a  s
#include <mach/da8xx.h>) t, r7 ]- c9 _: x" t& O
#include <mach/mux.h>: @' [1 Q+ k& n0 ~

. E. I# i  X% s7 k6 y#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)1 A: `( Q8 l/ a
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
" H( o* e# ^( P2 Q" E#define DA850_USER_LED2        GPIO_TO_PIN(0, 1); `- N+ M% ~, ~# z
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
5 }) J# Q/ F" E# m) V% S
5 G5 c! F9 x: d+ ^/* assign the tl som board LED-GPIOs*/
, x' G# a0 p& Y" j( b  ?5 Sstatic const short da850_evm_tl_user_led_pins[] = {
7 _  `/ D7 [2 X        /* These pins are definition at <mach/mux.h> file */
5 J) B! L: E" H% L        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ q7 n) c* s/ j  b        -1
- q6 w# }7 _0 z};. ]2 }5 ]8 O( M* C% W

/ |' {, o; C; T% Mstatic struct gpio_led da850_evm_tl_leds[] = {  M9 X& w* f/ w$ V) L. c$ T  `
        {; Q# @+ |$ |$ O
                .active_low = 0,0 ^. ^; e* [1 v0 c# K$ t) P
                .gpio = DA850_USER_LED0,8 ^7 `" t. o- y  |
                .name = "user_led0",
5 \- Z8 t: _  j7 _                .default_trigger = "default-on",* i. p; t7 s% c* d% b4 \+ ~% f7 @
        },
+ S2 e1 N" n. b! j; x. [( @$ \- v9 _        {
. W, \+ h8 J9 u                .active_low = 0,
4 k; r0 ?2 o. z& Q* U  ^; D                .gpio = DA850_USER_LED1,
, w, e* K) \  Q/ [# @                .name = "user_led1",: F1 Y4 l5 f$ J6 c8 _# z
                .default_trigger = "default-on"," G& N2 p/ c: _! [3 P
        },
( H5 M( _! q- T7 Z: m9 n        {) {% j5 x) V( m- ]9 x# s
                .active_low = 0,
+ s4 t$ _( J1 z3 g8 |                .gpio = DA850_USER_LED2,0 m) \' w" ]8 u9 S; z
                .name = "user_led2",
2 J  _" z: ~& ?! ?/ w# s                .default_trigger = "default-on",
; i$ A; S% Z2 N- P; t8 M7 a        },! |, I9 D1 r, b
        {
# P- D# g1 C4 H4 c                .active_low = 0,3 H" V7 |9 t- D! u- o
                .gpio = DA850_USER_LED3,( a9 P% u0 K' q  R! U" J- s0 l
                .name = "user_led3",, z  t" `* v% ?4 o: Y
                .default_trigger = "default-on",
0 s% e5 B. V1 j3 o7 B        },- u! }. O! _4 v4 ~" p3 R
};, G2 q7 e) M7 c" p! J* r/ q7 z

( ]# o1 _* Y( S; S$ z9 {/ Q& ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' [" p/ s, O9 c( E8 S: x# `5 |' [
        .leds = da850_evm_tl_leds,' t) j9 a- |9 Q  c! k' V9 ]7 N
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) K" @+ D! a+ D( f8 k9 u& A
};
  k8 |: q. O& ~7 a% p7 R6 M
# a. e$ d3 p1 D6 ustatic void led_dev_release(struct device *dev)
9 r) P/ p3 c3 i3 ?, b% w  f{# d$ X( g/ U3 {7 \$ Y
};/ t8 I# y8 G! k$ J% R
, j" I$ U" S* a+ o4 a4 V* R
static struct platform_device da850_evm_tl_leds_device = {! L. C. r8 e1 i7 R6 ]0 c+ T1 U
        .name                = "leds-gpio",$ y& I# y6 [! z+ P& S
        .id                = 1,! H: z! x: j  r2 `) j# W! h
        .dev = {
; P) t4 S+ }2 z+ Z# ^                .platform_data = &da850_evm_tl_leds_pdata,2 W1 S- w  U; b" g+ U
                .release = led_dev_release,
+ `* _4 d; L* t& `  P8 U: d        }
" O' w/ U1 p7 B4 J# a- L};
! c5 A' }# ~- g) ~
% E6 T1 c: j7 H/ K1 j7 _static int __init led_platform_init(void)
7 f3 f. \1 ]& b! m1 h0 U{6 f) X' h9 ]- P1 N: j
        int ret;- g, b4 H. y" Q: g
#if 02 f& {+ L/ {1 z
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) g& l. A& \/ M! M" @( D$ M# Z        if (ret)- B5 o& f0 Z# T+ l8 {1 b7 Y, I, |
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! |. O* D7 C: B# |+ R7 [0 w
                                "%d\n", ret);
6 o' ^  Q$ `; g& N* e0 c#endif
) j' C7 Y3 F" y: Y  U        ret = platform_device_register(&da850_evm_tl_leds_device);6 r2 U  x" M% V2 h
        if (ret)
, X& ~% @# R0 M) T2 N9 y$ v8 b                pr_warning("Could not register som GPIO expander LEDS");
4 ^8 n9 O+ t) i! s# u+ C% F        else5 Y: p3 \6 X% [2 f7 x
                printk(KERN_INFO "LED register sucessful!\n");
$ Y) X- h( A' [8 o$ ]% F8 R% ]1 y
: D  R% g7 c9 v- J' F' H        return ret;: U! x- n6 C4 k' m9 |$ p9 O0 f  P
}0 |7 i7 W. {1 I/ R

  J( y5 j7 \$ T+ u: X+ astatic void __exit led_platform_exit(void)
* }$ V: r" H. Z: e& j9 N{
# y( c6 P2 t* A( C        platform_device_unregister(&da850_evm_tl_leds_device);+ ^! i% j5 b- v0 f# i" X

9 l  N0 D+ X7 J        printk(KERN_INFO "LED unregister!\n");; I' k3 Z" H: z
}4 e( ?7 [7 Q# j; \2 r3 R. v4 x
/ x( ~( u) e! K/ }
module_init(led_platform_init);  q: R: R0 I- w" F- \  `5 e
module_exit(led_platform_exit);6 [0 p' l- y3 y6 ~( z3 @
. I9 R4 Q/ K6 s' v' _: R6 P$ B
MODULE_DESCRIPTION("Led platform driver");" `0 V. q  D5 z4 {
MODULE_AUTHOR("Tronlong");( h. \+ ?5 G' S# B: [' u
MODULE_LICENSE("GPL");
- q4 G5 S: i9 K, E0 t' {1 B) M7 r$ l, ?  y4 o! e! a
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

点击跳转“创龙科技服务通”

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

GMT+8, 2026-2-7 20:37 , Processed in 0.042862 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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