err_t sio_close_low_level( u8_t devnr, serdev_t * dev ) { err_t error = ERR_OK; if( devnr == 0 ) { UART_Init( dev->UARTx ); /* Disable the GPIO pints for the UART device. */ GPIO_Config( UART0_TX_PORT, 1 << UART1_TX_PIN, GPIO_IN_TRI_TTL ); GPIO_Config( UART0_RX_PORT, 1 << UART1_RX_PIN, GPIO_IN_TRI_TTL ); /* Disable the UART interrupts in the EIC. */ EIC_IRQChannelConfig( UART0_IRQ_CH, DISABLE ); } else if( devnr == 1 ) { UART_Init( dev->UARTx ); /* Disable the GPIO pints for the UART device. */ GPIO_Config( UART1_TX_PORT, 1 << UART1_TX_PIN, GPIO_IN_TRI_TTL ); GPIO_Config( UART1_RX_PORT, 1 << UART1_RX_PIN, GPIO_IN_TRI_TTL ); /* Disable the UART interrupts in the EIC. */ EIC_IRQChannelConfig( UART1_IRQ_CH, DISABLE ); } else { error = ERR_IF; } return error; }
err_t sio_open_low_level( u8_t devnr, serdev_t * dev ) { err_t error = ERR_OK; if( devnr == 0 ) { /* Return value. */ dev->UARTx = UART0; /* Reset the UART. */ UART_Init( dev->UARTx ); /* Configure the GPIO pints for the UART device. */ GPIO_Config( UART0_TX_PORT, 1 << UART0_TX_PIN, GPIO_AF_PP ); GPIO_Config( UART0_RX_PORT, 1 << UART0_RX_PIN, GPIO_IN_TRI_CMOS ); /* Configure the IEC for the UART interrupts. */ EIC_IRQChannelPriorityConfig( UART0_IRQ_CH, UART0_IRQ_PRIORITY ); EIC_IRQChannelConfig( UART0_IRQ_CH, ENABLE ); } else if( devnr == 1 ) { /* Return value. */ dev->UARTx = UART1; /* Reset the UART. */ UART_Init( dev->UARTx ); /* Configure the GPIO pints for the UART device. */ GPIO_Config( UART1_TX_PORT, 1 << UART1_TX_PIN, GPIO_AF_PP ); GPIO_Config( UART1_RX_PORT, 1 << UART1_RX_PIN, GPIO_IN_TRI_TTL ); /* Configure the EIC for the UART interrupts. */ EIC_IRQChannelPriorityConfig( UART1_IRQ_CH, UART1_IRQ_PRIORITY ); EIC_IRQChannelConfig( UART1_IRQ_CH, ENABLE ); } else { error = ERR_IF; } return error; }
static void str7_IrqInit() { //设置外部中断 EIC_IRQConfig(ENABLE); XTI_Init(); XTI_ModeConfig(XTI_Interrupt, ENABLE ); EIC->SIR[XTI_IRQChannel] = ((int)XTI_IRQHandler << 16) | 8; EIC_IRQChannelConfig(XTI_IRQChannel, ENABLE); }
static void prvSetupTimerInterrupt( void ) { /* Set the watchdog up to generate a periodic tick. */ WDG_ECITConfig( DISABLE ); WDG_CntOnOffConfig( DISABLE ); WDG_PeriodValueConfig( portMICROS_PER_SECOND / configTICK_RATE_HZ ); /* Setup the tick interrupt in the EIC. */ EIC_IRQChannelPriorityConfig( WDG_IRQChannel, 1 ); EIC_IRQChannelConfig( WDG_IRQChannel, ENABLE ); EIC_IRQConfig( ENABLE ); WDG_ECITConfig( ENABLE ); /* Start the timer - interrupts are actually disabled at this point so it is safe to do this here. */ WDG_CntOnOffConfig( ENABLE ); }
/* * See the serial2.h header file. */ xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength ) { xComPortHandle xReturn; /* Create the queues used to hold Rx and Tx characters. */ xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed char ) ); xCharsForTx = xQueueCreate( uxQueueLength + 1, ( unsigned portBASE_TYPE ) sizeof( signed char ) ); /* If the queues were created correctly then setup the serial port hardware. */ if( ( xRxedChars != serINVALID_QUEUE ) && ( xCharsForTx != serINVALID_QUEUE ) ) { portENTER_CRITICAL(); { /* Setup the UART port pins. */ GPIO_Config( GPIO0, UART0_Tx_Pin, GPIO_AF_PP ); GPIO_Config( GPIO0, UART0_Rx_Pin, GPIO_IN_TRI_CMOS ); /* Configure the UART. */ UART_OnOffConfig( UART0, ENABLE ); UART_FifoConfig( UART0, DISABLE ); UART_FifoReset( UART0, UART_RxFIFO ); UART_FifoReset( UART0, UART_TxFIFO ); UART_LoopBackConfig(UART0, DISABLE ); UART_Config( UART0, ulWantedBaud, UART_NO_PARITY, UART_1_StopBits, UARTM_8D ); UART_RxConfig( UART0, ENABLE ); /* Configure the IEC for the UART interrupts. */ EIC_IRQChannelPriorityConfig( UART0_IRQChannel, 1 ); EIC_IRQChannelConfig( UART0_IRQChannel, ENABLE ); EIC_IRQConfig( ENABLE ); UART_ItConfig( UART0, UART_RxBufFull, ENABLE ); } portEXIT_CRITICAL(); } else { xReturn = ( xComPortHandle ) 0; } /* This demo file only supports a single port but we have to return something to comply with the standard demo header file. */ return xReturn; }
BOOL xMBPortSerialInit( UCHAR ucPort, ULONG ulBaudRate, UCHAR ucDataBits, eMBParity eParity ) { BOOL xResult = TRUE; UARTParity_TypeDef eUARTParity; UARTMode_TypeDef eUARTMode; (void)ucPort; switch ( eParity ) { case MB_PAR_EVEN: eUARTParity = UART_EVEN_PARITY; break; case MB_PAR_ODD: eUARTParity = UART_ODD_PARITY; break; case MB_PAR_NONE: eUARTParity = UART_NO_PARITY; break; } switch ( ucDataBits ) { case 7: if( eParity == MB_PAR_NONE ) { /* not supported by our hardware. */ xResult = FALSE; } else { eUARTMode = UARTM_7D_P; } break; case 8: if( eParity == MB_PAR_NONE ) { eUARTMode = UARTM_8D; } else { eUARTMode = UARTM_8D_P; } break; default: xResult = FALSE; } if( xResult != FALSE ) { /* Setup the UART port pins. */ GPIO_Config( MB_UART_TX_PORT, 1 << MB_UART_TX_PIN, GPIO_AF_PP ); GPIO_Config( MB_UART_RX_PORT, 1 << MB_UART_RX_PIN, GPIO_IN_TRI_CMOS ); /* Configure the UART. */ UART_OnOffConfig( MB_UART_DEV, ENABLE ); UART_FifoConfig( MB_UART_DEV, DISABLE ); UART_FifoReset( MB_UART_DEV, UART_RxFIFO ); UART_FifoReset( MB_UART_DEV, UART_TxFIFO ); UART_LoopBackConfig( MB_UART_DEV, DISABLE ); UART_Config( MB_UART_DEV, ulBaudRate, eUARTParity, UART_1_StopBits, eUARTMode ); UART_RxConfig( UART0, ENABLE ); vMBPortSerialEnable( FALSE, FALSE ); /* Configure the IEC for the UART interrupts. */ EIC_IRQChannelPriorityConfig( MB_UART_IRQ_CH, MB_IRQ_PRIORITY ); EIC_IRQChannelConfig( MB_UART_IRQ_CH, ENABLE ); } return xResult; }