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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。: Q8 K; O3 |* B
#include <linux/init.h>2 ?( U* f3 g( r5 V; U1 B+ Y
#include <linux/module.h>  b  i- W% c7 C  ?5 |6 _4 f
#include <linux/kernel.h>
& \1 @7 g$ s* k7 f7 o$ C#include <linux/types.h>, ~+ ]# r8 _0 G; U+ Q3 ^
#include <linux/gpio.h>
6 _5 S, ~4 M4 w: z& y#include <linux/leds.h>
7 c% E% b* Y" c/ H#include <linux/platform_device.h>
7 B! ]  \, G0 @8 D( a6 Y  U
# A8 U8 G0 a9 d4 I; ?1 O#include <asm/mach-types.h>, U0 A0 Y" l4 Y) v% X; |# i* h. x
#include <asm/mach/arch.h>
' c) F" N8 H( B  K5 c, z#include <mach/da8xx.h>- N' s( x$ ]4 R" c0 \  p
#include <mach/mux.h>
/ R! O; a: q5 {$ ^$ e7 r  C9 ~; o7 E7 j9 P$ A/ {2 H
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)1 Z( ~; J( r$ c7 W
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)& G8 L8 m) A2 K$ V& ~5 m7 q
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)' \, ?8 o; E8 }$ `' \$ S9 f3 j
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
+ L; Q: G$ [: O, b
. z: |/ V9 {. |- F% j7 O/* assign the tl som board LED-GPIOs*/. A1 f' }3 p/ F; }/ h6 D- L, Q1 J% r
static const short da850_evm_tl_user_led_pins[] = {5 h+ P4 e# I8 q/ S( L, F2 Z% j
        /* These pins are definition at <mach/mux.h> file */
* Y* n9 n$ N+ G" c        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ [/ i3 o; P: @; [% M( a: z
        -1
4 k" M: a8 |( l# Y& |};' b# S# v( y; T, L# \2 k

7 o) s' s, X& O  V1 ?% nstatic struct gpio_led da850_evm_tl_leds[] = {5 n) ?( I% q9 Y
        {) Y. F, O' d3 ?; W" y' w
                .active_low = 0,
7 o, W3 h* z1 }  z                .gpio = DA850_USER_LED0,% l+ ]$ b* V: a
                .name = "user_led0",
& r& o; J  X" g                .default_trigger = "default-on",' a- l, b# N' _% k0 }( N& q
        },
$ N) r* i+ L: z) }        {; z6 b* o% W, {5 x$ C; F
                .active_low = 0,; y9 k# T: I  ^. Y
                .gpio = DA850_USER_LED1,2 l( i6 `& R1 m) y" S
                .name = "user_led1",, o1 c! @) m% D9 \7 O$ w
                .default_trigger = "default-on",
/ U; I$ v$ U5 q) {        },; g$ F) {# G. o: b9 w6 A) J- m1 I
        {
. x! M$ p0 f; {( }; \( z0 b2 z                .active_low = 0,
5 u7 B: U" K+ _& I9 u; f3 a                .gpio = DA850_USER_LED2,! `8 _4 v2 a% R  F8 j
                .name = "user_led2",3 S: R7 a' @, F5 i% {2 w
                .default_trigger = "default-on",2 K7 m1 z4 y: |& e5 z2 K  w
        },; P( M* Y1 g7 h1 o2 b) q$ n! \, T
        {
) ?" H2 q' N) P. q. h                .active_low = 0,
7 B+ K3 ^; }/ B# d- \0 }6 z6 R; t                .gpio = DA850_USER_LED3,! W, N' s' S0 V- [9 k" {) H
                .name = "user_led3",
" A/ ]% r6 a9 Z3 Y                .default_trigger = "default-on",) b3 t9 I& q) z  z9 g
        },
, m/ m& R; }7 N- U3 A};- c2 i* l, A0 b7 Q& E

( E1 d2 q; X; v7 |9 xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" P, U3 o& O5 @( s: R. I$ Q7 r# G        .leds = da850_evm_tl_leds,7 \. H# U$ Q9 }9 r1 [9 M
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 z9 ~: z9 O# k. _: _+ P# W
};( T$ t6 a- w( e: A0 ?1 R
* o4 s1 O" A1 I
static void led_dev_release(struct device *dev)7 K4 }' Z* V( m% ?
{
. S. g) ^% Z0 ?( _( A8 r' {% ?};
9 o1 e; ?4 Z$ c0 Z$ b: N4 L  W0 X* A! y% X* g0 h
static struct platform_device da850_evm_tl_leds_device = {
4 l4 K  O! N1 n0 F6 D/ i        .name                = "leds-gpio",4 p! P! _1 p) j2 D+ D" S4 Y" r
        .id                = 1,8 z9 |" h2 C" Y9 ~
        .dev = {
$ Y; Q' [5 K: ?: n, r% r                .platform_data = &da850_evm_tl_leds_pdata,
" }" `6 ^$ q4 r, _                .release = led_dev_release,
5 q# j3 ]) w8 V" W7 T& F' m" L        }
+ c6 [) C; \& r6 K4 ^# j; C};# t* d/ l+ L- R  A3 X3 C4 t4 B
% u  |7 Z7 Q5 p2 [
static int __init led_platform_init(void)
# \, K) z" l/ K8 W0 ?* `{
( p& G$ B3 I% O, y6 s$ g        int ret;1 W' v+ O) c3 K/ e
#if 0
" D0 D/ x& T$ z% x; l$ u, g- `        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 M) M1 B& B2 c% G  `/ ]$ R
        if (ret)
# Z" ?, h+ O; n+ R' u                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 N2 Z! S% S% X& e0 G$ J& P7 _: R
                                "%d\n", ret);
* o- l9 Z2 P/ X" Z, G3 r#endif
3 }0 G0 R1 E$ j9 Y  T8 B$ A" R7 j' ?& g        ret = platform_device_register(&da850_evm_tl_leds_device);
* @0 e; x& g: ~( {1 t; \% j, |/ I        if (ret)$ V9 f! u, D& @" O) E* X
                pr_warning("Could not register som GPIO expander LEDS");7 [; h1 n/ [5 n# G- X! M# n8 R
        else
0 b* x) d) G% Q/ v* |  k2 W                printk(KERN_INFO "LED register sucessful!\n");/ p4 _1 t) l6 }0 b4 ~; K
5 B2 X1 w3 l# W  `  T8 O& Z
        return ret;4 I* \2 n+ y1 @6 ^% a, f% ]
}6 D  f5 @7 r3 `

% A+ K7 M# l/ V4 e' K% v; istatic void __exit led_platform_exit(void): Z& Z1 [! P1 E
{
) d6 k% ^$ L& H" b        platform_device_unregister(&da850_evm_tl_leds_device);
' U- w4 N# [) l  a# j6 r8 I6 P1 X8 z8 y  e
        printk(KERN_INFO "LED unregister!\n");: j$ m* A% E& o: U
}: \# {  V" W. b1 Q: |% O) ?, R

( A) q# d$ U3 W9 Q- \/ ~- [" pmodule_init(led_platform_init);
7 f6 c0 U: M7 [7 w' Vmodule_exit(led_platform_exit);# I8 A  @( |4 x  Z; s
# m' y0 P3 }& w
MODULE_DESCRIPTION("Led platform driver");: {7 o( I4 ]+ ^1 e2 o) T
MODULE_AUTHOR("Tronlong");. b& a3 \, r; ~  E6 k7 d% @
MODULE_LICENSE("GPL");) L+ s# o& c3 i7 q

; n; a' K; r- t- t: M& N
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-22 13:57 , Processed in 0.042088 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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