void startup_task (void *pvParameters) { (void) pvParameters; MX_GPIO_Init(); /* Init Device Library */ USBD_Init(&hUsbDeviceFS, &VCP_Desc, 0); /* Add Supported Class */ USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC); /* Add CDC Interface Class */ USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS); /* Start Device Process */ USBD_Start(&hUsbDeviceFS); xdev_out(putchar); MX_SDIO_SD_Init(); FATFS_LinkDriver(&SD_Driver, SD_Path); fsInit(); vTaskDelete(NULL); }
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(); }
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_TIM1_Init(); HAL_TIM_Base_Start_IT(&htim1); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { // uint32_t ticksPassed = 0; // if (GPIOA->IDR & 0x01) { // uint32_t ticksPassed = 0; // while (GPIOA->IDR & 0x01) { // ticksPassed++; // } // SysTick_Config(ticksPassed); // } // if (GPIOA->IDR & 0x01) { // // } /* USER CODE END WHILE */ // GPIOE->ODR ^= 0x0000FF00; // int i = 0; // while (i < 1000000) { // i++; // } // HAL_GPIO_TogglePin(GPIOE, 0xFF00); // HAL_Delay(1000); /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ }
int main(void) { /* USER CODE BEGIN 1 */ uint8_t Buf[0x10],Buf1[0x10]; uint16_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(); /* USER CODE BEGIN 2 */ trace_printf("Hello\n"); BSP_UART_Init(115200); /* Initialize I2C */ ASK25_I2C1_Init(); /* Initialize virtual com port */ BSP_VCP_Init(); vgetche(BLOCKING); // Dummy read to get the VCP Connected for(i=0;i<sizeof(Buf);i++) { Buf[i] = i; } /* Write Array to EEPROM */ ASK25_AT24C16_Write(0x106,Buf,sizeof(Buf)); /* Read from EEPROM */ ASK25_AT24C16_Read(0x106,Buf1,sizeof(Buf1)); /* Print to virtual Com port */ ASK25_AT24C16_Display_Array(Buf1,sizeof(Buf1)); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ }
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_ADC_Init(); MX_USART1_UART_Init(); /* USER CODE BEGIN 2 */ char ch; ch = 'x'; HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 100); sprintf(strbuf,"Hello\n"); uint32_t adcvals[5]; HAL_ADC_Start(&hadc); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ HAL_ADC_Start(&hadc); for (int i=0;i<3;i++){ while(HAL_IS_BIT_CLR(hadc.Instance->ISR, (ADC_FLAG_EOC|ADC_FLAG_EOS))){} adcvals[i] = hadc.Instance->DR; } for (int i=0;i<5;i++){ sprintf(strbuf,"i:%d,adc:%4d ",i,adcvals[i]); HAL_UART_Transmit(&huart1,strbuf,strlen(strbuf),1000); } sprintf(strbuf,"\n"); HAL_UART_Transmit(&huart1,strbuf,strlen(strbuf),1000); HAL_Delay(1000); } /* 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_USART1_UART_Init(); /* USER CODE BEGIN 2 */ LCD_Init(2, 20); LCD_PrintString(0, 0, "Damogran Labs"); Encoder_Init(&encoder1, ENC1_A_GPIO_Port, ENC1_A_Pin, ENC1_B_GPIO_Port, ENC1_B_Pin); Encoder_Init(&encoder2, ENC2_A_GPIO_Port, ENC2_A_Pin, ENC2_B_GPIO_Port, ENC2_B_Pin); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ LCD_PrintNumber(1, 0, encoder1.abs_rot); LCD_PrintNumber(1, 6, encoder2.abs_rot); while (1) { if(Encoder_GetState(&encoder1)){ LCD_PrintString(1, 0, " "); LCD_PrintNumber(1, 0, encoder1.abs_rot); } if(Encoder_GetState(&encoder2)){ LCD_PrintString(1, 6, " "); LCD_PrintNumber(1, 6, encoder2.abs_rot); } if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) == GPIO_PIN_SET){ Encoder_SetAbsToZero(&encoder1); Encoder_SetAbsToZero(&encoder2); } HAL_Delay(100); /* 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_I2C2_Init(); MX_RTC_Init(); MX_SPI1_Init(); MX_SPI3_Init(); MX_USB_OTG_FS_PCD_Init(); //HAL_SPI_MspInit(&hspi3); /* USER CODE BEGIN 2 */ //begin(); //setWrap(false); //fillRect(0,0,128,20,ColorHSV(1200,255,255)); // USART_TypeDef USB_UART; // HAL_UART_MspInit(&USB_UART); // HAL_UART_Init(&USB_UART); /* USER CODE END 2 */ /* Infinite loop */ char test[5]= "test"; /* USER CODE BEGIN WHILE */ while (1) { // fillRect(0,0,128,128,ColorHSV(1200,255,255)); HAL_GPIO_WritePin(RED_GPIO_Port, RED_Pin, GPIO_PIN_SET); HAL_Delay(500); HAL_GPIO_WritePin(RED_GPIO_Port, RED_Pin, GPIO_PIN_RESET); HAL_Delay(500); } /* USER CODE END 3 */ }
int main(void) { /* USER CODE BEGIN 1 */ uint8_t data1[0x10],data2[0x10],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(); /* USER CODE BEGIN 2 */ trace_printf("Hello\n"); BSP_UART_Init(115200); /* Initialize SPI */ ASK25_SPI1_Init(); /* Initialize virtual com port */ BSP_VCP_Init(); vgetche(BLOCKING); // Dummy read to get the VCP Connected ASK25_25AA160A_Write_Status_Reg(0x00); for(i=0;i<sizeof(data1);i++) { data1[i] = i; } /* Write Array to EEPROM */ ASK25_25AA160A_Write(0x0000,data1,sizeof(data1)); /* Read from EEPROM */ ASK25_25AA160A_Read(0x0000,data2,sizeof(data2)); /* Print to virtual Com port */ ASK25_25AA160A_Display_Array(data2,sizeof(data2)); /* 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_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 */ USBD_StatusTypeDef result = USBD_OK; uint32_t userSw_old = 0; /* 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_USB_DEVICE_Init(); /* USER CODE BEGIN 2 */ BSP_LED_Init(LED3); BSP_LED_Init(LED4); BSP_PB_Init(BUTTON_USER, BUTTON_MODE_GPIO); userSw_old = BSP_PB_GetState(BUTTON_USER); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ HAL_Delay(40); BSP_LED_Toggle(LED4); if ((BSP_PB_GetState(BUTTON_USER) == GPIO_PIN_SET) && (userSw_old == GPIO_PIN_RESET)) { result = CDC_Transmit_FS(USB_TxBufferFS, sizeof(USB_TxBufferFS)); } userSw_old = BSP_PB_GetState(BUTTON_USER); /* USB Error */ if (result != USBD_OK) { while (1) { BSP_LED_On(LED3); HAL_Delay(100); } } } /* 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_I2S2_Init(); MX_SDIO_SD_Init(); MX_FATFS_Init(); /* USER CODE BEGIN 2 */ printf("Init complete"); //WavePlayerStartSample(); while((res=f_mount (&fatfs, SD_Path, 1))!=FR_OK) { printf("QQ"); } WavePlayerStart_DMA("0:/akuno.wav"); //playindex=rand()%6; /*switch(playindex) { case : WavePlayerStart_DMA("0:/test.wav"); break; case 1: WavePlayerStart_DMA("0:/akuno.wav"); break; default: WavePlayerStart_DMA("0:/akuno.wav"); break; }*/ /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ //WavePlayerStart_DMA("0:/test.wav"); } /* USER CODE END 3 */ }
int main(void) { /* USER CODE BEGIN 1 */ trace_printf("Hello\n"); /* 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(); /* USER CODE BEGIN 2 */ BSP_PB_Init(BUTTON_KEY,BUTTON_MODE_EXTI); // initialize on board switch BSP_LED_Init(LED5); // initialize on baord LED 4 and LED 5 BSP_LED_Init(LED4); /* Check if the system has resumed from WWDG reset */ if(__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET) { /* WWDGRST flag set: Turn LED1 on */ BSP_LED_On(LED5); /* Clear reset flags */ __HAL_RCC_CLEAR_RESET_FLAGS(); } else { /* WWDGRST flag is not set: Turn LED1 off */ BSP_LED_Off(LED5); } /* Initialize and start IWDG */ BSP_IWDG_Init(2000); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ BSP_LED_Toggle(LED4); HAL_Delay(1850); /* Refresh the IWDG reload count value */ HAL_IWDG_Refresh(&hiwdg_bsp); } /* 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_ADC1_Init(); MX_USART6_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_ADC_Start_IT(&hadc1); //Zonder DMA (op interrupt) // while(counter < 2)HAL_GPIO_WritePin(GPIOD,LD6_Pin,GPIO_PIN_SET); //HAL_GPIO_WritePin(GPIOD,LD6_Pin,GPIO_PIN_RESET); if(counter == BUFFER_LENGTH * 2) { Uart_transmit(BufferPin1); Uart_transmit(BufferPin2); counter = 0; } /*if(HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0)) { HAL_Delay(500); HAL_GPIO_WritePin(GPIOD,LD3_Pin,GPIO_PIN_SET);//GREEN //zonder DMA Single Scan sprintf(buffer,"pin a1: %05d ",val1); HAL_UART_Transmit(&huart6,(uint8_t*) buffer,strlen(buffer),HAL_MAX_DELAY); sprintf(buffer,"pin a2: %05d ",val2); HAL_UART_Transmit(&huart6,(uint8_t*) buffer,strlen(buffer),HAL_MAX_DELAY); HAL_UART_Transmit(&huart6,"\r\n",strlen("\r\n"),HAL_MAX_DELAY); }*/ } /* 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_I2C1_Init(); MX_RTC_Init(); MX_SPI2_Init(); MX_TIM1_Init(); MX_TIM2_Init(); MX_TIM3_Init(); MX_TIM4_Init(); MX_USART3_UART_Init(); /* USER CODE BEGIN 2 */ encoderInit(); pwmInit(); // adcInit(); uartInit(); timInterruptInit(); gyroInit(GYROHIGH); calibrateGyro(); // rotaryRight(800); // HAL_Delay(500); // rotaryLeft(800); drive(VEL); /* 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) { RCC->AHB1ENR |= 0xFFFFFFFF; RCC->AHB2ENR |= 0xFFFFFFFF; RCC->AHB3ENR |= 0xFFFFFFFF; RCC->APB1ENR |= 0xFFFFFFFF; RCC->APB2ENR |= 0xFFFFFFFF; /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); initIGVCCallbackTimer(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_ADC2_Init(); i2cInit(); commsUsartInit(); MX_USB_OTG_FS_USB_Init(); adc_init(); initSteeringMotor(); initSteering(); initSpeedDAC(); initEncoderInputCapture(); initAutomanInt(); addCallbackTimer(1000, led6Toggle, NULL); printf("Hello.\r\n"); while(1) { serviceTxDma(); serviceCallbackTimer(); serviceUSBWrite(); serviceI2C(); serviceAutoman(); consoleProcessBytes(); uint8_t dataIn; while (doubleBuffer_read(&usbReceiveBuffer, &dataIn, 1)) { runCommsFSM((char)dataIn); } } }
int main(void) { /* USER CODE BEGIN 1 */ uint32_t test; /* 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(); /* USER CODE BEGIN 2 */ BSP_UART_Init(115200); /* Initialize on board LED4 */ BSP_LED_Init(LED4); trace_printf("Hello\n"); /* Configure MPU region */ MPU_Config(); /* Try to access memory region 1 */ uprintf("Trying to read memory from region 1\n\r"); test = (*(unsigned int *)0x08000010); uprintf("some value at location 0x08000010: %08x \n\r",test ); uprintf("Read successful!!!\n\r"); /* Try to access memory region 2 */ uprintf("Trying to read memory from region 2\n\r"); uprintf("Memory management fault occur: LED4 will Glow"); test = (*(unsigned int *)0x20002001); uprintf("some value at location 0x20002001: %08x \n\r",test ); /* 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 */ 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_ADC1_Init(); MX_DMA2D_Init(); MX_FMC_Init(); MX_I2C3_Init(); MX_LTDC_Init(); MX_RNG_Init(); MX_SPI5_Init(); BSP_LCD_Init(); BSP_LCD_LayerDefaultInit(LCD_BACKGROUND_LAYER, LCD_FRAME_BUFFER); BSP_LCD_LayerDefaultInit(LCD_FOREGROUND_LAYER, LCD_FRAME_BUFFER); BSP_LCD_SelectLayer(LCD_FOREGROUND_LAYER); BSP_LCD_Clear(LCD_COLOR_BLACK); BSP_LCD_DisplayOn(); uint8_t Button_Value; GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitStruct.Pin |= GPIO_PIN_0; GPIO_InitStruct.Mode = 0x00; GPIO_InitStruct.Pull = 0x02; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); while (1) { for(uint16_t i = 0; i < SIZE; i+=2) { HAL_ADC_Start(&hadc1); HAL_ADC_PollForConversion(&hadc1,1000); samples[i] = HAL_ADC_GetValue(&hadc1); samples[i+1] = 0; HAL_ADC_Stop(&hadc1); } Button_Value = HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0); if( Button_Value ) { fft(); } else { display_samples(samples); } } }
int main(void) { /* USER CODE BEGIN 1 */ trace_printf("Hello\n"); /* 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(); /* USER CODE BEGIN 2 */ BSP_UART_Init(9600); BSP_VCP_Init(); vgetche(BLOCKING); // Dummy read to get the VCP Connected /* display string */ vuprintf("AT\n\r"); HAL_Delay(500); if(BSP_GSM_ConnectTest()==1) { /* display string */ vuprintf("Connecting... \n\r"); HAL_Delay(500); vuprintf("Successful! \n\r"); HAL_Delay(500); } else { vuprintf("Fail \n\r"); while(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) { 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(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_ADC1_Init(); MX_CAN1_Init(); MX_CAN2_Init(); MX_I2C2_Init(); MX_IWDG_Init(); MX_SPI2_Init(); MX_SPI3_Init(); MX_TIM1_Init(); MX_USART1_UART_Init(); MX_USART6_UART_Init(); /* USER CODE BEGIN 2 */ /* 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 */ trace_printf("Hello\n"); RTC_TimeTypeDef Tim; RTC_DateTypeDef Dat; /* 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(); /* USER CODE BEGIN 2 */ /* Initialize LED 4 */ BSP_LED_Init(LED4); /* Initialize RTC */ BSP_RTC_Init(); BSP_RTC_Alarm_Init(AlarmA,0,0,5,RTC_ALARMDATEWEEKDAYSEL_DATE); //Generate alarm interrupt /* Initialize UART with 115200 baud rate */ BSP_UART_Init(115200); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ __HAL_RTC_ALARM_CLEAR_FLAG(&hrtc_bsp,RTC_ISR_ALRAF); __HAL_RTC_ALARM_CLEAR_FLAG(&hrtc_bsp,RTC_ISR_ALRBF); HAL_RTC_GetTime(&hrtc_bsp,&Tim,FORMAT_BIN); HAL_RTC_GetDate(&hrtc_bsp,&Dat,FORMAT_BIN); Tim.SubSeconds = 1000 - ((hrtc_bsp.Instance->SSR*1000)/hrtc_bsp.Init.SynchPrediv); // Count msec uprintf("\x1b[3;1H %d02 : %d02 : %d02 : %d04",Tim.Hours,Tim.Minutes,Tim.Seconds,Tim.SubSeconds); // uprintf("\x1b[4;1H %d02 / %d02 / %d04", Dat.Date,Dat.Month,Dat.Year); } /* USER CODE END 3 */ }
int main(void) { int autorun; // double calcfreq; // double CurrentFreq = 144e6; /* 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_SPI1_Init(); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET); MX_TIM3_Init(); MX_TIM14_Init(); MX_USB_DEVICE_Init(); Morse_Init(); // prepare_pll(); // UpdateFrequencyRegisters(CurrentFreq, 50000000.0, 5000, 1, 1, &calcfreq); // PLL_Sync(); autorun = cmd_isautorun() ; /* Infinite loop */ while (1) { if (is_line_received()) { // Process received line cmd_proc(get_line_buffer()); } HAL_Delay(10); ar_count++; if ((ar_count > 1000) & (autorun>0)) { // Start Autorun cmd_autorun(autorun); cw_autorunning = 1; while(cw_autorunning) HAL_Delay(10); } } }
void board_init(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(); // HAL_UART_Init(&huartex2.huart); HAL_UART_Init(&huartex3.huart); }
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_IWDG_Init(); /* USER CODE BEGIN 2 */ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ HAL_Delay(500); HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET); // Watchdog will reset once its timer runs out // unless it is refreshed with the following line uncommented: //HAL_IWDG_Refresh(&hiwdg); } /* 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(); /* 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 */ /* 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_USART3_UART_Init(); MX_TIM2_Init(); /* USER CODE BEGIN 2 */ nec.timerHandle = &htim2; nec.timerChannel = TIM_CHANNEL_1; nec.timerChannelActive = HAL_TIM_ACTIVE_CHANNEL_1; nec.timingBitBoundary = 1680; nec.timingAgcBoundary = 12500; nec.type = NEC_NOT_EXTENDED; nec.NEC_DecodedCallback = myNecDecodedCallback; nec.NEC_ErrorCallback = myNecErrorCallback; nec.NEC_RepeatCallback = myNecRepeatCallback; NEC_Read(&nec); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_12); HAL_Delay(100); HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_13); HAL_Delay(100); } /* USER CODE END 3 */ }
int main(void) { /* USER CODE BEGIN 1 */ char ADC_Tx_Data[70]; /* 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_USART1_UART_Init(); /* USER CODE BEGIN 2 */ HAL_UART_Receive_IT(&huart1, (uint8_t *)Rx_Data, 1); HAL_ADC_Start_DMA(&hadc1, (uint32_t*)&ADC_Value, 6); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { HAL_Delay(15); HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_4); HAL_Delay(15); HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_0); HAL_Delay(15); HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_1); HAL_Delay(15); HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_2); HAL_Delay(15); sprintf(ADC_Tx_Data,"ADC1:%4d\tADC2:%4d\tADC3:%4d\tADC4:%4d\tADC5:%4d\tADC6:%4d\n\r", ADC_Value[0], ADC_Value[1], ADC_Value[2], ADC_Value[3], ADC_Value[4], ADC_Value[5]); HAL_UART_Transmit_IT(&huart1, (uint8_t *)ADC_Tx_Data, 70); /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ }