void DisableDebugTester(void) { //send command to disable the connection to debug tester UartPutc((char) DBG_ESCAPE); //send debug test disable command, UartPutc((char) DBG_CONNECT_DISABLE); //send debug test disable command, UartEndSimulation(); //stop simulation }
int main() { uint32_t i; /*System clock configuration*/ SystemInit(); // *(volatile uint32_t *)(0x41001014) = 0x0060100; //clock setting 48MHz /* CLK OUT Set */ // PAD_AFConfig(PAD_PA,GPIO_Pin_2, PAD_AF2); // PAD Config - CLKOUT used 3nd Function /*using debugging*/ S_UART_Init(115200); /* UART0 and UART1 configuration*/ UART_StructInit(&UART_InitStructure); /* Configure UART0 */ UART_Init(UART0,&UART_InitStructure); /* Configure UART1 */ UART_Init(UART1,&UART_InitStructure); /* Configure Uart0 Interrupt Enable*/ UART_ITConfig(UART0, (UART_IT_FLAG_TXI|UART_IT_FLAG_RXI),ENABLE); /* NVIC configuration */ NVIC_ClearPendingIRQ(UART0_IRQn); NVIC_EnableIRQ(UART0_IRQn); /* Configure Uart1 Interrupt Enable*/ UART_ITConfig(UART1,(UART_IT_FLAG_TXI|UART_IT_FLAG_RXI),ENABLE); /* NVIC configuration */ NVIC_ClearPendingIRQ(UART1_IRQn); NVIC_EnableIRQ(UART1_IRQn); /*send the data from UART0 to UART1*/ printf("Send UART0\r\n"); for(i=0;i<409600;i++) { UartPutc(UART0,(uint8_t)i); } /*send the data from UART1 to UART0*/ printf("Send UART1\r\n"); for(i=0;i<409600;i++) { UartPutc(UART1,(uint8_t)i); } /*confirm the rx/tx data counter of Uart0,1 using Uart2*/ printf("Press Any Key\r\n"); while( S_UartGetc() != 0 ) { printf("uart0_rx_cnt = %d, uart0_tx_cnt = %d\r\n",uart0_rx_cnt, uart0_tx_cnt); printf("uart1_rx_cnt = %d, uart1_tx_cnt = %d\r\n",uart1_rx_cnt, uart1_tx_cnt); } }
int32_t uart_putc(uint8_t uartNum, uint8_t ch) { if(uartNum == 0) { if(IS_BUFFER_FULL(u0tx)) { BUFFER_CLEAR(u0tx); return RET_NOK; } else { BUFFER_IN(u0tx) = ch; BUFFER_IN_MOVE(u0tx, 1); UART_ITConfig(UART0,(UART_IT_FLAG_TXI),ENABLE); } } else if(uartNum == 1) { if(IS_BUFFER_FULL(u1tx)) { BUFFER_CLEAR(u1tx); return RET_NOK; } else { UartPutc(UART1,ch); //BUFFER_IN(u1tx) = ch; //BUFFER_IN_MOVE(u1tx, 1); //UART_ITConfig(UART1,(UART_IT_FLAG_TXI),ENABLE); } } return RET_OK; }
size_t __write(int handle, const unsigned char * buffer, size_t size) { /* Remove the #if #endif pair to enable the implementation */ size_t nChars = 0; if (buffer == 0) { /* * This means that we should flush internal buffers. Since we * don't we just return. (Remember, "handle" == -1 means that all * handles should be flushed.) */ return 0; } /* This template only writes to "standard out" and "standard err", * for all other file handles it returns failure. */ for (/* Empty */; size != 0; --size) { UartPutc(*buffer++); ++nChars; } return nChars; }
__attribute__ ((used)) int _write (int fd, char *ptr, int len) { size_t i; for (i=0; i<len;i++) { UartPutc(ptr[i]); // call character output function } return len; }
int _write_r(void *reent, int fd, char *ptr, size_t len) { size_t i; for (i=0; i<len;i++) { UartPutc(ptr[i]); // call character output function in uart_stdout.c } return len; }
int main() { uint32_t i; /*System clock configuration*/ SystemInit(); /*using debugging*/ S_UART_Init(115200); /* UART0 and UART1 configuration*/ UART_StructInit(&UART_InitStructure); /* Configure UART0 */ UART_Init(UART0,&UART_InitStructure); /* Configure UART1 */ UART_Init(UART1,&UART_InitStructure); /* Configure Uart0 Interrupt Enable*/ UART_ITConfig(UART0, (UART_IT_FLAG_TXI|UART_IT_FLAG_RXI),ENABLE); /* NVIC configuration */ NVIC_ClearPendingIRQ(UART0_IRQn); NVIC_EnableIRQ(UART0_IRQn); /* Configure Uart1 Interrupt Enable*/ UART_ITConfig(UART1,(UART_IT_FLAG_TXI|UART_IT_FLAG_RXI),ENABLE); /* NVIC configuration */ NVIC_ClearPendingIRQ(UART1_IRQn); NVIC_EnableIRQ(UART1_IRQn); /*send the data from UART0 to UART1*/ printf("Send UART0\r\n"); for(i=0;i<409600;i++) { UartPutc(UART0,(uint8_t)i); } /*send the data from UART1 to UART0*/ printf("Send UART1\r\n"); for(i=0;i<409600;i++) { UartPutc(UART1,(uint8_t)i); } /*confirm the rx/tx data counter of Uart0,1 using Uart2*/ printf("Press Any Key\r\n"); while( S_UartGetc() != 0 ) { printf("uart0_rx_cnt = %d, uart0_tx_cnt = %d\r\n",uart0_rx_cnt, uart0_tx_cnt); printf("uart1_rx_cnt = %d, uart1_tx_cnt = %d\r\n",uart1_rx_cnt, uart1_tx_cnt); } }
void EnableDebugTester(void) { uint32_t i; // // Initialise GPIO from MCU to Debug Tester // //Initialize the GPIO0 higher 8 bits output value, set to 0 CMSDK_GPIO0->DATAOUT = (0x00000000); //set GPIO output to 0 for default value, disable the function strobe CMSDK_gpio_SetOutEnable (CMSDK_GPIO0, DEBUG_CMD); // set specified bit in out enable register // // Enable the Debug Tester in the testbench // // send command to enable the connection to debug tester UartPutc((char) DBG_ESCAPE); //send ESCAPE code UartPutc((char) DBG_CONNECT_ENABLE); //send debug test enable command puts("\nEnabling debug tester...\n"); // If debug tester is not present, if((CMSDK_GPIO0->DATA & DEBUG_ERROR) != 0) { puts("DBGERROR bit (debug error) asserted.\n"); puts("Debug tester not available:\n"); puts("1: The ARM_CMSDK_INCLUDE_DEBUG_TESTER macro is not defined, or\n"); puts("2: Cortex-M0 DesignStart is used\n"); puts("** TEST SKIPPED **\n"); // End simulation UartEndSimulation(); } // // Initialise the Communication Region // (Zero the 4 words above Stack Top) // for(i=0; i<4 ; i++) { DEBUGTESTERDATA[i] = 0; } }
static void UART_SendBuf(u8 *data, ulong length) { ulong i; for (i = 0; i < length; i++) { //putc (*data); UartPutc(1, *data); data++; //udelay (20); } }
void UartPuts(UART_TypeDef* UARTx, uint8_t *str) { uint8_t ch; do{ ch = *str; if(ch != (uint8_t)0x0) { UartPutc(UARTx, ch); } *str++; }while(ch != 0); }
void UartEndSimulation(void) { UartPutc((char) 0x4); // End of simulation while(1); }
void _ttywrch(int ch) { UartPutc (ch); }
int fgetc(FILE *f) { return (UartPutc(UartGetc())); }
int fputc(int ch, FILE *f) { return (UartPutc(ch)); }