예제 #1
0
void lcd_cmd( char cmd )          // subroutiune for lcd commands
{
    while(checkBusy());
//	TRISD &= 0xFF00;              // ensure RD0 - RD7 are outputs
	DATA &= 0xFF00;               // prepare RD0 - RD7
    DATA |= cmd;                  // command byte to lcd
	RW = 0;                       // ensure RW is 0
    RS = 0;
    E = 1;                        // toggle E line
    Nop();
    Nop();
    Nop();
    E = 0;
}
예제 #2
0
void lcd_data( char data )        // subroutine for lcd data
{
    while(checkBusy());
//	TRISD &= 0xFF00;              // ensure RD0 - RD7 are outputs
	RW = 0;       				 // ensure RW is 0
    RS = 1;                       // assert register select to 1
	DATA &= 0xFF00;               // prepare RD0 - RD7
    DATA |= data;                 // data byte to lcd
    E = 1;
 	Nop();
    Nop();
    Nop();
    E = 0;                       // toggle E signal
    RS = 0;                      // negate register select to 0
}
예제 #3
0
void waitUntilNotBusy(void)
{
	while(checkBusy()==1);
}
예제 #4
0
/**
 * @brief Read and send EPD response
 * @return Status-response
 */
LDD_TError readAndSendEPD()
{
	TCM_enable();
	PE_low_level_init();

	// Pointer to part of an image.
	uint32 ii = 0;
	uint32 a = 0;

	uint32 nr_block_flash = 0;
	LDD_TError Result = -1;

	uint32_t ImageDatatoSend = 0;
	uint32_t image_shift = 0;
	uint8_t fileDetected = 0;
	uint32_t imageStart = 0x7000;
	uint32_t controlFileStartAddress = 0;

	fileDetected = findFileStartAddress(&imageStart, &controlFileStartAddress);
	
	if(controlFileStartAddress)
	{
		EM_ReadData((uint8_t*) &upload_image2, controlFileStartAddress, 16);
		uint32_t len = upload_image2[0];
		if(len > 0)
		{
			tcm_drivescheme = upload_image2[1];
		}
		if(len > 1)
		{
			tcm_framebuffer_slot = upload_image2[2];
		}
	}
	else
	{
		tcm_drivescheme = 0x24;
		tcm_framebuffer_slot = 0; 
	}
	
	display_update[0] = tcm_drivescheme;
	upload_image[2] = tcm_framebuffer_slot;
	display_update[2] = tcm_framebuffer_slot;
	
	if (fileDetected == 1)
	{

		EM_ReadData((uint8_t*) &upload_image2, imageStart, 400);  
		
		uint16_t res_x, res_y, color_bit;
		
		res_x = upload_image2[1] * 256 + upload_image2[2];
		res_y = upload_image2[3] * 256 + upload_image2[4];
		color_bit = upload_image2[5];
		ImageDatatoSend = res_x * res_y / 8;
		if(color_bit)
		{
			ImageDatatoSend *= color_bit;
		}
		
		ImageDatatoSend += 16; //image header
		
		if (ImageDatatoSend < EM_SETUP_MEMORY_SIZE_BYTES)
		{
			LED_ClrVal(NULL);
			nr_block_flash=0;
			while(ImageDatatoSend>0)
			{
				
				EM_ReadData((uint8_t*) &upload_image2,imageStart - image_shift + (nr_block_flash * 400), 400);
				for (ii = 0; ii < 4; ii++)
				{
					// Copying part of image.
					for (a = 0; a < 100; a++)
					{
						upload_image[a + 4] = upload_image2[100 * ii + a];
					}
					
					// Sending image to TCM.
					 if(ImageDatatoSend>=100)
					 {
						 upload_image[3] = 100;
						 tcm_receive=TCM_ImageUpload(upload_image, 104);
					 	 ImageDatatoSend-=100;
					 }
					 else
					 {	 
						 upload_image[3] = ImageDatatoSend;
						 tcm_receive=TCM_ImageUpload(upload_image, ImageDatatoSend+4);
						 ImageDatatoSend=0;
					 }
					 
					 if(tcm_receive != 0x90)
					 {
						 if((ii != 0)||(nr_block_flash != 0))
						 {
							 errorSTOP();
							 return Result;
						 }
					 }	
					 if(ImageDatatoSend==0)
					 {
						 break; 
					 }				 
				}
				nr_block_flash++;
			}
		}
	}
	else
	{
		//if there was no upload then give time for the TCM to start-up (upload is starting with a delay)
		WAIT_Waitms(20); 
	}
	
	if((USBTCM_error == 0) && (fileDetected || controlFileStartAddress))
	{
		WAIT_Waitms(1);         //The period of this WAIT is different ~(x 0.5)
		tcm_receive=TCM_DisplayUpdate();
		if(tcm_receive != 0x90 && fileDetected) //check response for upload command
		 {
			errorSTOP();
			return Result;
		 }	
		WAIT_Waitms(1);
		checkBusy(); 			// Check Busy pin to low
		if(USBTCM_error!=0)
		{
			return Result;
		}
		checkBusytoHigh();		// Check Busy pin to 
		if(USBTCM_error!=0)
		{
			return Result;
		}
		WAIT_Waitms(2);
		
		tcm_receive=TCM_GetAnswer();
		if(tcm_receive != 0x90)
		 {
			errorSTOP();
			return Result;
		 }	
	}
	
	possibleFile = 0;
	TCM_disable();
	return Result;
}