File indexing completed on 2025-05-11 08:23:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 #include <rtems/bspIo.h>
0045 #include <rtems/sysinit.h>
0046 #include <stdint.h>
0047 #include <string.h>
0048 #include <bsp/tms570-sci-driver.h>
0049
0050 #define TMS570_CONSOLE (&driver_context_table[0])
0051
0052
0053
0054
0055
0056
0057
0058
0059 static void tms570_debug_console_out(char ch)
0060 {
0061 tms570_sci_context *ctx = TMS570_CONSOLE;
0062 volatile tms570_sci_t *regs = ctx->regs;
0063
0064 while ( true ) {
0065 rtems_interrupt_level level;
0066
0067 while ( ( regs->FLR & TMS570_SCI_FLR_TXRDY ) == 0) {
0068
0069 }
0070
0071 rtems_interrupt_disable( level );
0072
0073 if ( ( regs->FLR & TMS570_SCI_FLR_TXRDY ) != 0) {
0074 regs->TD = ch;
0075 rtems_interrupt_enable( level );
0076
0077 break;
0078 }
0079
0080 rtems_interrupt_enable( level );
0081 }
0082
0083 while ( ( regs->FLR & TMS570_SCI_FLR_TX_EMPTY ) == 0) {
0084
0085 }
0086 }
0087
0088 static void tms570_debug_console_init(void)
0089 {
0090 tms570_sci_context *ctx = TMS570_CONSOLE;
0091 struct termios term;
0092
0093 tms570_sci_initialize(ctx);
0094 memset(&term, 0, sizeof(term));
0095 term.c_ospeed = B115200;
0096 tms570_sci_set_attributes(&ctx->base, &term);
0097 BSP_output_char = tms570_debug_console_out;
0098 }
0099
0100 static void tms570_debug_console_early_init(char c)
0101 {
0102 tms570_debug_console_init();
0103 tms570_debug_console_out(c);
0104 }
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114 static int tms570_debug_console_in( void )
0115 {
0116 tms570_sci_context *ctx = TMS570_CONSOLE;
0117 volatile tms570_sci_t *regs = ctx->regs;
0118 rtems_interrupt_level level;
0119 int c;
0120
0121 rtems_interrupt_disable(level);
0122
0123 if ( regs->FLR & TMS570_SCI_FLR_RXRDY ) {
0124 c = (unsigned char) regs->RD;
0125 } else {
0126 c = -1;
0127 }
0128
0129 rtems_interrupt_enable(level);
0130
0131 return c;
0132 }
0133
0134 BSP_output_char_function_type BSP_output_char =
0135 tms570_debug_console_early_init;
0136
0137 BSP_polling_getchar_function_type BSP_poll_char = tms570_debug_console_in;
0138
0139 RTEMS_SYSINIT_ITEM(
0140 tms570_debug_console_init,
0141 RTEMS_SYSINIT_BSP_START,
0142 RTEMS_SYSINIT_ORDER_LAST_BUT_5
0143 );