关于STM32单片机的问题2 - 问答 - 电子技术论坛 - 最好最受欢迎电子论坛!

关于STM32单片机的问题2

wangxd5429 ( 楼主 ) 2015-11-17 08:16:05  只看该作者 倒序浏览

" e( A" X7 D* Q+ r. x
各位高手,小弟正在调试一个基于WIFI控制电机的应用。操作系统是mico,开发板是mico-3165。庆科提供了TCP server的源码,测试这个源码时发现,没有执行连接AP的操作。单步调试这个源码,进入mico_system_init.c这个文件中的mico_system_init函数,继续单步调试,运行到“#ifdef

2 o) b7 A; d: H! d3 w6 l! V
MICO_WLAN_CONNECtiON_ENABLE”,mico_config.h中已经定义了
; {  e- k9 o. A& S/ s
MICO_WLAN_CONNECTION_ENABLE这个宏,但是系统没有进入这个分支运行,而是直接跳转到了最后一行“return err”,请教各位高手其中的原因。谢谢。mico_system_init函数的源码如下:
/ A% n  h! ~) H* w! R8 x% l
OSStatus  mico_system_init( mico_Context_t* in_context)

0 T9 Z% ?9 I: ~" k+ d8 |- _+ t3 d
{
$ {0 R0 Z( z/ S
OSStatus err = kNoErr;

9 S4 @/ ]9 X1 a1 q; e4 J; n1 V5 ~9 @

' X' N9 s3 b+ v9 O3 D0 Q6 k: X4 D
require_action( in_context, exit, err = kNotPreparedErr );

8 U( d  X1 Q+ L" o4 m2 @$ o

; C( e8 g% H4 D3 E! F
/* Initialize power management daemen */
% G  M. G" z6 t- M4 |
err = mico_system_power_daemon_start( in_context );/*启动电源管理后台*/

0 D) k1 S) z/ D) u5 t3 U  h
require_noerr( err, exit );

6 X+ A) L% P( t( q" j
. G8 D  b/ x, r( Q7 g, {
/* Initialize mico notify system */

# {% F$ D) O$ @4 N; K9 V
err = system_notification_init( in_context );/*初始化通知事件回调机制*/
) y  x) c: O; r; \3 d
require_noerr( err, exit );

. m' A0 t+ g  }

: _+ n3 j7 `1 M7 `
#ifdef mico_system_MONITOR_ENABLE
  ^; W' h0 s2 ^# M
/* MiCO system monitor */
* l9 G4 c) P5 j4 J0 i. n. s+ K
err = mico_system_monitor_daemen_start( );
8 C9 C; C* d$ V* v$ P* K& X
require_noerr( err, exit );
; e4 Y5 M7 R" R1 V6 |: Y
#endif

  d8 s3 ?3 S$ @, z1 [: Z
& [, Z* K* k/ H4 J. h# J
#ifdef MICO_CLI_ENABLE
- v" A# w0 P9 a! K- Z$ l/ u
/*初始化命令行接口, MiCO command line interface */
$ v' y- P. k; u. g( [' @
cli_init();

' i: b8 M% V4 m
#endif
! I7 o( Y- C3 X
2 D# q) y! ^) t( w- q) G5 k) S7 E
/*网卡驱动和TCP/IP协议栈初始化, Network PHY driver and tcp/ipstatic init */
, x$ M8 T  u% U% S
err = system_network_daemen_start( in_context );

7 c, [3 c( k: [4 k  Q
require_noerr( err, exit );

$ t. a# Z6 p5 n
# V/ G% R# h  X. W4 `
#ifdef USE_MiCOKit_EXT

) ~! ~" U, }+ N: Z) a; C9 d
/*如果按键按下,则测试扩展板. user test mode to testMiCOKit-EXT board */
/ Y) @: e2 h& Q2 d8 @
if(MicoExtShouldEnterTestMode()){

' v3 Z: h. m  I+ M
   system_log("Enter ext-board test mode by key2.");

( T( N  }- @" o% l7 T/ s' @' v* u
   micokit_ext_mfg_test(in_context);

$ K0 [# p  p3 s& Q; _( z
}
3 i4 b6 a! B0 _  n9 g* g8 e: O6 S; g
#endif

- ~- k6 E2 @6 H  s! l
. b0 y2 ~3 P, K* H$ x4 M2 T
#ifdef MICO_WLAN_CONNECTION_ENABLE

* s: \7 E: ]% n
if( in_context->flashContentInRam.micoSystemConfig.configured ==wLanUnConfigured ||

! d# k8 B! K" ?- O, O. E- t% w
     in_context->flashContentInRam.micoSystemConfig.configured ==unConfigured){
# b- D5 d" p- I1 }8 W. v, c
   system_log("Empty configuration. Starting configurationmode...");

3 a3 a  M8 B8 H9 O. r0 c
) q8 V: W* T$ ?5 `9 o4 Q) q
#if (MICO_CONFIG_MODE ==CONFIG_MODE_EASYLINK) ||
4 K9 j& A- k- B( X% m7 y3 h* i0 Y
   (MICO_CONFIG_MODE == CONFIG_MODE_SOFT_AP) ||  

" K" N% C- H( D, a4 n
    (MICO_CONFIG_MODE == CONFIG_MODE_EASYLINK_WITH_SOFTAP)
& v+ {) F8 Q  N3 |* P+ ~& v$ D
   err = system_easylink_start( in_context );/*启动EASYLINK*/

# W* z3 y' r: e3 ?) d- t
   require_noerr( err, exit );
1 |! m' L2 \4 k% }
#elif ( MICO_CONFIG_MODE ==CONFIG_MODE_WAC)
: E+ A  u" |% o0 z% ]( n" B
   err = mico_easylink_start( in_context );
0 d( w, r& y2 y& F; {6 W, \, N; s
   require_noerr( err, exit );
$ v/ g' j6 ^1 _7 F
#else
% H9 P4 x% t/ J" W: E5 A8 K& S
   #error "Wi-Fi configuration mode is not defined"
& i4 A2 Q2 [+ n% O. M
#endif

- w0 Y& E( I5 n/ z+ B
}
  ?: E) T( [; n
#ifdef MFG_MODE_AUTO

; t1 k9 k5 J4 t1 C  r9 E% k/ z
else if( in_context->flashContentInRam.micoSystemConfig.configured ==mfgConfigured ){

: |1 ]6 t- m; A
   system_log( "Enter MFG mode automatically" );

* P/ d5 ]: q/ }% N  h% }
   mico_mfg_test( in_context );

2 h+ V$ |9 m( n  p, ~' Y5 T2 ~
   mico_thread_sleep( MICO_NEVER_TIMEOUT );

2 Y, v* I; D" M+ D" {* z
}
; l$ k1 |, z* B5 C! C. s
#endif
4 g  C. v8 }' w% {" K) b
else{
- W. b8 m( |1 ?9 H: D
   system_log("Available configuration. Starting Wi-Ficonnection...");
& W, i0 n/ ?; k/ V& B
   system_connect_wifi_fast( in_context );/*建立WIFI连接*/

% p: c6 e0 ?# ^2 i& M
}
: y- N6 o( H* X6 J+ N
#endif

# V) m. r+ A) `) [# c' }: e

$ R3 s: u$ R5 W; d  `7 S
/*Local configuration server*/
" Z3 }  O) {# }: R9 K
#ifdef MICO_CONFIG_SERVER_ENABLE
  j; ]; ]/ Q+ b: T, j
config_server_start( in_context );/*创建本地配置服务器*/

: ~5 \/ r6 U8 A" @) V
#endif

3 P2 s% B3 R: i# A3 W

( O" i! K+ w2 t* l, l; }' z
require_noerr_action( err, exit, system_log("Closing main threadwith err num: %d.", err) );

& G1 V" Z7 m7 _. B1 x
exit:
0 X2 o6 }; f) e1 x3 Z* `
" Z' Z, _4 k7 E9 i( R3 }
return err;
}
9 a( m: a6 E; E( f  E! E

0个回复

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

本版积分规则


关闭

站长推荐上一条 /6 下一条

小黑屋|手机版|Archiver|电子发烧友 ( 湘ICP备2023018690号 )

GMT+8, 2024-11-21 01:32 , Processed in 0.714715 second(s), Total 35, Slave 25 queries .

Powered by 电子发烧友网

© 2015 bbs.elecfans.com

微信扫描
快速回复 返回顶部 返回列表