Beispiel #1
0
	bool_t gdispInit(void) {
		bool_t		res;
		unsigned	i;

		/* Mark all the Messages as free */
		for(i=0; i < GDISP_QUEUE_SIZE; i++)
			gdispMsgs[i].action = GDISP_LLD_MSG_NOP;

		/* Initialise our Mailbox, Mutex's and Counting Semaphore.
		 * 	A Mutex is required as well as the Mailbox and Thread because some calls have to be synchronous.
		 *	Synchronous calls get handled by the calling thread, asynchronous by our worker thread.
		 */
		chMBInit(&gdispMailbox, gdispMailboxQueue, sizeof(gdispMailboxQueue)/sizeof(gdispMailboxQueue[0]));
		chMtxInit(&gdispMutex);
		chMtxInit(&gdispMsgsMutex);
		chSemInit(&gdispMsgsSem, GDISP_QUEUE_SIZE);

		lldThread = chThdCreateStatic(waGDISPThread, sizeof(waGDISPThread), NORMALPRIO, GDISPThreadHandler, NULL);

		/* Initialise driver - synchronous */
		chMtxLock(&gdispMutex);
		res = gdisp_lld_init();
		chMtxUnlock();

		return res;
	}
Beispiel #2
0
	bool_t gdispInit(void) {
		bool_t	res;

		/* Initialise Mutex */
		chMtxInit(&gdispMutex);

		/* Initialise driver */
		chMtxLock(&gdispMutex);
		res = gdisp_lld_init();
		chMtxUnlock();

		return res;
	}
Beispiel #3
0
	void gdisp_lld_control(unsigned what, void *value) {
		switch(what) {
			case GDISP_CONTROL_POWER:
				if(GDISP.Powermode == (gdisp_powermode_t)value)
					return;
				switch((gdisp_powermode_t)value) {
					case powerOff:
						lld_lcdWriteReg(0x0007, 0x0000);
						lld_lcdWriteReg(0x0010, 0x0000);
						lld_lcdWriteReg(0x0011, 0x0000);
						lld_lcdWriteReg(0x0012, 0x0000);
						lld_lcdWriteReg(0x0013, 0x0000);
						gdisp_lld_backlight(0);
						break;
			
					case powerOn:
						//*************Power On sequence ******************//
						lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
						lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */
						lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */
						lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
						lld_lcdDelay(2000);            /* Dis-charge capacitor power voltage */
						lld_lcdWriteReg(0x0010, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
						lld_lcdWriteReg(0x0011, 0x0147); /* DC1[2:0], DC0[2:0], VC[2:0] */
						lld_lcdDelay(500);
						lld_lcdWriteReg(0x0012, 0x013C); /* VREG1OUT voltage */
						lld_lcdDelay(500);
						lld_lcdWriteReg(0x0013, 0x0E00); /* VDV[4:0] for VCOM amplitude */
						lld_lcdWriteReg(0x0029, 0x0009); /* VCM[4:0] for VCOMH */
						lld_lcdDelay(500);
						lld_lcdWriteReg(0x0007, 0x0173); /* 262K color and display ON */	
						gdisp_lld_backlight(GDISP.Backlight);
						if(GDISP.Powermode != powerSleep || GDISP.Powermode != powerDeepSleep)
							gdisp_lld_init();
						break;
	
					case powerSleep:
	             		lld_lcdWriteReg(0x0007, 0x0000); /* display OFF */
	                   	lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
	                  	lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */
	                  	lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */
	                  	lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
	                  	lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */
	                   	lld_lcdWriteReg(0x0010, 0x0002); /* SAP, BT[3:0], APE, AP, DSTB, SLP */				
						gdisp_lld_backlight(0);
						break;

					case powerDeepSleep:
					    lld_lcdWriteReg(0x0007, 0x0000); /* display OFF */
					    lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
					    lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */
	   					lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */
	   					lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
	   					lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */
	  					lld_lcdWriteReg(0x0010, 0x0004); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
						gdisp_lld_backlight(0);
						break;

					default:
						return;
				}
				GDISP.Powermode = (gdisp_powermode_t)value;
				return;

			case GDISP_CONTROL_ORIENTATION:
				if(GDISP.Orientation == (gdisp_orientation_t)value)
					return;
				switch((gdisp_orientation_t)value) {
					case GDISP_ROTATE_0:
						lld_lcdWriteReg(0x0001, 0x0100);
						lld_lcdWriteReg(0x0003, 0x1038);
						lld_lcdWriteReg(0x0060, 0x2700);
						GDISP.Height = GDISP_SCREEN_HEIGHT;
						GDISP.Width = GDISP_SCREEN_WIDTH;
						break;

					case GDISP_ROTATE_90:
						lld_lcdWriteReg(0x0001, 0x0000);
						lld_lcdWriteReg(0x0003, 0x1030);
						lld_lcdWriteReg(0x0060, 0x2700);
						GDISP.Height = GDISP_SCREEN_WIDTH;
						GDISP.Width = GDISP_SCREEN_HEIGHT;
						break;
			
					case GDISP_ROTATE_180:
						lld_lcdWriteReg(0x0001, 0x0000);
						lld_lcdWriteReg(0x0003, 0x1038);
						lld_lcdWriteReg(0x0060, 0xa700);
						GDISP.Height = GDISP_SCREEN_HEIGHT;
						GDISP.Width = GDISP_SCREEN_WIDTH;
						break;
		
					case GDISP_ROTATE_270:
						lld_lcdWriteReg(0x0001, 0x0100);
						lld_lcdWriteReg(0x0003, 0x1030);
						lld_lcdWriteReg(0x0060, 0xA700);
						GDISP.Height = GDISP_SCREEN_WIDTH;
						GDISP.Width = GDISP_SCREEN_HEIGHT;
						break;
			
					default:
						return;
				}
			
				#if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION
				GDISP.clipx0 = 0;
				GDISP.clipy0 = 0;
				GDISP.clipx1 = GDISP.Width;
				GDISP.clipy1 = GDISP.Height;
				#endif
				GDISP.Orientation = (gdisp_orientation_t)value;
				return;

			case GDISP_CONTROL_BACKLIGHT:
				if((unsigned)value > 100) value = (void *)100;
				gdisp_lld_backlight((unsigned)value);
				GDISP.Backlight = (unsigned)value;
				break;
			
			default:
				return;
		}
	}
Beispiel #4
0
	/**
	 * @brief   Driver Control
	 * @details	Unsupported control codes are ignored.
	 * @note	The value parameter should always be typecast to (void *).
	 * @note	There are some predefined and some specific to the low level driver.
	 * @note	GDISP_CONTROL_POWER			- Takes a gdisp_powermode_t
	 * 			GDISP_CONTROL_ORIENTATION	- Takes a gdisp_orientation_t
	 * 			GDISP_CONTROL_BACKLIGHT -	 Takes an int from 0 to 100. For a driver
	 * 											that only supports off/on anything other
	 * 											than zero is on.
	 * 			GDISP_CONTROL_CONTRAST		- Takes an int from 0 to 100.
	 * 			GDISP_CONTROL_LLD			- Low level driver control constants start at
	 * 											this value.
	 *
	 * @param[in] what		What to do.
	 * @param[in] value		The value to use (always cast to a void *).
	 *
	 * @notapi
	 */
	void gdisp_lld_control(unsigned what, void *value) {
		switch(what) {
		case GDISP_CONTROL_POWER:
			if (GDISP.Powermode == (gdisp_powermode_t)value)
				return;
			switch((gdisp_powermode_t)value) {
			case powerOff:
				acquire_bus();
				write_reg(0x0010, 0x0000);	// leave sleep mode
				write_reg(0x0007, 0x0000);	// halt operation
				write_reg(0x0000, 0x0000);	// turn off oszillator
				write_reg(0x0010, 0x0001);	// enter sleepmode
				release_bus();
				break;
			case powerOn:
				acquire_bus();
				write_reg(0x0010, 0x0000);	// leave sleep mode
				release_bus();
				if (GDISP.Powermode != powerSleep)
					gdisp_lld_init();
				break;
			case powerSleep:
				acquire_bus();
				write_reg(0x0010, 0x0001);	// enter sleep mode
				release_bus();
				break;
			default:
				return;
			}
			GDISP.Powermode = (gdisp_powermode_t)value;
			return;
		case GDISP_CONTROL_ORIENTATION:
			if (GDISP.Orientation == (gdisp_orientation_t)value)
				return;
			switch((gdisp_orientation_t)value) {
			case GDISP_ROTATE_0:
				acquire_bus();
				write_reg(0x0001, 0x2B3F);
				/* ID = 11 AM = 0 */
				write_reg(0x0011, 0x6070);
				release_bus();
				GDISP.Height = GDISP_SCREEN_HEIGHT;
				GDISP.Width = GDISP_SCREEN_WIDTH;
				break;
			case GDISP_ROTATE_90:
				acquire_bus();
				write_reg(0x0001, 0x293F);
				/* ID = 11 AM = 1 */
				write_reg(0x0011, 0x6078);
				release_bus();
				GDISP.Height = GDISP_SCREEN_WIDTH;
				GDISP.Width = GDISP_SCREEN_HEIGHT;
				break;
			case GDISP_ROTATE_180:
				acquire_bus();
				write_reg(0x0001, 0x2B3F);
				/* ID = 01 AM = 0 */
				write_reg(0x0011, 0x6040);
				release_bus();
				GDISP.Height = GDISP_SCREEN_HEIGHT;
				GDISP.Width = GDISP_SCREEN_WIDTH;
				break;
			case GDISP_ROTATE_270:
				acquire_bus();
				write_reg(0x0001, 0x293F);
				/* ID = 01 AM = 1 */
				write_reg(0x0011, 0x6048);
				release_bus();
				GDISP.Height = GDISP_SCREEN_WIDTH;
				GDISP.Width = GDISP_SCREEN_HEIGHT;
				break;
			default:
				return;
			}
			#if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION
				GDISP.clipx0 = 0;
				GDISP.clipy0 = 0;
				GDISP.clipx1 = GDISP.Width;
				GDISP.clipy1 = GDISP.Height;
			#endif
			GDISP.Orientation = (gdisp_orientation_t)value;
			return;
/*
		case GDISP_CONTROL_BACKLIGHT:
		case GDISP_CONTROL_CONTRAST:
*/
		}
	}
Beispiel #5
0
	/**
	 * @brief   Driver Control
	 * @details	Unsupported control codes are ignored.
	 * @note	The value parameter should always be typecast to (void *).
	 * @note	There are some predefined and some specific to the low level driver.
	 * @note	GDISP_CONTROL_POWER			- Takes a gdisp_powermode_t
	 * 			GDISP_CONTROL_ORIENTATION	- Takes a gdisp_orientation_t
	 * 			GDISP_CONTROL_BACKLIGHT -	 Takes an int from 0 to 100. For a driver
	 * 											that only supports off/on anything other
	 * 											than zero is on.
	 * 			GDISP_CONTROL_CONTRAST		- Takes an int from 0 to 100.
	 * 			GDISP_CONTROL_LLD			- Low level driver control constants start at
	 * 											this value.
	 *
	 * @param[in] what		What to do.
	 * @param[in] value		The value to use (always cast to a void *).
	 *
	 * @notapi
	 */
	void gdisp_lld_control(unsigned what, void *value) {
		/* NOT IMPLEMENTED YET */
		switch(what) {
			case GDISP_CONTROL_POWER:
				if (GDISP.Powermode == (gdisp_powermode_t)value)
					return;
				switch((gdisp_powermode_t)value) {
					case powerOff:
						write_index(SSD1963_EXIT_SLEEP_MODE); // leave sleep mode
						chThdSleepMilliseconds(5);
						write_index(SSD1963_SET_DISPLAY_OFF);
						write_index(SSD1963_SET_DEEP_SLEEP); // enter deep sleep mode
						break;
					case powerOn:
						read_reg(0x0000); chThdSleepMilliseconds(5); // 2x Dummy reads to wake up from deep sleep
						read_reg(0x0000); chThdSleepMilliseconds(5);
						if (GDISP.Powermode != powerSleep)
							gdisp_lld_init();
						write_index(SSD1963_SET_DISPLAY_ON);
	
						break;
					case powerSleep:
						write_index(SSD1963_SET_DISPLAY_OFF);
						write_index(SSD1963_ENTER_SLEEP_MODE); // enter sleep mode
						chThdSleepMilliseconds(5);
						break;
					default:
						return;
				}
				GDISP.Powermode = (gdisp_powermode_t)value;
				return;
			case GDISP_CONTROL_ORIENTATION:
				if (GDISP.Orientation == (gdisp_orientation_t)value)
					return;
				switch((gdisp_orientation_t)value) {
					case GDISP_ROTATE_0:
						/* 	Code here */
						GDISP.Height = GDISP_SCREEN_HEIGHT;
						GDISP.Width = GDISP_SCREEN_WIDTH;
						break;
					case GDISP_ROTATE_90:
						/* 	Code here */
						GDISP.Height = GDISP_SCREEN_WIDTH;
						GDISP.Width = GDISP_SCREEN_HEIGHT;
						break;
					case GDISP_ROTATE_180:
						/* 	Code here */
						GDISP.Height = GDISP_SCREEN_HEIGHT;
						GDISP.Width = GDISP_SCREEN_WIDTH;
						break;
					case GDISP_ROTATE_270:
						/* 	Code here */
						GDISP.Height = GDISP_SCREEN_WIDTH;
						GDISP.Width = GDISP_SCREEN_HEIGHT;
						break;
					default:
						return;
				}
				#if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION
					GDISP.clipx0 = 0;
					GDISP.clipy0 = 0;
					GDISP.clipx1 = GDISP.Width;
					GDISP.clipy1 = GDISP.Height;
				#endif
				GDISP.Orientation = (gdisp_orientation_t)value;
				return;
			case GDISP_CONTROL_BACKLIGHT:
				gdisp_lld_bg_dimmer(54 + ((uint8_t)value) << 1);//turn 0..100% in 54..255
				return;
/*
			case GDISP_CONTROL_CONTRAST:
*/
		}
	}