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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
: G4 ?. W1 z. q# i' O& X' M#include <linux/init.h>
# F: k+ H" r& a1 Y' a! d* z#include <linux/module.h>
6 M% N( X9 R" W6 Z#include <linux/kernel.h>  S/ a, q7 n5 u& H) a
#include <linux/types.h>
9 h' H" v: M! i( K: r4 }#include <linux/gpio.h>
/ L" h) v7 R. g" K8 Q#include <linux/leds.h>  u8 N3 L4 d6 \
#include <linux/platform_device.h>
3 r: _& h' h! D2 U. m7 Z  i+ ?
! F* W" d- c. h: {#include <asm/mach-types.h>' w  Z; `" R6 ~; y- {
#include <asm/mach/arch.h>
9 z1 z. M; T1 G% w! T#include <mach/da8xx.h>
( x* h7 ?2 T4 C* ], e) {4 y  L: T#include <mach/mux.h>
3 b& e* l  U) Q5 G% E  K' B) [, ]
" K7 f: m% X/ o) C/ ?4 G#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
; S4 [" u. v3 V) b- _% y! K#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)/ {  `- ]* X: F- L# n4 @
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
, h8 a7 D4 c" ^8 [1 }#define DA850_USER_LED3        GPIO_TO_PIN(0, 2); P! P: y2 o* g  b1 e

) v# j# a; @$ Q/ ^, q8 Z/* assign the tl som board LED-GPIOs*/! r2 f: @2 |" x( |& S& }
static const short da850_evm_tl_user_led_pins[] = {3 a! q. O4 u8 E
        /* These pins are definition at <mach/mux.h> file */: c. e# m5 U, j! O6 @
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 c( r( g7 R# g& i' b        -1  m2 Y0 B$ _) l
};( G$ Q, V, [5 t; J! C+ j  j  n
9 l8 W  s: _7 I
static struct gpio_led da850_evm_tl_leds[] = {
: s& ^- v5 w0 N/ l& ]        {0 W( [% Z7 R1 ?. L+ s- {" D. y
                .active_low = 0,
9 F( r, A* T2 w% Y9 b* a  X5 r                .gpio = DA850_USER_LED0,& C) A. y1 \3 B5 s
                .name = "user_led0",
* N7 p$ ~# p6 `# z2 o7 R  R                .default_trigger = "default-on",
' s- G2 G; C) |6 D        },
& G, Q5 N- T) |' q8 k# Y        {
4 J' ~5 T! a/ q/ M& M, H2 w! v9 M                .active_low = 0,' m' {+ g$ L& K# n! S
                .gpio = DA850_USER_LED1,# e- j' w; t# V; U* z& q! e
                .name = "user_led1",
* p4 t5 B0 ?7 j5 E0 @0 l                .default_trigger = "default-on",
8 t5 K9 R* t7 C# M' c        },
$ S- G- o1 y7 r1 n4 F; o        {4 Y: Y! t' \% j; I; `
                .active_low = 0,
1 A3 h! q. u6 {$ T$ _                .gpio = DA850_USER_LED2,8 n: j  U4 r. M" v6 e: t
                .name = "user_led2",
: e9 }! _$ M- \: {                .default_trigger = "default-on",% k& F6 W4 M- Y+ p  U4 q
        },8 L& T) m0 M' t7 ~5 |# K+ v9 c
        {
/ ?8 i# z% Q* e  O9 T+ ^* R                .active_low = 0,+ ^  s! K4 g  j' g  V  [
                .gpio = DA850_USER_LED3,, o' t. F' e7 N! b2 S5 G! w
                .name = "user_led3",# n! {) W! v, |0 j" N
                .default_trigger = "default-on",
: q+ [8 Q  \% Y4 K/ p$ c7 F, `        },# N( Z( p  x# B+ ~
};7 ?' ~5 w* k  F5 B! J! @
- ?/ ^% |1 F8 ~! B4 ~
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 g! b8 B% e( A4 g4 ?5 ?
        .leds = da850_evm_tl_leds,. l2 m0 s. t. o; _( l0 ~/ U1 \, P' Y
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" }8 k4 U6 P/ J};5 w  B9 `9 M7 u: |, z# Y; n1 Y/ b
3 `& ~+ ~3 c0 W! }% R; m- t% o
static void led_dev_release(struct device *dev)4 e( U( E( f2 O3 F$ |' P! k
{
/ T) H$ r3 L6 k$ o3 W' s0 N};3 q/ H# x) j( M8 n4 B2 b

( \" o8 ^5 I- S: rstatic struct platform_device da850_evm_tl_leds_device = {
2 t$ s8 W( ?; l6 E0 `" j        .name                = "leds-gpio",9 I5 G2 x1 I( y+ j. N; J
        .id                = 1,% G* }/ \. z: r% R1 A  o+ i/ T  J
        .dev = {/ `6 i; J/ g# U2 M; A; B
                .platform_data = &da850_evm_tl_leds_pdata,7 F3 [3 w: j5 L5 q
                .release = led_dev_release," {; c  T- [: t
        }/ e) J. T1 H1 }( S4 G) G% }
};
; c9 f6 k! V# V# K
  [3 a' G3 ^. N! Astatic int __init led_platform_init(void)) z" L' i3 s) J! _4 ?9 ~9 U
{8 ?% G8 D$ N( O9 c& N+ |) g
        int ret;
! R5 x# M  e4 R  Y' N( U#if 0
. F# c: F. C7 o$ J8 R$ R        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 ?! u( ^3 o% N* \7 x
        if (ret)$ Y7 A6 m' |& U# G  G! G4 ?
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% q" E8 p/ }7 T                                "%d\n", ret);
  `) K" B# P, E8 M; y#endif
" P* i/ h  Z) L        ret = platform_device_register(&da850_evm_tl_leds_device);' |8 O! A! M# F% F2 p1 X
        if (ret)
+ J; b' f3 [/ l: W0 }2 w                pr_warning("Could not register som GPIO expander LEDS");
7 N6 T7 |' o* n  T. W        else
1 i) S  a- g5 j+ x' }+ N                printk(KERN_INFO "LED register sucessful!\n");8 {0 r" k5 L  Q% @/ ^
+ P; i8 [/ q4 b7 @, d
        return ret;; M9 a2 r* D1 ^  X% n) o- v5 [
}6 w8 n% v5 R6 m
$ S  g! I; N$ B: z
static void __exit led_platform_exit(void)+ }, V, d3 M; H/ Y* E2 |. q$ z4 `0 ~
{
3 u: Z+ [* F) c4 |5 D$ e( F) X        platform_device_unregister(&da850_evm_tl_leds_device);& L# \  P3 ^& D3 `' `- t

! w' o2 ?8 \3 @/ M7 H( [; E        printk(KERN_INFO "LED unregister!\n");% P, ]* d+ h& O6 R+ x
}  B2 w  j( ~( g

' s8 t1 {) B  u7 L+ [3 l- dmodule_init(led_platform_init);5 t" A0 G  a% b0 l- `0 h$ E  q
module_exit(led_platform_exit);
" d; c. K& t; M' ^: `( j$ G& D  j, s! H9 }* g4 S% f6 ]
MODULE_DESCRIPTION("Led platform driver");" _3 E' H) [" L9 F
MODULE_AUTHOR("Tronlong");
7 Z5 x6 x) X1 W8 `MODULE_LICENSE("GPL");
3 l5 X' D+ M7 z: A" ~/ ?
4 J) [  R1 V+ z" d1 @8 _- E
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-7 05:50 , Processed in 0.042766 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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