RT-thread-학습 노트 2 직렬 장치 추가

오늘 직렬 장 치 를 추가 합 니 다.직렬 ESP 8266 은 urt 2 통신 을 사용 합 니 다.urt 1 을 디 버 깅 직렬 로 사용 하기 때 문 입 니 다.
urt.c 에서 urt 밑바닥 을 초기 화 합 니 다.이때 urt.h 에서 RT 를 확보 합 니 다.USING_UART 2 는 define 이면 돼 요.
스 레 드 만 들 기
/* wifi thread entry */
static void wifi_thread_entry(void* parameter)
{
rt_device_t uart_wifi_dev;

uart_wifi_dev = rt_device_find("uart2");

if(uart_wifi_dev!=RT_NULL)
{
rt_device_open(uart_wifi_dev, RT_DEVICE_OFLAG_RDWR);
while(1)
{
rt_device_write(uart_wifi_dev,0,"Hello Wi-Fi!\r
",14); rt_thread_delay(RT_TICK_PER_SECOND); } } }

시작 루틴
/* wifi thread entry */
static void wifi_thread_entry(void* parameter)
{
rt_device_t uart_wifi_dev;

uart_wifi_dev = rt_device_find("uart2");

if(uart_wifi_dev!=RT_NULL)
{
rt_device_open(uart_wifi_dev, RT_DEVICE_OFLAG_RDWR);
while(1)
{
rt_device_write(uart_wifi_dev,0,"Hello Wi-Fi!\r
",14); rt_thread_delay(RT_TICK_PER_SECOND); } } }

debug 직렬 포트 보기
msh >ps  thread  pri  status      sp     stack size max used   left tick  error -------- ---- ------- ---------- ---------- ---------- ---------- --- wifi     0x14 suspend 0x00000084 0x00000100 0x0000009c 0x00000014 000 led      0x14 suspend 0x0000007c 0x00000100 0x0000007c 0x00000014 000 tshell   0x19 ready   0x0000008c 0x00000400 0x0000013c 0x00000006 000 tidle    0x1f ready   0x00000050 0x00000100 0x00000050 0x0000001a 000
urt 2 직렬 포트 보기,
Hello Wi-Fi! Hello Wi-Fi! Hello Wi-Fi! Hello Wi-Fi! Hello Wi-Fi! Hello Wi-Fi! Hello Wi-Fi!
이로써 와 이 파이 가 사용 하 는 직렬 연결 이 되 었 습 니 다.다음은 와 이 파 이 를 연결 하 는 것 입 니 다.

좋은 웹페이지 즐겨찾기