int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_ADC1_Init(); MX_ADC2_Init(); MX_DAC_Init(); MX_TIM2_Init(); MX_TIM3_Init(); /* USER CODE BEGIN 2 */ configure_modem(); acquisition_init(); acquisition_start(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ }
int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* System interrupt init*/ /* Sets the priority grouping field */ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_ADC1_Init(); MX_DAC_Init(); MX_TIM2_Init(); /* USER CODE BEGIN 2 */ HAL_ADC_Start(&hadc1); HAL_DAC_Start(&hdac, DAC_CHANNEL_1); /* USER CODE END 2 */ /* USER CODE BEGIN 3 */ /* Infinite loop */ while (1) { } /* USER CODE END 3 */ }
int main(void) { /* USER CODE BEGIN 1 */ /* Data initialization */ int_T i; /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_ADC1_Init(); MX_ADC2_Init(); MX_CAN1_Init(); MX_CAN2_Init(); MX_DAC_Init(); MX_I2C1_Init(); MX_SPI2_Init(); MX_SPI3_Init(); MX_SPI4_Init(); MX_TIM2_Init(); MX_TIM3_Init(); MX_TIM5_Init(); MX_TIM8_Init(); MX_TIM9_Init(); MX_TIM13_Init(); MX_USART1_UART_Init(); MX_USART2_UART_Init(); MX_USART6_UART_Init(); /* USER CODE BEGIN 2 */ /* Systick configuration and enable SysTickHandler interrupt */ if (SysTick_Config((uint32_t)(SystemCoreClock * 0.5))) { autoReloadTimerLoopVal_S = 1; do { autoReloadTimerLoopVal_S++; } while ((uint32_t)(SystemCoreClock * 0.5)/autoReloadTimerLoopVal_S > SysTick_LOAD_RELOAD_Msk); SysTick_Config((uint32_t)(SystemCoreClock * 0.5)/autoReloadTimerLoopVal_S); } remainAutoReloadTimerLoopVal_S = autoReloadTimerLoopVal_S;//Set nb of loop to do /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ for (i=0;i<1;i++) { OverrunFlags[i] = 0; } /* Model initialization call */ Test_Stateflow_initialize(); /* Infinite loop */ /* Real time from systickHandler */ while (1) { /*Process tasks every solver time*/ if (remainAutoReloadTimerLoopVal_S == 0) { remainAutoReloadTimerLoopVal_S = autoReloadTimerLoopVal_S; /* Check base rate for overrun */ if (OverrunFlags[0]) { rtmSetErrorStatus(Test_Stateflow_M, "Overrun"); } OverrunFlags[0] = true; /* Step the model for base rate */ Test_Stateflow_step(); /* Get model outputs here */ /* Indicate task for base rate complete */ OverrunFlags[0] = false; } } /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ /* USER CODE END 3 */ }
int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_ADC_Init(); APP_ADC_Init(&hadc); #ifdef USE_COMPARATORS MX_COMP1_Init(); MX_COMP2_Init(); #endif MX_DAC_Init(); MX_USART2_UART_Init(); /* USER CODE BEGIN 2 */ HAL_UART_Transmit(&huart2,str,strlen((const char *) str),1000); HAL_UART_Transmit(&huart2,heading,strlen((const char *) heading),1000); dacConfig.DAC_Trigger = DAC_TRIGGER_NONE; dacConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_DISABLE; HAL_DAC_ConfigChannel(&hdac,&dacConfig,DAC_CHANNEL_1); HAL_DAC_SetValue(&hdac,DAC_CHANNEL_1,DAC_ALIGN_12B_R,2048); HAL_DAC_Start(&hdac,DAC_CHANNEL_1); /* Initialize ADC peripheral according to the passed parameters */ if (HAL_ADC_Init(&hadc) != HAL_OK) { while(-1); } /* ### - 2 - Start calibration ############################################ */ if (HAL_ADCEx_Calibration_Start(&hadc, ADC_SINGLE_ENDED) != HAL_OK) { while(-1); } /* ### - 3 - Channel configuration ######################################## */ /* Select Channel 0 to be converted */ ///sConfig.Channel = ADC_CHANNEL_0; //if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK) //{ // Error_Handler(); //} /* ### - 4 - Start conversion in DMA mode ################################# */ if (HAL_ADC_Start_DMA(&hadc, (uint32_t *) adcBuf,ADC_BUFSIZE) != HAL_OK) { while(-1); } compValues[0]= '-'; compValues[1]= '-'; #ifdef USE_COMPARATORS HAL_COMP_Start_IT(&hcomp1); HAL_COMP_Start_IT(&hcomp2); #endif /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ uint16_t cnt=0; uint16_t dacValue = 0; memset(dataline, ' ', sizeof(dataline)); dataline[sizeof(dataline)-1] = 0; while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ HAL_DAC_SetValue(&hdac,DAC_CHANNEL_1,DAC_ALIGN_12B_R,dacValue); #ifdef WAIT_BEFORE_READING int i; for(i=0; i < 10000; i++); #endif itoa (cnt,(char *) &dataline[0],5); itoa (dacValue,(char *)&dataline[10],5); itoa (adcBuf[0],(char *)&dataline[20],4); dataline[25] = '/'; itoa (adcBuf[2],(char *)&dataline[25],4); itoa (adcBuf[1],(char *)&dataline[40],4); dataline[45] = '/'; itoa (adcBuf[3],(char *)&dataline[45],4); #ifdef USE_COMPARATORS dataline[60] = compValues[0]; dataline[65] = compValues[1]; #else // memcpy("Not Used",dataline[60],8); #endif dataline[70] = (HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_6)==GPIO_PIN_SET)?'X':'0'; dataline[75] = (HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_7)==GPIO_PIN_SET)?'X':'0'; dataline[87] = '\r'; dataline[88] = '\n'; dataline[89] = 0; HAL_UART_Transmit(&huart2,dataline,strlen((const char *) dataline),1000); cnt++; dacValue = (dacValue >= (4096-DAC_STEPSIZE))?0:dacValue+DAC_STEPSIZE; } /* USER CODE END 3 */ }
int main(void) { uint8_t oldRelease = 0; /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* Enable I-Cache-------------------------------------------------------------*/ SCB_EnableICache(); /* Enable D-Cache-------------------------------------------------------------*/ SCB_EnableDCache(); /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_ADC1_Init(); MX_DMA_Init(); MX_CAN1_Init(); MX_CAN2_Init(); MX_DAC_Init(); MX_DMA2D_Init(); MX_FMC_Init(); MX_I2C2_Init(); MX_SDMMC1_SD_Init(); MX_SPI2_Init(); MX_TIM6_Init(); MX_TIM7_Init(); MX_USART2_UART_Init(); MX_USART3_UART_Init(); MX_USART6_UART_Init(); MX_FATFS_Init(); MX_USB_HOST_Init(); MX_TIM11_Init(); MX_TIM13_Init(); MX_TIM14_Init(); /* USER CODE BEGIN 2 */ //MPU_Config(); InitPeriph(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while(1){ /* USER CODE END WHILE */ MX_USB_HOST_Process(); /* USER CODE BEGIN 3 */ RoutineFast(); // get and run deals from medium queue if(oldRelease && Touch_Data.status == TOUCH_RELEASED){ ReleaseFunction(); } else {oldRelease = 1;} if(UpdateScreen|| DISP.ReleaseFlag || TimeIsReady){ Run_GUI(); Show_GUI(); UpdateScreen = 0; DISP.ReleaseFlag = 0; } } /* USER CODE END 3 */ }
int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_ADC1_Init(); MX_ADC2_Init(); MX_ADC3_Init(); MX_ADC4_Init(); MX_DAC_Init(); MX_TIM3_Init(); MX_TIM6_Init(); MX_TIM7_Init(); MX_USART2_UART_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /* USER CODE BEGIN RTOS_MUTEX */ /* add mutexes, ... */ /* USER CODE END RTOS_MUTEX */ /* USER CODE BEGIN RTOS_SEMAPHORES */ /* add semaphores, ... */ /* USER CODE END RTOS_SEMAPHORES */ /* USER CODE BEGIN RTOS_TIMERS */ /* start timers, add new ones, ... */ /* USER CODE END RTOS_TIMERS */ /* Create the thread(s) */ /* definition and creation of defaultTask */ osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128); defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); /* USER CODE BEGIN RTOS_THREADS */ /* add threads, ... */ /* USER CODE END RTOS_THREADS */ /* USER CODE BEGIN RTOS_QUEUES */ /* add queues, ... */ /* USER CODE END RTOS_QUEUES */ /* Start scheduler */ osKernelStart(NULL, NULL); /* We should never get here as control is now taken by the scheduler */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ }
int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_ADC_Init(); MX_DAC_Init(); MX_I2C1_Init(); MX_RTC_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ //int loopCnt = 0; while (1) { Button_Function buttonFunction = checkButtonFunction(); if (buttonFunction == BTNFUNC_STATECHN) { wakeupSleepState = (wakeupSleepState == STATE_WAKEUP) ? STATE_SLEEP : STATE_WAKEUP; } if (buttonFunction == BTNFUNC_CAL) { setSensorDevPwr(DEV_PWR_ON); getSnrDrvDacVal(); setSensorDevPwr(DEV_PWR_OFF); wakeupSleepState = STATE_WAKEUP; } if (wakeupSleepState == STATE_WAKEUP) { uint16_t snrAdcVal = 0; setBlueToothDevPwr(DEV_PWR_ON); setSensorDevPwr(DEV_PWR_ON); setSysWakeUpLed(LED_ON); setSysStsLed(LED_OFF); int snrDrvDacVal = readEEPROM32(EEPROM_ADDR_SNRDRVVAL); if ((snrDrvDacVal < 1) || (snrDrvDacVal > 0xFFF)) { getSnrDrvDacVal(); } snrAdcVal = (uint16_t)dacOutAdcIn(snrDrvDacVal, ADC_CHANNEL_8); if (snrAdcVal > SNR_PASS_THRESHOLD) { setTestPassLed(LED_ON); setTestFailLed(LED_OFF); } else { setTestFailLed(LED_ON); setTestPassLed(LED_OFF); } if (hi2c1.State == HAL_I2C_STATE_READY) { setBleSig(BLESIG_HI); if (HAL_I2C_Slave_Transmit(&hi2c1, (uint8_t *)&snrAdcVal, 2, 3000) == HAL_OK) { setSysStsLed(LED_ON); HAL_Delay(100); setSysStsLed(LED_OFF); HAL_Delay(100); setSysStsLed(LED_ON); HAL_Delay(100); setSysStsLed(LED_OFF); } else { setSysStsLed(LED_ON); HAL_Delay(300); setSysStsLed(LED_OFF); } } else { setSysWakeUpLed(LED_OFF); HAL_Delay(100); setSysWakeUpLed(LED_ON); HAL_Delay(100); setSysWakeUpLed(LED_OFF); HAL_Delay(100); setSysWakeUpLed(LED_ON); HAL_Delay(100); } setTestFailLed(LED_OFF); setTestPassLed(LED_OFF); HAL_Delay(1000); setBleSig(BLESIG_LO); HAL_Delay(1000); } else { goSleep(); } /* loopCnt++; if (loopCnt >= 2) { loopCnt = 0; } */ /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ }