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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
2 K. K8 U1 B. ~( l. J! c- f#include <linux/init.h>
$ R3 l, c6 I$ {3 m) i#include <linux/module.h>
" f- _* v; x8 c5 X" C#include <linux/kernel.h>
) D* M3 u, ^% M' r9 Y#include <linux/types.h>: g' H; |/ p- `8 e( C
#include <linux/gpio.h>- e2 A" }8 w& l
#include <linux/leds.h>
  Y$ B) H% [3 M#include <linux/platform_device.h>9 t% f( L0 @0 U+ _# E. ]' e
; C5 I+ w( n1 T* E( K  |" @5 [
#include <asm/mach-types.h>
4 g4 y& p5 Q- A#include <asm/mach/arch.h>
* o! K' ]7 r& G7 g! @+ F, V#include <mach/da8xx.h>; O& s# r# P/ T( T
#include <mach/mux.h>" Y  ?& t; H3 X/ H2 G9 a* u5 J0 z

5 y7 ?  v; y& n' k# O# j#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)6 |7 P1 Y, m" R7 o( b
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
6 D' X3 z' P6 b* S/ m#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
% x4 K. L, X6 |" P6 j5 E. |#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)- z$ J, `: p* ^4 T

) w/ m) k; J5 R! \% \: M* Z3 L8 g/* assign the tl som board LED-GPIOs*/# ?2 d! U  ]! |9 H$ T- S8 @
static const short da850_evm_tl_user_led_pins[] = {
5 q( H) ?# a, ~- x        /* These pins are definition at <mach/mux.h> file */
2 C8 \$ b7 `$ I& P) m% R        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# n3 V2 J# E/ k$ n
        -1
5 h7 F- X; C3 L0 n# [};5 U# H% Z3 B. n  G9 j6 R8 h
8 \7 C& l- V' r
static struct gpio_led da850_evm_tl_leds[] = {
# K2 R6 b# F+ M! k: u# ]5 b        {
# B. B, \) S' k# X0 a+ s6 y# g  f                .active_low = 0,
1 ~2 H; j  Z2 r5 P8 ?6 I8 `! ?6 q                .gpio = DA850_USER_LED0,# q' ~$ z# |( b( z* t
                .name = "user_led0",
9 F1 I7 a* U, J* U$ |+ S! S$ K+ x2 g* i                .default_trigger = "default-on",8 d+ u6 g; N- c( d0 U
        },
& M) P; c% D3 q- a/ j3 {0 [4 L" J        {
2 \9 K; G3 n! a) S  G2 d! T                .active_low = 0,2 n5 y* G! Q- d$ w
                .gpio = DA850_USER_LED1,
" K# `% u0 R" q0 O$ Q+ E3 B                .name = "user_led1",
4 l4 S6 Q/ D2 P. n                .default_trigger = "default-on",) J3 M* V5 t; o4 S, ~
        },
9 s- [. k$ W$ K1 X( k        {% \( n9 ?2 x9 w% {6 }. Z4 M3 A9 `
                .active_low = 0,5 r: z% Y. ?; b. X% A2 j
                .gpio = DA850_USER_LED2,$ g, S4 V( P7 ?2 L
                .name = "user_led2",
9 x$ Y7 e- v0 a; R7 F6 Q. J                .default_trigger = "default-on"," k7 I$ J, K. `. Y" S7 J7 a1 O
        },
  p7 ^+ l. r5 B. j0 N: x5 j        {
# W* ~. I: E% W" u1 L  R" X                .active_low = 0,
7 D" P6 H* x; M0 B; k                .gpio = DA850_USER_LED3,' A9 M0 \3 c- \. s! |
                .name = "user_led3",
8 i' {4 O5 T. V) A' U                .default_trigger = "default-on",
% u: u  c8 n, E% {/ |5 d        },
6 H6 [, p! B0 Q$ N};
0 K4 m/ `8 r$ z9 r2 S( Q( A/ {  o! A2 _$ q! w
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! n7 s6 n( S0 R5 N8 I, n2 x        .leds = da850_evm_tl_leds,! e+ k9 o' x3 l7 g& ?
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 x; u+ Z6 o! _' _# w9 @$ l& l};
$ \* V7 T1 K% }1 U) O' b1 s* @# ]/ M6 d
static void led_dev_release(struct device *dev)& D. _9 y) M2 q) w1 T/ @
{4 N' B) k" e( i/ I+ O# Q2 y# r
};0 M! {  y) t$ L' b8 N; O! K

+ ^5 W  i; N! i' G$ Nstatic struct platform_device da850_evm_tl_leds_device = {( t7 }1 q+ ]8 P* Y* R" X, e
        .name                = "leds-gpio",
% |! o! N3 ~  g+ a( y2 h( f* c; d        .id                = 1,
. C& v, ]! o  D6 [5 V        .dev = {
/ K, E5 ^" s) ]$ e                .platform_data = &da850_evm_tl_leds_pdata,
" H: ^* d% p- Q7 A                .release = led_dev_release,
2 H# c+ X7 w/ C- n) Y' `; O4 e9 W        }
  f6 ~8 Z/ ?6 n0 X' l3 N& D4 B3 V};% G% _% k4 [" u) Y$ t& C

* i8 p7 G/ m7 G. p5 Ustatic int __init led_platform_init(void)
# w9 h* U' ~( m9 d2 l* q{6 R; X, ~0 S3 T, E0 @1 i# f
        int ret;  d. i: S! w% F9 g  a) j
#if 0% Y  g5 h% K/ r) W$ x( X- a) n& a, I
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 W0 z- t6 O& f0 F        if (ret)
: p2 [# D: W+ U7 b% u                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" [- R  q0 Y7 d9 }& q7 H7 _
                                "%d\n", ret);
& e) j% P4 Y' z+ a0 `1 |0 I% h0 ^+ ?#endif4 r/ e! }' v* x
        ret = platform_device_register(&da850_evm_tl_leds_device);
/ H3 S" D3 ]3 p/ P/ J, T* t* `        if (ret)3 n9 s! F2 c2 z3 F1 x- w2 ?" d  n& r
                pr_warning("Could not register som GPIO expander LEDS");( w- z4 T8 `+ c# H' U: V7 A! V, l
        else
  x  z% q: x2 Q, s; E                printk(KERN_INFO "LED register sucessful!\n");- [. b4 B: X; r9 U
7 F3 }* \& q' }% i
        return ret;
$ F  t' @- `$ D. P3 z}+ [& V( Q0 u3 v& y% e8 i. M
' i. h" R  g% d; A
static void __exit led_platform_exit(void)) C$ ?2 A4 C) G; l3 d' `
{
0 I& y; Q  B, O1 _$ o, u        platform_device_unregister(&da850_evm_tl_leds_device);
, L$ F9 W. |& `0 E( L( {, h# }! l5 y) n: d; A" g4 S
        printk(KERN_INFO "LED unregister!\n");
4 g/ T( K7 r5 i1 P& E}
6 v( e! z# @5 v2 F0 T* _" S' X. }2 a3 m( k
module_init(led_platform_init);  T: b! t2 R! z# P* `9 l
module_exit(led_platform_exit);
1 t4 W1 P2 H* J; f" @0 U/ n6 x* _  g$ T' l1 H
MODULE_DESCRIPTION("Led platform driver");
% L- F5 w  y! K9 c  K/ Z% FMODULE_AUTHOR("Tronlong");
7 K! {( P0 f2 A9 u$ c2 F- UMODULE_LICENSE("GPL");5 \7 _( i) ~5 m8 P2 ], w7 \% u

$ C8 g! u: v- o/ S: R* r
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-22 16:24 , Processed in 0.039231 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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