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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。" y9 W' ^6 f/ V* G3 U1 V0 s* B5 I
#include <linux/init.h>
, w- c. }) B  W9 B& X#include <linux/module.h>
1 a; M) B* x3 p9 o% m/ v  L5 N#include <linux/kernel.h>
' L' E9 o+ L5 \#include <linux/types.h>- [+ }/ M3 l: q. e% t
#include <linux/gpio.h>
1 e4 R7 l; v! v#include <linux/leds.h>8 ?9 p" x& ^- }# {
#include <linux/platform_device.h>
2 ]3 F! p5 o& ~3 _
% |( p( {6 E4 _( a/ H+ b* x, p+ P#include <asm/mach-types.h>
( }' [* `( }' h9 l+ X* ~3 h6 J7 @#include <asm/mach/arch.h>
" W6 k5 D$ t: Q& Q% M#include <mach/da8xx.h>
& D6 u0 S/ N) f& a7 U- Y9 O5 j( |' m#include <mach/mux.h>  ?  d- j% V* t+ j# ^. I$ R; d

. w' E- s/ l& x#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
. S( F4 O5 N: [+ V' p#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
* Z5 C5 H! H# W) q1 V- c#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
5 Z4 a0 J& d7 r. o2 f0 G#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
3 v. K9 |9 F$ z) D$ [
& g% Z/ M9 t, x6 e4 i$ E' Z/* assign the tl som board LED-GPIOs*/
1 q/ h+ R: m! R# Y# @3 Q) I: Qstatic const short da850_evm_tl_user_led_pins[] = {
) f5 |3 S) T1 K        /* These pins are definition at <mach/mux.h> file */
' ]/ l3 G# X9 h& D        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 e/ e5 k) @5 V5 c, Y        -15 O2 }3 X. U( a6 f
};
5 J) m4 w) I  M+ G' `' ?  F. q/ U2 Z, j: `" V9 E
static struct gpio_led da850_evm_tl_leds[] = {
; Z; z# R( X/ _7 u4 J. k$ q7 ]3 b        {
, M$ x6 b, ^5 m5 ^9 @0 a& S                .active_low = 0,* X- J% e% J; ]2 e; l' ?7 ]
                .gpio = DA850_USER_LED0,
8 n2 {* `% J! R4 G9 w# k                .name = "user_led0",
. n6 n9 b% ]) ]: H0 w9 Z* Y                .default_trigger = "default-on",9 k) n& ^1 P$ \' ^& }* [  K) C  }' G
        },' U3 _. O! ?8 o) G9 @% X
        {
' @( s" s, P' q2 Y* C& |                .active_low = 0,- O9 c; w9 O' p- \7 y, N3 E
                .gpio = DA850_USER_LED1,8 {$ p# \" O6 w4 k' ^
                .name = "user_led1",; Z* j- P* p8 Y' K  Z. [
                .default_trigger = "default-on",! _2 k' |  }2 L5 G
        },; f2 v1 E* U% Y7 Y7 ]& j8 r/ i% D
        {
* f% d  s7 Q* b; ^, N7 L                .active_low = 0,
+ M1 w+ f: [2 u0 C* y, b                .gpio = DA850_USER_LED2,
8 s+ D/ t1 z/ C                .name = "user_led2",
$ [' p) `3 d' R                .default_trigger = "default-on",
. a% G! R% w# |        },
2 C4 {$ h* b! e& n        {2 W7 b' R; {3 p2 h- G! H
                .active_low = 0,* h1 _; @/ U5 Z/ V& ]# z+ n" N
                .gpio = DA850_USER_LED3,
' D9 K9 z. w1 T8 x                .name = "user_led3",
/ ~! d3 n  z) G                .default_trigger = "default-on",
$ r( H+ U" W- S8 G3 T" `$ h: d        }," Z' `* n  S# u% c5 T- g2 b$ _
};% J% V" Y: U1 A# N% B& s
. L  S" \- n& F
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 N$ b% p# h+ V0 k+ T
        .leds = da850_evm_tl_leds,$ A+ R. i& _9 {
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 E4 u7 ?  s/ ?$ F6 n+ R};
+ ]; N+ S) m9 I9 U" k) `& L- [8 f0 k2 A  q1 D' K: W
static void led_dev_release(struct device *dev)0 t0 f7 d' X7 K( ]% b
{4 g& _7 c2 l* l/ }) K
};6 h2 l, y1 a, I/ \  E' F: G

& {  s6 L2 j; P  m0 Sstatic struct platform_device da850_evm_tl_leds_device = {- o" c: W! @3 K2 o
        .name                = "leds-gpio",0 W" f9 R0 I/ D; ?
        .id                = 1,( O( ]. J% L' r: K; r3 U/ [
        .dev = {
/ k3 \. o+ y" T                .platform_data = &da850_evm_tl_leds_pdata,/ N: `  i" P9 \- |4 }- l
                .release = led_dev_release,
: h6 o; i/ p+ W  v& F3 u9 @, E        }2 l8 _/ D* c* w7 P/ N
};
* m# \  t9 L' A# k$ ~/ {, \( p: G6 ~" X/ ~2 D, a, R
static int __init led_platform_init(void)) V' q) ~" E3 T$ C) I9 m5 t
{
2 q: H* x5 `# m' Y4 i1 P4 [4 u        int ret;1 z; p( l7 u/ B7 |, v
#if 0) e  U& a# \8 |- K
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( G, n2 Y8 l8 {, m        if (ret)' \+ ^0 V7 H" l& b
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; m0 a) k$ i6 c! {/ S, w1 f4 R                                "%d\n", ret);, R5 O* Y( r- x7 ?
#endif' }7 j& `) b" F) d! \3 P9 H
        ret = platform_device_register(&da850_evm_tl_leds_device);
/ X1 s- R# y% }8 B' z: \        if (ret)
2 u" @& P+ H5 C; s8 c                pr_warning("Could not register som GPIO expander LEDS");# e9 C. B: f) r2 E
        else2 n' X( L8 S6 B
                printk(KERN_INFO "LED register sucessful!\n");
0 Z+ m* r! H% Z* B- V0 i5 U8 v7 L0 e1 r" G
        return ret;, K) c) Y, O6 b8 S2 |
}0 X2 X3 y! X. [
7 I0 q+ X2 ^& f9 b' A8 D
static void __exit led_platform_exit(void)1 R: \! H1 ^9 p- ^2 f3 y5 o
{
; h$ C6 G  x  V# X3 |! I5 Q0 X        platform_device_unregister(&da850_evm_tl_leds_device);1 L1 ?8 K. c& j) c1 s9 m8 P. {; H
1 b) x' [0 k% m( U9 B* B
        printk(KERN_INFO "LED unregister!\n");$ O  \) v- P$ Y4 c
}
4 J& I' w# C0 R# a% W, U/ O- C. f( [
2 M4 L; h2 `; I) |: l! y" Kmodule_init(led_platform_init);
! f- k7 h  ?$ O7 L' Imodule_exit(led_platform_exit);
$ k# j; K" @+ l9 P+ g, I& A; M' d# T2 n
MODULE_DESCRIPTION("Led platform driver");
0 e9 J8 @, [5 F7 h$ N# {. {$ @6 dMODULE_AUTHOR("Tronlong");7 I% q7 K! k% Z7 d5 r3 k# e
MODULE_LICENSE("GPL");
2 h' J( D1 B5 k9 C" q( m
) P- t) z- W" s
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-4 20:44 , Processed in 0.039122 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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