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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
4 E8 m5 ?1 |% J+ n5 |( N#include <linux/init.h>
! b9 ^2 d! F: J#include <linux/module.h>, u8 |6 G9 O  F  J# A# s  r% N
#include <linux/kernel.h>7 a6 t9 T2 U! r2 k% f
#include <linux/types.h>
1 j4 K. b( F2 ~# p#include <linux/gpio.h>9 b+ k- z% M& F* i
#include <linux/leds.h>
5 M4 o3 Q  P$ Q& t& C#include <linux/platform_device.h>
' e7 ~. U! i3 i* Q0 U# P
8 {1 m2 K8 H; E9 B. v#include <asm/mach-types.h>9 Q1 j) Q* _# k( \; E1 l" H  x
#include <asm/mach/arch.h>
3 M6 C  \3 \% B1 }- b  j& X#include <mach/da8xx.h># }1 {0 S: J( U6 @3 o: N
#include <mach/mux.h>
2 k  ?& A, T7 @9 e: ?0 L% Z
3 f$ y5 ]7 N, C8 t* H" E- ?#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)" G; B' _2 }; M& U, X
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
* f- K) Z9 z9 ~" G4 b$ D' a#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
! s  n$ Z1 u" c( d% ]#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
! c$ S2 H6 W; Z$ u3 z: V. q+ y
- z" Q( X) h! q% K0 f/* assign the tl som board LED-GPIOs*/
! M  D# S5 s6 f) X" o( ystatic const short da850_evm_tl_user_led_pins[] = {
/ B/ m: l  I7 C) i$ h        /* These pins are definition at <mach/mux.h> file */) W% {. @- B" k$ O0 t/ ^7 f: U
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ N% ]) u4 t0 p$ L        -1! z/ K- Y. j( Q4 b
};
) X/ v0 [/ p4 C  G5 y7 R
, ?& H' p" Y6 T# y; T! J+ istatic struct gpio_led da850_evm_tl_leds[] = {
2 J- |, Q6 i' K* Z" ?) c% Y        {0 b* Z7 u  k  V2 K
                .active_low = 0,: u# a9 R( @2 M- U3 s
                .gpio = DA850_USER_LED0,
8 s: n& i2 q7 K# B8 n, n. d                .name = "user_led0",
8 h; v/ n5 }' H5 M) L" F                .default_trigger = "default-on",
! D  Q0 R/ ]( |5 l        },4 q  s& B* {/ V7 D7 g
        {+ ^6 I4 g$ L3 g: x& y
                .active_low = 0,
, U0 }0 p! E1 U+ M5 c                .gpio = DA850_USER_LED1,) E: H9 N8 N% S& `; D$ C
                .name = "user_led1",
( o  M8 U! W- m6 g+ J' c  D6 k                .default_trigger = "default-on",) S% V0 q- H' e( z+ D) n
        },  ?2 n2 G+ T& {7 w
        {
3 n. u* \5 |' d9 G* B                .active_low = 0,
1 S+ `5 \# i; p$ r6 s, g                .gpio = DA850_USER_LED2,
" Y( Y1 c: z  {) e. o                .name = "user_led2",
! g: X& m" I- f* e$ G4 y, H                .default_trigger = "default-on",
8 A+ h* w' `4 @5 b8 [  t5 d        },
' H  k% U; C' k, U0 o, |- t, N        {
1 H7 O" E2 t$ v5 J0 [: ^! k$ {                .active_low = 0,5 _. y6 P* N4 c: J+ g
                .gpio = DA850_USER_LED3,
3 L: Y' V7 X( v  j9 a" J$ D- w( A                .name = "user_led3",
* m5 v. u; A* e0 n: Z$ Z                .default_trigger = "default-on",& t  H! l" Q& U  ^2 S  H9 @
        },% [9 Y7 C' v' r! ]( y$ l& E
};
% \9 f7 Q2 A# e3 D6 R0 q
( V6 F4 Q% f% s9 k' Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 o) |  u+ i6 ]! s; ^        .leds = da850_evm_tl_leds,& G- r0 Z; p$ I9 P/ l2 O
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 z" ?  ]3 M7 P/ ~' ^+ _};* [& d4 n0 N4 A: _
; t# \. w# c8 [+ `$ [
static void led_dev_release(struct device *dev)
  y  @% w# h7 v7 e{
2 ]/ [: ~6 D4 P8 q" W# E" w};) ~- s9 x- ^3 `6 c: |4 q" j& z8 X) ^

1 w2 x$ v/ a/ m9 x, I1 Hstatic struct platform_device da850_evm_tl_leds_device = {$ y9 i$ m1 c! L% g
        .name                = "leds-gpio",6 \( G6 ^# L  r7 j( U
        .id                = 1,
! p4 L$ G$ U- Z* n" v. a4 H        .dev = {
+ Q; N* L9 O- r- U; _# K- j                .platform_data = &da850_evm_tl_leds_pdata,$ C/ A* @: R/ a3 N; L
                .release = led_dev_release,+ M' W, _$ g2 s  }# \5 ?
        }4 ?0 d* `  J' |" P- @: [6 y# i4 h8 [
};( X# }( ]0 ?: J+ ?8 [' |

) Y" k1 S0 Y: ]8 f1 X* ?static int __init led_platform_init(void)6 ?8 X! }" y9 f3 S( D
{- r0 k( |: t, V+ v
        int ret;2 O* y" y8 _9 W9 _
#if 0+ C5 e+ F9 v+ S$ J, o& l9 m4 F
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& Y4 I# f" |# l6 E
        if (ret)
9 f* E3 e6 A  I                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 i* V7 h- H% J6 q, U( \0 O/ Q1 Y                                "%d\n", ret);2 `6 D$ t  G1 b) m0 w' A
#endif
" C1 @% }: b6 I) _/ ^        ret = platform_device_register(&da850_evm_tl_leds_device);
- B. H0 w9 c+ U  l5 J1 B        if (ret)6 S' n! ?: d5 C  W
                pr_warning("Could not register som GPIO expander LEDS");
8 C1 d0 l, [% I+ O5 K& B& g% [! X        else
( O8 s# b7 m! ^1 g0 e- x- v) K- e                printk(KERN_INFO "LED register sucessful!\n");
$ A+ Y3 C$ W4 \# ?5 `5 R
: ?/ i1 Q# G+ }        return ret;' E% k2 I% e5 Y
}
1 ^" k  y& J" b2 X8 {! `
! K, e# m, k- U% sstatic void __exit led_platform_exit(void)+ @2 b6 G! M$ }* S- m  l4 z
{
( W# H5 e" D  `; u6 B' m+ R        platform_device_unregister(&da850_evm_tl_leds_device);
! C* Y3 Q4 f3 f6 `+ @" D  v( A1 S, |5 B1 m
        printk(KERN_INFO "LED unregister!\n");, w! ~5 O$ R" ?) x0 x: @0 U
}, C+ ^3 L6 C0 c) n
+ p) g& y3 E. y# b" `. Z! Z
module_init(led_platform_init);" A6 P6 i/ ~8 ~0 p* g4 B7 }
module_exit(led_platform_exit);8 ?3 |/ a0 f& O, a2 }) ~

/ ]' Q# ^6 l' ]# S) J- {MODULE_DESCRIPTION("Led platform driver");
  Z) t7 I& c9 r0 oMODULE_AUTHOR("Tronlong");$ a2 Y9 w. q$ }8 @( {3 H8 M
MODULE_LICENSE("GPL");, R9 K2 {' ]7 w3 [0 U

; ]2 D3 I' Y* c2 ^* V. e, I
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-7 15:17 , Processed in 0.058594 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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