luat_shell_air101.c 827 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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] = {0};
  19. if(uartid >= 100)
  20. {
  21. int l = 1;
  22. while (l > 0) {
  23. l = luat_uart_read(0, buff, 512);
  24. //printf("uart read buff %d %s\n", l, buff);
  25. if (l > 0)
  26. luat_shell_push(buff, l);
  27. }
  28. }
  29. return 0;
  30. }
  31. void luat_shell_poweron(int _drv) {
  32. tls_uart_rx_callback_register(0, luat_shell_uart_cb, NULL);
  33. }