示例#1
0
void TM_LCD_Init(void) {
	/* Initialize pins used */
	TM_LCD_InitPins();
	/* Init SDRAM */
	TM_SDRAM_Init();
	/* Initialize LTDC */
	TM_LCD_InitLTDC();
	/* Initialize LTDC layers */
	TM_LCD_InitLayers();
	/* Enable LCD */
	TM_LCD_DisplayOn();
}
TM_LCD_Result_t TM_LCD_Init(void) {
	TM_DMA2DGRAPHIC_INT_Conf_t DMA2DConf;
	
	/* Init SDRAM */
	if (!TM_SDRAM_Init()) {
		/* Return error */
		return TM_LCD_Result_SDRAM_Error;
	}
	
	/* Fill default structure */
	LCD.Width = LCD_PIXEL_WIDTH;
	LCD.Height = LCD_PIXEL_HEIGHT;
	LCD.CurrentFrameBuffer = LCD_FRAME_BUFFER;
	LCD.FrameStart = LCD_FRAME_BUFFER;
	LCD.FrameOffset = LCD_BUFFER_OFFSET;
	LCD.CurrentFont = &TM_Font_11x18;
	LCD.ForegroundColor = 0x0000;
	LCD.BackgroundColor = 0xFFFF;
	
	/* Set configrations for DMA2D */
	DMA2DConf.BufferStart = LCD_FRAME_BUFFER;
	DMA2DConf.BufferOffset = LCD_BUFFER_OFFSET;
	DMA2DConf.BytesPerPixel = 2;
	DMA2DConf.Height = LCD_PIXEL_HEIGHT;
	DMA2DConf.Width = LCD_PIXEL_WIDTH;
	DMA2DConf.Orientation = 1;
	
	/* Init LCD pins */
	TM_LCD_INT_InitPins();
	
	/* Init LTDC peripheral */
	TM_LCD_INT_InitLTDC();
	
	/* Init LTDC layers */
	TM_LCD_INT_InitLayers();
	
	/* Init LCD dependant settings */
	TM_LCD_INT_InitLCD();
	
	/* Init DMA2D graphics */
	TM_DMA2DGRAPHIC_Init();
	
	/* Set settings */
	TM_INT_DMA2DGRAPHIC_SetConf(&DMA2DConf);
	
	/* Enable LCD */
	TM_LCD_DisplayOn();
	
	TM_LCD_SetLayer1();
	
	/* Return OK */
	return TM_LCD_Result_Ok;
}
示例#3
0
DSTATUS TM_FATFS_SDRAM_disk_initialize(void) {
	/* Init SDRAM */
	if (!TM_SDRAM_Init()) {
		/* Set NOINIT flag */
		SDRAM_Status |= STA_NOINIT;
		
		/* Return error */
		return STA_NODISK;
	}
	
	/* Clear NOINIT flag */
	SDRAM_Status &= ~STA_NOINIT;
	
	/* Return status */
	return SDRAM_Status;
}
/**
------------------------------------
     GRAPHIC LIBRARY FUNCTIONS
------------------------------------
*/
TM_GRAPHIC_Result TM_GRAPHICLCDDriver_Init(TM_GRAPHIC_Options_t* LCD_Options) {
	//Initialize pins used
	TM_GRAPHIC_ILI9341_InitPins();
	//SPI chip select high
	ILI9341_CS_SET;
	//Init SPI
	TM_SPI_Init(ILI9341_SPI, ILI9341_SPI_PINS);
	//SDram Init
	TM_SDRAM_Init();
	//Initialize LCD for LTDC
	TM_GRAPHIC_ILI9341_InitLCD();
	//Initialize LTDC
	TM_LCD9341_InitLTDC();
	//Initialize LTDC layers
	TM_GRAPHIC_ILI9341_InitLayers();
	
	//Set options for GRAPHIC library
	LCD_Options->DefaultWidth = ILI9341_WIDTH;
	LCD_Options->DefaultHeight = ILI9341_HEIGHT;
	LCD_Options->PixelsCount = ILI9341_PIXEL;
	
	//Current layer is layer 1
	ILI9341_LTDC_Opts.CurrentLayer = 0;
	//Start on the beginning of SDRAM
	ILI9341_LTDC_Opts.CurrentLayerOffset = 0;
	//Set layer opacity to maximum, 255
	ILI9341_LTDC_Opts.Layer1Opacity = 255;
	//Hide layer 2, set opacity to 0
	ILI9341_LTDC_Opts.Layer2Opacity = 0;
	
	//Set layer 1
	TM_GRAPHIC_ILI9341_SetLayer1();
	//Fill layer 1 with white color
	TM_GRAPHICLCDDriver_Fill(LCD_Options, GRAPHIC_COLOR_WHITE);
	//Set layer 2
	TM_GRAPHIC_ILI9341_SetLayer2();
	//Fill layer 2 with white color
	TM_GRAPHICLCDDriver_Fill(LCD_Options, GRAPHIC_COLOR_WHITE);
	//Set back to layer 1
	TM_GRAPHIC_ILI9341_SetLayer1();
	
	/* Return OK */
	return TM_GRAPHIC_OK;
}
示例#5
0
文件: main.c 项目: MaJerle/stm32f429
int main(void) {
	uint16_t write, read;
	uint8_t i;
	/* Initialize system */
	SystemInit();
	
	/* Initialize delay */
	TM_DELAY_Init();
	
	/* Initialize leds */
//	TM_DISCO_LedInit();
	
	/* Initialize SDRAM */
	if (TM_SDRAM_Init()) {
//		TM_DISCO_LedOn(LED_GREEN);
	} else {
//		TM_DISCO_LedOn(LED_RED);
	}
	
	/* Some delay */
	Delayms(2000);
	
	write = 1234;
	/* Write 16bit value to SDRAM at location 0x3214 */
	TM_SDRAM_Write16(0x3214, write);
	/* Read from location 0x3214 */
	read = TM_SDRAM_Read16(0x3214);
	
	/* Check if read data is the same as written data */
	if (write == read) {
		TM_DISCO_LedOff(LED_GREEN | LED_RED);
		/* Blink leds to indicate that reading and writing was correct */
		for (i = 0; i < 10; i++) {
			TM_DISCO_LedToggle(LED_GREEN | LED_RED);
			Delayms(100);
		}
	}
	
	while (1) {
	
	}
}
示例#6
0
int main(void) {
	uint8_t i = 0;
	
	/* Init system clock for maximum system speed */
	TM_RCC_InitSystem();
	
	/* Init HAL layer */
	HAL_Init();
	
	/* Init leds */
	TM_DISCO_LedInit();
	
	/* Init SDRAM */
	TM_SDRAM_Init();
	
	/* Fill write data */
	for (i = 0; i < 32; i++) {
		Write[i] = 1 << i;
		
		/* Write to SDRAM */
		TM_SDRAM_Write32(4 * i, Write[i]);
	}

	/* Read data from SDRAM */
	for (i = 0; i < 32; i++) {
		Read[i] = TM_SDRAM_Read32(4 * i);
	}
	
	/* Memory compare */
	if (memcmp((uint8_t *)Read, (uint8_t *)Write, sizeof(Read)) == 0) {
		/* SDRAM is OK */
		TM_DISCO_LedOn(LED_GREEN);
	} else {
		/* SDRAM failed */
		TM_DISCO_LedOn(LED_RED);
	}
	
	while (1) {
		
	}
}
void TM_ILI9341_Init() {
	//Initialize pins used
	TM_ILI9341_InitPins();
	//SPI chip select high
	ILI9341_CS_SET;
	//Init SPI
	TM_SPI_Init(ILI9341_SPI, ILI9341_SPI_PINS);
	//Init SDRAM
	TM_DISCO_LedInit();
	if (!TM_SDRAM_Init()) {
		TM_DISCO_LedOn(LED_RED);
	}
	//Initialize LCD for LTDC
	TM_ILI9341_InitLCD();
	//Initialize LTDC
	TM_LCD9341_InitLTDC();
	//Initialize LTDC layers
	TM_ILI9341_InitLayers();
	//Set cursor X and Y
	ILI9341_x = ILI9341_y = 0;
	
	ILI9341_Opts.Width = ILI9341_WIDTH;
	ILI9341_Opts.Height = ILI9341_HEIGHT;
	ILI9341_Opts.Orientation = TM_ILI9341_Portrait;
	ILI9341_Opts.Orient = TM_ILI9341_Orientation_Portrait_1;
	ILI9341_Opts.CurrentLayer = 0;
	ILI9341_Opts.CurrentLayerOffset = 0;
	ILI9341_Opts.Layer1Opacity = 255;
	ILI9341_Opts.Layer2Opacity = 0;
	
	TM_ILI9341_SetLayer1();
	TM_ILI9341_Fill(ILI9341_COLOR_WHITE);
	TM_ILI9341_SetLayer2();
	TM_ILI9341_Fill(ILI9341_COLOR_WHITE);
	TM_ILI9341_SetLayer1();
}