Technical discussions about the TI C54x DSPs (including the c5401, c5402, c5402a, c5404, c5407, c5409, c5409a, c5410, c5410a, c5416, c5420, c5421, c5441, c549, c5470 and c5471).
|
I have a UART chip with two Uarts on it, and the registers are mapped into memory locations 0-7 for Uart A and 8-15 for Uart B. I have them defined like this: #define UART_RBR_A_REG port0 #define UART_THR_A_REG port0 #define UART_IER_A_REG port1 #define UART_IIR_A_REG port2 #define UART_FCR_A_REG port2 #define UART_LCR_A_REG port3 #define UART_MCR_A_REG port4 #define UART_LSR_A_REG port5 #define UART_MSR_A_REG port6 #define UART_SCR_A_REG port7 // uart B registers #define UART_RBR_B_REG port8 #define UART_THR_B_REG port8 #define UART_IER_B_REG port9 #define UART_IIR_B_REG porta #define UART_FCR_B_REG porta #define UART_LCR_B_REG portb #define UART_MCR_B_REG portc #define UART_LSR_B_REG portd #define UART_MSR_B_REG porte #define UART_SCR_B_REG portf I also have a enumerated type like this : typedef enum { UART_A = 0x00, UART_B = 0x01, } UartSelect, *PUartSelect; with a variable declared as : UartSelect selectedUart; what I would like to be able to do is like this: UART_RBR_A_REG + selectedUart = somevalue I need to write Instead of doing this If(selectedUArt == UART_A) { UART_RBR_A_REG = somevalue; } else { UART_RBR_B_REG = somevalue; } Is there a way of doing this? Carl Chipman Nomadics, Inc. http://www.nomadics.com |
|
I bet you could do UART_RBR_A_REG + (8*selectedUart) = somevalue I need to write I do this kind of branch elimination optimization all the time. Good luck, Dave Helsley ----- Original Message ----- From: <> To: <> Sent: Monday, November 19, 2001 11:57 AM Subject: [c54x] ioport > I have a UART chip with two Uarts on it, and the registers are mapped > into memory locations 0-7 for Uart A and 8-15 for Uart B. > > I have them defined like this: > > #define UART_RBR_A_REG port0 > #define UART_THR_A_REG port0 > #define UART_IER_A_REG port1 > #define UART_IIR_A_REG port2 > #define UART_FCR_A_REG port2 > #define UART_LCR_A_REG port3 > #define UART_MCR_A_REG port4 > #define UART_LSR_A_REG port5 > #define UART_MSR_A_REG port6 > #define UART_SCR_A_REG port7 > > // uart B registers > #define UART_RBR_B_REG port8 > #define UART_THR_B_REG port8 > #define UART_IER_B_REG port9 > #define UART_IIR_B_REG porta > #define UART_FCR_B_REG porta > #define UART_LCR_B_REG portb > #define UART_MCR_B_REG portc > #define UART_LSR_B_REG portd > #define UART_MSR_B_REG porte > #define UART_SCR_B_REG portf > I also have a enumerated type like this : > typedef enum > { > UART_A = 0x00, > UART_B = 0x01, > } UartSelect, *PUartSelect; > > with a variable declared as : > UartSelect selectedUart; > > what I would like to be able to do is like this: > > UART_RBR_A_REG + selectedUart = somevalue I need to write > > Instead of doing this > > If(selectedUArt == UART_A) > { > UART_RBR_A_REG = somevalue; > } > else > { > UART_RBR_B_REG = somevalue; > } > Is there a way of doing this? > Carl Chipman > Nomadics, Inc. > > http://www.nomadics.com > _____________________________________ |