程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。. m2 a8 d! _! y
#include <linux/init.h>
. W3 n/ R9 c, d8 w2 |#include <linux/module.h>
7 c. o* Y1 ^7 C5 e" b$ O#include <linux/kernel.h>) H, x/ i3 K, e0 C% y
#include <linux/types.h>
- @; H6 ~6 F( Z9 U; }3 ]#include <linux/gpio.h>% |. e* F8 J- u$ K: f# v& p
#include <linux/leds.h>% H6 R  w7 b& g+ e. @5 F2 X2 Y
#include <linux/platform_device.h>
  b9 X& x' l  G, c
4 Y: {# q& ?, B* V#include <asm/mach-types.h>
! E/ a% p4 d  X2 Q$ M, c5 a. ^#include <asm/mach/arch.h>* T1 |' N3 s0 _! [
#include <mach/da8xx.h>
4 P$ g) G3 h" i4 ~. X; f#include <mach/mux.h>; n: v; Q! t2 H: C9 d
2 V- \& a4 \) o! W3 T3 ?- W* D
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)2 F# c* ?  c; t: N0 j
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
5 D' G. N3 Q' X. H& K#define DA850_USER_LED2        GPIO_TO_PIN(0, 1). ?+ Y$ N6 U( M! k1 N
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)! D5 f$ S  m, d* P/ r1 ?

# E' C# N5 y8 \6 v  R4 Y9 c) R% ]/* assign the tl som board LED-GPIOs*/1 K% s6 T: }5 I) V5 Y# b/ J  e/ Z
static const short da850_evm_tl_user_led_pins[] = {
  p: G6 M1 ?  u# Q        /* These pins are definition at <mach/mux.h> file */
& n. s  h8 Y! d" O% _        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,  R5 @8 D; o* x2 C1 L; ^5 {* k
        -14 X' h$ a( x+ k( Y/ u$ s
};7 V# ]6 N- b( J7 |4 a) o* R
2 d- k' p3 |0 [9 j
static struct gpio_led da850_evm_tl_leds[] = {: g& u3 q; V- F& E
        {
, z& Z5 \2 L! a% p2 }' l                .active_low = 0,
5 f- O' |5 f2 K3 p                .gpio = DA850_USER_LED0,
, K, o" l) x9 K8 b6 e                .name = "user_led0",0 b2 ^6 i5 j' f' B! l5 E& u- K
                .default_trigger = "default-on",% g3 t% D/ h- t5 W- M$ z* n
        },9 U; P5 I3 F: a( L; n
        {9 E' }7 k0 m! ]; L2 i4 |
                .active_low = 0,, f% A7 B2 v" S) n2 A3 W9 J  u
                .gpio = DA850_USER_LED1,
. ~5 D- z/ D; j0 g# X( d% h: |5 a                .name = "user_led1",& n5 G/ y  I& j, `4 m# R
                .default_trigger = "default-on",
( f4 o  ?% M/ R6 ]1 C% G! H9 f$ k3 Z        },6 A: s; U9 S# d5 r( [# \, v
        {
7 J. R! j- X- P$ f2 S# S- M' E1 e                .active_low = 0,* c  y+ {" m$ }3 ]; R* N
                .gpio = DA850_USER_LED2,4 ?# c9 @" {6 \! ~
                .name = "user_led2",
- b# r; B" H  N8 Y$ Z  {                .default_trigger = "default-on",
7 t8 @, V8 {7 b& s7 g        },
2 p* R* T/ @- P: g( ^        {8 h: H2 n1 C7 X$ K5 e- ^. H
                .active_low = 0,( U7 A. P' v. }* G) v! n% K: e
                .gpio = DA850_USER_LED3,0 e, V! D1 `' ?+ i9 v
                .name = "user_led3",
6 b3 S6 Z. e9 C                .default_trigger = "default-on",' U6 n$ ?7 A! Z  E
        },& N* E0 n0 Y2 U* C; e: `
};2 l3 |$ U/ n! c7 Z$ t" M( H
6 X- [  x0 }; |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, g# S. w, C) ?" q0 e! v        .leds = da850_evm_tl_leds,
- x9 [1 ]; }' E' j        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ }9 \" X6 Y9 P) O0 d, T* J};
, D3 Z/ j' m3 c( S$ F" W! {5 D8 t3 r+ f( T" M
static void led_dev_release(struct device *dev)
; e0 m; R: m) r6 U. C: o9 V8 @{
8 M* y- l  B2 w% j};: ^# m& x+ D, n1 y. x/ f

5 t8 G9 p; `! Z/ estatic struct platform_device da850_evm_tl_leds_device = {) |% ]8 P6 D: E- O1 l4 }* x
        .name                = "leds-gpio",/ u4 D0 Z% l) ~4 I8 b
        .id                = 1,
) H4 ?0 W+ r# h! V; H        .dev = {
! |+ x# }# }; u/ t7 T2 K                .platform_data = &da850_evm_tl_leds_pdata,
7 V* `, x; b1 V$ G8 F                .release = led_dev_release,
% {" }- s9 b: O( a  X) }        }- N9 R* |; J3 J7 O  a: |( N0 o. v
};
+ L, q+ B+ x  G/ }2 @  M
! ?2 d# H) V" A$ Dstatic int __init led_platform_init(void)$ X0 w8 R0 Q7 T
{
/ m- k, Z$ n5 A& m        int ret;
; p) c( O  q7 `5 E8 Q* L#if 0& J9 ~: k, C9 G5 P0 v  h/ _. X
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 _) H" L; w5 g" O! J' K        if (ret)
6 \% `; c  b% y& C" D                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 Q& D1 s$ d( N; v/ R4 z                                "%d\n", ret);
$ D7 P4 R  x, g* L+ H9 r% F  W#endif$ |* s2 j7 }- x8 H% U
        ret = platform_device_register(&da850_evm_tl_leds_device);/ T  G" o0 R$ z! E' K
        if (ret)4 o0 @& M2 e( J) q4 y8 U
                pr_warning("Could not register som GPIO expander LEDS");
- v9 y4 ~: F& }4 y& R2 i        else; O6 q' g8 Z1 k( R, F; \! }; ]' u9 F2 R
                printk(KERN_INFO "LED register sucessful!\n");8 d, {3 T: W7 m+ q# T
( e- R3 K0 c) z3 O& Q! o
        return ret;
% U8 G6 V/ t( {2 K. `' {}# ]: n( D; c( f
- T6 T2 J/ S( t" f
static void __exit led_platform_exit(void)
& ^( `) U- K* U$ i{3 J: Z' R( a, M% J: E  n: \
        platform_device_unregister(&da850_evm_tl_leds_device);
* y! l. K4 ^4 d' S, h7 V8 R& Q& @) m; c
        printk(KERN_INFO "LED unregister!\n");
4 p' \8 _4 F/ b: f8 z}9 U0 W, |1 G6 @
5 b$ _0 v8 {+ W0 z$ |
module_init(led_platform_init);) Y# `( t# K- E- [/ x
module_exit(led_platform_exit);
; i3 T. T& _' X, ]  z: D# J1 D' h! t5 u* Y- u! E
MODULE_DESCRIPTION("Led platform driver");
$ S  |& s2 O# E" i" `MODULE_AUTHOR("Tronlong");  _- v: ~5 `% d5 ?7 ~  X
MODULE_LICENSE("GPL");& u0 L2 S6 X4 G7 a# B) g

9 k5 B' O' Y" _+ Y
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-20 07:46 , Processed in 0.039156 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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