Example #1
0
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 */

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

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

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

}
Example #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_USART3_UART_Init();
  MX_LWIP_Init();
  MX_ADC3_Init();

  /* USER CODE BEGIN 2 */
  
  /* Http webserver Init */
  http_server_init();
  
  /* Notify user about the network interface config */
  User_notification(&gnetif);
  /* USER CODE END 2 */

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

  /* USER CODE BEGIN 3 */
    /* Read a received packet from the Ethernet buffers and send it 
       to the lwIP for handling */
    ethernetif_input(&gnetif);

    /* Handle timeouts */
    sys_check_timeouts();
  }
  /* USER CODE END 3 */

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

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

}
Example #8
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);
}
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_USART3_UART_Init();
  MX_USB_OTG_FS_PCD_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 */

}
Example #10
0
int main(void)
{

  /* USER CODE BEGIN 1 */
  my_usb_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_TIM1_Init();
  MX_USB_DEVICE_Init();
  MX_USART3_UART_Init();
  MX_TIM2_Init();

  /* USER CODE BEGIN 2 */
  HAL_TIM_Base_Start(&htim2);
  delay_us_init(&htim2);
  softserial_init(SOFTSERIAL_TX_GPIO_Port, SOFTSERIAL_TX_Pin);
  hmi_lcd_init(&huart3);
  cpu_ctrl_init(&htim1);
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  HAL_Delay(100);
  hsc_stop();
  cpu_reset();
  lcd_clear();
  addr_input();
  data_input();
  build_ui();
  HAL_Delay(100);

  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
    if(is_running == 0)
      addr_data_display_update();

    // z80 reset button
    if(is_button_1_pressed)
    {
      hsc_stop();
      cpu_reset();
      lcd_print_width(130, 110, 180, 45, "CYAN", "RESET");
      is_button_1_pressed = 0;
      HAL_Delay(500);
      build_ui();
    }

    // clk step button
    if(is_button_3_pressed)
    {
      hsc_stop();
      cycle_clock(1);
      lcd_print_width(130, 110, 180, 45, "RED", "CLK STEP");
      is_button_3_pressed = 0;
      HAL_Delay(100);
      build_ui();
    }

    // ins step button
    if(is_button_4_pressed)
    {
      hsc_stop();
      lcd_print_width(130, 110, 180, 45, "GREEN", "INS STEP");
      // cycle clock until we're at next M1 cycle
      while(HAL_GPIO_ReadPin(CPU_CTRL_PORT, M1_Pin) == LOW)
        cycle_clock(1);
      while(HAL_GPIO_ReadPin(CPU_CTRL_PORT, M1_Pin) == HIGH)
        cycle_clock(1);
      is_button_4_pressed = 0;
      HAL_Delay(100);
      build_ui();
    }

    // run/stop button
    if(is_button_5_pressed)
    {
      is_running = (is_running + 1) % 2;
      if(is_running)
      {
        lcd_print_width(130, 110, 180, 45, "GREEN", "RUNNING");
        hsc_start();
      }
      else
      {
        hsc_stop();
        build_ui();
      }
      is_button_5_pressed = 0;
    }

    usb_data = my_usb_readline();
    if(usb_data != NULL && strstr(usb_data, "epm") != NULL)
    {
      hsc_stop();
      program_mode();
      build_ui();
    }
  }
  /* USER CODE END 3 */

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

}
Example #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_CAN_Init();
  MX_I2C1_Init();
  MX_SPI1_Init();
  MX_USART1_UART_Init();
  MX_USART3_UART_Init();

  /* USER CODE BEGIN 2 */
  /* these calls are from arduino main */

	init();

	initVariant();
	
	HAL_Delay(3000); 	/* Wait 3 seconds to enable a serial coms channel */
	
	/* 
		Usart6 is linked to printf for diagnostic use It is also mapped to
		alternate function pins 12 and 14.  This code is adapted from
		the prinf demo in the STM32F401 Nucleo examples folder
	*/
	
	//printf("Serial backchannel enabled.\r\n");
  
  	/* Arduino optionally sets up USB callback stream here 
#if defined(USBCON)
	USBDevice.attach();
#endif
	*/
	
	setup();

  /* USER CODE END 2 */

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

  /* USER CODE BEGIN 3 */
	loop();
	/* Arduino callback	if (serialEventRun) serialEventRun(); */

  }
  /* USER CODE END 3 */

}
Example #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();

	HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
#ifdef DEBUG_MODE
	usb_init();
	setbuf(stdout, NULL);
#endif 
	HAL_Delay(200); 
  /* Initialize all configured peripherals */
	
  MX_GPIO_Init();
  MX_TIM2_Init();
  MX_USART1_UART_Init();
  MX_USART3_UART_Init();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */


 uint8_t push_button_cmd[] = {NOTF_VOICE_RECORD, 0x00, 0x00}; 


// enable encoders
// HAL_GPIO_WritePin(GPIOE, GPIO_PIN_6, GPIO_PIN_RESET);
uint16_t c = 0; 
uint8_t current_state = 0, old_state = 0; 
 
 while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
    

     current_state = (HAL_GPIO_ReadPin(GPIOD, GPIO_PIN_2) == GPIO_PIN_SET)? 1 : 0; 
      if(( current_state == 1) && ( old_state == 0) ){
     //          LOG("push button ... \r\n"); 
     //          HAL_UART_Transmit(&huart1, push_button_cmd, 3, 1000);

        }
      old_state = current_state; 

    stateMachine();
    controller(); 
    driveMotors(u);
    HAL_Delay(20);
	

}
  /* USER CODE END 3 */

}
Example #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();

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

}
Example #15
0
/**
  * @brief  VCP_COMConfig
  *         Configure the COM Port with default values or values received from host.
  * @param  Conf: can be DEFAULT_CONFIG to set the default configuration or OTHER_CONFIG
  *         to set a configuration received from the host.
  * @retval None.
  */
uint16_t VCP_COMConfig(uint8_t Conf, LINE_CODING linecoding)
{
  if (Conf == DEFAULT_CONFIG)  
  {
    /*
    - BaudRate = 115200 baud  
    - Word Length = 8 Bits
    - One Stop Bit
    - Parity Odd
    - Hardware flow control disabled
    - Receive and transmit enabled
    */
    
   MX_USART3_UART_Init();
    
    
    /* Enable the USART Receive interrupt */
    //USART_ITConfig(EVAL_COM1, USART_IT_RXNE, ENABLE);
  }
  else
  {
    /* set the Stop bit*/
    switch (linecoding.format)
    {
    case 0:
      huart3.Init.StopBits = UART_STOPBITS_1;
      break;
    case 1:
      huart3.Init.StopBits = UART_STOPBITS_1;
      break;
    case 2:
      huart3.Init.StopBits = UART_STOPBITS_2;
      break;
    default :
      VCP_COMConfig(DEFAULT_CONFIG,linecoding_def);
      return (USBD_FAIL);
    }
    
    /* set the parity bit*/
    switch (linecoding.paritytype)
    {
    case 0:
      huart3.Init.Parity = UART_PARITY_NONE;
      break;
    case 1:
      huart3.Init.Parity = UART_PARITY_EVEN;
      break;
    case 2:
      huart3.Init.Parity = UART_PARITY_ODD;
      break;
    default :
      VCP_COMConfig(DEFAULT_CONFIG,linecoding_def);
      return (USBD_FAIL);
    }
    
    /*set the data type : only 8bits and 9bits is supported */
    switch (linecoding.datatype)
    {
    case 0x07:
      /* With this configuration a parity (Even or Odd) should be set */
      huart3.Init.WordLength = UART_WORDLENGTH_8B;
      break;
    case 0x08:
      if (huart3.Init.Parity == UART_PARITY_NONE)
      {
        huart3.Init.WordLength = UART_WORDLENGTH_8B;
      }
      else 
      {
        huart3.Init.WordLength = UART_WORDLENGTH_9B;
      }
      
      break;
    default :
      VCP_COMConfig(DEFAULT_CONFIG,linecoding_def);
      return (USBD_FAIL);
    }
    
    huart3.Init.BaudRate = linecoding.bitrate;
    huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
    huart3.Init.Mode = UART_MODE_TX_RX;
    
    /* Configure and enable the USART */
    HAL_UART_Init(&huart3);
  }
  return USBD_OK;
}
Example #16
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 */

}
Example #17
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_USART3_UART_Init();
	MX_SPI1_Init();
	MX_SPI2_Init();

	/* USER CODE BEGIN 2 */

	uint8_t init_bytes[] = { 0x07, 0x40, 0xC0, 0x01, 0x00, 0x8C, 0x8E, 0x00 };

	for (int i = 0; i < 2; i++) {
		HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);
		HAL_SPI_Transmit(&hspi1, (uint8_t*) (&init_bytes[i]), 1, 1000);
		HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);
	}

	for (int i = 0; i < 0x16; i++) {
		HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);
		HAL_SPI_Transmit(&hspi1, (uint8_t*) (&init_bytes[2]), 1, 1000);
		HAL_SPI_Transmit(&hspi1, (uint8_t*) (&init_bytes[4]), 1, 1000);
		init_bytes[2]++;
		HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);
	}

	HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);
	HAL_SPI_Transmit(&hspi1, (uint8_t*) (&init_bytes[5]), 1, 1000);
	HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);

//	ds3234_set_time();
	vfd_display();

	ds3234_set_reg(DS3234_REG_CONTROL, 0x00);

//	vfd_write_display_flag(0x03, 0x04);
//	vfd_write_display_flag(0x0F, 0x03);

	while (1) {
	};

	/* 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, osPriorityIdle, 0, 128);
	defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);

	/* definition and creation of myTask02 */
	osThreadDef(myTask02, StartTask02, osPriorityNormal, 0, 128);
	myTask02Handle = osThreadCreate(osThread(myTask02), NULL);

	/* definition and creation of myTask03 */
	osThreadDef(myTask03, StartTask03, osPriorityNormal, 0, 128);
	myTask03Handle = osThreadCreate(osThread(myTask03), NULL);

	/* definition and creation of myTask01 */
	osThreadDef(myTask01, StartTask01, osPriorityNormal, 0, 128);
	myTask01Handle = osThreadCreate(osThread(myTask01), NULL);

	/* definition and creation of myTask04 */
	osThreadDef(myTask04, StartTask04, osPriorityNormal, 0, 128);
	myTask04Handle = osThreadCreate(osThread(myTask04), 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 */
	char i = 0;

	while (1) {
		/* USER CODE END WHILE */

		/* USER CODE BEGIN 3 */

		HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
		HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);
		HAL_GPIO_TogglePin(LED3_GPIO_Port, LED3_Pin);
		HAL_GPIO_TogglePin(LED4_GPIO_Port, LED4_Pin);

		aTxBuffer[30] = ((i++) % 10) + '0';
		HAL_UART_Transmit(&huart3, aTxBuffer, RXBUFFERSIZE, 5000);
		HAL_Delay(1000);
	}
	/* USER CODE END 3 */

}