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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
; ?8 e% Y* ~$ `4 e# A3 f5 m#include <linux/init.h>
; c9 m* o! K9 `' G#include <linux/module.h>
' R3 R6 i+ z8 N2 w  x: }: N0 \#include <linux/kernel.h>
6 _4 o' g( S2 B+ R. j#include <linux/types.h>( V0 Y+ `$ w% n& n9 t. p
#include <linux/gpio.h>& Z8 I- ]' f; p
#include <linux/leds.h>7 H; L4 d8 W) |0 ]% u
#include <linux/platform_device.h>
7 K* q5 [# y3 H9 K  `+ e% C
) Q# T) h( h, H/ }#include <asm/mach-types.h>6 Y% y( w( _! N4 J9 R3 v
#include <asm/mach/arch.h>& K+ Z) s% Z/ c: f8 T
#include <mach/da8xx.h>; ^" M; J7 |! U, l+ s# v6 ]
#include <mach/mux.h>' C- L5 x$ }# Q, ?1 i

' J# S4 i+ |) K6 D/ K9 [" ?/ `#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
. a" r9 g: H% E% r" V#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
1 E; N2 p, U! k8 B9 n#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)2 D8 D7 ~7 ~0 m; _7 A
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
' K  \4 Y4 V' n3 {
1 _. n* b) C$ g- b/* assign the tl som board LED-GPIOs*/
& X( z+ B7 S& b% N2 v9 P% ?8 pstatic const short da850_evm_tl_user_led_pins[] = {
" x2 m# }5 J' H+ @        /* These pins are definition at <mach/mux.h> file */( N& c3 E8 @6 ]: B0 X* ^
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- _; u: C! G% R+ s' X% F; M        -1" j' h/ \/ k$ A( s
};* a  x& Y( f: y! a% }, f
7 p! E$ p1 E& r' V( }/ ?
static struct gpio_led da850_evm_tl_leds[] = {
4 r; \% Y- ]. u. z) c0 n6 o        {
" c; Y( o& N' D8 D                .active_low = 0,) g& \% ^) S0 r5 U8 V6 v+ n
                .gpio = DA850_USER_LED0,1 H" s2 m, D# C; e/ u3 N
                .name = "user_led0",$ `4 V# E, y9 m$ V2 L4 H# q
                .default_trigger = "default-on",8 i' L# d( l7 m" ]
        },5 c8 |* I, V9 W7 o
        {8 D. O4 T0 j9 z8 r1 H; a4 N
                .active_low = 0,+ I; q3 S1 y9 C4 s1 g  Z+ [
                .gpio = DA850_USER_LED1,
3 k& K, n8 R6 M) K! a1 h( ^# W                .name = "user_led1",6 _# B5 v$ @; ^
                .default_trigger = "default-on",, M( v3 \" b6 ^
        },' }7 G, }" O5 j/ P& e5 H$ u1 F
        {6 q# a0 X. L2 u* e
                .active_low = 0,1 U& M' R- H* L9 S( D6 m. p# q
                .gpio = DA850_USER_LED2,
: V' Q( M, d1 N( s, @8 F                .name = "user_led2",: l- Q6 d. m# U3 i# i( }
                .default_trigger = "default-on",& `6 t  k) I! b* j' t$ \
        },  g$ T; t5 T- o& H2 i
        {
; L: k- X; A. J. Y! K& k                .active_low = 0,
$ y+ S5 ~$ A( v& ?: T                .gpio = DA850_USER_LED3,
2 Y! `0 n2 ]8 x3 ]( `7 C2 `  s                .name = "user_led3",
( h" k6 q' [2 u7 K                .default_trigger = "default-on",
2 g$ _1 g6 i* v* Y& l- ~        },
$ w: ]" y! [! P};
9 q1 h! Y( `/ K( ]2 }2 V
. G) |" ^# Q+ f& Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* o0 k, _* T7 S& ^& u
        .leds = da850_evm_tl_leds,& B0 `8 X' |$ V* |3 f( g
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* X. |0 I2 o- U- B  m  U- z
};; U& I2 o- T4 I  X7 B

" c2 \- H- y/ y0 sstatic void led_dev_release(struct device *dev)5 k; J" R3 e# c6 A% W$ Q
{
: a$ H8 C& B) L};
7 n; t) S1 x) ]# O6 Z9 J0 ~/ k5 Z* H7 _6 f
static struct platform_device da850_evm_tl_leds_device = {
" R  ^/ K5 D) t0 h; Q" U6 U        .name                = "leds-gpio",
8 E% p2 [0 v& p; Y        .id                = 1,
7 T/ A, ?8 l& O' f, J8 V        .dev = {
. _4 n; }$ k$ J" D' c4 I3 h9 B5 S% J                .platform_data = &da850_evm_tl_leds_pdata,
$ [( q4 H7 Q# R8 n9 ]+ o8 Z                .release = led_dev_release,
3 j$ ?& t7 d' Z5 e" m/ o        }
7 Y$ n9 A( Z$ L2 j, B  ~' R};$ |8 Q6 s1 `% n$ L. Q& h0 o

' ^# a: t% C$ H! p0 [+ wstatic int __init led_platform_init(void)9 `8 t4 k% m* W4 j5 T6 h: u
{
% ]: ?6 Y9 X9 O/ l% m/ x1 B5 X        int ret;& i  q% j4 Z4 e; `
#if 0  }( g( L8 s7 D# Y$ @' ^/ T
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 v4 ]7 \- Q8 K: K$ E  ^* Z
        if (ret)
4 \2 ]0 F- J3 d. Y6 T9 Q3 F1 o                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 z7 U$ b/ k% {2 h1 {
                                "%d\n", ret);8 Y% i% y2 g7 Q: A6 O0 ~* @
#endif3 O6 E( {  Z8 q
        ret = platform_device_register(&da850_evm_tl_leds_device);  s% Q% \: @! y# P' M! _; b4 o
        if (ret)+ O7 k2 {1 C! d2 _) Y
                pr_warning("Could not register som GPIO expander LEDS");' U0 P: g; o' I6 T4 H" o. d% Y: e
        else
6 ]; x2 R; W2 C  A$ b- D                printk(KERN_INFO "LED register sucessful!\n");
6 C6 w# e) S+ V8 I4 {% |7 j( _
* S$ _# ~3 @% f- E        return ret;& ]1 W+ U7 t7 G) Z5 X1 L) l' F
}3 e1 U" P  r$ p4 M: r5 i* e
  v5 ^$ e$ P& [' g$ Y+ V
static void __exit led_platform_exit(void)( J; F5 _; y( r  \' X; Z1 d
{. v$ y9 m  F5 B: _$ x
        platform_device_unregister(&da850_evm_tl_leds_device);
7 L1 b4 D( Y( d/ w& F. v
, |/ q# E; X# w        printk(KERN_INFO "LED unregister!\n");# n+ N1 s# ^, t+ P9 x
}& z2 O# E/ m5 A! O4 t; b
7 m- K8 j2 e- Z0 u
module_init(led_platform_init);
4 ]/ e  q4 t: n; j  hmodule_exit(led_platform_exit);
# v+ s7 y+ }( ^- l/ m9 I' Z
: B( T2 A2 \; q' l5 _MODULE_DESCRIPTION("Led platform driver");
' A7 o  V2 Q7 NMODULE_AUTHOR("Tronlong");: ?  ]* U% v) W+ N1 _
MODULE_LICENSE("GPL");
5 }( p' Q* z2 A
  q/ T7 u0 t" A0 d8 E
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-1 14:50 , Processed in 0.040645 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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