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

}
Beispiel #2
0
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 */

}
Beispiel #3
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 */

}
Beispiel #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_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 */

}
Beispiel #5
0
int main(void)
{

    /* USER CODE BEGIN 1 */
    int spi_slave_enabled = 0;
    int uart_slave_enabled = 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();
    MX_GPIO_Init();

    USB_Soft_Disconnect();

    MX_DMA_Init();
    MX_I2C2_Init();

    HAL_DIP_Switches_Init();
    spi_slave_enabled = HAL_SPI_Slave_Enabled();
    uart_slave_enabled = HAL_UART_Slave_Enabled();

    MX_I2C3_Init();

    if (spi_slave_enabled) {
        MX_SPI1_Init();
    }

    if (uart_slave_enabled) {
        MX_USART6_UART_Init();
    }

    MX_USB_DEVICE_Init();
    /* USER CODE BEGIN 2 */
    nav10_init();
    /* USER CODE END 2 */

    nav10_main();

    return 0; /* Note:  Control will never reach this point. */
}
Beispiel #6
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_SPI2_Init();
  MX_TIM1_Init();
  MX_USART1_UART_Init();
  MX_USART2_UART_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 */

  }
  /* USER CODE END 3 */

}
Beispiel #7
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 */

}
Beispiel #8
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.
		}
	}
}
Beispiel #9
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 */

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

}