// Send string of given length void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) { for (int i = 0; i < len; i++) { // Wait until THR is empty while (1 != ALT_UART_LSR_THRE_GET(alt_read_word(ALT_UART0_LSR_ADDR))) { } // Write character to THR alt_write_word(ALT_UART0_RBR_THR_DLL_ADDR, str[i]); } }
int _write(int file, char * ptr, unsigned len, int flag ) { /* Fails if not STDOUT */ if(file != STDOUT_FILENO) { return -1; } /* Print each character to UART */ for(int i=0; i<len; i++) { /* Wait until THR is empty*/ while(1 != ALT_UART_LSR_THRE_GET(alt_read_word(ALT_UART0_LSR_ADDR))) { } /* Write character to THR */ alt_write_word(ALT_UART0_RBR_THR_DLL_ADDR, ptr[i]); } /* All printed fine */ return len; }