Beispiel #1
0
int stm32_hw_lcd_init(void)
{
    _rt_framebuffer = rt_malloc_align(sizeof(rt_uint16_t) * RT_HW_LCD_WIDTH * RT_HW_LCD_HEIGHT, 32);
    if (_rt_framebuffer == RT_NULL) 
        return -1; /* no memory yet */
    
    LTDC_CLK_Config();
    MX_LTDC_Init();
    lcd_backlight_init();
    MX_DMA2D_Init();
    
    _lcd_info.bits_per_pixel = LCD_BITS_PER_PIXEL;
    _lcd_info.pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565;		// RTGRAPHIC_PIXEL_FORMAT_ARGB888
    _lcd_info.framebuffer = (void *)_rt_framebuffer;
    _lcd_info.width = RT_HW_LCD_WIDTH;
    _lcd_info.height = RT_HW_LCD_HEIGHT;
    
        /* init device structure */
    lcd.type = RT_Device_Class_Graphic;
    lcd.init = rt_lcd_init;
    lcd.open = rt_lcd_open;
    lcd.close = rt_lcd_close;
    lcd.read = NULL;
    lcd.write = NULL;
    lcd.control = rt_lcd_control;
    lcd.user_data = (void *)&_lcd_info;
    
    /* register lcd device to RT-Thread */
    rt_device_register(&lcd, "lcd", RT_DEVICE_FLAG_RDWR);
    
    return 0;
}
Beispiel #2
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);

		}
	}
}
Beispiel #3
0
int _not_using_this_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_DCMI_Init();
  MX_DMA2D_Init();
  MX_ETH_Init();
  MX_FMC_Init();
  MX_I2C1_Init();
  MX_LTDC_Init();
  MX_QUADSPI_Init();
  MX_SDMMC1_SD_Init();
  MX_SPDIFRX_Init();
  MX_USART1_UART_Init();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */

  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */

  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */

  /* Create the thread(s) */
  /* definition and creation of defaultTask */
  osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
  defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);

  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  /* USER CODE END RTOS_THREADS */

  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */


  /* Start scheduler */
  osKernelStart();

  /* We should never get here as control is now taken by the scheduler */

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

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}
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_DMA_Init();
  MX_FMC_Init();
  MX_DMA2D_Init();
  MX_LTDC_Init();
  MX_SPI5_Init();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
	HAL_GPIO_TogglePin(green_led_GPIO_Port,green_led_Pin);
  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
		HAL_GPIO_TogglePin(red_led_GPIO_Port,red_led_Pin);
		HAL_GPIO_TogglePin(green_led_GPIO_Port,green_led_Pin);
		HAL_Delay(1000);
		
	
		p = (uint32_t*)sdram_start_address;
		//r(i=0;i<8*1024*1024;i+=4){
			//HAL_SDRAM_Write_32b(&hsdram1,(uint32_t*)(sdram_start_address+i),&pattern,1);			
			//(__IO uint32_t *)(p++) = pattern;
//}
		
		//L_DMA_XFER_CPLT_CB_ID
		pattern = rand();
		
		HAL_DMA_RegisterCallback(&hdma_memtomem_dma2_stream0,HAL_DMA_XFER_CPLT_CB_ID,myDMA_Callback);
		for(i=0;i<2;i++){
			HAL_DMA_Start_IT(&hdma_memtomem_dma2_stream0,
			(uint32_t)&pattern,
			(uint32_t)p,38400);
			p+=38400;
			while(!done);
			done = 0;
		}
		HAL_Delay(1000);
		start = HAL_GetTick();
	//todo add mandelbrot here
		{
			 float sx,ex,sy,ey;
			 float	zof = 0.00001;
		   float zfi = 0.00001;
			sx = -1.4481471; ex = -1.4472926; sy = -0.0012840417; ey = -0.00030747990;
			
			while(zof<0.00163999794){
				
				drawset2(sx, ex, sy, ey);
				
				zof+=zfi;
				sx -= zof;
				ex += zof;
				sy -= zof;
				ey += zof;
				
				HAL_Delay(16);
			}
			
			
		}
		//HAL_Delay(1000);
		//drawset2(-1.4494717,-1.4477627,-0.0017153568,0.00023776683);
		
		
		stop = HAL_GetTick();
		delta = stop- start;
		#if 0
		p = (uint32_t*)sdram_start_address;
		for(i=0;i<128*65532;i+=4){
			//HAL_SDRAM_Read_32b(&hsdram1,(uint32_t*)(sdram_start_address+i),&read_pattern,1);
			read_pattern = *(__IO uint32_t *)(p++);
			if(read_pattern!=0xaa55aa55)
			{
				while(1){
					HAL_GPIO_TogglePin(red_led_GPIO_Port,red_led_Pin);
					HAL_GPIO_TogglePin(green_led_GPIO_Port,green_led_Pin);
					HAL_Delay(50);
				}
			}
		}
		stop = HAL_GetTick();
		delta = stop- start;
		#endif

  }
  /* USER CODE END 3 */

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

  /* 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_CAN2_Init();
  MX_DMA2D_Init();
  MX_FMC_Init();
//  MX_SPI1_Init();
//  MX_SPI5_Init();
  MX_TIM2_Init();
  MX_I2C3_Init();

//  SET RESET HIGH ~~ TURN ON


  ILI9341Init();
//  ili9341_Init();
  volatile uint16_t lcd_id =  ili9341_ReadID();

  MX_LTDC_Init();

//  lcd_id++;

  /* USER CODE BEGIN 2 */
  UserInitCan2();

//  HAL_GPIO_WritePin(BMS_ERR_GPIO_Port, BMS_ERR_Pin, GPIO_PIN_RESET);
//  HAL_GPIO_WritePin(BMS_ERR_GPIO_Port, BMS_ERR_Pin, GPIO_PIN_SET);

//  char recv_string[10] = "";
//  HAL_SDRAM_Write_8b(&hsdram1, 0, "hi", 3);
//  HAL_SDRAM_Read_8b(&hsdram1, 0, recv_string, 3);

  /* 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 */
  	  /* Button polling task. 100Hz. */
	  osThreadDef(buttonTask, vPollButtonsTask, osPriorityHigh, 1, 1024);
	  buttonTaskHandle = osThreadCreate(osThread(buttonTask), NULL);

	  osThreadDef(canTask, vCanTask, osPriorityHigh, 1, 1024);
	  canTaskHandle = osThreadCreate(osThread(canTask), NULL);

	  osThreadDef(ledTask, vLedUpdateTask, osPriorityLow, 1, 1024);
	  ledTaskHandle = osThreadCreate(osThread(ledTask), NULL);



  /* USER CODE END RTOS_THREADS */

  /* USER CODE BEGIN RTOS_QUEUES */
	  osMessageQDef(ibutton_queue, 12, ButtonObject); // Declare a message queue
	  interfaceButtonQueue = osMessageCreate(osMessageQ(ibutton_queue), NULL);

	  osMessageQDef(sbutton_queue, 12, ButtonObject); // Declare a message queue
	  stateButtonQueue = osMessageCreate(osMessageQ(sbutton_queue), NULL);

  /* USER CODE END RTOS_QUEUES */
 

  /* Start scheduler */




  osKernelStart();
  
  /* We should never get here as control is now taken by the scheduler */

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

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}