void stm32_soc_init(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_USART2_UART_Init(); }
int main(void) { HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); MX_CAN_Init(); MX_I2C1_Init(); MX_USART3_UART_Init(); MX_USART2_UART_Init(); MX_USART1_UART_Init(); MX_TIM1_Init(); USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS); USBD_RegisterClass(&hUsbDeviceFS, &USBD_CUSTOM_HID); USBD_CUSTOM_HID_RegisterInterface(&hUsbDeviceFS, &USBD_CustomHID_fops_FS); USBD_Start(&hUsbDeviceFS); while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_1); HAL_Delay(blinkingDelay); } /* 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_USART2_UART_Init(); /* USER CODE BEGIN 2 */ dc_main(); /* 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) { uint8_t opt = 0; /* 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_USART2_UART_Init(); /* Enable USART2 interrupt */ HAL_NVIC_SetPriority(USART2_IRQn, 0, 0); HAL_NVIC_EnableIRQ(USART2_IRQn); printMessage: printWelcomeMessage(); while (1) { opt = readUserInput(); if(opt > 0) { processUserInput(opt); if(opt == 3) goto printMessage; } performCriticalTasks(); } }
void SleepMode(void) { GPIO_InitTypeDef GPIO_InitStruct; /* Disable all GPIOs to reduce power */ MX_GPIO_Deinit(); /* Configure User push-button as external interrupt generator */ __HAL_RCC_GPIOC_CLK_ENABLE(); GPIO_InitStruct.Pin = B1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); HAL_UART_DeInit(&huart2); /* Suspend Tick increment to prevent wakeup by Systick interrupt. Otherwise the Systick interrupt will wake up the device within 1ms (HAL time base) */ HAL_SuspendTick(); __HAL_RCC_PWR_CLK_ENABLE(); /* Request to enter SLEEP mode */ HAL_PWR_EnterSLEEPMode(0, PWR_SLEEPENTRY_WFI); /* Resume Tick interrupt if disabled prior to sleep mode entry*/ HAL_ResumeTick(); /* Reinitialize GPIOs */ MX_GPIO_Init(); /* Reinitialize UART2 */ MX_USART2_UART_Init(); }
void Nucleo_BSP_Init() { /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_USART2_UART_Init(); }
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_I2C3_Init(); MX_TIM1_Init(); MX_TIM2_Init(); MX_TIM3_Init(); MX_TIM4_Init(); MX_TIM5_Init(); MX_USART1_UART_Init(); MX_USART2_UART_Init(); MX_TIM11_Init(); /* USER CODE BEGIN 2 */ HAL_TIM_Base_Start_IT(&htim11); // 100 msec timer initSonar( MAX_SONAR); initSerOutput(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ // >>>>> Sonar reading triggerSonar( COUPLE_0_2); HAL_Delay(49); triggerSonar( COUPLE_1_3); HAL_Delay(49); // <<<<< Sonar reading // >>>>> Serial Output convertMeasures(); sendMeasures(); // <<<<< Serial Output } /* USER CODE END 3 */ }
int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ Task_Info_t TaskState=TASK_INFO_INIT; /* 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_DMA_Init(); MX_USART6_UART_Init(); MX_USART1_UART_Init(); MX_USART2_UART_Init(); MX_USART3_UART_Init(); MX_TimerDynamixel_Init(&TimHandle2 , TIM2); MX_TimerDynamixel_Init(&TimHandle3 , TIM3); MX_TimerDynamixel_Init(&TimHandle4 , TIM4); Trace_Init(); HAL_Delay(1000); Trace_Raw("Medula control board start...\n\r"); Dynamixel_Init(); IO_Data_init(); while (0) { Dynamixel_test(&TaskState); Trace_Task(); } while (1) { HAL_Delay(10); IO_Data_Scan_In(); Appli(&TaskState); Trace_Task(); HAL_Delay(5); IO_Data_Scan_Out(); } /* USER CODE END 3 */ }
int main(void) { HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); MX_SPI2_Init(); MX_USART2_UART_Init(); CMainMenu::init(); CMainMenu::run(); }
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(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_SPI1_Init(); MX_USART2_UART_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ int code = init(); if(code < 0) { UART_Printf("init() failed with code %d, terminating.\r\n", code); return 0; } while (1) { loop(); /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ }
int main(void) { /* USER CODE BEGIN 1 */ SCB->VTOR = FLASH_START_SECTOR_ADDR; SEGGER_RTT_Init(); /* 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_I2C1_Init(); MX_I2C2_Init(); MX_SPI1_Init(); MX_TIM3_Init(); MX_USART2_UART_Init(); MX_RTC_Init(); /* USER CODE BEGIN 2 */ //as7000_init(); /* USER CODE END 2 */ /* Call init function for freertos objects (in freertos.c) */ MX_FREERTOS_Init(); /* Start scheduler */ osKernelStart(); /* 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_DMA_Init(); MX_SPI1_Init(); MX_TIM2_Init(); MX_TIM3_Init(); MX_TIM7_Init(); MX_TIM10_Init(); MX_TIM11_Init(); MX_TIM13_Init(); MX_TIM14_Init(); MX_USART1_UART_Init(); MX_USART2_UART_Init(); /* USER CODE BEGIN 2 */ HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); //Motor1 HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4); //Motor2 HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1); //Motor3 HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4); //Motor4 /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ }
/** * @brief The application entry point. * @retval int */ 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(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_USART2_UART_Init(); MX_I2C1_Init(); MX_TIM2_Init(); /* USER CODE BEGIN 2 */ Display_Init(); CircularBuff_Init(); DisplayUpdater_Init(); HAL_TIM_Base_Start_IT(&htim2); //start timer2 in interrupt mode. /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ __WFI(); // CPU sleep } /* 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_USART2_UART_Init(); MX_USART3_UART_Init(); MX_TIM3_Init(); /* USER CODE BEGIN 2 */ HAL_TIM_Base_Start_IT(&htim3); HAL_UART_Transmit_DMA(&huart3,g_cUart3_Buff,BUFFSIZE); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ HAL_UART_Receive_DMA(&huart3,g_cUart3_Buff,BUFFSIZE); //HAL_UART_Transmit_IT(&huart3,g_cUart3_Buff,5); /* 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_TIM2_Init(); MX_USART2_UART_Init(); MX_USART6_UART_Init(); MX_USART1_UART_Init(); /* USER CODE BEGIN 2 */ HAL_TIM_Base_Start_IT(&htim2); #ifdef DEBUG_TO_CONSOLE initialise_monitor_handles(); printf("start\n"); #endif UARTInit(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ UARTLoopDemo(); } /* 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_DMA_Init(); MX_I2C1_Init(); MX_I2S2_Init(); MX_I2S3_Init(); MX_SPI1_Init(); MX_SPI4_Init(); MX_TIM3_Init(); MX_USART2_UART_Init(); MX_USB_DEVICE_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /*## FatFS: Link the USER disk I/O driver ###############################*/ USER_DriverNum = FATFS_LinkDriver(&USER_Driver, USER_Path); /* USER CODE BEGIN 3 */ dabstick_loop(); // endless return 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_RTC_Init(); //if(!(*(volatile uint32_t *) (BDCR_RTCEN_BB)))__HAL_RCC_RTC_ENABLE(); MX_TIM2_Init(); MX_TIM3_Init(); MX_USART1_UART_Init(); MX_USART2_UART_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ HAL_RTC_GetTime(&hrtc, &myTime, FORMAT_BIN); HAL_RTC_GetDate(&hrtc, &myDate, FORMAT_BIN); } /* 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_USART2_UART_Init(); /* USER CODE BEGIN 2 */ char *msg = "Nucleo-64 ISR-UART-DMA Fun!\n\r"; HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), 0xFFFF); HAL_UART_Receive_DMA(&huart2, &rxBuffer, 1); /* 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(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_I2C1_Init(); MX_USART2_UART_Init(); /* USER CODE BEGIN 2 */ HAL_DBGMCU_EnableDBGSleepMode(); HAL_SuspendTick(); // we don't want systick to wake us up every 1ms main_app(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI); } /* 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_USART2_UART_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ HAL_UART_Transmit_IT(&huart2,pString,sizeof(pString)/sizeof(char)); HAL_Delay(500); } /* USER CODE END 3 */ }
int main(void) { uint8_t opt = 0; /* 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_USART2_UART_Init(); printMessage: printWelcomeMessage(); while (1) { opt = readUserInput(); processUserInput(opt); if(opt == 3) goto printMessage; } }
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_USART1_UART_Init(); MX_USART2_UART_Init(); MX_SPI1_Init(); /* USER CODE BEGIN 2 */ /* 硬件初始化开始 */ // USART_printf( &BSP_USART_PRINT, "开始硬件初始化!\n"); /* 初始化输出 */ ControlOut_Init( ); /* 初始化控制模式 */ ModeControl_Init( ); /* 初始化主控模块 */ DataProcess_Init( ); /*启动循环接收DMA*/ HAL_UART_Receive_DMA(&BSP_USART_SENSOR, (uint8_t*)&gUSART1_RX_TMP, 1); /* 硬件初始化结束 */ // USART_printf( &BSP_USART_PRINT, "硬件初始化结束 !\n"); /* 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 MainTask */ osThreadDef(MainTask, StartMainTask, osPriorityBelowNormal, 0, 128); MainTaskHandle = osThreadCreate(osThread(MainTask), NULL); /* definition and creation of DataParseTask */ osThreadDef(DataParseTask, StartDataParseTask, osPriorityNormal, 0, 160); DataParseTaskHandle = osThreadCreate(osThread(DataParseTask), NULL); /* definition and creation of DataProcessTask */ osThreadDef(DataProcessTask, StartDataProcessTask, osPriorityAboveNormal, 0, 256); DataProcessTaskHandle = osThreadCreate(osThread(DataProcessTask), NULL); /* definition and creation of DataOutTask */ osThreadDef(DataOutTask, StartDataOutTask, osPriorityHigh, 0, 160); DataOutTaskHandle = osThreadCreate(osThread(DataOutTask), NULL); /* definition and creation of PrintTask */ osThreadDef(PrintTask, StartPrintTask, osPriorityBelowNormal, 0, 128); PrintTaskHandle = osThreadCreate(osThread(PrintTask), NULL); /* USER CODE BEGIN RTOS_THREADS */ /* add threads, ... */ /* USER CODE END RTOS_THREADS */ /* Create the queue(s) */ /* definition and creation of ReceiveDataQueue */ osMessageQDef(ReceiveDataQueue, 128, uint8_t); ReceiveDataQueueHandle = osMessageCreate(osMessageQ(ReceiveDataQueue), NULL); /* definition and creation of PrintQueues */ osMessageQDef(PrintQueues, 512, uint8_t); PrintQueuesHandle = osMessageCreate(osMessageQ(PrintQueues), NULL); /* USER CODE BEGIN RTOS_QUEUES */ /* add queues, ... */ /* 创建传感器采集值邮箱 */ gSenorDataMail = osMailCreate(osMailQ(gSenorDataMail), NULL); /* 创建处理结果输出邮箱 */ gControlDataMail = osMailCreate(osMailQ(gSenorDataMail), NULL); /* USER CODE END RTOS_QUEUES */ /* Start scheduler */ osKernelStart(); /* 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_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) { /* 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_CRC_Init(); MX_I2C1_Init(); MX_SPI2_Init(); MX_TIM2_Init(); MX_TIM3_Init(); MX_TIM4_Init(); MX_USART2_UART_Init(); /* USER CODE BEGIN 2 */ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET); // reinitialize uart with speed from config huart2.Init.BaudRate = USART_DEBUG_SPEED; HAL_UART_Init(&huart2); DEBUG_PRINTF("Hello, Lepton!\n\r"); fflush(stdout); lepton_init(); HAL_Delay(1000); init_lepton_command_interface(); #ifdef ENABLE_LEPTON_AGC enable_lepton_agc(); #endif #ifdef Y16 enable_telemetry(); #else enable_rgb888(PSUEDOCOLOR_LUT); #endif DEBUG_PRINTF("reading_tmp007_regs...\n\r"); read_tmp007_regs(); DEBUG_PRINTF("Initialized...\n\r"); HAL_Delay(250); MX_USB_DEVICE_Init(); PT_INIT(&lepton_task_pt); PT_INIT(&usb_task_pt); PT_INIT(&uart_task_pt); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ PT_SCHEDULE(lepton_task(&lepton_task_pt)); PT_SCHEDULE(usb_task(&usb_task_pt)); PT_SCHEDULE(uart_task(&uart_task_pt)); PT_SCHEDULE(button_task(&button_task_pt)); } /* 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 */ osKernelInitialize(); /* 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_TIM2_Init(); MX_USART2_UART_Init(); MX_TIM4_Init(); MX_TIM3_Init(); MX_ADC1_Init(); /* USER CODE BEGIN 2 */ //#ifdef USE_FULL_ASSERT #ifndef MAC_COORDINATOR // Board - Serial identification sprintf(Buf, "\x0cNUCLEO-F446 Debug Terminal\r\nVisible Light Communication " "Project\r\n---\r\nDEV_CONFIG=%d\r\n\r\n", DEV_CONFIG); HAL_UART_Transmit(&huart2, (uint8_t *) Buf, strlen(Buf), 0xffff); #endif //#endif // Initialize Optical Driver DRV_Init(); // Initialize PHY layer PHY_Init(); // Initialize MAC APP layer MAC_AppInit(); // Create threads #ifdef MAC_COORDINATOR tid_blinkLED = osThreadCreate (osThread(blinkLED), NULL); #endif //tid_sendSerial = osThreadCreate (osThread(sendSerial), NULL); //tid_checkButton = osThreadCreate (osThread(checkButton), NULL); // Start thread execution osKernelStart(); // Run codes DRV_RX_Start(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { osDelay(1000); #ifdef MAC_COORDINATOR osSignalSet(tid_blinkLED, 0x0001); #endif } /* 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(); char is_joint = 1; if(is_joint) { // init multiplexer pins MX_SPI1_Init(); } else { MPX_UART_Init(); } MX_USART1_UART_Init(); MX_USART2_UART_Init(); /* USER CODE BEGIN 2 */ LED_init(); if(is_joint) { // set spi chip select high HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET); //init_2D(hspi1, GPIOB, GPIO_PIN_1); init_1D(); } else { // set spi chip select high MPX_UART_ONOFF(1); } huart_T = &huart2; huart_U = &huart1; float alpha, beta, delta; /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ USART_RX_FINISHED=0; USART_TX_FINISHED=1; // if(HAL_UART_Receive_IT(huart_U, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK) // { // char error = 1; // } int i = 0; //MPX_UART_Open(3); while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ if(is_joint & USART_TX_FINISHED) { get_2D(hspi1, GPIOB, GPIO_PIN_1, &alpha, &beta); get_1D(hspi1, GPIOA, GPIO_PIN_4, &delta); length = snprintf(usart_buffer, 128, "%f : %f : %f\r\n", alpha, beta, delta); USART_TX_FINISHED = 0; HAL_UART_Transmit(huart_T, usart_buffer, length, 20); } else { //length = snprintf(usart_buffer, 128, "hello"); //MPX_UART_Transmit(huart_T, i%5, usart_buffer, length, 20); //HAL_Delay(200); //length = snprintf(usart_buffer, 128, "hello\r\n", alpha, beta, delta); //HAL_UART_Transmit(huart_U, usart_buffer, length, 20); } // // if(USART_RX_FINISHED==1) // { // if(aRxBuffer[0]=='r') // { // HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0); // } // else if(aRxBuffer[0]=='b') // { // HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_4); // } // /*else if(aRxBuffer[0]=='g') // { // HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_1); // }*/ // else // { // //HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_1); // HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_4); // HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0); // } // // HAL_UART_Transmit(huart_T, aRxBuffer, RXBUFFERSIZE, 20); // // USART_RX_FINISHED=0; // // if(HAL_UART_Receive_IT(huart_U, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK) // { // char error = 1; // } // } //HAL_UART_Transmit(&huart2, "ABC", 3, 20); i++; } /* 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_CAN_Init(); MX_IWDG_Init(); MX_USART1_UART_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(); /* 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) { /* 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_TIM3_Init(); MX_USART2_UART_Init(); MX_USART6_UART_Init(); //Clean the one-byte buffer used to for UART reception husart6RxBuffer = 0; husart2RxBuffer = 0; //Initialize the LEDs BSP_LED_Init(LED3); BSP_LED_Init(LED4); BSP_LED_Init(LED5); BSP_LED_Init(LED6); BSP_LED_Toggle(LED3); BSP_LED_Toggle(LED5); //Clear the buffer to remove trash memset(localDataBuffer,0, sizeof(localDataBuffer)); localDataLength = 0; //Enable IT upon reception for userUart HAL_UART_Receive_IT(&huart6, &husart6RxBuffer,1); //Enable IT upon reception for deviceUart HAL_UART_Receive_IT(&huart2, &husart2RxBuffer,1); //Enable PeriodEllapsed IT for TIM3 (used for periodic data transfer) HAL_TIM_Base_Start_IT(&htim3); //Init the BTDevice library initBTDevice(); //Init the reed switch sensor: GPIO, NVIC initReedSwitch(); //Display the command menu on userUart BTDevice_displayMenu(); //Automatically initialize the BTDevice with default settings and perfom a signal check //The device will try to join the network untill successful. LED visuals will signal success. BTDevice_AutoInitTypeDef defaultValues = {0}; defaultValues.timerPeriodValue = 300; defaultValues.autoModeStatus = AUTOMODE_OFF; while(BTDevice_initLoop(defaultValues) != BTDevice_OK) ; //Blink the LEDS when the device joins the network doTheLEDPlay(NULL); /** * Main Loop * the library mainLoop fct will be called to process UART and TIM interupts * when a message was received by the device (from the gateway), a special handler function is called */ while (1) { BTDevice_mainLoop(); //True when data is received from the gateway if(deviceCommandReceivedFlag){ deviceCommandReceivedFlag = 0; //Lower the flag deviceCommandReceived(); //Call the handler to analyse the received data. } } }