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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
9 z% o2 h# _, D! O2 B+ `/ Q( d$ K#include <linux/init.h>
' E* q# s4 ?2 O5 z7 z  [#include <linux/module.h>
! J! y9 ]. Z3 [( W# g( Z2 z* n#include <linux/kernel.h>: M1 S6 v) M3 P5 L
#include <linux/types.h>1 C; d" g# Q6 ^2 f& h
#include <linux/gpio.h>
5 L4 T# _% X) [) B' |) L#include <linux/leds.h>
+ _9 m& e1 ~% ]1 e4 ?, ]#include <linux/platform_device.h>1 G* ~! R( R8 c( }# t3 J
% h. u  C* D7 b
#include <asm/mach-types.h>
6 b/ e8 ~) ~9 F#include <asm/mach/arch.h>
/ C! u) q& c& F/ b& ?7 d7 s#include <mach/da8xx.h>
. f0 D. z- U! {$ W0 a#include <mach/mux.h>
! V# r- q4 @0 S- k( Q, G% Z$ C6 ^4 ]8 F# |( ]! V# D5 m9 `
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
) q, N2 h. W4 i7 c- q# m3 @  k+ p5 P/ B#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
- [: d8 V1 f8 a# T#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
( l# r( i) A6 N: S  ~#define DA850_USER_LED3        GPIO_TO_PIN(0, 2); x* i. t* \$ {4 ?% H) ?1 s
- A& S: b5 u- Q9 o- X5 \6 o- P" w
/* assign the tl som board LED-GPIOs*/
, T& Z8 t- i" E9 b6 @& @& jstatic const short da850_evm_tl_user_led_pins[] = {
& ^, f* A" }% H7 J8 g        /* These pins are definition at <mach/mux.h> file */
$ B# Y4 C  Q. i5 b+ Z' X        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 F' W! k6 E5 i2 H
        -1+ T; D2 v( H0 o8 k4 I; u6 T$ L
};: x: z4 r6 V6 ^, ?0 H
1 E+ G: F+ A! U' o
static struct gpio_led da850_evm_tl_leds[] = {
9 M* g6 s9 Q1 x& `% y5 ^7 h$ l        {
- a: Z3 V4 h4 T4 q5 D8 u: b( D                .active_low = 0,
2 d1 L. l. d. m4 g% a7 h                .gpio = DA850_USER_LED0,
5 ^# C% I' }5 Z* h3 f( G1 j                .name = "user_led0"," N5 J2 G) j9 j0 ]/ T% p8 ^( M! d3 X* e
                .default_trigger = "default-on",9 M2 {7 C9 b- C% O( K: O$ z
        },
8 M/ E2 h% d9 t' j  q        {
1 K( L  j! }: O8 Z+ _+ b                .active_low = 0,
3 ^; w$ C2 t. M                .gpio = DA850_USER_LED1,
9 ~9 T" V0 G  u- n" ~* K                .name = "user_led1",; s- ^* Z' Z3 e  s; k
                .default_trigger = "default-on",. R" B! Z9 o) b0 d
        },
2 L: }, r- O+ K4 w# ?' p% l- X0 _        {
7 g! K5 J4 ]  \0 q) V% c" h5 s                .active_low = 0,
% b$ J) G4 T9 Y2 ^( N4 ?                .gpio = DA850_USER_LED2,
5 L$ U; H! ~# f& z6 a                .name = "user_led2",. w! w/ R% Y3 ]# y7 A9 L
                .default_trigger = "default-on",
8 s& H) s2 C* I        },
/ k0 R: J5 y9 Z" Z/ N0 o        {
0 N* f1 n. f7 _2 l* [/ u                .active_low = 0,
2 t% [( U* s) j, T. n$ b) A                .gpio = DA850_USER_LED3,
* D$ e4 d' s* x, A( q2 G; R                .name = "user_led3",
/ U! g1 e) S7 }- U                .default_trigger = "default-on",
. s- z+ K  Y$ d/ j" w        },6 r* z  r( W% N/ ?! u+ ?, C( q4 [
};" E! E- {; Y% r& u; e; _
$ z4 d$ z$ E/ W6 P/ ?% M: K9 L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
  r+ j1 b7 O+ j* Y# \- G        .leds = da850_evm_tl_leds,
# }: ~2 M5 j5 e9 t        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 Y0 p3 t, P8 z: p};
  T5 Z5 z3 L& [, e$ Y. Z" i3 c2 X
9 E" C8 f1 j; A  jstatic void led_dev_release(struct device *dev)1 H& ^& b0 v; g4 k$ V% R
{
- N; f2 l& @$ C) G* A};
5 Q! O) G# p+ e1 R% C" [- |4 H1 b6 S5 B
static struct platform_device da850_evm_tl_leds_device = {0 b1 U( V  L$ W3 w! T
        .name                = "leds-gpio"," [5 M9 `/ Q, H+ E. q4 c
        .id                = 1,6 |0 B' F: ?, |: T' H7 V* m
        .dev = {. T( r( U$ o6 }# T. }& v0 }
                .platform_data = &da850_evm_tl_leds_pdata,
5 R3 ^1 m6 S+ x+ b, d% {. q( d3 u                .release = led_dev_release,2 w; V2 z6 Q+ k/ {9 H: l
        }$ G# a6 h! q3 a/ s( d9 i
};
. t  n  O( r& J0 D3 ?
- J  O3 Q) p% I: bstatic int __init led_platform_init(void)* _3 a- j* l! V0 t& L/ D6 H  m
{# i" z- [! V9 K1 `6 \
        int ret;
% p0 P6 V7 i: O2 E#if 0$ v; s) h+ D: c7 `
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 O# _" b. s0 K' E2 ]. O
        if (ret)/ |5 w& [( E9 @" }( g1 S& f& O
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& R* Z+ s% P2 A$ l& D' E2 h                                "%d\n", ret);8 e1 `/ ~1 a) K
#endif
" r( T- l0 ]/ D        ret = platform_device_register(&da850_evm_tl_leds_device);' z2 n. s6 s6 t! `  |+ u& H7 D' U2 I
        if (ret)3 L/ o% {" {0 ~& N, p
                pr_warning("Could not register som GPIO expander LEDS");; l9 c, t$ Z" e. f. M
        else, f& B/ U, b# V9 u
                printk(KERN_INFO "LED register sucessful!\n");! c! s4 ?) W; ?

8 C( P6 i( C6 u, K+ e" D- c! h        return ret;$ G, m2 L2 S; I! A+ d: c! k
}
% Y' |( @' A8 v7 g" M6 C" J' w$ f: P
static void __exit led_platform_exit(void)7 u5 q4 G) ^' E3 x; V0 q" W, F
{
. d5 l7 b6 e" K' O1 {) r/ \        platform_device_unregister(&da850_evm_tl_leds_device);
4 f: A9 ]* I0 c; B/ L
" P# Q0 R7 U9 I        printk(KERN_INFO "LED unregister!\n");
, w* m: I- _- Y}: }) @  ^$ I' p0 E2 ?! n- ~
3 `! q! z9 h$ E  e* [1 Q) U; k
module_init(led_platform_init);
/ t7 `$ i; U1 Z9 W# Amodule_exit(led_platform_exit);
' {0 Z! f( K  n+ U' e& o# q) r- g$ I+ l: z9 p
MODULE_DESCRIPTION("Led platform driver");
3 S, A7 [2 h+ K) K# ^0 K& lMODULE_AUTHOR("Tronlong");; F' W5 s6 g9 b( s5 ~
MODULE_LICENSE("GPL");
8 _4 R. b3 I- L5 ?7 Y% U: t0 {: H# ~! K1 P
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-16 14:01 , Processed in 0.040758 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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