里面的程序封装已写好但是没有在主函数里调用,需要大家把程序
理解透再自行利用函数编写
单片机源程序如下:
- #include "common.h"
- #include "MK60_uart.h"
- #include "my.h"
- /*!
- * @brief 无线调参--从字符串中提取参数
- * @param UARTn_e 模块号(UART0~UART5)
- * @param * Dbg_Channel 参数通道号
- * @param * Dbg_parameter 调试的参数
- * @return 是否本次获得信息
- * @since 2018-10-22
- * Sample usage:
- static char Dbg_Channel; //调试通道(共9个)
- static float Dbg_parameter = 0; //调试参数
-
- if (wireless_debug(UART4, &Dbg_Channel, &Dbg_parameter) )
- {
- printf("%c %f\n", Dbg_Channel, Dbg_parameter);
-
- //用户在此对参数进行操作
- }
- */
- 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个:%s}$", num_str, str);
- *Dbg_Channel = *(str+1);
- //printf("{调试通道:%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;
- }
复制代码
所有资料51hei提供下载:
平衡车2.rar
(2.56 MB, 下载次数: 34)
|