Changeset 5ca634e9 in rtems for c/src/lib/libbsp/arm/tms570
- Timestamp:
- 03/09/17 12:23:54 (7 years ago)
- Branches:
- 5, master
- Children:
- dc95663e
- Parents:
- ce5bcc87
- Location:
- c/src/lib/libbsp/arm/tms570
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/arm/tms570/console/printk-support.c
rce5bcc87 r5ca634e9 25 25 26 26 #include <rtems/bspIo.h> 27 #include <rtems/sysinit.h> 27 28 #include <stdint.h> 28 29 #include <bsp/tms570-sci.h> 29 30 #include <bsp/tms570-sci-driver.h> 30 31 32 #define TMS570_CONSOLE (&driver_context_table[0]) 31 33 32 34 /** … … 37 39 * @retval Void 38 40 */ 39 static void tms570_ putc(char ch)41 static void tms570_debug_console_putc(char ch) 40 42 { 43 tms570_sci_context *ctx = TMS570_CONSOLE; 44 volatile tms570_sci_t *regs = ctx->regs; 41 45 rtems_interrupt_level level; 42 46 43 47 rtems_interrupt_disable(level); 44 while ( ( driver_context_table[0].regs->FLR & TMS570_SCI_FLR_TXRDY ) == 0) {48 while ( ( regs->FLR & TMS570_SCI_FLR_TXRDY ) == 0) { 45 49 rtems_interrupt_flash(level); 46 50 } 47 driver_context_table[0].regs->TD = ch; 51 regs->TD = ch; 52 while ( ( regs->FLR & TMS570_SCI_FLR_TX_EMPTY ) == 0) { 53 rtems_interrupt_flash(level); 54 } 48 55 rtems_interrupt_enable(level); 49 56 } … … 56 63 * @retval Void 57 64 */ 58 static void tms570_ uart_output(char c)65 static void tms570_debug_console_out(char c) 59 66 { 60 67 if ( c == '\n' ) { 61 char r = '\r'; 62 tms570_putc(r); 68 tms570_debug_console_putc('\r'); 63 69 } 64 tms570_putc(c); 70 71 tms570_debug_console_putc(c); 72 } 73 74 static void tms570_debug_console_init(void) 75 { 76 tms570_sci_context *ctx = TMS570_CONSOLE; 77 struct termios term; 78 79 tms570_sci_initialize(ctx); 80 memset(&term, 0, sizeof(term)); 81 term.c_cflag = B115200; 82 tms570_sci_set_attributes(&ctx->base, &term); 83 BSP_output_char = tms570_debug_console_out; 84 } 85 86 static void tms570_debug_console_early_init(char c) 87 { 88 tms570_debug_console_init(); 89 tms570_debug_console_out(c); 65 90 } 66 91 … … 73 98 * @retval -1 No input character available 74 99 */ 75 static int tms570_ uart_input( void )100 static int tms570_debug_console_in( void ) 76 101 { 77 if ( driver_context_table[0].regs->FLR & TMS570_SCI_FLR_RXRDY ) { 78 return driver_context_table[0].regs->RD; 102 tms570_sci_context *ctx = TMS570_CONSOLE; 103 volatile tms570_sci_t *regs = ctx->regs; 104 rtems_interrupt_level level; 105 int c; 106 107 rtems_interrupt_disable(level); 108 109 if ( regs->FLR & TMS570_SCI_FLR_RXRDY ) { 110 c = (unsigned char) regs->RD; 79 111 } else { 80 return-1;112 c = -1; 81 113 } 114 115 rtems_interrupt_enable(level); 116 117 return c; 82 118 } 83 119 84 BSP_output_char_function_type BSP_output_char = tms570_uart_output; 85 BSP_polling_getchar_function_type BSP_poll_char = tms570_uart_input; 120 BSP_output_char_function_type BSP_output_char = 121 tms570_debug_console_early_init; 122 123 BSP_polling_getchar_function_type BSP_poll_char = tms570_debug_console_in; 124 125 RTEMS_SYSINIT_ITEM( 126 tms570_debug_console_init, 127 RTEMS_SYSINIT_BSP_START, 128 RTEMS_SYSINIT_ORDER_LAST 129 ); -
c/src/lib/libbsp/arm/tms570/console/tms570-sci.c
rce5bcc87 r5ca634e9 59 59 }; 60 60 61 void tms570_sci_initialize(tms570_sci_context *ctx) 62 { 63 uint32_t rx_pin = 1 << 1; 64 uint32_t tx_pin = 1 << 2; 65 66 /* Resec SCI peripheral */ 67 ctx->regs->GCR0 = TMS570_SCI_GCR0_RESET * 0; 68 ctx->regs->GCR0 = TMS570_SCI_GCR0_RESET * 1; 69 70 /* Clear all interrupt sources */ 71 ctx->regs->CLEARINT = 0xffffffff; 72 73 /* Map all interrupts to SCI INT0 line */ 74 ctx->regs->CLEARINTLVL = 0xffffffff; 75 76 ctx->regs->GCR1 = TMS570_SCI_GCR1_TXENA * 0 | 77 TMS570_SCI_GCR1_RXENA * 0 | 78 TMS570_SCI_GCR1_CONT * 0 | /* continue operation when debugged */ 79 TMS570_SCI_GCR1_LOOP_BACK * 0 | 80 TMS570_SCI_GCR1_POWERDOWN * 0 | 81 TMS570_SCI_GCR1_SLEEP * 0 | 82 TMS570_SCI_GCR1_SWnRST * 0 | /* reset state */ 83 TMS570_SCI_GCR1_CLOCK * 1 | /* internal clock */ 84 TMS570_SCI_GCR1_TIMING_MODE * 1 | 85 TMS570_SCI_GCR1_COMM_MODE * 0; 86 87 /* Setup connection of SCI peripheral Rx and Tx pins */ 88 ctx->regs->PIO0 = rx_pin * 1 | tx_pin * 1; /* Rx and Tx pins are not GPIO */ 89 ctx->regs->PIO3 = rx_pin * 0 | tx_pin * 0; /* Default output low */ 90 ctx->regs->PIO1 = rx_pin * 0 | tx_pin * 0; /* Input when not used by SCI */ 91 ctx->regs->PIO6 = rx_pin * 0 | tx_pin * 0; /* No open drain */ 92 ctx->regs->PIO7 = rx_pin * 0 | tx_pin * 0; /* Pull-up/down enabled */ 93 ctx->regs->PIO8 = rx_pin * 1 | tx_pin * 1; /* Select pull-up */ 94 95 /* Bring device out of software reset */ 96 ctx->regs->GCR1 |= TMS570_SCI_GCR1_SWnRST; 97 } 98 61 99 /** 62 100 * @brief Serial drivers init function … … 96 134 ) { 97 135 tms570_sci_context *ctx = &driver_context_table[minor]; 98 uint32_t rx_pin = 1 << 1; 99 uint32_t tx_pin = 1 << 2; 100 101 /* Resec SCI peripheral */ 102 ctx->regs->GCR0 = TMS570_SCI_GCR0_RESET * 0; 103 ctx->regs->GCR0 = TMS570_SCI_GCR0_RESET * 1; 104 105 /* Clear all interrupt sources */ 106 ctx->regs->CLEARINT = 0xffffffff; 107 108 /* Map all interrupts to SCI INT0 line */ 109 ctx->regs->CLEARINTLVL = 0xffffffff; 110 111 ctx->regs->GCR1 = TMS570_SCI_GCR1_TXENA * 0 | 112 TMS570_SCI_GCR1_RXENA * 0 | 113 TMS570_SCI_GCR1_CONT * 0 | /* continue operation when debugged */ 114 TMS570_SCI_GCR1_LOOP_BACK * 0 | 115 TMS570_SCI_GCR1_POWERDOWN * 0 | 116 TMS570_SCI_GCR1_SLEEP * 0 | 117 TMS570_SCI_GCR1_SWnRST * 0 | /* reset state */ 118 TMS570_SCI_GCR1_CLOCK * 1 | /* internal clock */ 119 TMS570_SCI_GCR1_TIMING_MODE * 1 | 120 TMS570_SCI_GCR1_COMM_MODE * 0; 121 122 /* Setup connection of SCI peripheral Rx and Tx pins */ 123 ctx->regs->PIO0 = rx_pin * 1 | tx_pin * 1; /* Rx and Tx pins are not GPIO */ 124 ctx->regs->PIO3 = rx_pin * 0 | tx_pin * 0; /* Default output low */ 125 ctx->regs->PIO1 = rx_pin * 0 | tx_pin * 0; /* Input when not used by SCI */ 126 ctx->regs->PIO6 = rx_pin * 0 | tx_pin * 0; /* No open drain */ 127 ctx->regs->PIO7 = rx_pin * 0 | tx_pin * 0; /* Pull-up/down enabled */ 128 ctx->regs->PIO8 = rx_pin * 1 | tx_pin * 1; /* Select pull-up */ 129 130 /* Bring device out of software reset */ 131 ctx->regs->GCR1 |= TMS570_SCI_GCR1_SWnRST; 136 137 tms570_sci_initialize(ctx); 132 138 133 139 /* … … 237 243 * @retval true peripheral setting is changed 238 244 */ 239 staticbool tms570_sci_set_attributes(245 bool tms570_sci_set_attributes( 240 246 rtems_termios_device_context *base, 241 247 const struct termios *t -
c/src/lib/libbsp/arm/tms570/include/tms570-sci-driver.h
rce5bcc87 r5ca634e9 50 50 extern tms570_sci_context driver_context_table[]; 51 51 52 void tms570_sci_initialize(tms570_sci_context *ctx); 53 54 bool tms570_sci_set_attributes( 55 rtems_termios_device_context *base, 56 const struct termios *term 57 ); 58 52 59 /** @} */ 53 60
Note: See TracChangeset
for help on using the changeset viewer.