void board_init(void) { GPIO_InitTypeDef gpio; SystemCoreClockUpdate( ); // turn on peripherals needed by all RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA1 | RCC_AHB1Periph_DMA2 | RCC_AHB1Periph_BKPSRAM, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1 | RCC_APB2Periph_TIM1 | RCC_APB2Periph_SYSCFG, ENABLE); RCC_APB1PeriphClockCmd( RCC_APB1Periph_SPI2 | RCC_APB1Periph_SPI3 | RCC_APB1Periph_TIM2 | RCC_APB1Periph_TIM3 | RCC_APB1Periph_TIM4 | RCC_APB1Periph_TIM5 | RCC_APB1Periph_TIM12 | RCC_APB1Periph_PWR, ENABLE); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK); RCC_LSEConfig(RCC_LSE_OFF); LEDInit(LED_BLUE); LEDInit(LED_GREEN); gpio.GPIO_Pin = GPIO_Pin_0; gpio.GPIO_Mode = GPIO_Mode_OUT; gpio.GPIO_OType = GPIO_OType_PP; gpio.GPIO_PuPd = GPIO_PuPd_UP; gpio.GPIO_Speed = GPIO_Speed_100MHz; GPIO_Init(GPIOC, &gpio); GPIO_SetBits(GPIOC, GPIO_Pin_0); gpio.GPIO_Pin = GPIO_Pin_1; gpio.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_Init(GPIOC, &gpio); GPIO_ResetBits(GPIOC, GPIO_Pin_1); //SPI1 output to electronic switch to control mask GPIO_StructInit(&gpio); gpio.GPIO_Pin = GPIO_Pin_6; // SPI1 MISO gpio.GPIO_Mode = GPIO_Mode_AF; gpio.GPIO_OType = GPIO_OType_PP; gpio.GPIO_Speed = GPIO_Speed_50MHz; gpio.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &gpio); GPIO_ResetBits(GPIOA, GPIO_Pin_6); GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_SPI3); GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_SPI3); GPIO_PinAFConfig(GPIOC, GPIO_PinSource12, GPIO_AF_SPI3); // max7456 SPI MOIS MISO SLK pin config gpio.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12; gpio.GPIO_Mode = GPIO_Mode_AF; gpio.GPIO_OType = GPIO_OType_PP; gpio.GPIO_Speed = GPIO_Speed_50MHz; gpio.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_Init(GPIOC, &gpio); // max7456 SPI CS Pin gpio.GPIO_Pin = GPIO_Pin_15; gpio.GPIO_Mode = GPIO_Mode_OUT; gpio.GPIO_OType = GPIO_OType_PP; gpio.GPIO_Speed = GPIO_Speed_50MHz; gpio.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &gpio); GPIO_SetBits(GPIOA,GPIO_Pin_15); Build_Sin_Cos_Tables(); LoadParams(); checkDefaultParam(); SPI_MAX7456_init(); atti_mp_scale = (float)eeprom_buffer.params.Atti_mp_scale_real + (float)eeprom_buffer.params.Atti_mp_scale_frac * 0.01; atti_3d_scale = (float)eeprom_buffer.params.Atti_3D_scale_real + (float)eeprom_buffer.params.Atti_3D_scale_frac * 0.01; atti_3d_min_clipX = eeprom_buffer.params.Atti_mp_posX - (uint32_t)(22*atti_mp_scale); atti_3d_max_clipX = eeprom_buffer.params.Atti_mp_posX + (uint32_t)(22*atti_mp_scale); atti_3d_min_clipY = eeprom_buffer.params.Atti_mp_posY - (uint32_t)(30*atti_mp_scale); atti_3d_max_clipY = eeprom_buffer.params.Atti_mp_posY + (uint32_t)(34*atti_mp_scale); }
void board_init(void) { GPIO_InitTypeDef gpio; SystemCoreClockUpdate(); // turn on peripherals needed by all RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA1 | RCC_AHB1Periph_DMA2 | RCC_AHB1Periph_BKPSRAM, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1 | RCC_APB2Periph_TIM1 | RCC_APB2Periph_SYSCFG, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2 | RCC_APB1Periph_SPI3 | RCC_APB1Periph_TIM2 | RCC_APB1Periph_TIM3 | RCC_APB1Periph_TIM4 | RCC_APB1Periph_TIM5 | RCC_APB1Periph_TIM12 | RCC_APB1Periph_PWR, ENABLE); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK); RCC_LSEConfig(RCC_LSE_OFF); LEDInit(LED_BLUE); LEDInit(LED_GREEN); gpio.GPIO_Pin = GPIO_Pin_0; gpio.GPIO_Mode = GPIO_Mode_OUT; gpio.GPIO_OType = GPIO_OType_PP; gpio.GPIO_PuPd = GPIO_PuPd_UP; gpio.GPIO_Speed = GPIO_Speed_100MHz; GPIO_Init(GPIOC, &gpio); GPIO_SetBits(GPIOC, GPIO_Pin_0); gpio.GPIO_Pin = GPIO_Pin_1; gpio.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_Init(GPIOC, &gpio); GPIO_ResetBits(GPIOC, GPIO_Pin_1); //SPI1 output to electronic switch to control mask GPIO_StructInit(&gpio); gpio.GPIO_Pin = GPIO_Pin_6; // SPI1 MISO gpio.GPIO_Mode = GPIO_Mode_AF; gpio.GPIO_OType = GPIO_OType_PP; gpio.GPIO_Speed = GPIO_Speed_50MHz; gpio.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &gpio); GPIO_ResetBits(GPIOA, GPIO_Pin_6); GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_SPI3); GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_SPI3); GPIO_PinAFConfig(GPIOC, GPIO_PinSource12, GPIO_AF_SPI3); // max7456 SPI MOIS MISO SLK pin config gpio.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12; gpio.GPIO_Mode = GPIO_Mode_AF; gpio.GPIO_OType = GPIO_OType_PP; gpio.GPIO_Speed = GPIO_Speed_50MHz; gpio.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_Init(GPIOC, &gpio); // max7456 SPI CS Pin gpio.GPIO_Pin = GPIO_Pin_15; gpio.GPIO_Mode = GPIO_Mode_OUT; gpio.GPIO_OType = GPIO_OType_PP; gpio.GPIO_Speed = GPIO_Speed_50MHz; gpio.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &gpio); GPIO_SetBits(GPIOA, GPIO_Pin_15); Build_Sin_Cos_Tables(); bool force_clear_params = false; force_clear_params = test_force_clear_all_params(); if (force_clear_params) { clear_all_params(); } LoadParams(); checkDefaultParam(); SPI_MAX7456_init(); set_up_offsets_and_scale(); }