luat_shell_air101.c 776 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "luat_shell.h"
  2. #include "wm_include.h"
  3. #define LUAT_LOG_TAG "luat.shell"
  4. #include "luat_log.h"
  5. #include "wm_uart.h"
  6. #include "luat_uart.h"
  7. void luat_shell_write(char* buff, size_t len) {
  8. int i=0;
  9. while (i < len){
  10. while(tls_reg_read32(HR_UART0_FIFO_STATUS) & 0x3F);
  11. tls_reg_write32(HR_UART0_TX_WIN, (unsigned int)buff[i++]);
  12. }
  13. }
  14. void luat_shell_notify_recv(void) {
  15. }
  16. static int16_t luat_shell_uart_cb(uint16_t len, void* user_data){
  17. int uartid = (int)user_data;
  18. char buff[512];
  19. if(uartid >= 100)
  20. {
  21. int l = 1;
  22. while (l > 0) {
  23. l = luat_uart_read(0, buff, 512);
  24. if (l > 0)
  25. luat_shell_push(buff, 0, l);
  26. }
  27. }
  28. return 0;
  29. }
  30. void luat_shell_poweron(int _drv) {
  31. tls_uart_rx_callback_register(0, luat_shell_uart_cb, NULL);
  32. }