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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。% M+ Z( Y2 h% w' S
#include <linux/init.h>; B( e: R; F; B
#include <linux/module.h>& w5 N- s  z+ L
#include <linux/kernel.h>
# o) m  r$ h9 h0 V, |#include <linux/types.h>9 S# G" e' P- S& a( }5 A* I
#include <linux/gpio.h>
3 V1 u1 V: w) j: c' z5 ?) C#include <linux/leds.h>
# q! J, E8 m  J+ W) }3 _#include <linux/platform_device.h>
. f- L' ^! u  n0 J: U3 v
- s: y; z# p# u+ ]  v- _#include <asm/mach-types.h>. u* g5 n6 L" C& `* C: L
#include <asm/mach/arch.h>9 i$ V7 r$ S) Q& M; ~
#include <mach/da8xx.h>  b( c6 Y0 A$ r" P% A: m9 Z( Y
#include <mach/mux.h>
9 j: s( g" m8 u# x) n/ k# q- U9 V+ J7 `3 V) |6 Q, B
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)7 d0 [4 M2 ]( X, V* O2 b8 X
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5); j5 b1 X3 I$ ^# F( t( B
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
1 N7 M3 L+ H9 F. t, H/ s#define DA850_USER_LED3        GPIO_TO_PIN(0, 2); A2 \( o; I) M
* G6 l7 i% u7 ^2 ]8 a4 y, n: ?
/* assign the tl som board LED-GPIOs*/  l: [0 Q" S! X: |
static const short da850_evm_tl_user_led_pins[] = {. e% p7 Q) F5 z
        /* These pins are definition at <mach/mux.h> file */  G/ S* N8 Y  R0 j7 n# p
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 Y: {& p8 F# s, v. e2 _        -1
$ E# v. j" D- V" o) Q};
  z* R# p/ A$ ^# {
3 f( i$ G5 c# @( Z0 Y+ qstatic struct gpio_led da850_evm_tl_leds[] = {
9 b' B' z( D) P; ]        {7 a3 W2 |4 a1 _; x/ \* ]
                .active_low = 0,) `3 d' }8 _( e4 S
                .gpio = DA850_USER_LED0,
5 K7 X( m7 ~# t0 |# w7 M                .name = "user_led0",
+ S5 R6 Q2 y7 P% D8 F                .default_trigger = "default-on",
7 Z# K9 @' \, ]        },
& v9 _! l- X* a6 h! _1 s        {
: D. O$ @4 W! F: ?2 p                .active_low = 0,5 H8 l/ J  R' G5 S
                .gpio = DA850_USER_LED1,
  B8 ^% [/ X: m+ ~2 h' S: M                .name = "user_led1",
! @  J/ N% A0 P2 n                .default_trigger = "default-on",  n' T3 v. j+ T; l* o% z8 S! c
        },
: o! G; O7 v& K        {& ?# G- ^4 w% u/ x+ l$ S% u
                .active_low = 0,
. @6 Y$ w8 \$ x6 u/ C8 e                .gpio = DA850_USER_LED2,! t  k/ e& y* N* M
                .name = "user_led2",
6 u% c- q# ~: j                .default_trigger = "default-on",
/ _! N& Q" v' m, g8 p5 m        },8 `. S( P+ Q7 b8 v' v7 q- e
        {2 S6 x* n0 N* ~1 C
                .active_low = 0,
1 L3 W8 P3 B' G/ w' A# z  M9 p                .gpio = DA850_USER_LED3,
5 G8 R8 I' y8 K' I* Y. u                .name = "user_led3",5 |; ~2 q: l1 {5 l! z+ |' \
                .default_trigger = "default-on",  |/ B+ \6 u7 H  j" g% m/ N! Q
        },8 W7 {0 D( P4 m4 {! m  y
};
$ j" V; X) k$ R. C, U
0 n4 p& q" b" z& D) l2 I3 X( m9 bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
  C( U7 d% ^' W2 E6 `- L! g        .leds = da850_evm_tl_leds,
7 c, j' Q, e8 Y/ \0 v% s0 f. m, v        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* M& Y+ v! |" c. e};
1 A+ V5 M* g# q8 Q$ T0 i9 k2 {
' G8 C1 T7 x' o! k0 B/ D3 W1 f! gstatic void led_dev_release(struct device *dev)
! t! T0 K7 Q9 O0 B' _: r{
% v& C0 ^% j' ^6 m* V+ D1 h6 G0 T};
5 P, [, o2 p7 u5 g# c0 t
6 x. [& V9 K  `( e/ p! Wstatic struct platform_device da850_evm_tl_leds_device = {
4 n/ k" o0 C  f" _) B8 C% I8 l        .name                = "leds-gpio",- f( C! z" q: x8 k
        .id                = 1,
; W, i" a  f5 U/ r8 S. M4 ~        .dev = {% n2 U( ~9 `. b  \; Z- j8 Y, [: W! q
                .platform_data = &da850_evm_tl_leds_pdata,8 R9 [  R' i9 h& J
                .release = led_dev_release,7 q5 H) C' \# P7 U: g
        }
& U% i! s3 p6 D/ B3 m8 b, N! w};1 c+ x5 T. q2 L1 w
8 K" f0 i' L; \6 h2 K' w" ]
static int __init led_platform_init(void)
  l1 E) _% T1 s7 C# \' t{
( ^- g1 t# b8 `/ {, C$ K$ N        int ret;# q, ^1 h4 C5 o- v$ l
#if 06 S% m1 n+ j; T2 b6 L
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 Q7 p7 i) L7 ?  A% l' n& \
        if (ret)' K% e% M8 \2 C3 I, l6 ]
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 ^6 J% D$ q$ S; K5 I: [                                "%d\n", ret);
, k- `$ N) B+ ~, n( S9 }& k#endif% Q3 m" R. B. F8 D% j, @+ x$ K
        ret = platform_device_register(&da850_evm_tl_leds_device);  Q1 \1 p: u  ?
        if (ret)1 N/ h# }" M  E3 `
                pr_warning("Could not register som GPIO expander LEDS");
1 P* V' W4 H. {: {/ k. y( g        else, c; f3 O0 k4 Z' X- r% v4 A' A/ o
                printk(KERN_INFO "LED register sucessful!\n");, V  W& Q2 p. f  I* g: ?! I# `

! F7 D# s6 u0 m- ^3 c. p        return ret;% ]' {0 S! N3 o5 K; o7 J
}3 `/ }9 b( p# K# d) S% X6 O

3 [! w6 a3 G" `" L' Gstatic void __exit led_platform_exit(void)( Z5 P2 ]1 h: Z/ m2 }5 z4 x, x
{% D( z+ u: g+ }1 F& f9 Y2 R
        platform_device_unregister(&da850_evm_tl_leds_device);. u" ?8 ^) H- D& z  V% C; H

# f0 Z7 J. F1 k) A        printk(KERN_INFO "LED unregister!\n");/ Y# p, m, M( x0 h8 ?
}
; _  i/ O- B1 S1 I. u' i7 Y
8 x8 k1 I9 E1 p$ u# w/ omodule_init(led_platform_init);2 K" T: k6 v' R1 c3 y' {
module_exit(led_platform_exit);  _3 m/ G2 A* b& R2 A# _  u& n

9 j7 \/ ^4 F/ u5 y1 L2 HMODULE_DESCRIPTION("Led platform driver");
0 \8 [! Y) \! ^7 s2 w# `MODULE_AUTHOR("Tronlong");
1 ~7 ]- h6 u: f4 T% E9 ~0 A9 NMODULE_LICENSE("GPL");3 S% u8 V# c" M5 d

$ W$ k5 w" l* w$ Y+ z3 ~! U) U
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-24 18:58 , Processed in 0.047982 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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