/* * 函数名:CAN_Config * 描述 :完整配置CAN的功能 * 输入 :无 * 输出 : 无 * 调用 :外部调用 */ void CAN_Config(void) { CAN_GPIO_Config(); CAN_NVIC_Config(); CAN_Mode_Config(); CAN_Filter_Config(); }
/** * @brief Setup STM32 system (clocks, Ethernet, GPIO, NVIC) and STM3210C-EVAL resources. * @param None * @retval None */ void System_Setup(void) { // GPIO_InitTypeDef GPIO_InitStructure1; RCC_ClocksTypeDef RCC_Clocks; /* Setup STM32 clock, PLL and Flash configuration) */ SystemInit(); /* Enable USART2 clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); /* Enable ETHERNET clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_ETH_MAC | RCC_AHBPeriph_ETH_MAC_Tx | RCC_AHBPeriph_ETH_MAC_Rx, ENABLE); /* Enable GPIOs and ADC1 clocks */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO | RCC_APB2Periph_ADC1, ENABLE); /* NVIC configuration */ NVIC_Configuration(); /* ADC configuration */ ADC_Configuration(); /* Configure the GPIO ports */ GPIO_Configuration(); // /* Initialize the STM3210C-EVAL's LCD */ // STM3210C_LCD_Init(); CAN_NVIC_Config(); CAN_Config(); // /* Initialize STM3210C-EVAL's LEDs */ // STM_EVAL_LEDInit(LED1); // STM_EVAL_LEDInit(LED2); // STM_EVAL_LEDInit(LED3); // STM_EVAL_LEDInit(LED4); // /* Turn on leds available on STM3210X-EVAL */ // STM_EVAL_LEDOn(LED1); // STM_EVAL_LEDOn(LED2); // STM_EVAL_LEDOn(LED3); // STM_EVAL_LEDOn(LED4); // /* Enable the GPIO_LED Clock */ // RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); // /* Configure the GPIO_LED pin */ // GPIO_InitStructure1.GPIO_Pin = GPIO_Pin_9; // GPIO_InitStructure1.GPIO_Mode = GPIO_Mode_Out_PP; // GPIO_InitStructure1.GPIO_Speed = GPIO_Speed_50MHz; // GPIO_Init(GPIOB, &GPIO_InitStructure1); /* Clear the LCD */ LCD_Clear(Blue); /* Set the LCD Back Color */ LCD_SetBackColor(Blue); /* Set the LCD Text Color */ LCD_SetTextColor(White); /* Display message on the LCD*/ LCD_DisplayStringLine(Line0, MESSAGE1); LCD_DisplayStringLine(Line1, MESSAGE2); LCD_DisplayStringLine(Line2, MESSAGE3); LCD_DisplayStringLine(Line3, MESSAGE4); /* Configure the Ethernet peripheral */ Ethernet_Configuration(); /* SystTick configuration: an interrupt every 10ms */ RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(RCC_Clocks.SYSCLK_Frequency / 100); /* Update the SysTick IRQ priority should be higher than the Ethernet IRQ */ /* The Localtime should be updated during the Ethernet packets processing */ NVIC_SetPriority (SysTick_IRQn, 1); // NVIC_SetPriority (CAN2_RX0_IRQn, 1); /* Configure the Key button */ //STM_EVAL_PBInit(Button_KEY, Mode_GPIO); }