| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- /**
- * @file shell_port.c
- * @author Letter (NevermindZZT@gmail.com)
- * @brief
- * @version 0.1
- * @date 2019-02-22
- *
- * @copyright (c) 2019 Letter
- *
- */
- #include "shell.h"
- // #include <stdio.h>
- // #include <dirent.h>
- // #include <unistd.h>
- // #include <stddef.h>
- // #include <string.h>
- #include <sys/time.h>
- #include <string.h>
- #include <stdio.h>
- // #include <pthread.h>
- Shell shell;
- char shellBuffer[512];
- /**
- * @brief 获取系统tick
- *
- * @return unsigned int 系统tick
- */
- unsigned int userGetTick()
- {
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return (tv.tv_sec * 1000 + tv.tv_usec / 1000) & 0x7FFFFFFF;
- }
- /**
- * @brief 用户shell写
- *
- * @param data 数据
- */
- unsigned short userShellWrite(char *data, unsigned short len)
- {
- unsigned short length = len;
- while (length--)
- {
- putchar(*data++);
- }
- return len;
- }
- /**
- * @brief 用户shell读
- *
- * @param data 数据
- * @return char 状态
- */
- unsigned short userShellRead(char *data, unsigned short len)
- {
- unsigned short length = len;
- while (length--)
- {
- *data++ = getchar();
- }
- return len;
- }
- /**
- * @brief 用户shell初始化
- *
- */
- void userShellInit(void)
- {
- shell.write = userShellWrite;
- shell.read = userShellRead;
- shellInit(&shell, shellBuffer, 512);
- shellTask(&shell);
- }
|