/******************************************************************************* Name : UART_Term Description : Terminate the UART driver Parameters : None Assumptions : Limitations : Returns : none *******************************************************************************/ void UART_Term(void) { ST_ErrorCode_t ErrorCode = ST_NO_ERROR; STUART_TermParams_t TermParams; char Msg[256]; TermParams.ForceTerminate = FALSE; ErrorCode = STUART_Term(STUART_DEVICE_NAME, &TermParams); if (ErrorCode == ST_ERROR_OPEN_HANDLE) { sprintf(Msg,"STUART_Term(%s): Warning !! Still open handle\n", STUART_DEVICE_NAME); debugmessage(Msg); TermParams.ForceTerminate = TRUE; ErrorCode = STUART_Term(STUART_DEVICE_NAME, &TermParams); } if (ErrorCode == ST_NO_ERROR) { sprintf(Msg,"STUART_Term(%s): ok\n", STUART_DEVICE_NAME); } else { sprintf(Msg,"STUART_Term(%s): error 0x%0x\n", STUART_DEVICE_NAME, ErrorCode); } debugmessage(Msg); } /* end UART_Term() */
/******************************************************************************* Name : PIO_Term Description : Terminate the PIO driver Parameters : None Assumptions : Limitations : Returns : none *******************************************************************************/ void PIO_Term(void) { ST_ErrorCode_t ErrorCode = ST_NO_ERROR; STPIO_TermParams_t TermParams; char Msg[256]; U8 i; for (i = 0; i < NUMBER_PIO; i++) { TermParams.ForceTerminate = FALSE; ErrorCode = STPIO_Term(PioDeviceName[i], &TermParams); if (ErrorCode == ST_ERROR_OPEN_HANDLE) { sprintf(Msg,"STPIO_Term(%s): Warning !! Still open handle\n", PioDeviceName[i]); debugmessage(Msg); TermParams.ForceTerminate = TRUE; ErrorCode = STPIO_Term(PioDeviceName[i], &TermParams); } if (ErrorCode == ST_NO_ERROR) { sprintf(Msg,"STPIO_Term(%s): ok\n", PioDeviceName[i]); } else { sprintf(Msg,"STPIO_Term(%s): error 0x%0x\n", PioDeviceName[i], ErrorCode); } debugmessage(Msg); } } /* end PIO_Term() */
/******************************************************************************* Name : UART_Open Description : Open a connection Parameters : None Assumptions : Limitations : Returns : TRUE if success, FALSE otherwise *******************************************************************************/ BOOL UART_Open(void) { BOOL RetOk = TRUE; char Msg[256]; ST_ErrorCode_t ErrorCode; STUART_OpenParams_t UartOpenParams; UartOpenParams.LoopBackEnabled = FALSE; /* NO internal loopback */ UartOpenParams.FlushIOBuffers = TRUE; /* Flush before open */ UartOpenParams.DefaultParams = NULL; /* Don't overwrite default parameters set at init */ #if defined(ST_7100) || defined (ST_7109) || defined(ST_7200) /* Testtool on STUART_DEVICE_NAME (ASC2), traces on TRACE_UART_DEVICE (ASC3) */ ErrorCode = STUART_Open(TRACE_UART_DEVICE, &UartOpenParams, &TraceUartHandle); #else ErrorCode = STUART_Open(STUART_DEVICE_NAME, &UartOpenParams, &TraceUartHandle); #endif if ( ErrorCode != ST_NO_ERROR) { /* error handling */ RetOk = FALSE; sprintf(Msg,"Error: UART Open failed ! Error 0x%0x\n", ErrorCode); debugmessage(Msg); } else { debugmessage("STUART Opened\n"); } return(RetOk); } /* end UART_Open() */
static void draw_nodes() #endif { GNODE v; debugmessage("draw_nodes",""); if (supress_nodes) return; v = nodelist; while (v) { if (NWIDTH(v)==0) { v = NNEXT(v); continue; } gs_setshrink(G_stretch * NSTRETCH(v), G_shrink * NSHRINK(v) ); gs_setto(NX(v) * G_stretch / G_shrink, NY(v) * G_stretch / G_shrink ); draw_one_node(v); v = NNEXT(v); } v = labellist; while (v) { if (NWIDTH(v)==0) { v = NNEXT(v); continue; } gs_setshrink(G_stretch * NSTRETCH(v), G_shrink * NSHRINK(v) ); gs_setto(NX(v) * G_stretch / G_shrink, NY(v) * G_stretch / G_shrink ); gs_stringbox(v); v = NNEXT(v); } #undef DEBUGDUMMY #ifdef DEBUGDUMMY v = dummylist; while (v) { if ((NWIDTH(v)==0)&&(NHEIGHT(v)==0)) { NWIDTH(v) = NHEIGHT(v) = 9; NBORDERW(v) = 5; NCOLOR(v) = BLACK; gs_setshrink(G_stretch, G_shrink); gs_setto(NX(v) * G_stretch / G_shrink, NY(v) * G_stretch / G_shrink ); draw_one_node(v); NWIDTH(v) = NHEIGHT(v) = 0; NBORDERW(v) = 0; } v = NNEXT(v); } #endif /* Normal dummy nodes need not to be drawn, because they have no size. * Anchor nodes are drawn. */ v = dummylist; while (v) { if (NANCHORNODE(v)) gs_anchornode(v); v = NNEXT(v); } }
/******************************************************************************* Name : UART_Close Description : Close the UART connection Parameters : None Assumptions : Limitations : Returns : none *******************************************************************************/ void UART_Close(void) { ST_ErrorCode_t ErrorCode = ST_NO_ERROR; char Msg[256]; ErrorCode = STUART_Close(TraceUartHandle); if ( ErrorCode != ST_NO_ERROR) { /* error handling */ sprintf(Msg,"Error: trace UART closing failed ! Error 0x%0x\n", ErrorCode); debugmessage(Msg); } else { debugmessage("trace UART closed\n"); } } /* end UART_Close() */
/******************************************************************************* Name : Test_Uart_Driver_fn Description : just makes an open+write+close of STUART to test it Parameters : none Assumptions : STUART initialized Limitations : Returns : none *******************************************************************************/ void Test_Uart_Driver_fn(void) { STUART_OpenParams_t UartOpenParams; STUART_Handle_t UartHandle; char UartTab[2]; U32 UARTNumberWritten; ST_ErrorCode_t ErrorCode; ErrorCode = ST_NO_ERROR; strcpy(UartTab, ""); /* Open UART if support is required */ UartOpenParams.LoopBackEnabled = FALSE; /* NO internal loopback */ UartOpenParams.FlushIOBuffers = TRUE; /* Flush before open */ UartOpenParams.DefaultParams = NULL; /* Don't overwrite default parameters set at init */ ErrorCode = STUART_Open(STUART_DEVICE_NAME, &UartOpenParams, &UartHandle); if (ErrorCode != ST_NO_ERROR) { debugmessage("UART failed to open !\n"); } else { debugmessage("UART opened just to check it works.\n"); ErrorCode = STUART_Write(UartHandle, (U8 *) UartTab, 0, &UARTNumberWritten, 0); if ((ErrorCode != ST_NO_ERROR) && (ErrorCode != ST_ERROR_INVALID_HANDLE)) { printf("Could not write on UART (ErrorCode = 0x%0x) !\n", ErrorCode); } ErrorCode = STUART_Close(UartHandle); if(ErrorCode != ST_NO_ERROR) { /* error handling: UART failed to open in toolbox ! */ debugmessage("UART failed to close !\n"); } else { debugmessage("UART closed\n"); } } } /* end of Test_Uart_Driver_fn() */
void draw_main() #endif { debugmessage("draw_main",""); start_time(); draw_nodes(); stop_time("draw_main draw_nodes"); start_time(); draw_edges(); stop_time("draw_main draw_edges"); }
/******************************************************************************* Name : PIO_Init Description : Initialise the PIO driver Parameters : None Assumptions : Limitations : Returns : TRUE if success, FALSE otherwise *******************************************************************************/ BOOL PIO_Init(void) { #ifdef ST_OSLINUX #define ST5528_PIO0_INTERRUPT 0 #define ST5528_PIO1_INTERRUPT 1 #define ST5528_PIO2_INTERRUPT 2 #define ST5528_PIO3_INTERRUPT 3 #define ST5528_PIO4_INTERRUPT 4 #define ST5528_PIO5_INTERRUPT 5 #define ST5528_PIO6_INTERRUPT 6 #define ST5528_PIO7_INTERRUPT 7 #endif BOOL RetOk = TRUE; ST_ErrorCode_t ErrorCode; STPIO_InitParams_t PioInitParams[NUMBER_PIO]; char Msg[256]; U8 i; /* Setup PIO global parameters */ PioInitParams[0].BaseAddress = (U32 *)PIO_0_BASE_ADDRESS; PioInitParams[0].InterruptNumber = PIO_0_INTERRUPT; PioInitParams[0].InterruptLevel = PIO_0_INTERRUPT_LEVEL; PioInitParams[1].BaseAddress = (U32 *)PIO_1_BASE_ADDRESS; PioInitParams[1].InterruptNumber = PIO_1_INTERRUPT; PioInitParams[1].InterruptLevel = PIO_1_INTERRUPT_LEVEL; PioInitParams[2].BaseAddress = (U32 *)PIO_2_BASE_ADDRESS; PioInitParams[2].InterruptNumber = PIO_2_INTERRUPT; PioInitParams[2].InterruptLevel = PIO_2_INTERRUPT_LEVEL; PioInitParams[3].BaseAddress = (U32 *)PIO_3_BASE_ADDRESS; PioInitParams[3].InterruptNumber = PIO_3_INTERRUPT; PioInitParams[3].InterruptLevel = PIO_3_INTERRUPT_LEVEL; #if (NUMBER_PIO > 4) PioInitParams[4].BaseAddress = (U32 *)PIO_4_BASE_ADDRESS; PioInitParams[4].InterruptNumber = PIO_4_INTERRUPT; PioInitParams[4].InterruptLevel = PIO_4_INTERRUPT_LEVEL; #endif #if (NUMBER_PIO > 5) PioInitParams[5].BaseAddress = (U32 *)PIO_5_BASE_ADDRESS; PioInitParams[5].InterruptNumber = PIO_5_INTERRUPT; PioInitParams[5].InterruptLevel = PIO_5_INTERRUPT_LEVEL; #endif #if (NUMBER_PIO > 6) PioInitParams[6].BaseAddress = (U32*)PIO_6_BASE_ADDRESS; PioInitParams[6].InterruptNumber = PIO_6_INTERRUPT; PioInitParams[6].InterruptLevel = PIO_6_INTERRUPT_LEVEL; #endif #if (NUMBER_PIO > 7) PioInitParams[7].BaseAddress = (U32*)PIO_7_BASE_ADDRESS; PioInitParams[7].InterruptNumber = PIO_7_INTERRUPT; PioInitParams[7].InterruptLevel = PIO_7_INTERRUPT_LEVEL; #endif /* Initialize all pio devices */ for (i = 0; i < NUMBER_PIO; i++) { PioInitParams[i].DriverPartition = DriverPartition_p; ErrorCode = STPIO_Init(PioDeviceName[i], &PioInitParams[i]); if ( ErrorCode != ST_NO_ERROR) { RetOk = FALSE; sprintf(Msg,"Error: %s init failed ! Error 0x%0x\n", PioDeviceName[i], ErrorCode); debugmessage(Msg); } } if (RetOk) { sprintf(Msg,"PIO 0-%d initialized,\trevision=%s\n", NUMBER_PIO-1, STPIO_GetRevision()); debugmessage(Msg); } return(RetOk); } /* end PIO_Init() */
/******************************************************************************* Name : UART_Init Description : Initialise the UART drivers Parameters : None Assumptions : Limitations : Returns : TRUE if success, FALSE otherwise *******************************************************************************/ BOOL UART_Init(void) { #if defined(ST_7100) || defined(ST_7109) CkgA_Clock_t CkgAClock; #endif BOOL RetOk = TRUE; char Msg[256]; ST_ErrorCode_t ErrorCode; STUART_Params_t UartDefaultParams; STUART_InitParams_t UartInitParams; ST_ClockInfo_t ClockInfo; ST_GetClockInfo(&ClockInfo); memset(&UartInitParams, 0, sizeof(UartInitParams)); UartInitParams.RXD.PortName[0] = '\0'; UartInitParams.TXD.PortName[0] = '\0'; UartInitParams.RTS.PortName[0] = '\0'; UartInitParams.CTS.PortName[0] = '\0'; UartInitParams.UARTType = ASC_DEVICE_TYPE; UartInitParams.DriverPartition = DriverPartition_p; UartInitParams.BaseAddress = (U32 *)UART_BASEADDRESS; UartInitParams.InterruptNumber = UART_IT_NUMBER; UartInitParams.InterruptLevel = UART_IT_LEVEL; UartInitParams.ClockFrequency = ClockInfo.CommsBlock; UartInitParams.SwFIFOEnable = TRUE; UartInitParams.FIFOLength = 4096; strcpy(UartInitParams.RXD.PortName, PioDeviceName[UART_RXD_PORTNAME_IDX]); UartInitParams.RXD.BitMask = UART_RXD_BITMASK; strcpy(UartInitParams.TXD.PortName, PioDeviceName[UART_TXD_PORTNAME_IDX]); UartInitParams.TXD.BitMask = UART_TXD_BITMASK; strcpy(UartInitParams.RTS.PortName, PioDeviceName[UART_RTS_PORTNAME_IDX]); UartInitParams.RTS.BitMask = UART_RTS_BITMASK; strcpy(UartInitParams.CTS.PortName, PioDeviceName[UART_CTS_PORTNAME_IDX]); UartInitParams.CTS.BitMask = UART_CTS_BITMASK; UartDefaultParams.RxMode.DataBits = STUART_8BITS_EVEN_PARITY; UartDefaultParams.RxMode.StopBits = STUART_STOP_1_0; UartDefaultParams.RxMode.FlowControl = STUART_NO_FLOW_CONTROL; UartDefaultParams.RxMode.BaudRate = UART_BAUD_RATE; UartDefaultParams.RxMode.TermString = NULL; UartDefaultParams.RxMode.TimeOut = 1; /* As short as possible */ UartDefaultParams.RxMode.NotifyFunction = NULL; /* No callback */ UartDefaultParams.TxMode.DataBits = STUART_8BITS_EVEN_PARITY; UartDefaultParams.TxMode.StopBits = STUART_STOP_1_0; UartDefaultParams.TxMode.FlowControl = STUART_NO_FLOW_CONTROL; UartDefaultParams.TxMode.BaudRate = UART_BAUD_RATE; UartDefaultParams.TxMode.TermString = NULL; UartDefaultParams.TxMode.TimeOut = 0; /* No time-out */ UartDefaultParams.TxMode.NotifyFunction = NULL; /* No callback */ UartDefaultParams.SmartCardModeEnabled = FALSE; UartDefaultParams.GuardTime = 0; UartInitParams.DefaultParams = &UartDefaultParams; #if defined(ST_7100) || defined(ST_7109) /* CL quick fix to get UART working properly on mb411 */ ST_CkgA_GetClock(&CkgAClock); UartInitParams.ClockFrequency = CkgAClock.icdiv2_emi_clk; #endif #if defined(ST_7200) /*COMMS clock clk_ic_100*/ /* Need to call Getclock function to determine if 100MHz or 133MHz */ UartInitParams.ClockFrequency = 100000000; #endif ErrorCode = STUART_Init(STUART_DEVICE_NAME, &UartInitParams); if ( ErrorCode != ST_NO_ERROR) { /* error handling */ RetOk = FALSE; sprintf(Msg,"Error: UART Init failed ! Error 0x%0x\n", ErrorCode); debugmessage(Msg); } else { sprintf(Msg,"STUART initialized, \trevision=%s\n", STUART_GetRevision() ); debugmessage(Msg); } #if (defined(ST_7100) || defined(ST_7109)|| defined(ST_7200)) && defined(TRACE_UART) /* Testtool on ASC2, traces on ASC3 required. Reuse same config 115200 bauds 8bits/Even */ UartInitParams.BaseAddress = (U32 *)ASC_3_BASE_ADDRESS; UartInitParams.InterruptNumber = ASC_3_INTERRUPT; UartInitParams.InterruptLevel = ASC_3_INTERRUPT_LEVEL; strcpy(UartInitParams.RXD.PortName, PioDeviceName[ASC_3_RXD_DEV]); UartInitParams.RXD.BitMask = ASC_3_RXD_BIT; strcpy(UartInitParams.TXD.PortName, PioDeviceName[ASC_3_TXD_DEV]); UartInitParams.TXD.BitMask = ASC_3_TXD_BIT; strcpy(UartInitParams.RTS.PortName, PioDeviceName[ASC_3_RTS_DEV]); UartInitParams.RTS.BitMask = ASC_3_RTS_BIT; strcpy(UartInitParams.CTS.PortName, PioDeviceName[ASC_3_CTS_DEV]); UartInitParams.CTS.BitMask = ASC_3_CTS_BIT; ErrorCode = STUART_Init(TRACE_UART_DEVICE, &UartInitParams); if ( ErrorCode != ST_NO_ERROR) { /* error handling */ RetOk = FALSE; sprintf(Msg,"Error: UART Init for debug traces failed ! Error 0x%0x\n", ErrorCode); debugmessage(Msg); } else { sprintf(Msg,"STUART ASC3 for debug traces initialized, \trevision=%s\n", STUART_GetRevision() ); debugmessage(Msg); } #endif #if defined(ST_5514) /* For the STi5514 there are two registers we must configure to * allow the ASC2 to be used for RS232: * * IRB_ASC_CONTROL => Must be set for ASC2 TXD and RXD to * bypass the IRDA Data part of IRB module. * CFG_CONTROL_C => Configure the PIO MUX for IRB operation * and not IrDA Control. */ STSYS_WriteRegDev32LE(((U32)IRB_BASE_ADDRESS + 0xD0), STSYS_ReadRegDev32LE(((U32)IRB_BASE_ADDRESS + 0xD0)) | 1); STSYS_WriteRegDev32LE(((U32)CFG_BASE_ADDRESS + 0x08), STSYS_ReadRegDev32LE(((U32)CFG_BASE_ADDRESS + 0x08)) | 0x10); #elif defined(ST_5516) || defined(ST_5517) /* CONFIG REG E: Bit 16 (CONFIG_IRB_UART2RXD_BYPASS) 0: IRB to UART2RXD 1: PIO4[3] to UART2 directly */ STSYS_WriteRegDev32LE(CONFIG_CONTROL_E, STSYS_ReadRegDev32LE(CONFIG_CONTROL_E) | 0x00010000 ); /* [15] CONFIG_IRDACTRL_DIN_DISABLE Always set to 1*/ STSYS_WriteRegDev32LE(CONFIG_CONTROL_E, STSYS_ReadRegDev32LE(CONFIG_CONTROL_E) | 0x00008000 ); /* [4] CONFIG_OTHER_ALT_IRD_NOTIRC_DOUT Always set this bit to 1*/ STSYS_WriteRegDev32LE(CONFIG_CONTROL_C, STSYS_ReadRegDev32LE(CONFIG_CONTROL_C) | 0x10 ); /* wakeup enables */ STSYS_WriteRegDev32LE(CONFIG_CONTROL_D, STSYS_ReadRegDev32LE(CONFIG_CONTROL_D) | 0x1800000 ); /* CFG_CONTROL_D => Select UART4 instead of MAFE on PIO2 */ STSYS_WriteRegDev32LE(CONFIG_CONTROL_D, STSYS_ReadRegDev32LE(CONFIG_CONTROL_D) | 0x100000 ); /* Bypass IrDA Control to allow ASC TX output */ STSYS_WriteRegDev16LE(0x201150d0, 0x01); #elif defined(ST_5301) || defined(ST_5100) || defined(ST_5525) /* Configure PIOs */ STSYS_WriteRegDev8(PIO_4_BASE_ADDRESS+0x20, 0x0); STSYS_WriteRegDev8(PIO_4_BASE_ADDRESS+0x30, 0x1); STSYS_WriteRegDev8(PIO_4_BASE_ADDRESS+0x40, 0x1); #endif return(RetOk); } /* end UART_Init() */
void disable_signal() #endif { debugmessage("disable_signal",""); signal_allowed = 0; }
void enable_signal() #endif { debugmessage("enable_signal",""); signal_allowed = 1; }