- /* retarget the C library printf function to the USART */
- int fputc(int ch, FILE *f)
- {
- usart_data_transmit(USART0, (uint8_t)ch);
- while (RESET == usart_flag_get(USART0, USART_FLAG_TBE))
- ;
- return ch;
- }
-
- void USART0_DMA_Printf(const char *format, ...)
- {
- static char buffer[100];//数组大小的定义?增加static防止数组被回收
-
- va_list args;
- va_start(args, format);
- uint16_t len = vsnprintf((char *)buffer, sizeof(buffer), (char *)format, args);
- va_end(args);
-
- dma_channel_disable(DMA0, DMA_CH3);
- dma_memory_address_config(DMA0, DMA_CH3, (uint32_t)buffer);
- dma_transfer_number_config(DMA0, DMA_CH3, len);
- dma_channel_enable(DMA0, DMA_CH3);
- }
|