]> rtime.felk.cvut.cz Git - sysless.git/commitdiff
Select UART1 alternative pins according to their declaration in system_def.h.
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Tue, 14 Sep 2010 18:39:49 +0000 (20:39 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Tue, 14 Sep 2010 18:39:49 +0000 (20:39 +0200)
Used pins are configured according to
 TXD1_BIT, RXD1_BIT, CTS1_BIT, DSR1_BIT, RTS1_BIT
values.

Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
board/arm/lpc17xx-common/libs/bspbase/bsp0hwinit.c

index d8a6a221a0b8e79d81f0c4af0b60c41dd135ac4e..73cc6ae4df87175923edda0318665fd744a81d0e 100644 (file)
@@ -261,10 +261,69 @@ int ul_iac_call_res(struct ul_drv *udrv,ul_msginfo *msginfo,char *ibuff,ul_iac_d
 int uLanInit()
 {
   struct ul_drv *udrv;
+  unsigned int pinsel1_mask = 0;
+  unsigned int pinsel1_set  = 0;
+  unsigned int pinsel4_mask = 0;
+  unsigned int pinsel4_set  = 0;
 
   /* set rs485 mode for UART1 */
-  PINCON->PINSEL1 = (PINCON->PINSEL1 & ~0x00003000) | 0x00001000; /* rts(uDIR) */
-  PINCON->PINSEL4 = (PINCON->PINSEL4 & ~0x00000C0F) | 0x0000080A; /* dsr(rxd), rxd, txd */
+ #if TXD1_BIT == BIT(15)
+  PINCON->PINSEL0 = (PINCON->PINSEL0 & ~0xC0000000) | 0x40000000; /* rxd on P0.15 */
+ #elif TXD1_BIT == BIT(0)
+  pinsel4_mask |= 3 << (0*2);
+  pinsel4_set  |= 2 << (0*2);
+ #else
+  #error TXD1_BIT is not set or valid
+ #endif
+
+ #if RXD1_BIT == BIT(16)
+  pinsel1_mask |= 3 << ((16-16)*2);
+  pinsel1_set  |= 1 << ((16-16)*2);
+ #elif RXD1_BIT == BIT(1)
+  pinsel4_mask |= 3 << (1*2);
+  pinsel4_set  |= 2 << (1*2);
+ #else
+  #error RXD1_BIT is not set or valid
+ #endif
+
+ #ifdef CTS1_BIT
+ #if CTS1_BIT == BIT(17)
+  pinsel1_mask |= 3 << ((17-16)*2);
+  pinsel1_set  |= 1 << ((17-16)*2);
+ #elif CTS1_BIT == BIT(2)
+  pinsel4_mask |= 3 << (2*2);
+  pinsel4_set  |= 2 << (2*2);
+ #else
+  #error CTS1_BIT is not valid
+ #endif
+ #endif
+
+ #ifdef DSR1_BIT
+ #if DSR1_BIT == BIT(19)
+  pinsel1_mask |= 3 << ((19-16)*2);
+  pinsel1_set  |= 1 << ((19-16)*2);
+ #elif DSR1_BIT == BIT(4)
+  pinsel4_mask |= 3 << (4*2);
+  pinsel4_set  |= 2 << (4*2);
+ #else
+  #error CTS1_BIT is not valid
+ #endif
+ #endif
+
+ #if RTS1_BIT == BIT(22)
+  pinsel1_mask |= 3 << ((22-16)*2);
+  pinsel1_set  |= 1 << ((22-16)*2);
+ #elif RTS1_BIT == BIT(7)
+  pinsel4_mask |= 3 << (7*2);
+  pinsel4_set  |= 2 << (7*2);
+ #else
+  #error RTS1_BIT is not set or valid
+ #endif
+
+  /* port 0 .. 0x00003000; 0x00001000; rts(uDIR) */
+  PINCON->PINSEL1 = (PINCON->PINSEL1 & ~pinsel1_mask) | pinsel1_set; 
+  /* port 2 .. 0x00000C0F;  0x0000080A; dsr(rxd), rxd, txd */
+  PINCON->PINSEL4 = (PINCON->PINSEL4 & ~pinsel4_mask) | pinsel4_set;
 
   udrv=ul_drv_new(UL_DRV_SYSLESS_PORT,     /* port */
              UL_DRV_SYSLESS_IRQ,            /* irq */