main.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #include "nim_config.h"
  2. #include "lwiplib.h"
  3. #include "lwipopts.h"
  4. #include "hlx.h"
  5. #define LEN_IP_ADDR (4u)
  6. #define ASCII_NUM_IDX (48u)
  7. void DeviceInit();
  8. char* dd;
  9. int main()
  10. {
  11. DeviceInit();
  12. ConsolePuts("\r\n ============NIM DSP START===========.\r\n", -1);
  13. lwip_tcp_init(TCP_SERVER_PORT); //开启本设备TCP服务器
  14. // 主循环
  15. float t = 0;
  16. #define ALGORITHM_SIZE 1000
  17. for (;;)
  18. {
  19. if(t>2){
  20. t=0;
  21. }
  22. t += 0.1;
  23. // 发送数据
  24. float ch1[ALGORITHM_SIZE];
  25. float ch2[ALGORITHM_SIZE];
  26. int i=0;
  27. for(i = 0;i<ALGORITHM_SIZE;i++)
  28. {
  29. ch1[i] = (t*i);
  30. }
  31. emg_denoised(ch1, ALGORITHM_SIZE, 1000, ch2);
  32. // 发送帧尾
  33. lwip_udp_send_vofa2(ch1,ch2,sizeof(ch1)/sizeof(float));
  34. // ConsoleRecvWait(10);
  35. // if (ConsoleRecvFlag() == REV_OK)
  36. // {
  37. // unsigned char *data = ConsoleRecvData();
  38. // lwip_udp_send_gui(sdata, sizeof(sdata));
  39. // ConsolePrintf("data %s,len %d,%d",sdata,sizeof(sdata),sizeof(struct pbuf));
  40. // ConsoleRecvClear();
  41. // }
  42. short s1[ALGORITHM_SIZE] = {0};
  43. for(i = 0;i<ALGORITHM_SIZE;i++)
  44. {
  45. s1[i] = i;
  46. }
  47. //lwip_udp_send_gui((unsigned char*)s1,sizeof(s1));
  48. HlxMain();
  49. }
  50. }
  51. /**
  52. * @title 全局中断
  53. */
  54. void InterruptInit(void)
  55. {
  56. // 初始化 DSP 中断控制器
  57. IntDSPINTCInit();
  58. // 使能 DSP 全局中断
  59. IntGlobalEnable();
  60. }
  61. /**
  62. * 设备初始化
  63. */
  64. void DeviceInit()
  65. {
  66. InterruptInit();
  67. ConsoleDeviceInit();//控制台初始化
  68. lwip_device_init(); //以太网模块初始化
  69. HlxInit();
  70. }