//--------------------------------------------------------------------------------------- bool MRCC_Config(void) { MRCC_DeInit(); int i = 16; while (i > 0 && MRCC_WaitForOSC4MStartUp() != SUCCESS) i--; if (i != 0) { /* Set HCLK to 60 MHz */ MRCC_HCLKConfig(MRCC_CKSYS_Div1); /* Set CKTIM to 60 MHz */ MRCC_CKTIMConfig(MRCC_HCLK_Div1); /* Set PCLK to 30 MHz */ MRCC_PCLKConfig(MRCC_CKTIM_Div2); CFG_FLASHBurstConfig(CFG_FLASHBurst_Enable); MRCC_CKSYSConfig(MRCC_CKSYS_OSC4MPLL, MRCC_PLL_Mul_15); } /* GPIO pins optimized for 3V3 operation */ MRCC_IOVoltageRangeConfig(MRCC_IOVoltageRange_3V3); MRCC_PeripheralClockConfig(MRCC_Peripheral_GPIO, ENABLE); MRCC_PeripheralClockConfig(MRCC_Peripheral_TIM0, ENABLE); MRCC_PeripheralClockConfig(MRCC_Peripheral_I2C, ENABLE); MRCC_PeripheralClockConfig(MRCC_Peripheral_SSP0, ENABLE); return i > 0; }
static void prvSetupHardware(void) { ErrorStatus OSC4MStartUpStatus01; /* ST provided routine. */ /* MRCC system reset */ MRCC_DeInit(); /* Wait for OSC4M start-up */ OSC4MStartUpStatus01 = MRCC_WaitForOSC4MStartUp(); if(OSC4MStartUpStatus01 == SUCCESS) { /* Set HCLK to 60MHz */ MRCC_HCLKConfig(MRCC_CKSYS_Div1); /* Set CKTIM to 60MHz */ MRCC_CKTIMConfig(MRCC_HCLK_Div1); /* Set PCLK to 30MHz */ MRCC_PCLKConfig(MRCC_CKTIM_Div2); /* Enable Flash Burst mode */ CFG_FLASHBurstConfig(CFG_FLASHBurst_Enable); /* Set CK_SYS to 60 MHz */ MRCC_CKSYSConfig(MRCC_CKSYS_OSC4MPLL, MRCC_PLL_Mul_15); } /* GPIO pins optimized for 3V3 operation */ MRCC_IOVoltageRangeConfig(MRCC_IOVoltageRange_3V3); /* GPIO clock source enable */ MRCC_PeripheralClockConfig(MRCC_Peripheral_GPIO, ENABLE); /* EXTIT clock source enable */ MRCC_PeripheralClockConfig(MRCC_Peripheral_EXTIT, ENABLE); /* TB clock source enable */ MRCC_PeripheralClockConfig(MRCC_Peripheral_TB, ENABLE); /* Initialize the demonstration menu */ LCD_Init(); LCD_DisplayString(Line1, ( unsigned char * ) "www.FreeRTOS.org", BlackText); LCD_DisplayString(Line2, ( unsigned char * ) " STR750 Demo ", BlackText); EIC_IRQCmd(ENABLE); }
/* * See the serial2.h header file. */ xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength ) { xComPortHandle xReturn; UART_InitTypeDef UART_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; EIC_IRQInitTypeDef EIC_IRQInitStructure; /* 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(); { /* Enable the UART0 Clock. */ MRCC_PeripheralClockConfig( MRCC_Peripheral_UART0, ENABLE ); /* Configure the UART0_Tx as alternate function */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; GPIO_Init(GPIO0, &GPIO_InitStructure); /* Configure the UART0_Rx as input floating */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_Init(GPIO0, &GPIO_InitStructure); /* Configure UART0. */ UART_InitStructure.UART_WordLength = UART_WordLength_8D; UART_InitStructure.UART_StopBits = UART_StopBits_1; UART_InitStructure.UART_Parity = UART_Parity_No; UART_InitStructure.UART_BaudRate = ulWantedBaud; UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None; UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx; UART_InitStructure.UART_TxFIFOLevel = UART_FIFOLevel_1_2; /* FIFO size 16 bytes, FIFO level 8 bytes */ UART_InitStructure.UART_RxFIFOLevel = UART_FIFOLevel_1_2; /* FIFO size 16 bytes, FIFO level 8 bytes */ UART_Init(UART0, &UART_InitStructure); /* Enable the UART0 */ UART_Cmd(UART0, ENABLE); /* Configure the IEC for the UART interrupts. */ EIC_IRQInitStructure.EIC_IRQChannelCmd = ENABLE; EIC_IRQInitStructure.EIC_IRQChannel = UART0_IRQChannel; EIC_IRQInitStructure.EIC_IRQChannelPriority = 1; EIC_IRQInit(&EIC_IRQInitStructure); xQueueEmpty = pdTRUE; UART_ITConfig( UART0, UART_IT_Transmit | UART_IT_Receive, 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; }
/******************************************************************************* * Function Name : Set_System * Description : Set System clock. * Input : None. * Return : None. *******************************************************************************/ void Set_System(void) { GPIO_InitTypeDef GPIO_InitStructure; // EXTIT_InitTypeDef EXTIT_InitStructure; /* MRCC configuration --------------------------------------------------------*/ /* MRCC system reset(for debug purpose) */ MRCC_DeInit(); /* Wait for OSC4M start-up */ OSC4MStartUpStatus = MRCC_WaitForOSC4MStartUp(); if(OSC4MStartUpStatus == SUCCESS) { /* Set HCLK to 60MHz */ MRCC_HCLKConfig(MRCC_CKSYS_Div1); /* Set CKTIM to 60MHz */ MRCC_CKTIMConfig(MRCC_HCLK_Div1); /* Set PCLK to 30MHz */ MRCC_PCLKConfig(MRCC_CKTIM_Div2); /* Enable Flash burst mode */ CFG_FLASHBurstConfig(CFG_FLASHBurst_Enable); /* Set CKSYS to 60MHz */ MRCC_CKSYSConfig(MRCC_CKSYS_OSC4MPLL, MRCC_PLL_Mul_15); } /* Enbale No Clock Detected interrupt */ MRCC_ITConfig(MRCC_IT_NCKD, ENABLE); /* Enable GPIOs, USB and EXTIT clocks */ MRCC_PeripheralClockConfig(MRCC_Peripheral_GPIO | MRCC_Peripheral_EXTIT | MRCC_Peripheral_USB | MRCC_Peripheral_UART0, ENABLE); MRCC_IOVoltageRangeConfig(MRCC_IOVoltageRange_3V3); //EXTIT_ClearITPendingBit(EXTIT_ITLine14); //EXTIT_InitStructure.EXTIT_ITLine = EXTIT_ITLine14; //EXTIT_InitStructure.EXTIT_ITTrigger = EXTIT_ITTrigger_Rising; //EXTIT_InitStructure.EXTIT_ITLineCmd = ENABLE; //EXTIT_Init(&EXTIT_InitStructure); /* Configure P2.18 ( USB Suspend/Resume ) as Output push-pull */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_19; GPIO_Init(GPIO2, &GPIO_InitStructure); GPIO_WriteBit(GPIO2, GPIO_Pin_19, (BitAction)(0)); /* Configure P1.0 (D+ Pull up) as Output push-pull */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_Init(GPIO1, &GPIO_InitStructure); /* Configure P0.1 (RED LED) as Output push-pull */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_Init(GPIO0, &GPIO_InitStructure); GPIO_WriteBit(GPIO0, GPIO_Pin_1, (BitAction)(1)); /* Configure the UART0_Tx as Alternate function Push-Pull */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; GPIO_Init(GPIO0, &GPIO_InitStructure); /* Configure the UART0_Rx as input floating */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_Init(GPIO0, &GPIO_InitStructure); UART_DeInit(UART0); UART_ITConfig(UART0, UART_IT_Receive, ENABLE); /* Configure the interrupt controller for UART0 channel */ EIC_IRQInitStructure.EIC_IRQChannel = UART0_IRQChannel; EIC_IRQInitStructure.EIC_IRQChannelPriority = 1; EIC_IRQInitStructure.EIC_IRQChannelCmd = ENABLE; EIC_IRQInit(&EIC_IRQInitStructure); }