510
个编辑
更改
→实验14-二维码显示
== 实验13-TFT显示屏 ==
=== STM32L476 UART简介 SPI简介 ===USART主要功能:SPI接口说明:
- 传输奇偶校验位 CRC值可以在Tx模式下作为最后一个字节发送
- 检查接收数据字节的奇偶校验自动CRC错误检查最后接收的字节
==== TFT简介 ====
暂缺,有需要开发驱动的朋友,可以参照我们的源码和TFT使用手册。
''<span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span><span class="tlid-translation-gender-indicator translation-gender-indicator"></span>''
=== 硬件设计 ===
}
}
}
</syntaxhighlight>
==== gyu_uasrt_isr_exgui.c c等 ====此文件是gyu_uasrt_usr.c中函数的底层处理函数,为了方便大家使用,我们将其从中分离出来。这部分大家根据自己实际情况选择看或者不看,熟悉ti芯片的朋友,可以看出这部分的串口数据处理是copy的ti CC25XX芯片的。 首先是有关串口中断的结构体定义,并且根据结构体参数的具体功能,分别RX缓冲区数据长度。<syntaxhighlight lang="c++" line="1" start="30">// 串口RX缓冲区数据长度#define HAL_UART_ISR_RX_AVAIL() \ (isrCfg.rxTail >= isrCfg.rxHead) ? \ (isrCfg.rxTail - isrCfg.rxHead) TFT驱动文件,请大家查看[http: \ (RECE_BUF_MAX_LEN - isrCfg.rxHead + isrCfg.rxTail) static uartISRCfg_t isrCfg;</syntaxhighlight>初始化串口中断结构体的isrCfg。<syntaxhighlight lang="c++" line="1" start="47">void UartIsr_Init(UART_HandleTypeDef*huart){ isrCfg.rxHead = 0; isrCfg.rxTail = 0; isrCfg.rxTick = 0; isrCfg.rxShdw = 0; hUart = huart;}</syntaxhighlight>获取串口RX缓冲区中的数据,由gyu_usart_isrdoc.c的HAL_UART_StartRece()函数中调用,并指向RX缓冲区。<syntaxhighlight lang="c++" line="1" start="64">uint8_t* UartIsr_GetBuf(void){ return isrCfgiotxx.rxBuf; // 指向串口RX缓冲区}<com/syntaxhighlight>读取串口RX缓冲区中的数据的函数。<syntaxhighlight lang="c++" line="1" start="78">uint16_t UartIsr_Read(uint8_t *buf, uint16_t len){ uint16_t cnt = 0; while ((isrCfg.rxHead != isrCfg.rxTail) && (cnt < len)) { *buf++ = isrCfg.rxBuf[isrCfg.rxHead++%E8%B0%B7%E9%9B%A8%E6%98%BE%E7%A4%BA%E6%8E%A5%E5%8F%A3%E5%8E%9F%E7%90%86%E8%AF%B4%E6%98%8E 谷雨显示接口原理说明]; if (isrCfg.rxHead >= RECE_BUF_MAX_LEN) { isrCfg.rxHead = 0; } cnt++; } return cnt;}</syntaxhighlight>串口RX缓冲区数据长度获取函数。<syntaxhighlight lang="c++" line="1" start="103">uint16_t UartIsr_Avail(void){ return HAL_UART_ISR_RX_AVAIL();}</syntaxhighlight>串口轮询函数,主要目的是检测串口RX缓冲区数据,一个是是否超过了设置的缓冲区大小,另一个是是否超时了。<syntaxhighlight lang="c++" line="1" start="116">uint8_t UartIsr_Poll(void){ uint8_t evt = 0; uint16_t cnt = 0; volatile uint16_t tail = RECE_BUF_MAX_LEN - hUart->RxXferCount; if(isrCfg.rxHead != tail) { if(tail != isrCfg.rxTail) { isrCfg.rxTail = tail; if(isrCfg.rxTick == 0) { isrCfg.rxShdw = HAL_GetTick(); } isrCfg.rxTick = HAL_UART_ISR_IDLE; } else if(isrCfg.rxTick) { uint32_t Tick = HAL_GetTick(); uint32_t delta = Tick >= isrCfg.rxShdw ? (Tick - isrCfg.rxShdw ): (Tick + (UINT32_MAX - isrCfg.rxShdw)); if (isrCfg.rxTick > delta) { isrCfg.rxTick -= delta; } else { isrCfg.rxTick = 0; } } cnt = UartIsr_Avail(); } else { isrCfg.rxTick = 0; } if (cnt >= HAL_UART_ISR_FULL) { evt = HAL_UART_RX_FULL; } else if (cnt && !isrCfg.rxTick) { evt = HAL_UART_RX_TIMEOUT; } return evt;} </syntaxhighlight>。
== 实验14-二维码显示 ==