/** @brief Write a string to a user-visible output location. Write a null-terminated string to the serial port, console, terminal, or other display device, such that the text is visible to the user. @param pszString A null-terminated string. */ void RedOsOutputString( const char *pszString) { if(pszString == NULL) { REDERROR(); } else { /* The arm-atollic-eabi version of putchar has been observed not to end up calling __io_putchar() (as would have been expected), so we call it directly instead. */ uint32_t ulIdx = 0U; while(pszString[ulIdx] != '\0') { __io_putchar(pszString[ulIdx]); /* Serial output often requires a \r to print newlines correctly. */ if(pszString[ulIdx] == '\n') { __io_putchar('\r'); } ulIdx++; } } }
void USART3_IRQHandler(void) { ot_u8 rxchar; if (USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) { /* Read one byte from the receive data register */ rxchar = USART_ReceiveData(USART3); if (rxchar == '\r') { uart_rx_buf[uart_rx_buf_idx++] = 0; // null terminate new_uart_rx = 1; } else if (rxchar == 8) { if (uart_rx_buf_idx > 0) { __io_putchar(8); __io_putchar(' '); __io_putchar(8); uart_rx_buf_idx--; #ifndef BLOCKING_UART_TX if (dma_running == 0) kick_dma_usart_tx(2); #endif } } else if (uart_rx_buf_idx < UART_RX_BUF_SIZE) { uart_rx_buf[uart_rx_buf_idx++] = rxchar; __io_putchar(rxchar); #ifndef BLOCKING_UART_TX if ( (dma_running == 0) && (rxchar != '\n') ) kick_dma_usart_tx(2); #endif } } if (USART_GetITStatus(USART3, USART_IT_TXE) != RESET) { USART_ClearFlag(USART3, USART_FLAG_TXE); USART_ITConfig(USART3, USART_IT_TXE, DISABLE); #ifndef BLOCKING_UART_TX usart_tx_dmafifo_out_idx += UTX_DMA_Init.DMA_BufferSize; if (usart_tx_dmafifo_out_idx == TX_DMA_FIFO_SIZE) usart_tx_dmafifo_out_idx = 0; // this was a "wrap" if (usart_tx_dmafifo_out_idx == usart_tx_dmafifo_in_idx) { // no more to send, shut down dma_running = 0; DMA_ITConfig(USART3_TX_DMA_CHANNEL, DMA_IT_TC, DISABLE); DMA_Cmd(USART3_TX_DMA_CHANNEL, DISABLE); } else { kick_dma_usart_tx(2); } #endif } // ...if (USART_GetITStatus(USART3, USART_IT_TC) != RESET) //lr = LR_U3; }
/*--------------------------------------------------------------------------*/ size_t _write(int handle, const unsigned char *buffer, size_t size) { size_t nChars = 0; if(handle != _LLIO_STDOUT && handle != _LLIO_STDERR) { return _LLIO_ERROR; } if(buffer == 0) { /* This means that we should flush internal buffers. */ /* spin until TX complete (TX is idle) */ while((SC1_UARTSTAT & SC_UARTTXIDLE) != SC_UARTTXIDLE) { } return 0; } /* ensure port is configured for UART */ if(SC1_MODE != SC1_MODE_UART) { return _LLIO_ERROR; } while(size--) { __io_putchar(*buffer++); ++nChars; } return nChars; }
int _write(int file, char* ptr, int len) { int DataIdx; for (DataIdx = 0; DataIdx < len; DataIdx++) { __io_putchar( *ptr++ ); } return len; }
int _write(int f, char*pointer, int length) { int i = 0; while (i < length) { __io_putchar(*(pointer + i)); i++; } return length; }
int _write(int file, char *ptr, int len) { int i; for (i = 0; i < len; i++) { __io_putchar( *ptr++ ); } return len; }
int _write(int file, char *ptr, int len) { int todo; for (todo = 0; todo < len; todo++) { __io_putchar( *ptr++ ); } /* Implement your write code here, this is used by puts and printf for example */ return len; }
int fputc(int ch, FILE *fp) { return __io_putchar(ch); }
int putchar (int c) { __io_putchar((char) c); return c; }