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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。" y% `' ~- A" |5 S
#include <linux/init.h>
5 y* R" W+ [8 d/ N#include <linux/module.h>
8 n$ c! E+ K8 S. d0 E, W2 ^8 b#include <linux/kernel.h>% L" r; e4 X7 g; n: o4 X; k
#include <linux/types.h>3 W: S& F" Q, l& B4 d) {1 {
#include <linux/gpio.h>0 |" H. V& r# X- \$ v7 u
#include <linux/leds.h>
4 V4 s* u$ Z/ v# ]/ y#include <linux/platform_device.h>! g: K  K  d6 j
& H. W. l' R% Z; P2 i8 L" z
#include <asm/mach-types.h>3 w, U, S. E3 j# R: x# c
#include <asm/mach/arch.h>
0 a( g$ x* p# q+ ^- _#include <mach/da8xx.h>
4 E" {3 X9 v3 v& o+ R#include <mach/mux.h>
! M( L/ o& q0 A# L& j4 A
2 \! W) ^) {9 C. N; |#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
6 _% w8 |( \. h5 d& @#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
. F6 I% x: s+ M' ^#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)* Z  N$ q, ^# K3 x" z  N/ q
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2): `1 Y$ R+ S6 f% h1 m* e

) u/ o4 ]6 ]% I% X1 M, `9 t; h/* assign the tl som board LED-GPIOs*/& O& q0 D, z$ `7 b3 E3 x0 \# {
static const short da850_evm_tl_user_led_pins[] = {4 r* o" U2 c. ?6 c7 W
        /* These pins are definition at <mach/mux.h> file */+ c5 R4 o) F9 H0 ^6 h3 d
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( z# R; n& f: m6 Y0 [/ ?
        -1+ m7 C8 ]4 t' M" H3 ^
};  j- d6 J4 L# K& x) _

7 B9 {. q7 X5 ]4 h/ E# _static struct gpio_led da850_evm_tl_leds[] = {
  Z) \( ?5 h- o( n: c        {9 E# D5 U' L# e
                .active_low = 0,
# Z+ x% n! z# m1 x0 r* s                .gpio = DA850_USER_LED0,( m0 H$ J7 q! y8 q5 [+ a& C
                .name = "user_led0",9 o$ o6 B4 J2 ]' {' |
                .default_trigger = "default-on",
0 X2 Y: j7 x- }        },
. W3 ~6 Y7 M: }1 l' o- g        {* q  c+ ^% y7 h0 f. y# A1 `5 G( M6 T
                .active_low = 0,0 {% Y# Y0 Y7 P, Z; H, R( M* }
                .gpio = DA850_USER_LED1,
0 r5 ]# a& f3 ?2 V, w9 K$ c  y                .name = "user_led1",
" Z" h' P$ M' J9 T0 P- F2 y- P                .default_trigger = "default-on",
; e; R" g3 I; @$ Q7 B+ |        },9 _0 j/ i  _9 L; i% a. T. ?' j
        {$ q& u! z& C2 [
                .active_low = 0,+ }0 P+ Z0 D( \0 n: y
                .gpio = DA850_USER_LED2,' f! N1 b' S% b
                .name = "user_led2",7 j! J1 E- Q' w7 U+ q
                .default_trigger = "default-on",$ i& ^2 A3 k. L! p5 N( l' E
        },) Z& Q) k  U+ ]# t% M' ?! X
        {
9 Y7 q5 i7 T# R- K' A                .active_low = 0,
) P- |! g( p$ p- K7 a0 U" S                .gpio = DA850_USER_LED3,! T6 l+ d9 q8 D) x
                .name = "user_led3",
9 k# w# g' j3 {! W                .default_trigger = "default-on",+ X, o  y* ^/ f! @
        },
. x& `6 G2 _+ U3 n" Z1 B0 d};
  H0 x/ M* t" `2 j9 s8 g1 G2 R
2 |; D7 B& m* @8 vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 w0 x" S8 |" j/ {' p2 }: L- ?
        .leds = da850_evm_tl_leds,
4 \, ~8 M. m- v7 F6 p        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" y2 q, z  q. i. I; f$ \};
/ x  I6 Q0 e- U( F) F6 ~1 P* Y$ h3 J' }
static void led_dev_release(struct device *dev)
8 s0 K1 x2 r$ o! l3 Q{: k$ u' }& i- T3 p9 M
};
& U1 B8 S$ [; w; l$ P9 R$ Y% t( o' k+ w. \/ L
static struct platform_device da850_evm_tl_leds_device = {8 X, \2 ^% y6 `8 i: ]: @( Q, o
        .name                = "leds-gpio",
9 |5 r0 {" X. N' B: \9 A        .id                = 1,
5 Y1 O! u' h  [& f  V4 [        .dev = {
% o/ ~* B% ^2 ^                .platform_data = &da850_evm_tl_leds_pdata,
" L/ n0 ?# {' }9 b% p                .release = led_dev_release,
8 \9 i1 _4 L. ~& ~7 Z        }+ N$ g2 v4 h6 k/ e4 T' [; E
};
- X+ Y# k% f0 x  u1 p: m! u$ T; H/ U: J1 I; [& B. x
static int __init led_platform_init(void)
# H4 u6 @9 a0 |- Z% ~3 w! M" F, d{
6 Q% n* X0 U) {        int ret;
4 w: ]+ E9 ?) }. g+ {' X' A9 E#if 0
7 V, m% G% k0 J' c6 m/ U# A        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 C1 a6 }! k, R, H% @
        if (ret)1 o1 m, m6 u; n2 i" P/ W: ^1 ^( P
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- Z; v; x, O# R: b* s: R. D
                                "%d\n", ret);7 D( h( }' V& v
#endif5 q& A! f+ q) @, u
        ret = platform_device_register(&da850_evm_tl_leds_device);
0 k7 m* }6 c: b! A' u4 }        if (ret)$ b6 x# Z. J: F, f# x+ N% c
                pr_warning("Could not register som GPIO expander LEDS");: n8 |: `! l3 D' L/ f7 w
        else* U* Y8 n* }, c
                printk(KERN_INFO "LED register sucessful!\n");
% n# u+ V$ g" h! m, ~1 S9 t8 J; F5 G( T/ S
        return ret;4 H" ]' K4 j$ V, W8 y, s# d. h
}# I9 P4 `( I! Y9 N7 v! _. T

; x& O4 h! o: @4 z7 pstatic void __exit led_platform_exit(void)) n  R! t/ Y7 J& H) ]  v9 A
{
5 ?' \1 d2 f, P8 i        platform_device_unregister(&da850_evm_tl_leds_device);& Z, S& M' t/ i  y/ j1 W5 E. l

$ h0 k# T( X( J% |        printk(KERN_INFO "LED unregister!\n");1 b9 h/ p( o  g5 K4 R- [6 M
}
- X; C! L3 K( N  }% L8 w$ A, _. }( Z1 O; L/ ^% K
module_init(led_platform_init);
2 q1 S3 h" [9 q. u& y7 Rmodule_exit(led_platform_exit);  G& z$ k3 N9 s- ^2 R; K

0 u! D4 X: a3 VMODULE_DESCRIPTION("Led platform driver");  v$ E# @$ t2 Q0 F- N1 Q$ ~
MODULE_AUTHOR("Tronlong");0 h; x# R8 ?1 Y- }5 B# f( i
MODULE_LICENSE("GPL");$ k" y2 B5 I% d6 A7 W+ |* @

/ Z& B7 \3 R8 S) U/ Z1 v4 O7 S
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-16 00:03 , Processed in 0.037700 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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