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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。/ I2 G+ J9 Q2 D/ T1 D
#include <linux/init.h>- ^$ W6 u; \9 n; m, E
#include <linux/module.h>
) w/ w& h0 x; i5 c6 t3 b8 s; Y#include <linux/kernel.h>) ^/ k. N( Y' Z; K6 q
#include <linux/types.h>( a) z$ }5 U: L, N) S# `, |
#include <linux/gpio.h>
  b6 |% I1 `9 B' q#include <linux/leds.h>& j: J/ p0 V8 y
#include <linux/platform_device.h>
4 j* B! h9 R- [) z) h: x+ @# @
, l* ?" b3 s7 Z1 R/ d& w#include <asm/mach-types.h>4 A3 Y1 Z8 f& ?  l+ [* _
#include <asm/mach/arch.h>
! C! M! |6 [% j& u) i  X2 I#include <mach/da8xx.h>% C- D  D( s( z& v) V# \  U
#include <mach/mux.h>
( z6 u, P; m3 M; L- r" \
, A8 i. s; q- _, H, `% S#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
7 M% l! o+ k6 F" y* Q$ a#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)& o) N1 a0 C, a! H
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)7 h9 V- S# g) V* H8 e' @
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)) l' y7 @: i4 @: T! i

% Z( M- _6 v# M% O2 X/* assign the tl som board LED-GPIOs*/
+ I4 O: g2 P$ l# ^static const short da850_evm_tl_user_led_pins[] = {+ ?; A. x2 J+ ]
        /* These pins are definition at <mach/mux.h> file */
/ |+ z0 `$ j' c; M# f! ^        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 V2 T- G9 u) J6 X) z" b
        -15 `9 e1 `2 V( r/ ]; y
};
2 q& [) [  Z/ j
0 x, M7 E( |7 A; astatic struct gpio_led da850_evm_tl_leds[] = {; x9 L& w  J  F. ?
        {
3 h3 a( @. Q8 ^  e1 Z) i2 J                .active_low = 0,
5 N8 A0 d' x5 L5 ~& T$ o. m$ V                .gpio = DA850_USER_LED0,4 Z0 l$ Y% R5 G9 @9 F
                .name = "user_led0",/ p# Y! G/ d9 k* w
                .default_trigger = "default-on",0 X6 ^) B1 ?# R  O; |) j  j# v
        },
! n2 C' d( [/ N* ^        {! q  F: T1 y& d. q6 T
                .active_low = 0,# o: X3 E& Z5 @/ W$ [6 J6 A
                .gpio = DA850_USER_LED1,
0 ~3 {3 s+ ~  S3 p! L  F% B* H                .name = "user_led1",+ E( h! y4 L& R4 d: ~: K4 P% {0 N4 ^
                .default_trigger = "default-on",; W$ j1 d! A, h
        },
/ w/ _8 s6 P6 m, R9 s9 q        {
; Q' U9 ]4 k- O! x% n                .active_low = 0,
6 C2 ^! Y) H* Z  O3 M1 f                .gpio = DA850_USER_LED2,0 ^& s5 g: [$ x0 r% D7 t
                .name = "user_led2",
$ i" I/ a/ O0 U                .default_trigger = "default-on",( M! ]- u% p& L$ C( e
        },
& y: I- m6 e/ \4 I        {
) z/ p% }. Y: @$ V& C5 @2 l                .active_low = 0,
' Q& m+ \' y- Z4 b2 p                .gpio = DA850_USER_LED3,' f9 a, ~. K" J# j% {& T9 _' F
                .name = "user_led3",
' k. l" C' z, |" y                .default_trigger = "default-on",
' o4 N& {- Y: p% ^4 C3 }        },
6 U0 W8 P* E) H' s7 ~};4 P7 O" o$ u1 _6 u

/ h: y$ D# }# k! tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* Y# F/ V2 z. M( w8 D        .leds = da850_evm_tl_leds,$ \+ k! p1 D: ]8 ?& e
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),  w& Z0 ]1 U, c3 g& D5 Y
};
9 M  f& D2 d, E. N7 y5 K0 h& \0 v  V! _5 a7 a
static void led_dev_release(struct device *dev)$ C( B6 b1 V- Q' |
{; R  n- P# U) E# Z$ U- E3 c8 [
};- N" o& c) z5 i5 ~

' L% c& Z5 Z& ~  A- H; X1 Estatic struct platform_device da850_evm_tl_leds_device = {8 h3 s& ?" s% w0 J2 w$ ?& P
        .name                = "leds-gpio",
* U$ T  F6 }& M        .id                = 1,
5 h6 R# v! {. m        .dev = {$ @* S5 A% E' N' R3 x
                .platform_data = &da850_evm_tl_leds_pdata,
" Y% _7 Q& C' S0 ?5 g& K) [3 ?/ }                .release = led_dev_release,
# S5 j" [& L: U& M        }  G& b8 y: s& }) I$ a
};' {- ?! q/ d$ y  p

( f( q9 K& j( \( `4 D, ?static int __init led_platform_init(void)3 [8 l( h& Y7 M3 q( l& K4 a
{
& k& k4 E& m# [! ?        int ret;* i% g( x' s8 T; S% v
#if 0# P* e/ g0 Q  f
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 e) U9 }" Y4 J4 l# N
        if (ret)
  ~8 X8 _6 G, Z/ \# ^# R) i                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ Z7 |) y9 l# o3 J" y
                                "%d\n", ret);
# n8 P( d& j+ r#endif
: P8 s  r( N8 f: |        ret = platform_device_register(&da850_evm_tl_leds_device);0 Y7 `; w- ]( Y& {" k1 J' k
        if (ret)! X; g0 A' m1 S' }8 h
                pr_warning("Could not register som GPIO expander LEDS");2 @  l, e# c' F8 U
        else
, H2 o' Z4 \. t6 f4 {: D3 K                printk(KERN_INFO "LED register sucessful!\n");" Y/ G' Y6 P" w4 L- [' U4 Q  L
! \  D9 }+ K3 h7 b' R: x
        return ret;
% l( ]  e3 u( ~' ~( x}
6 u2 {& y* n+ M1 ^. X  X- y& a2 t+ G$ y/ p% I6 z7 K2 q
static void __exit led_platform_exit(void)" N, i' X) j; w! P. r1 U6 p5 E2 P
{, M- f  ?- |$ i
        platform_device_unregister(&da850_evm_tl_leds_device);
4 b( S! s- C2 \8 E& l4 u
( R3 e6 R0 z. l6 f+ m        printk(KERN_INFO "LED unregister!\n");& f8 Z- M* o$ Z$ ~1 H& R* j- I' [' V
}' M9 t4 ~  j! ~( v$ E9 l& P

4 @: h3 r( @" r) c# ?: i  fmodule_init(led_platform_init);
; b9 d! E" {8 m- {" umodule_exit(led_platform_exit);
% n7 ]) e( W+ B$ j9 t3 C5 `& q* n( O& J7 h+ X! G
MODULE_DESCRIPTION("Led platform driver");. m# I3 ^( }; O0 I
MODULE_AUTHOR("Tronlong");5 g/ s: {9 w4 x0 d) u5 R
MODULE_LICENSE("GPL");
" L5 C7 f: x2 C2 k7 Z" q5 [0 i( r! @% c2 v( c$ y
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-17 20:06 , Processed in 0.040308 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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