|
里面的程序封裝已寫(xiě)好但是沒(méi)有在主函數(shù)里調(diào)用,需要大家把程序
理解透再自行利用函數(shù)編寫(xiě)
單片機(jī)源程序如下:
- #include "common.h"
- #include "MK60_uart.h"
- #include "my.h"
- /*!
- * @brief 無(wú)線調(diào)參--從字符串中提取參數(shù)
- * @param UARTn_e 模塊號(hào)(UART0~UART5)
- * @param * Dbg_Channel 參數(shù)通道號(hào)
- * @param * Dbg_parameter 調(diào)試的參數(shù)
- * @return 是否本次獲得信息
- * @since 2018-10-22
- * Sample usage:
- static char Dbg_Channel; //調(diào)試通道(共9個(gè))
- static float Dbg_parameter = 0; //調(diào)試參數(shù)
-
- if (wireless_debug(UART4, &Dbg_Channel, &Dbg_parameter) )
- {
- printf("%c %f\n", Dbg_Channel, Dbg_parameter);
-
- //用戶在此對(duì)參數(shù)進(jìn)行操作
- }
- */
- int wireless_debug(UARTn_e uratn,char* Dbg_Channel,float* Dbg_parameter)
- {
- static char str[100];
- static char num_str = 0;
-
- if ( Int_receive_str (uratn, str, &num_str) )
- {
- //printf("{#成功接收字符%d個(gè):%s}$", num_str, str);
- *Dbg_Channel = *(str+1);
- //printf("{調(diào)試通道:%c}", *Dbg_Channel); //獲取通道
- *Dbg_parameter = 0;
- for (int temp=num_str-2; *(str+temp)!=':'; temp-=1)
- {
- //printf("{%d }",*(str+temp)-48);
- (*Dbg_parameter) += ( *(str+temp)-48 )*pow(10,(num_str-2-temp));
-
- }
- (*Dbg_parameter) = (*Dbg_parameter*0.01);
- num_str = 0;
- return 1;
- }
- else
- return 0;
- }
復(fù)制代碼
所有資料51hei提供下載:
平衡車(chē)2.rar
(2.56 MB, 下載次數(shù): 34)
2018-11-4 23:56 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
評(píng)分
-
查看全部評(píng)分
|