Пример #1
1
int main(void) {
  char msg[20];
  uint16_t rawValues[3];
  float temp;

  HAL_Init();
  Nucleo_BSP_Init();

  /* Initialize all configured peripherals */
  MX_TIM1_Init();
  MX_ADC1_Init();

  HAL_ADCEx_Calibration_Start(&hadc1);

  HAL_TIM_Base_Start(&htim1);
  HAL_ADC_Start_DMA(&hadc1, (uint32_t*)rawValues, 1);

  while(1) {
    while(!convCompleted);

     for(uint8_t i = 0; i < 1; i++) {
      temp = ((float)rawValues[i]) / 4095 * 3300;
      temp = ((temp - 1430.0) / 4.3) + 25;

      sprintf(msg, "rawValue %d: %hu\r\n", i, rawValues[i]);
      HAL_UART_Transmit(&huart2, (uint8_t*) msg, strlen(msg), HAL_MAX_DELAY);

      sprintf(msg, "Temperature %d: %f\r\n",i,  temp);
      HAL_UART_Transmit(&huart2, (uint8_t*) msg, strlen(msg), HAL_MAX_DELAY);
    }
    convCompleted = 0;
  }
}
Пример #2
0
    result_t init(Port p, const Config &config)
    {
        if(false == supported(p))
        {
            return resNOK;
        }
        
        if(true == initialised(p))
        {
            return resOK;
        }
        
        s_config = config;
                        
        // init peripherals: adc1 and dma1
        MX_ADC1_Init();
        // dma is globally initted by stm32hal_bsp_init() because it hold all dma peripherals
        //MX_DMA_Init(); 
        

        // init internal variables        
        s_adc_isrunning = false;
        
        embot::binary::bit::set(initialisedmask, port2index(p));

        return resOK;
    }
Пример #3
0
void adcSetResolution (uint8_t res){
	samplingDisable();
	HAL_ADC_Stop_DMA(&hadc1);
	HAL_ADC_Stop_DMA(&hadc2);
	HAL_ADC_Stop_DMA(&hadc3);
	if(res==8){
		ADCResolution	= ADC_RESOLUTION8b;
	}else if(res==12){
		ADCResolution	= ADC_RESOLUTION12b;
	}else{
		return;
	}
	
	HAL_ADC_DeInit(&hadc1);
	HAL_ADC_DeInit(&hadc2);
	HAL_ADC_DeInit(&hadc3);
	
	HAL_DMA_DeInit(&hdma_adc1);
	HAL_DMA_DeInit(&hdma_adc2);
	HAL_DMA_DeInit(&hdma_adc3);
	
	MX_ADC1_Init();
  MX_ADC2_Init();
  MX_ADC3_Init();
} 
Пример #4
0
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 */

}
Пример #5
0
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 */

}
Пример #6
0
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);

		}
	}
}
Пример #7
0
void InitSystem(DeviceConfig *devState){
    // init HAL 
    HAL_Init();
   
    /* Configure the system clock */
    SystemClock_Config();

    /* Initialize all configured peripherals */ 
    InitDeviceConfig(devState);  
   
    MX_USB_DEVICE_Init();

    MX_GPIO_Init();
    MX_I2C2_Init(devState);
    MX_ADC1_Init(devState);
    MX_ADC1_Init(devState);
    MX_SPI2_Init(devState);
    MX_TIM4_Init(devState);
    MX_USART3_UART_Init(devState);
    init_printf(NULL,usb_putc);
}
Пример #8
0
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 */

}
Пример #9
0
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_IWDG_Init();
  MX_SDADC1_Init();
  MX_SDADC2_Init();
  MX_TSC_Init();
  MX_TIM2_Init();
  MX_TIM3_Init();
  MX_SDADC3_Init();
  MX_USB_DEVICE_Init();
  MX_RTC_Init();
  MX_TIM6_Init();
  MX_TIM7_Init();

  /* USER CODE BEGIN 2 */
  Setup();
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
	  loop();
  }
  /* USER CODE END 3 */

}
Пример #10
0
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_TIM1_Init();
  MX_TIM2_Init();
  MX_USART1_UART_Init();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  HAL_TIM_Base_Start_IT(&htim1);
  HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_1);
  HAL_TIMEx_PWMN_Start(&htim1,TIM_CHANNEL_1);
  HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_2);
  HAL_TIMEx_PWMN_Start(&htim1,TIM_CHANNEL_2);
  HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_3);
  HAL_TIMEx_PWMN_Start(&htim1,TIM_CHANNEL_3);
  HAL_TIM_Base_Start_IT(&htim2);
  while (1)
  {
  /* USER CODE END WHILE */
  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}
Пример #11
0
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_SPI1_Init();
  MX_TIM1_Init();
  MX_TIM4_Init();
  MX_TIM6_Init();
  MX_USART1_UART_Init();
  MX_USART2_UART_Init();
  MX_USART3_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 */

  FlyMain();
  }
  /* USER CODE END 3 */

}
Пример #12
0
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_TIM1_Init();
  MX_TIM3_Init();
  MX_ADC1_Init();
  MX_TIM2_Init();

  /* USER CODE BEGIN 2 */
  
  //Start PWM
  HAL_TIM_Base_Start(&htim1);
  HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_ALL);
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
	HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);     
	HAL_Delay(100);
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}
Пример #13
0
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();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  int ADCValue = 0;
  while (1)
  {
  /* USER CODE END WHILE */
	  HAL_ADC_Start(&hadc1);
	  if (HAL_ADC_PollForConversion(&hadc1, 1000000) == HAL_OK){
		  ADCValue = HAL_ADC_GetValue(&hadc1);
	  }
	  HAL_Delay(100);


  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}
Пример #14
0
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 */

}
Пример #15
0
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 */

}
Пример #16
0
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_DMA_Init();
  MX_ADC1_Init();
  MX_I2C1_Init();
  MX_TIM10_Init();
  MX_TIM11_Init();
  MX_USART1_UART_Init();

  xTaskCreate(task_safety, "Safety", 350, NULL, 1, NULL);
  xTaskCreate(task_master, "Master", 350, NULL, 1, NULL);
  xTaskCreate(task_control, "Control", 1000, NULL, 3, NULL);
  xTaskCreate(task_test, "Test", 500, NULL, 4, NULL);

  update_coefficients_QUEUE = xQueueCreate(3, sizeof(uint8_t));
  control_sig_QUEUE = xQueueCreate(3, sizeof(int16_t));;
  vSemaphoreCreateBinary(testing_SEMAPHORE);
  vSemaphoreCreateBinary(data_SEMAPHORE);
  osKernelStart();
  
  /* We should never get here as control is now taken by the scheduler */
  /* Infinite loop */
  while (1)
  {

  }

}
Пример #17
0
Файл: main.c Проект: kmos/janusb
/* Setup Function --------------------------*/
void setup(){
	HAL_Init();
	//Initializze board's led
	BSP_LED_Init(0);
	BSP_LED_Init(1);
	BSP_LED_Init(2);
	BSP_LED_Init(3);
	//Initializze board's accelerometer
    BSP_ACCELERO_Init();
	//Initializze USB device
	BSP_LED_On(LED3);
	USBD_Init(&USBD_Device, &VCP_Desc, 0);
	USBD_RegisterClass(&USBD_Device, &USBD_CDC);
	USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_Template_fops);
	USBD_Start(&USBD_Device);
	HAL_Delay(4000);
	BSP_LED_Off(LED3);
	//Initializze ADC conv
	MX_ADC1_Init();

	//Initializze logical variable and memory areas
	memset(request, '\0',256);
	memset(response,'\0',256);
}
Пример #18
0
int main(void)
{

    /* USER CODE BEGIN 1 */
    CMDLINE_CONTEXT cmd_context;
    const char *zhonx_info = (char *)CONFIG_ZHONX_INFO_ADDR;
    /* 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_I2C1_Init();
    MX_RNG_Init();
    MX_TIM1_Init();
    MX_TIM2_Init();
    MX_TIM3_Init();
    MX_TIM4_Init();
    MX_TIM5_Init();
    MX_TIM6_Init();
    MX_TIM7_Init();
    MX_TIM8_Init();
    MX_TIM11_Init();
    MX_USART3_UART_Init();

    /* USER CODE BEGIN 2 */
    expanderInit();
    HAL_Delay(100);
    mainControlInit();
    ssd1306Init(0);
    timesBaseInit();
    ledPowerBlink(990, 10);
    settingsInit();
    mulimeterInit();
    bluetoothInit();
    toneInit();
    spyPostInit();

    positionControlSetPositionType(GYRO);
    mainControlSetFollowType(NO_FOLLOW);

    toneSetVolulme(100);
    tone(F4, 50);
    toneItMode(A4, 50);

    // Register Output callback
    cmd_context.out = blockingPrintf;
    // Initialize Command Line module
    cmdline_init(&cmd_context);

    // Check if robot name is populated in Flash
    memset(zhonxName, 0, sizeof(zhonxName));
    // Retrieve ZHONX information from flash if any
    if (zhonx_info[0] == 'Z')
    {
        strcpy(zhonxName, zhonx_info);
    }

    while (zhonxName[0] == 0)
    {
        menu(zhonxNameMenu);
    }

    while (1)
    {
        menu(mainMenu);
        powerOffConfirmation();
    }

    /* USER CODE END 2 */

    /* Infinite loop */
    /* USER CODE BEGIN WHILE */
    while (1)
        ;
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */

    /* USER CODE END 3 */

}
Пример #19
0
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_ADC3_Init();
  MX_I2C1_Init();
  MX_SPI1_Init();
  MX_SPI2_Init();
  MX_TIM1_Init();
  MX_TIM2_Init();
  MX_USB_OTG_FS_PCD_Init();

  /* USER CODE BEGIN 2 */
  TIM1->CCR1 = 0x300;
  TIM1->CCR2 = 0x300;
  TIM2->CCR2 = 0x60;
  
  // Настройка deathTime
  pwm.init();
/* bugfix */   pwmDeathTime.setValue(10);
  htim1.Instance->BDTR &= ~TIM_BDTR_DTG;
  htim1.Instance->BDTR |= pwm.computeDeathTime(pwmDeathTime.getValueFlt());
  
  HAL_TIM_Base_Start(&htim1);
  // Выходной сигнал для ацп
  HAL_TIM_OC_Start(&htim2, TIM_CHANNEL_2);
  // Выходной сигнал для ацп
  HAL_TIM_OC_Start(&htim1, TIM_CHANNEL_3);
  
//  HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_1);
//  HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_2);
//  pwm.start();

//  HAL_TIMEx_PWMN_Start(&htim1,TIM_CHANNEL_1);
//  HAL_TIMEx_PWMN_Start(&htim1,TIM_CHANNEL_2);

  __HAL_RCC_DMA2_CLK_ENABLE();
  HAL_ADC_Start_DMA(&hadc1, (uint32_t*)adc1.getBufer(), adc1.getBuferSize());
  HAL_ADC_Start_DMA(&hadc3, (uint32_t*)adc3.getBufer(), adc3.getBuferSize());
  


//------------------------------------------------------------------------------
  //  Низкоуровневая инициализация
//------------------------------------------------------------------------------
  //  Разрешение выходов буферов
  GPIOC->BSRR = BIT_14;

  //  Инициализация SPI портов
  

//------------------------------------------------------------------------------
//  Агрегация объектов
//  Определяется только при инициализации программы
//------------------------------------------------------------------------------
  
  mainMenu.addObserver( &menuEngine );  //  Объект menuEngine подписался на рассылку событий, объявленных в IControlCommands
  
//------------------------------------------------------------------------------
//  Начальные условия
//------------------------------------------------------------------------------
  menuEngine.setMenuValue("");
 
// Затычка на время отсутствия FRAM. Инициализация float данных

  vICalibrating.setValue(vICalibrating.getValue());
  vUDcBusCodeUCal.setValue(vUDcBusCodeUCal.getValue());
  vUDcBusCodeZero.setValue(vUDcBusCodeZero.getValue());
  vIChargeCodeICal.setValue(vIChargeCodeICal.getValue());
  vUChargeCodeUCal.setValue(vUChargeCodeUCal.getValue());
  vIChargeCodeZero.setValue(vIChargeCodeZero.getValue());
  vUChargeCodeZero.setValue(vUChargeCodeZero.getValue());
  vDcBusLoadVoltageDifferent.setValue(vDcBusLoadVoltageDifferent.getValue());

  /* 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 */

}
Пример #20
0
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 */

}
Пример #21
0
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 */

}
Пример #22
0
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 */

}
Пример #23
0
int main(void)
{

  /* USER CODE BEGIN 1 */
int teller=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_DMA_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);
	  HAL_ADC_Start_DMA(&hadc1, &ADCBuffer3[0], ADC_BUFFER_LENGTH*4);
/*	  if(counter%2 == 0)
	  {
		  HAL_ADC_Start_DMA(&hadc1, &ADCBuffer1[0], ADC_BUFFER_LENGTH*2);
	  }
	  else
	  {
		  HAL_ADC_Start_DMA(&hadc1, &ADCBuffer2[0], ADC_BUFFER_LENGTH*2);
	  }
	  counter++;*/
//	  Uart_transmit(ADCBuffer);
//	  HAL_UART_Transmit(&huart6,"\r\n",strlen("\r\n"),HAL_MAX_DELAY);
//	  HAL_UART_Transmit(&huart6,"\r\n",strlen("\r\n"),HAL_MAX_DELAY);
	  //Zonder DMA (op interrupt)
	  //char buffer[50] = {"Empty.."};
	  //uint16_t val1;
	  //uint16_t val2;
/*	  while(counter < 2)HAL_GPIO_WritePin(GPIOD,LD6_Pin,GPIO_PIN_SET);
	  HAL_GPIO_WritePin(GPIOD,LD6_Pin,GPIO_PIN_RESET);
	  if(counter>= 2) {
	          val1 = a1;
	          val2 = a2;
	           …
	  }*/
	  if(HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0))
	  {
	   HAL_Delay(500);
	   HAL_GPIO_WritePin(GPIOD,LD3_Pin,GPIO_PIN_SET);//GREEN

	   //met DMA Continious Scan
	   DoubleUart_transmit(ADCBuffer1,ADCBuffer2);
	   Uart_transmit(ADCBuffer3);
//	   HAL_UART_Transmit(&huart6,(uint8_t*)"Buffer Pin 1\r\n",strlen("Buffer Pin 1\r\n"),HAL_MAX_DELAY);
//	   Uart_transmit(ADCBuffer1);
//	   HAL_UART_Transmit(&huart6,"Buffer Pin 2\r\n",strlen("Buffer Pin 2\r\n"),HAL_MAX_DELAY);
//	   Uart_transmit(ADCBuffer2);
//	   HAL_UART_Transmit(&huart6,"\r\n",strlen("\r\n"),HAL_MAX_DELAY);
//	   HAL_UART_Transmit(&huart6,(uint8_t*)"\r\n",strlen("\r\n"),HAL_MAX_DELAY);

	   //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 */

}
Пример #24
0
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_1);
  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 1);

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_ADC1_Init();
  MX_I2C1_Init();
  MX_TIM1_Init();
  MX_TIM3_Init();
  MX_TIM4_Init();
  MX_TIM6_Init();
  MX_TIM7_Init();
  MX_TIM8_Init();
  MX_TIM10_Init();
  MX_USART3_UART_Init();

  /* USER CODE BEGIN 2 */
  HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, SET);

  /* USER CODE END 2 */

  /* USER CODE BEGIN 3 */
//  test_Expander();
  ssd1306Init(0);
  test_Telemeters();
  ADXRS620_Init();
  TimesBase_Init();

  test_Encoders();

  Straight_Control_Start(GYRO);
  test_Beeper();
  Led_Power_Blink(990, 10, 0);
  //test_Gyro();
  Debug_ADXRS620();

//Debug_Straight_Control();
while(1);

//  test_Encoders();
//  test_Vbat();
//  test_EasterEgg();
//test_Gyro();
// test_Motor_Move();

//    test_Motors();

//  test_Telemeters();
//  HAL_Delay(1000);
//  test_LineSensors();
//  test_Oled();
//  test_IR_Sensors();

  /* USER CODE END 3 */

}
Пример #25
0
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 */

}
Пример #26
0
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.
		}
	}
}
Пример #27
-8
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 */

}