示例#1
0
/*** NOTIFICATIONS *****************************************************************/
void lcd_notifications(void)
{
	tag = 0;
	
	ButtonStruct btnHome  = TouchInit(5);
	ButtonStruct btnClear = TouchInit(6);
	
	draw_notifications_screen(&btnHome, &btnClear);
	
	while(1)
	{	
		/* Process Tasks */
		processTasks();
		
		/* Redraw in every sec */
		if(FLAG_datetime)
		{ 
			draw_notifications_screen(&btnHome, &btnClear);
			FLAG_datetime = 0;
		}
		
		tag = HOST_MEM_RD32(REG_TOUCH_TAG);
		switch(tag)
		{
			case 5:
				if(!btnHome.pressed)
				{
					btnHome.pressed = 1;
					draw_notifications_screen(&btnHome, &btnClear);
				}
			break;
			
			case 6:
				if(!btnClear.pressed)
				{
					btnClear.pressed = 1;
					draw_notifications_screen(&btnHome, &btnClear);
				}
			break;
			
			default:
				if(btnHome.pressed || btnClear.pressed)
				{
					if(buttonIsClicked(&btnHome, tag))  { return; }
					if(buttonIsClicked(&btnClear, tag)) { clearNotif(); }
					
					btnHome.pressed = 0;
					btnClear.pressed = 0;
					
					draw_notifications_screen(&btnHome, &btnClear);
				}
			break;
		}
		
	} /* while */
}
示例#2
0
/*** START SCREEN ******************************************************************/
void lcd_start(void)
{
	tag = 0;
	ButtonStruct btnContinue = TouchInit(1);
	
	/* startup animation */
	draw_startup_animation();

	/* startup screen */
	draw_start_screen(&btnContinue);
	
	while(1)
	{
		tag = HOST_MEM_RD32(REG_TOUCH_TAG);
		
		//button pressed
		if(tag == 1 && !btnContinue.pressed)
		{
			btnContinue.pressed = 1;
			draw_start_screen(&btnContinue);
		}
		
		//button released
		if(tag != btnContinue.tag && btnContinue.pressed)
		{
			if(buttonIsClicked(&btnContinue, tag)) { return; }
			btnContinue.pressed = 0;
			draw_start_screen(&btnContinue);
		}
	}
}
示例#3
0
void SYS_Initialize ( void* data )
{

       /* Initializethe interrupt system  */
    SYS_INT_Initialize();

    /* Initialize the global interrupts */
    SYS_INT_Enable();

    SYS_MSG_MESSAGING_OBJECT oSysMsg;
    SYS_MSG_INIT sSysMsgInit;
    uint16_t nQSizes[] = SYS_MSG_BUFFER_SIZES;

    sSysMsgInit.nMaxMsgsDelivered  = SYS_MSG_MAX_MSGS_DELIVERED;
    sSysMsgInit.nMessagePriorities = SYS_MSG_MAX_PRIORITY+1;
    sSysMsgInit.nQSizes = nQSizes;

    hSysMsg = SYS_MSG_Initialize(iSysMsg,(SYS_OBJ_HANDLE)&sSysMsgInit);
    oSysMsg = *(SYS_MSG_MESSAGING_OBJECT *)hSysMsg;

    hMsgType = SYS_MSG_TypeCreate(iSysMsg, TYPE_TOUCHSCREEN , 0);
    hMailbox = SYS_MSB_MailboxOpen( iSysMsg, (SYS_MSG_RECEIVE_CALLBACK)&TouchMessageCallback );

    SYS_MSG_MailboxMsgAdd(hMailbox,hMsgType);

    /////////////////////////////////////////////////////////////////////////////
    //                  DRIVER SPECIFIC INITIALIZATION DATA
    /////////////////////////////////////////////////////////////////////////////

    // initialize the timer that manages the tick counter
    TickInit();

    /////////////////////////////////////////////////////////////////////////////
    //                  DRIVER SPECIFIC INITIALIZATION DATA
    /////////////////////////////////////////////////////////////////////////////

    GFX_DRV_lcc_Initialize(0); //Initialize the Graphics Driver

    while (handle != 0)
    {
        handle = GFX_DRV_lcc_Open(0);
    }

    GFX_Initialize();

    // initialize the components for Resistive Touch Screen
    TouchInit((void *)0, (void *)0, (void *)0, NULL);

    ImageDecoderInit();

    JPEGInit();                  // Initialize JPEG

    /* Initialize the Application */
    APP_Initialize ( );
    
}
示例#4
0
/*** STATUS ************************************************************************/
void lcd_status(void)
{
	tag = 0;
	ButtonStruct btnHome = TouchInit(5);
	
	draw_status_screen(&btnHome);
	
	while(1)
	{	
		/* Process Tasks */
		processTasks();
		
		/* Get PeriphConnection Status */
		if(FLAG_getPeriphConnection)
		{
			getPeriphConnection(&PeriphConnection);
			draw_status_screen(&btnHome);
			FLAG_getPeriphConnection = 0;
		}
		
		tag = HOST_MEM_RD32(REG_TOUCH_TAG);
		switch(tag)
		{
			case 5:
				if(!btnHome.pressed)
				{
					btnHome.pressed = 1;
					draw_status_screen(&btnHome);
				}
			break;
			
			default:
				if(btnHome.pressed)
				{
					if(buttonIsClicked(&btnHome, tag)) { return; }
					btnHome.pressed = 0;
					
					draw_status_screen(&btnHome);
				}
			break;
		}
		
	} /* while */
}
示例#5
0
void SYSTEM_InitializeBoard(void)
{
    const DRV_SPI_INIT_DATA SPI_Init_Data = {2, 3, 7, 0, SPI_BUS_MODE_3, 0};

    // ---------------------------------------------------------
    // Make sure the display DO NOT flicker at start up
    // ---------------------------------------------------------
    DisplayBacklightConfig();
    DisplayPowerConfig();
    DisplayBacklightOff();

    // ---------------------------------------------------------
    // mikroe Board
    // SPI-Flash Device pins
    // ---------------------------------------------------------
    // chip select pin
    SST25_CS_TRIS   = 0;
    SST25_CS_LAT    = 1;
    // spi-clock pin
    SST25_SCK_TRIS  = 0;
    // spi-output pin
    SST25_SDO_TRIS  = 0;
    // spi-intput pin
    SST25_SDI_TRIS  = 1;

    /* Config the LED ports to output. */
    LEDPortsConfig();
    LEDPortsClear();
    // ---------------------------------------------------------
    // Initialize the Display Driver
    // ---------------------------------------------------------

    DRV_GFX_Initialize();

    DRV_NVM_M25P80_Initialize((DRV_SPI_INIT_DATA*)&SPI_Init_Data);

    // initialize system tick counter
    SYSTEM_TickInit();

    // initialize the components for Resistive Touch Screen
    TouchInit(NVMWrite, NVMRead, NVMSectorErase, NULL);
//    TouchInit(NULL, NULL, NULL, NULL);

}
示例#6
0
/*** ALERT *************************************************************************/
void lcd_alert(SensorStruct* sensor)
{
	tag = 0;
	ButtonStruct btnOk = TouchInit(1);
	draw_alert_screen(sensor, &btnOk);
	
	while(1)
	{
		/* Process Tasks */
		processTasks();
		
		/* Redraw if new alert comes during display */
		if(!(sensor->alert & 0x01))
		{
			draw_alert_screen(sensor, &btnOk);
			setAlertStateBit(sensor);
		}
		
		tag = HOST_MEM_RD32(REG_TOUCH_TAG);
		
		//button pressed
		if(tag == 1 && !btnOk.pressed)
		{
			btnOk.pressed = 1;
			draw_alert_screen(sensor, &btnOk);
		}
		
		//button released
		if(tag != 1 && btnOk.pressed)
		{
			if(buttonIsClicked(&btnOk, tag)) { return; }
			btnOk.pressed = 0;
			draw_alert_screen(sensor, &btnOk);
		}
	}
}
示例#7
0
// *****************************************************************************
void SYSTEM_InitializeBoard(void)
{

    const DRV_SPI_INIT_DATA SPI_Init_Data = {2, 3, 7, 0, SPI_BUS_MODE_3, 0};

    // ---------------------------------------------------------
    // Make sure the display DO NOT flicker at start up
    // ---------------------------------------------------------
    DisplayBacklightConfig();
    DisplayPowerConfig();
    DisplayBacklightOff();
	
    // ---------------------------------------------------------
    // ADC Explorer 16 Development Board Errata (work around 2)
    // RB15 should be output
    // ---------------------------------------------------------
    LATBbits.LATB15 = 0;
    TRISBbits.TRISB15 = 0;

    // ---------------------------------------------------------
    // Explorer 16 Development Board MCHP25LC256 chip select signal,
    // even if not used must be driven to high so it does not
    // interfere with other SPI peripherals that uses the same SPI signals.
    // ---------------------------------------------------------
    TRISDbits.TRISD12 = 0;
    LATDbits.LATD12 = 1;
    
    // ---------------------------------------------------------
    // Graphics LCD Controller PICtail Plus SSD1926 Board
    // SPI-Flash Device pins 
    // ---------------------------------------------------------
    // chip select pin
    TRISDbits.TRISD1 = 0;
    LATDbits.LATD1   = 1;
    // spi-clock pin
    TRISGbits.TRISG6 = 0;
    // spi-output pin
    TRISGbits.TRISG8 = 0;
    // spi-intput pin
    TRISGbits.TRISG7 = 1;

    // ---------------------------------------------------------
    // UART pins
    // ---------------------------------------------------------
    // initialize the UART pins
    TRISFbits.TRISF5 = 0;
    TRISFbits.TRISF4 = 1;

    // unlock PPS
    __builtin_write_OSCCONL(OSCCON & 0xbf);

    // set UART pins
    RPINR19bits.U2RXR = 10; 	// assign RP10 to RX
    RPOR8bits.RP17R = 5;    	// assign RP17 to TX

    // set SPI pins
    RPOR10bits.RP21R = 11;      // assign RP21 for SCK2
    RPOR9bits.RP19R = 10;       // assign RP19 for SDO2
    RPINR22bits.SDI2R = 26;     // assign RP26 for SDI2

    // lock   PPS
    __builtin_write_OSCCONL(OSCCON | 0x40);

    // ---------------------------------------------------------
    // Initialize the Display Driver
    // ---------------------------------------------------------
    DRV_GFX_Initialize();

    DRV_NVM_SST25VF016_Initialize((DRV_SPI_INIT_DATA*)&SPI_Init_Data);

    // initialize system tick counter
    SYSTEM_TickInit();

    // initialize the components for Resistive Touch Screen
    TouchInit(NVMWrite, NVMRead, NVMSectorErase, NULL);

    
}
示例#8
0
//*****************************************************************************
//
// The main code for the application.  It sets up the peripherals, displays the
// splash screens, and then manages the interaction between the game and the
// screen saver.
//
//*****************************************************************************
int
main(void)
{
	tRectangle sRect;
#ifndef _TMS320C6X
    unsigned int index;
#endif
	
    SetupIntc();

	
	/* Configuring UART2 instance for serial communication. */
    UARTStdioInit();

#ifdef _TMS320C6X
    CacheEnableMAR((unsigned int)0xC0000000, (unsigned int)0x20000000);
    CacheEnable(L1PCFG_L1PMODE_32K | L1DCFG_L1DMODE_32K | L2CFG_L2MODE_256K);
#else
    /* Sets up 'Level 1" page table entries. 
     * The page table entry consists of the base address of the page
     * and the attributes for the page. The following operation is to
     * setup one-to-one mapping page table for DDR memeory range and set
     * the atributes for the same. The DDR memory range is from 0xC0000000
     * to 0xDFFFFFFF. Thus the base of the page table ranges from 0xC00 to 
     * 0xDFF. Cache(C bit) and Write Buffer(B bit) are enabled  only for
     * those page table entries which maps to DDR RAM and internal RAM.
     * All the pages in the DDR range are provided with R/W permissions
     */
    for(index = 0; index < (4*1024); index++)
    {
         if((index >= 0xC00 && index < 0xE00)|| (index == 0x800))
         {             
              pageTable[index] = (index << 20) | 0x00000C1E;
         }
         else
         {
              pageTable[index] = (index << 20) | 0x00000C12;
         }
    }
     
    /* Configures translation table base register
     * with pagetable base address.
     */
    CP15TtbSet((unsigned int )pageTable);

    /* Enables MMU */
    CP15MMUEnable();
   
	/* Enable Instruction Cache */
    CP15ICacheEnable();

    /* Enable Data Cache */
    CP15DCacheEnable();
#endif

    SetUpLCD();
	
	ConfigureFrameBuffer();
		
	GrOffScreen16BPPInit(&g_sSHARP480x272x16Display0, (unsigned char *)g_pucBuffer0, LCD_WIDTH, LCD_HEIGHT);
	GrOffScreen16BPPInit(&g_sSHARP480x272x16Display1, (unsigned char *)g_pucBuffer1, LCD_WIDTH, LCD_HEIGHT);
	
	// Initialize a drawing context.
	GrContextInit(&sContext0, &g_sSHARP480x272x16Display0);
	GrContextInit(&sContext1, &g_sSHARP480x272x16Display1);

    /* enable End of frame interrupt */
    RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS);

    /* enable raster */
    RasterEnable(SOC_LCDC_0_REGS);

	PeripheralsSetup();
	I2C0IntRegister(4);
    AIC31Init();
    ToneLoopInit();
	/* Start playing the tone */
    ToneLoopStart();
	
    // TS init	
	TouchInit();
	
	GrContextForegroundSet(&sContext0, ClrBlack);
	GrContextForegroundSet(&sContext1, ClrBlack);
    sRect.sXMin = GAME_X - 1;
    sRect.sYMin = GAME_Y - 1;
    sRect.sXMax = GAME_X + GAME_W;
    sRect.sYMax = GAME_Y + GAME_H;
    GrRectFill(&sContext0, &sRect);
    GrRectFill(&sContext1, &sRect);

    GrImageDraw(&sContext0, g_pucTILogo128x96, GAME_X, GAME_Y);
	GrImageDraw(&sContext1, g_pucTILogo128x96, GAME_X, GAME_Y);
	
	Delay(0x5FFFFF);
	
	// Confiure and start timer2
	Timer2Config();
	Timer2Start();

    // Loop forever.
    while(1)
    {
        // Display the main screen.
        if(MainScreen())
        {
            // The button was pressed, so start the game.
            PlayGame();
        }
        else
        {
            // The button was not pressed during the timeout period, so start
            // the screen saver.
            ScreenSaver();
        }
    }
}
示例#9
0
文件: Main.c 项目: agus-xyz/cNGD-soft
int main(void)
{
    GOL_MSG msg;                    // GOL message structure to interact with GOL
    
    Nop();
    
    #if defined(PIC24FJ256DA210_DEV_BOARD)
    
    _ANSG8 = 0; /* S1 */
    _ANSE9 = 0; /* S2 */
    _ANSB5 = 0; /* S3 */
        
    #else
    /////////////////////////////////////////////////////////////////////////////
    // ADC Explorer 16 Development Board Errata (work around 2)
    // RB15 should be output
    /////////////////////////////////////////////////////////////////////////////
	#ifndef MULTI_MEDIA_BOARD_DM00123
    LATBbits.LATB15 = 0;
    TRISBbits.TRISB15 = 0;
    #endif
	#endif
    /////////////////////////////////////////////////////////////////////////////
    #if defined(__dsPIC33F__) || defined(__PIC24H__)

    // Configure Oscillator to operate the device at 40Mhz
    // Fosc= Fin*M/(N1*N2), Fcy=Fosc/2
    // Fosc= 8M*40(2*2)=80Mhz for 8M input clock
    PLLFBD = 38;                    // M=40
    CLKDIVbits.PLLPOST = 0;         // N1=2
    CLKDIVbits.PLLPRE = 0;          // N2=2
    OSCTUN = 0;                     // Tune FRC oscillator, if FRC is used

    // Disable Watch Dog Timer
    RCONbits.SWDTEN = 0;

    // Clock switching to incorporate PLL
    __builtin_write_OSCCONH(0x03);  // Initiate Clock Switch to Primary

    // Oscillator with PLL (NOSC=0b011)
    __builtin_write_OSCCONL(0x01);  // Start clock switching
    while(OSCCONbits.COSC != 0b011);

    // Wait for Clock switch to occur	
    // Wait for PLL to lock
    while(OSCCONbits.LOCK != 1)
    { };
    
    // Set PMD0 pin functionality to digital
    AD1PCFGL = AD1PCFGL | 0x1000;
    
    #elif defined(__PIC32MX__)
    INTEnableSystemMultiVectoredInt();
    SYSTEMConfigPerformance(GetSystemClock());
    #ifdef MULTI_MEDIA_BOARD_DM00123
    CPLDInitialize();
    CPLDSetGraphicsConfiguration(GRAPHICS_HW_CONFIG);
    CPLDSetSPIFlashConfiguration(SPI_FLASH_CHANNEL);
    #endif // #ifdef MULTI_MEDIA_BOARD_DM00123
    #endif // #if defined(__dsPIC33F__) || defined(__PIC24H__)

    GOLInit();                      // initialize graphics library &
                                    // create default style scheme for GOL

    #if defined (GFX_PICTAIL_V1) || defined (GFX_PICTAIL_V2)
    EEPROMInit();                   // initialize Exp.16 EEPROM SPI
    BeepInit();
    #else
	    #if defined (USE_SST25VF016)
            SST25Init();            // initialize GFX3 SST25 flash SPI
        #endif
    #endif
    
    TouchInit();                    // initialize touch screen
    HardwareButtonInit();           // Initialize the hardware buttons

    // create default style scheme for GOL
    TickInit();                     // initialize tick counter (for random number generation)

    // create default style scheme for GOL
    #if defined(__dsPIC33FJ128GP804__) || defined(__PIC24HJ128GP504__)

    // If S3 button on Explorer 16 board is pressed calibrate touch screen
    TRISAbits.TRISA9 = 1;
    if(PORTAbits.RA9 == 0)
    {
        TRISAbits.TRISA9 = 0;
        TouchCalibration();
        TouchStoreCalibration();
    }

    TRISAbits.TRISA9 = 0;
	#else

	    /**
	     * Force a touchscreen calibration by pressing the switch
	     * Explorer 16 + GFX PICTail    - S3 (8 bit PMP)
	     * Explorer 16 + GFX PICTail    - S5 (16 bit PMP)
	     * Starter Kit + GFX PICTail    - S0 (8 bit PMP)
	     * Multimedia Expansion Board   - Fire Button
	     * DA210 Developement Board     - S1
	     * NOTE:    Starter Kit + GFX PICTail will switches are shared
	     *          with the 16 bit PMP data bus.
	     **/
	    if(GetHWButtonTouchCal() == HW_BUTTON_PRESS)
	    {
	        TouchCalibration();
	        TouchStoreCalibration();
	    }
    #endif

    // If it's a new board (EEPROM_VERSION byte is not programed) calibrate touch screen
    #if defined (GFX_PICTAIL_V1) || defined (GFX_PICTAIL_V2)
    if(GRAPHICS_LIBRARY_VERSION != EEPROMReadWord(ADDRESS_VERSION))
    {
        TouchCalibration();
        TouchStoreCalibration();
    }

    #else
        #if defined (USE_SST25VF016)
        if(GRAPHICS_LIBRARY_VERSION != SST25ReadWord(ADDRESS_VERSION))
        {
            TouchCalibration();
            TouchStoreCalibration();
        }
        #elif defined (USE_SST39LF400)
        WORD tempArray[12], tempWord = 0x1234;

        SST39LF400Init(tempArray);
        tempWord = SST39LF400ReadWord(ADDRESS_VERSION);
        SST39LF400DeInit(tempArray);

        if(GRAPHICS_LIBRARY_VERSION != tempWord)
        {
            TouchCalibration();
            TouchStoreCalibration();
        }
        #endif
    #endif

    // Load touch screen calibration parameters from memory
    TouchLoadCalibration();

    GDDDemoCreateFirstScreen();

    while(1)
    {
        if(GOLDraw())               // Draw GOL object
        {
            TouchGetMsg(&msg);      // Get message from touch screen
			
            #if (NUM_GDD_SCREENS > 1)
			// GDD Readme:
			// The following line of code allows a GDD user to touch the touchscreen
			// to cycle through different static screens for viewing. This is useful as a
			// quick way to view how each screen looks on the physical target hardware.
			// This line of code should eventually be commented out for actual development.
			// Also note that widget/object names can be found in GDD_Screens.h
			if(msg.uiEvent == EVENT_RELEASE) GDDDemoNextScreen();
			#endif
			
            GOLMsg(&msg);           // Process message
        }
    }//end while
}
示例#10
0
/////////////////////////////////////////////////////////////////////////////
// Function: InitializeBoard()
// Input: none
// Output: none
// Overview: Initializes the hardware components including the PIC device
//           used.
/////////////////////////////////////////////////////////////////////////////
void InitializeBoard(void)
{
        /////////////////////////////////////////////////////////////////////////////
        // ADC Explorer 16 Development Board Errata (work around 2)
        // RB15 should be output
        /////////////////////////////////////////////////////////////////////////////
            LATBbits.LATB15 = 0;
            TRISBbits.TRISB15 = 0;

    #if defined(__dsPIC33F__) || defined(__PIC24H__)

        // Configure Oscillator to operate the device at 40Mhz
        // Fosc= Fin*M/(N1*N2), Fcy=Fosc/2
        // Fosc= 8M*40(2*2)=80Mhz for 8M input clock
        PLLFBD = 38;                    // M=40
        CLKDIVbits.PLLPOST = 0;         // N1=2
        CLKDIVbits.PLLPRE = 0;          // N2=2
        OSCTUN = 0;                     // Tune FRC oscillator, if FRC is used
    
        // Disable Watch Dog Timer
        RCONbits.SWDTEN = 0;
    
        // Clock switching to incorporate PLL
        __builtin_write_OSCCONH(0x03);  // Initiate Clock Switch to Primary
    
        // Oscillator with PLL (NOSC=0b011)
        __builtin_write_OSCCONL(0x01);  // Start clock switching
        while(OSCCONbits.COSC != 0b011);
    
        // Wait for Clock switch to occur	
        // Wait for PLL to lock
        while(OSCCONbits.LOCK != 1)
        { };
        
        // Set PMD0 pin functionality to digital
        AD1PCFGL = AD1PCFGL | 0x1000;

        #if defined(__dsPIC33FJ128GP804__) || defined(__PIC24HJ128GP504__)
            AD1PCFGLbits.PCFG6 = 1;
            AD1PCFGLbits.PCFG7 = 1;
            AD1PCFGLbits.PCFG8 = 1;
        #endif
        
    #elif defined(__PIC32MX__)
        INTEnableSystemMultiVectoredInt();
        SYSTEMConfigPerformance(GetSystemClock());
    #endif // #if defined(__dsPIC33F__) || defined(__PIC24H__)
    

    #if defined (EXPLORER_16)
/************************************************************************
* For Explorer 16 RD12 is connected to EEPROM chip select.
* To prevent a conflict between this EEPROM and SST25 flash
* the chip select of the EEPROM SPI should be pulled up.
************************************************************************/
        // Set IOs directions for EEPROM SPI
        MCHP25LC256_CS_LAT = 1;			    // set initial CS value to 1 (not asserted)
    	MCHP25LC256_CS_TRIS = 0;			// set CS pin to output
	#endif // #if defined (EXPLORER_16)


     //The following are PIC device specific settings for the SPI channel
     //used. 
    
     //Set IOs directions for SST25 SPI   
        SST25_CS_LAT = 1;
        SST25_CS_TRIS = 0;
 
       #ifndef __PIC32MX__
            SST25_SCK_TRIS = 0;
            SST25_SDO_TRIS = 0;
            SST25_SDI_TRIS = 1;
            #if defined(__PIC24FJ256GB210__)
            	SST25_SDI_ANS = 0;
    	    #endif
       #endif
    // set the peripheral pin select for the PSI channel used
    #if defined(__dsPIC33FJ128GP804__) || defined(__PIC24HJ128GP504__)
        AD1PCFGL = 0xFFFF;
        RPOR9bits.RP18R = 11;                   // assign RP18 for SCK2
        RPOR8bits.RP16R = 10;                   // assign RP16 for SDO2
        RPINR22bits.SDI2R = 17;                 // assign RP17 for SDI2	
    #elif defined(__PIC24FJ256GB110__) || defined(__PIC24FJ256GA110__) || defined (__PIC24FJ256GB210__)
        __builtin_write_OSCCONL(OSCCON & 0xbf); // unlock PPS
        RPOR10bits.RP21R = 11;                  // assign RP21 for SCK2
        RPOR9bits.RP19R = 10;                   // assign RP19 for SDO2
        RPINR22bits.SDI2R = 26;                 // assign RP26 for SDI2
        __builtin_write_OSCCONL(OSCCON | 0x40); // lock   PPS
    #elif defined(__PIC24FJ256DA210__)

        __builtin_write_OSCCONL(OSCCON & 0xbf); // unlock PPS

    	#if (SST25_SPI_CHANNEL == 1)
    	    RPOR1bits.RP2R = 8;                 // assign RP2 for SCK1
    	    RPOR0bits.RP1R = 7;                 // assign RP1 for SDO1
    	    RPINR20bits.SDI1R = 0;              // assign RP0 for SDI1
        #elif (SST25_SPI_CHANNEL == 2)
            RPOR1bits.RP2R = 11;                // assign RP2 for SCK2
    	    RPOR0bits.RP1R = 10;                // assign RP1 for SDO2
    	    RPINR22bits.SDI2R = 0;              // assign RP0 for SDI2
    	#endif

        __builtin_write_OSCCONL(OSCCON | 0x40); // lock   PPS

    #endif

    /////////////////////////////////////////////////////////////////////////////
    //                  DRIVER SPECIFIC INITIALIZATION DATA
    /////////////////////////////////////////////////////////////////////////////

	GOLInit();                      // Initialize graphics library and create default style scheme for GOL

    // initialize GFX3 SST25 flash SPI
    SST25Init((void*) &SPI_Init_Data);                    
   
    TickInit();                     	

	
#if defined(SPI_CHANNEL_1_ENABLE) && defined(__PIC32MX__)          //SPI1 shares pins with the PMP CS. Not recommended for use
    SPI1TouchInit();

/****
 * AR1020 Touch Screen Controller
 *
 * Because the AR1020 needs to use the SPI channel to retrieve data and 
 * SPI channel 1 shares the PMP CS pin, this combination is not supported.
 * The user will receive a compile time error to avoid run time errors 
 * with this combination.
 ****/
#ifdef USE_TOUCHSCREEN_AR1020
#error "The combination of AR1020 touch screen controller and SPI 1 channel is not supported.  Please use SPI channel 2 with the AR1020 controller, or resistive touch."
#endif

#else	
    // initialize the components for Resistive Touch Screen
    TouchInit(NVMWrite, NVMRead, NVMSectorErase, TOUCH_INIT_VALUES);  
#endif	

    HardwareButtonInit();           	// Initialize the hardware buttons

}   
示例#11
0
int main(void)
{
    tRectangle sRect;
    unsigned int i = 0;
    unsigned char *src = (unsigned char *) palette_32b;
    unsigned char *dest = (unsigned char *) (g_pucBuffer+4);

    MMUConfigAndEnable();

    //
    //Enable USB module clock
    //
    USB0ModuleClkConfig();
    //
    //Enable DM timer 3 module clock
    //
    DMTimer3ModuleClkConfig();
    //
    //Enbale touch screen module colock
    //
    TSCADCModuleClkConfig();
    //
    //Enable touch screen ADC pinmux
    //
    TSCADCPinMuxSetUp();
    //
    //Enbale USB interrupts
    //
    USBInterruptEnable();
    //
    //Switch ON LCD back light
    //
    LCDBackLightEnable();
    //
    //UDP Pin control
    //
    UPDNPinControl();

    //
    //Delay timer setup
    //
    DelayTimerSetup();

    //
    //Configures raster to display image
    //
    SetUpLCD();
    //
    //Register touch scren interrupt
    //
    TouchIntRegister();

    IntSystemEnable(SYS_INT_TINT3);
    IntPrioritySet(SYS_INT_TINT3, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_ADC_TSC_GENINT);
    IntPrioritySet(SYS_INT_ADC_TSC_GENINT, 0, AINTC_HOSTINT_ROUTE_IRQ);

    RasterDMAFBConfig(SOC_LCDC_0_REGS,
                      (unsigned int)(g_pucBuffer+PALETTE_OFFSET),
                      (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 -
                      PALETTE_OFFSET, FRAME_BUFFER_0);

    RasterDMAFBConfig(SOC_LCDC_0_REGS,
                      (unsigned int)(g_pucBuffer+PALETTE_OFFSET),
                      (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 -
                      PALETTE_OFFSET, FRAME_BUFFER_1);

    src = (unsigned char *) palette_32b;
    dest = (unsigned char *) (g_pucBuffer+PALETTE_OFFSET);

    // Copy palette info into buffer
    for( i = PALETTE_OFFSET; i < (PALETTE_SIZE+PALETTE_OFFSET); i++)
    {
        *dest++ = *src++;
    }

    GrOffScreen24BPPInit(&g_s35_480x272x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT);

    // Initialize a drawing context.
    GrContextInit(&g_sContext, &g_s35_480x272x24Display);

    /* enable End of frame interrupt */
    RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS);

    /* enable raster */
    RasterEnable(SOC_LCDC_0_REGS);

    //
    // Fill the top 24 rows of the screen with blue to create the banner.
    //
    sRect.sXMin = 0;
    sRect.sYMin = 0;
    sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
    sRect.sYMax = 23;
    GrContextForegroundSet(&g_sContext, ClrDarkBlue);
    GrRectFill(&g_sContext, &sRect);

    //
    // Put a white box around the banner.
    //
    GrContextForegroundSet(&g_sContext, ClrWhite);
    GrRectDraw(&g_sContext, &sRect);

    //
    // Put the application name in the middle of the banner.
    //
    GrContextFontSet(&g_sContext, &g_sFontCm20);
    GrStringDrawCentered(&g_sContext, "usb-dev-mouse", -1,
                         GrContextDpyWidthGet(&g_sContext) / 2, 10, 0);

    //
    // Fill the top 24 rows of the screen with blue to create the banner.
    //
    sRect.sXMin = 0;
    sRect.sYMin = 25;
    sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
    sRect.sYMax = GrContextDpyHeightGet(&g_sContext) - BUTTON_HEIGHT - 2;
    GrContextForegroundSet(&g_sContext, ClrDarkGray);
    GrRectFill(&g_sContext, &sRect);

    //
    // Put a white box around the banner.
    //
    GrContextForegroundSet(&g_sContext, ClrRed);
    GrRectDraw(&g_sContext, &sRect);

    //
    // Draw the buttons in their initial (unpressed)state.
    //
    UpdateDisplay(g_ucButtons, true);

    //
    //Initialize touch screen
    //
    TouchInit();
    //
    //Touch screen Interrupt enbale
    //
    TouchIntEnable();
    //
    //Touch Screen Enable
    //
    TouchEnable();
    //
    // Initialize the mouse
    //
    USBDHIDMouseInit(0, (tUSBDHIDMouseDevice *)&g_sMouseDevice);

    //
    // Drop into the main loop.
    //
    while(1)
    {
        //
        // Wait for USB configuration to complete.
        //
        while(!bConnected)
        {
        }

        //
        //Wait till someone touches the screen
        //
        while(!g_iTouch)
        {
            g_iTouch = TouchDetect();
        }

        //
        //Loop here as long as someone moving the finger/stylus on the touch screen
        //
        do
        {
            //
            //If so, read the x and Y vlaue and give it to touch handler
            //
            TouchCoOrdGet(&g_lScreenX, &g_lScreenY);
            //
            //Call touch handler
            //
            TouchHandler();

        }while(TouchDetect());
        //
        //Touch is released
        //
        g_released = 1;
        //
        //Reset the button status
        //
        g_ucButtons = 0;
        //
        //Call the touch handler to update the release status
        //
        TouchHandler();
        //
        //Reset the touch flag
        //
        g_iTouch = 0;
    }

}
示例#12
0
/*** MAIN **************************************************************************/
uint8_t lcd_main(void)
{
	tag = 0;
	
	/* init buttons */
	ButtonStruct btnStartStop 		= TouchInit(1);
	ButtonStruct btnStatus 			= TouchInit(2);
	ButtonStruct btnNotifications 	= TouchInit(3);
	ButtonStruct btnSettings 		= TouchInit(4);
	ButtonStruct btnSetDate 		= TouchInit(5);
	
	/* write background into memory */
	store_main_default();
	
	/* first start: display buttons & others */
	draw_main_screen(&btnStartStop, &btnStatus, &btnNotifications, &btnSettings, &btnSetDate);
	
	while(1)
	{
		/* Process Tasks */
		processTasks();
		
		/* Display Alerts */
		if(EnableAlerts)
		{
			/* Check Sensor1 for Alerts to display */
			if(isAlert(&Sensor1) && !FLAG_dispAlert)
			{
				FLAG_beepAlert = 1;
				FLAG_dispAlert = 1;
				setAlertStateBit(&Sensor1);
				lcd_alert(&Sensor1);
				Sensor1.alertTimer = ALERT_TIME;
				FLAG_dispAlert = 0;
			}
			
			/* Check Sensor2 for Alerts to display */
			if(isAlert(&Sensor2) && !FLAG_dispAlert)
			{
				FLAG_beepAlert = 1;
				FLAG_dispAlert = 1;
				setAlertStateBit(&Sensor2);
				lcd_alert(&Sensor2);
				Sensor2.alertTimer = ALERT_TIME;
				FLAG_dispAlert = 0;
			}
			
			/* Check Sensor3 for Alerts to display */
			if(isAlert(&Sensor3) && !FLAG_dispAlert)
			{
				FLAG_beepAlert = 1;
				FLAG_dispAlert = 1;
				setAlertStateBit(&Sensor3);
				lcd_alert(&Sensor3);
				Sensor3.alertTimer = ALERT_TIME;
				FLAG_dispAlert = 0;
			}
		}
		
		/* Draw date & time if needed AND redraw screen in every sec */
		if(FLAG_datetime)
		{ 
			draw_main_screen(&btnStartStop, &btnStatus, &btnNotifications, &btnSettings, &btnSetDate);
			FLAG_datetime = 0;
		}
		
		/* Check Touch TAG */
		tag = HOST_MEM_RD32(REG_TOUCH_TAG);
		
		switch(tag)
		{
			case 1:		// start/stop button
			if(!btnStartStop.pressed)
				{
					btnStartStop.pressed = 1;
					draw_main_screen(&btnStartStop, &btnStatus, &btnNotifications, &btnSettings, &btnSetDate);
				}
			break;
			
			case 2:		// status button
				if(!btnStatus.pressed)
				{
					btnStatus.pressed = 1;
					draw_main_screen(&btnStartStop, &btnStatus, &btnNotifications, &btnSettings, &btnSetDate);
				}
			break;
			
			case 3:		// notifications button
				if(!btnNotifications.pressed)
				{
					btnNotifications.pressed = 1;
					draw_main_screen(&btnStartStop, &btnStatus, &btnNotifications, &btnSettings, &btnSetDate);
				}
			break;
			
			case 4:		// settings button
				if(!btnSettings.pressed)
				{
					btnSettings.pressed = 1;
					draw_main_screen(&btnStartStop, &btnStatus, &btnNotifications, &btnSettings, &btnSetDate);
				}
			break;
			
			case 5:		// set Date & Time
				if(!btnSetDate.pressed)
				{
					btnSetDate.pressed = 1;
					draw_main_screen(&btnStartStop, &btnStatus, &btnNotifications, &btnSettings, &btnSetDate);
				}
			break;
			
			case 11:	// Select Sensor1 as Favorite
				SensorFav = &Sensor1;
				draw_main_screen(&btnStartStop, &btnStatus, &btnNotifications, &btnSettings, &btnSetDate);
			break;	
			case 12:	// Select Sensor2 as Favorite
				SensorFav = &Sensor2;
				draw_main_screen(&btnStartStop, &btnStatus, &btnNotifications, &btnSettings, &btnSetDate);
			break;
			case 13:	// Select Sensor3 as Favorite
				SensorFav = &Sensor3;
				draw_main_screen(&btnStartStop, &btnStatus, &btnNotifications, &btnSettings, &btnSetDate);
			break;
			
			default:	//only if something is pressed
				if(btnStartStop.pressed || btnStatus.pressed || btnNotifications.pressed || btnSettings.pressed || btnSetDate.pressed)
				{
					if(buttonIsClicked(&btnStartStop, tag))		{ Mode.state ^= ON; }
					if(buttonIsClicked(&btnStatus, tag))		{ return btnStatus.tag; }
					if(buttonIsClicked(&btnNotifications, tag))	{ /*Mode.type ^= 1;*/ return btnNotifications.tag; }
					if(buttonIsClicked(&btnSettings, tag))		{ return btnSettings.tag; }
					if(buttonIsClicked(&btnSetDate, tag))		{ return btnSetDate.tag; }
					
					btnStartStop.pressed = 0;
					btnStatus.pressed = 0;
					btnNotifications.pressed = 0;
					btnSettings.pressed	= 0;
					btnSetDate.pressed = 0;
					
					draw_main_screen(&btnStartStop, &btnStatus, &btnNotifications, &btnSettings, &btnSetDate);
				}
			break;
		} /* switch */
		
	} /* while */
	
}
示例#13
0
/*** SETTINGS: ALERT ***************************************************************/
void lcd_settings_alert(SensorStruct* Sensor)
{
	tag = 0;
	tracker = 0;
	
	SliderStruct Slider1;
	ButtonStruct btnBack 		= TouchInit(6);
	ButtonStruct btnTempMaxM	= TouchInit(10);
	ButtonStruct btnTempMaxP	= TouchInit(11);
	ButtonStruct btnHumMaxM		= TouchInit(12);
	ButtonStruct btnHumMaxP		= TouchInit(13);
	ButtonStruct btnCOMaxM		= TouchInit(14);
	ButtonStruct btnCOMaxP		= TouchInit(15);
	ButtonStruct btnTempMinM	= TouchInit(20);
	ButtonStruct btnTempMinP	= TouchInit(21);
	ButtonStruct btnHumMinM		= TouchInit(22);
	ButtonStruct btnHumMinP		= TouchInit(23);
	ButtonStruct btnCO2MaxM		= TouchInit(24);
	ButtonStruct btnCO2MaxP		= TouchInit(25);
	
	/* get default value for slider */
	sliderInit( &Slider1, (65535 - (uint16_t)((Sensor->target-5)/25*65535)) );
	
	/* write background into memory */
	store_settings_alert_default();
	
	/* display */
	draw_settings_alert_screen(Sensor, &btnBack, &Slider1, &btnTempMaxM, &btnTempMaxP, &btnHumMaxM, &btnHumMaxP, &btnCOMaxM, &btnCOMaxP, &btnTempMinM, &btnTempMinP, &btnHumMinM, &btnHumMinP, &btnCO2MaxM, &btnCO2MaxP);
	
	while(1)
	{
		tracker = HOST_MEM_RD32(REG_TRACKER);
		tag = HOST_MEM_RD32(REG_TOUCH_TAG);
		
		/* Slider */
		if((tracker & 0xFF) == 91)
		{	
			/*add to avg array & calculate avg*/			
			sliderPush(&Slider1, tracker>>16);
			Slider1.value = sliderAvg(&Slider1);
			
			/*set sensor & display*/
			Sensor->target = ((float)(65535-Slider1.value) / 65535 * 25.0) + 5.0;
			draw_settings_alert_screen(Sensor, &btnBack, &Slider1, &btnTempMaxM, &btnTempMaxP, &btnHumMaxM, &btnHumMaxP, &btnCOMaxM, &btnCOMaxP, &btnTempMinM, &btnTempMinP, &btnHumMinM, &btnHumMinP, &btnCO2MaxM, &btnCO2MaxP);
		}
		
		/* Buttons */
		switch(tag)
		{
			case 6:
				if(!btnBack.pressed)
				{
					btnBack.pressed = 1;
					draw_settings_alert_screen(Sensor, &btnBack, &Slider1, &btnTempMaxM, &btnTempMaxP, &btnHumMaxM, &btnHumMaxP, &btnCOMaxM, &btnCOMaxP, &btnTempMinM, &btnTempMinP, &btnHumMinM, &btnHumMinP, &btnCO2MaxM, &btnCO2MaxP);
				}
			break;
			
			case 10:
				if(!btnTempMaxM.pressed)
				{
					btnTempMaxM.pressed = 1;
					draw_settings_alert_screen(Sensor, &btnBack, &Slider1, &btnTempMaxM, &btnTempMaxP, &btnHumMaxM, &btnHumMaxP, &btnCOMaxM, &btnCOMaxP, &btnTempMinM, &btnTempMinP, &btnHumMinM, &btnHumMinP, &btnCO2MaxM, &btnCO2MaxP);
				}
			break;
			case 11:
				if(!btnTempMaxP.pressed)
				{
					btnTempMaxP.pressed = 1;
					draw_settings_alert_screen(Sensor, &btnBack, &Slider1, &btnTempMaxM, &btnTempMaxP, &btnHumMaxM, &btnHumMaxP, &btnCOMaxM, &btnCOMaxP, &btnTempMinM, &btnTempMinP, &btnHumMinM, &btnHumMinP, &btnCO2MaxM, &btnCO2MaxP);
				}
			break;
			
			case 12:
				if(!btnHumMaxM.pressed)
				{
					btnHumMaxM.pressed = 1;
					draw_settings_alert_screen(Sensor, &btnBack, &Slider1, &btnTempMaxM, &btnTempMaxP, &btnHumMaxM, &btnHumMaxP, &btnCOMaxM, &btnCOMaxP, &btnTempMinM, &btnTempMinP, &btnHumMinM, &btnHumMinP, &btnCO2MaxM, &btnCO2MaxP);
				}
			break;
			case 13:
				if(!btnHumMaxP.pressed)
				{
					btnHumMaxP.pressed = 1;
					draw_settings_alert_screen(Sensor, &btnBack, &Slider1, &btnTempMaxM, &btnTempMaxP, &btnHumMaxM, &btnHumMaxP, &btnCOMaxM, &btnCOMaxP, &btnTempMinM, &btnTempMinP, &btnHumMinM, &btnHumMinP, &btnCO2MaxM, &btnCO2MaxP);
				}
			break;
			
			case 14:
				if(!btnCOMaxM.pressed)
				{
					btnCOMaxM.pressed = 1;
					draw_settings_alert_screen(Sensor, &btnBack, &Slider1, &btnTempMaxM, &btnTempMaxP, &btnHumMaxM, &btnHumMaxP, &btnCOMaxM, &btnCOMaxP, &btnTempMinM, &btnTempMinP, &btnHumMinM, &btnHumMinP, &btnCO2MaxM, &btnCO2MaxP);
				}
			break;
			case 15:
				if(!btnCOMaxP.pressed)
				{
					btnCOMaxP.pressed = 1;
					draw_settings_alert_screen(Sensor, &btnBack, &Slider1, &btnTempMaxM, &btnTempMaxP, &btnHumMaxM, &btnHumMaxP, &btnCOMaxM, &btnCOMaxP, &btnTempMinM, &btnTempMinP, &btnHumMinM, &btnHumMinP, &btnCO2MaxM, &btnCO2MaxP);
				}
			break;
			
			case 20:
				if(!btnTempMinM.pressed)
				{
					btnTempMinM.pressed = 1;
					draw_settings_alert_screen(Sensor, &btnBack, &Slider1, &btnTempMaxM, &btnTempMaxP, &btnHumMaxM, &btnHumMaxP, &btnCOMaxM, &btnCOMaxP, &btnTempMinM, &btnTempMinP, &btnHumMinM, &btnHumMinP, &btnCO2MaxM, &btnCO2MaxP);
				}
			break;
			case 21:
				if(!btnTempMinP.pressed)
				{
					btnTempMinP.pressed = 1;
					draw_settings_alert_screen(Sensor, &btnBack, &Slider1, &btnTempMaxM, &btnTempMaxP, &btnHumMaxM, &btnHumMaxP, &btnCOMaxM, &btnCOMaxP, &btnTempMinM, &btnTempMinP, &btnHumMinM, &btnHumMinP, &btnCO2MaxM, &btnCO2MaxP);
				}
			break;
			
			case 22:
				if(!btnHumMinM.pressed)
				{
					btnHumMinM.pressed = 1;
					draw_settings_alert_screen(Sensor, &btnBack, &Slider1, &btnTempMaxM, &btnTempMaxP, &btnHumMaxM, &btnHumMaxP, &btnCOMaxM, &btnCOMaxP, &btnTempMinM, &btnTempMinP, &btnHumMinM, &btnHumMinP, &btnCO2MaxM, &btnCO2MaxP);
				}
			break;
			case 23:
				if(!btnHumMinP.pressed)
				{
					btnHumMinP.pressed = 1;
					draw_settings_alert_screen(Sensor, &btnBack, &Slider1, &btnTempMaxM, &btnTempMaxP, &btnHumMaxM, &btnHumMaxP, &btnCOMaxM, &btnCOMaxP, &btnTempMinM, &btnTempMinP, &btnHumMinM, &btnHumMinP, &btnCO2MaxM, &btnCO2MaxP);
				}
			break;
			
			case 24:
				if(!btnCO2MaxM.pressed)
				{
					btnCO2MaxM.pressed = 1;
					draw_settings_alert_screen(Sensor, &btnBack, &Slider1, &btnTempMaxM, &btnTempMaxP, &btnHumMaxM, &btnHumMaxP, &btnCOMaxM, &btnCOMaxP, &btnTempMinM, &btnTempMinP, &btnHumMinM, &btnHumMinP, &btnCO2MaxM, &btnCO2MaxP);
				}
			break;
			case 25:
				if(!btnCO2MaxP.pressed)
				{
					btnCO2MaxP.pressed = 1;
					draw_settings_alert_screen(Sensor, &btnBack, &Slider1, &btnTempMaxM, &btnTempMaxP, &btnHumMaxM, &btnHumMaxP, &btnCOMaxM, &btnCOMaxP, &btnTempMinM, &btnTempMinP, &btnHumMinM, &btnHumMinP, &btnCO2MaxM, &btnCO2MaxP);
				}
			break;
			
			default:
				if( btnBack.pressed ||
				    btnTempMaxM.pressed ||
					btnTempMaxP.pressed ||
					btnHumMaxM.pressed ||
					btnHumMaxP.pressed ||
					btnCOMaxM.pressed ||
					btnCOMaxP.pressed ||
					btnTempMinM.pressed ||
					btnTempMinP.pressed ||
					btnHumMinM.pressed ||
					btnHumMinP.pressed ||
					btnCO2MaxM.pressed ||
					btnCO2MaxP.pressed )
				{
					if(buttonIsClicked(&btnBack, tag)) 		{ return; }
					if(buttonIsClicked(&btnTempMaxM, tag))	{ Sensor->aTmax -= 0.1; }
					if(buttonIsClicked(&btnTempMaxP, tag)) 	{ Sensor->aTmax += 0.1; }
					if(buttonIsClicked(&btnHumMaxM, tag)) 	{ Sensor->aHmax -= 1; }
					if(buttonIsClicked(&btnHumMaxP, tag)) 	{ Sensor->aHmax += 1; }
					if(buttonIsClicked(&btnCOMaxM, tag)) 	{ Sensor->aCO -= 1; }
					if(buttonIsClicked(&btnCOMaxP, tag)) 	{ Sensor->aCO += 1; }
					if(buttonIsClicked(&btnTempMinM, tag))	{ Sensor->aTmin -= 0.1; }
					if(buttonIsClicked(&btnTempMinP, tag)) 	{ Sensor->aTmin += 0.1; }
					if(buttonIsClicked(&btnHumMinM, tag)) 	{ Sensor->aHmin -= 1; }
					if(buttonIsClicked(&btnHumMinP, tag)) 	{ Sensor->aHmin += 1; }
					if(buttonIsClicked(&btnCO2MaxM, tag)) 	{ Sensor->aCO2 -= 1; }
					if(buttonIsClicked(&btnCO2MaxP, tag)) 	{ Sensor->aCO2 += 1; }
					
					btnBack.pressed = 0;
					btnTempMaxM.pressed = 0;
					btnTempMaxP.pressed = 0;
					btnHumMaxM.pressed	= 0;
					btnHumMaxP.pressed	= 0;
					btnCOMaxM.pressed	= 0;
					btnCOMaxP.pressed	= 0;
					btnTempMinM.pressed	= 0;
					btnTempMinP.pressed	= 0;
					btnHumMinM.pressed	= 0;
					btnHumMinP.pressed	= 0;
					btnCO2MaxM.pressed	= 0;
					btnCO2MaxP.pressed	= 0;
					
					draw_settings_alert_screen(Sensor, &btnBack, &Slider1, &btnTempMaxM, &btnTempMaxP, &btnHumMaxM, &btnHumMaxP, &btnCOMaxM, &btnCOMaxP, &btnTempMinM, &btnTempMinP, &btnHumMinM, &btnHumMinP, &btnCO2MaxM, &btnCO2MaxP);
				}
			break;
		}
		
	} /* while */
示例#14
0
/*** SETTINGS **********************************************************************/
void lcd_settings(void)
{	
	tag = 0;
	uint8_t redraw = 1; 	/* set to 1 on first start and also set in case of return from a submenu (this rewrites the ft800 ram) */
	
	ButtonStruct btnHome = TouchInit(5);
	ButtonStruct btnEnableAlerts = TouchInit(6);
	ButtonStruct btnS1Alert = TouchInit(10);
	ButtonStruct btnS1Conf 	= TouchInit(11);
	ButtonStruct btnS1Name 	= TouchInit(12);
	ButtonStruct btnS2Alert = TouchInit(20);
	ButtonStruct btnS2Conf 	= TouchInit(21);
	ButtonStruct btnS2Name	= TouchInit(22);
	ButtonStruct btnS3Alert = TouchInit(30);
	ButtonStruct btnS3Conf 	= TouchInit(31);
	ButtonStruct btnS3Name 	= TouchInit(32);
	
	/* write background into memory and draw screen */
	store_settings_default();
	draw_settings_screen(&btnHome, &btnEnableAlerts, &btnS1Alert, &btnS1Conf, &btnS1Name, &btnS2Alert, &btnS2Conf, &btnS2Name, &btnS3Alert, &btnS3Conf, &btnS3Name);
	
	while(1)
	{		
		tag = HOST_MEM_RD32(REG_TOUCH_TAG);
		
		/* Buttons */
		switch(tag)
		{
			case 5:
				if(!btnHome.pressed)
				{
					btnHome.pressed = 1;
					draw_settings_screen(&btnHome, &btnEnableAlerts, &btnS1Alert, &btnS1Conf, &btnS1Name, &btnS2Alert, &btnS2Conf, &btnS2Name, &btnS3Alert, &btnS3Conf, &btnS3Name);
				}
			break;
			
			case 6:
				if(!btnEnableAlerts.pressed)
				{
					btnEnableAlerts.pressed = 1;
					draw_settings_screen(&btnHome, &btnEnableAlerts, &btnS1Alert, &btnS1Conf, &btnS1Name, &btnS2Alert, &btnS2Conf, &btnS2Name, &btnS3Alert, &btnS3Conf, &btnS3Name);
				}
			break;
			
			/* Sensor 1 Buttons */
			case 10:
				if(!btnS1Alert.pressed)
				{
					btnS1Alert.pressed = 1;
					draw_settings_screen(&btnHome, &btnEnableAlerts, &btnS1Alert, &btnS1Conf, &btnS1Name, &btnS2Alert, &btnS2Conf, &btnS2Name, &btnS3Alert, &btnS3Conf, &btnS3Name);
				}
			break;
			case 11:
				if(!btnS1Conf.pressed)
				{
					btnS1Conf.pressed = 1;
					draw_settings_screen(&btnHome, &btnEnableAlerts, &btnS1Alert, &btnS1Conf, &btnS1Name, &btnS2Alert, &btnS2Conf, &btnS2Name, &btnS3Alert, &btnS3Conf, &btnS3Name);
				}
			break;
			case 12:
				if(!btnS1Name.pressed)
				{
					btnS1Name.pressed = 1;
					draw_settings_screen(&btnHome, &btnEnableAlerts, &btnS1Alert, &btnS1Conf, &btnS1Name, &btnS2Alert, &btnS2Conf, &btnS2Name, &btnS3Alert, &btnS3Conf, &btnS3Name);
				}
			break;
			
			/* Sensor 2 Buttons */
			case 20:
				if(!btnS2Alert.pressed)
				{
					btnS2Alert.pressed = 1;
					draw_settings_screen(&btnHome, &btnEnableAlerts, &btnS1Alert, &btnS1Conf, &btnS1Name, &btnS2Alert, &btnS2Conf, &btnS2Name, &btnS3Alert, &btnS3Conf, &btnS3Name);
				}
			break;
			case 21:
				if(!btnS2Conf.pressed)
				{
					btnS2Conf.pressed = 1;
					draw_settings_screen(&btnHome, &btnEnableAlerts, &btnS1Alert, &btnS1Conf, &btnS1Name, &btnS2Alert, &btnS2Conf, &btnS2Name, &btnS3Alert, &btnS3Conf, &btnS3Name);
				}
			break;
			case 22:
				if(!btnS2Name.pressed)
				{
					btnS2Name.pressed = 1;
					draw_settings_screen(&btnHome, &btnEnableAlerts, &btnS1Alert, &btnS1Conf, &btnS1Name, &btnS2Alert, &btnS2Conf, &btnS2Name, &btnS3Alert, &btnS3Conf, &btnS3Name);
				}
			break;
			
			/* Sensor 3 Buttons */
			case 30:
				if(!btnS3Alert.pressed)
				{
					btnS3Alert.pressed = 1;
					draw_settings_screen(&btnHome, &btnEnableAlerts, &btnS1Alert, &btnS1Conf, &btnS1Name, &btnS2Alert, &btnS2Conf, &btnS2Name, &btnS3Alert, &btnS3Conf, &btnS3Name);
				}
			break;
			case 31:
				if(!btnS3Conf.pressed)
				{
					btnS3Conf.pressed = 1;
					draw_settings_screen(&btnHome, &btnEnableAlerts, &btnS1Alert, &btnS1Conf, &btnS1Name, &btnS2Alert, &btnS2Conf, &btnS2Name, &btnS3Alert, &btnS3Conf, &btnS3Name);
				}
			break;
			case 32:
				if(!btnS3Name.pressed)
				{
					btnS3Name.pressed = 1;
					draw_settings_screen(&btnHome, &btnEnableAlerts, &btnS1Alert, &btnS1Conf, &btnS1Name, &btnS2Alert, &btnS2Conf, &btnS2Name, &btnS3Alert, &btnS3Conf, &btnS3Name);
				}
			break;
			
			default:
				if(btnHome.pressed || btnEnableAlerts.pressed ||
				   btnS1Alert.pressed || btnS1Conf.pressed || btnS1Name.pressed ||
				   btnS2Alert.pressed || btnS2Conf.pressed || btnS2Name.pressed ||
				   btnS3Alert.pressed || btnS3Conf.pressed || btnS3Name.pressed)
				{
					if(buttonIsClicked(&btnHome, tag)) 			{ writeConfigToSD(); return; }
					if(buttonIsClicked(&btnEnableAlerts, tag)) 	{ EnableAlerts ^= 1; }
					if(buttonIsClicked(&btnS1Alert, tag)) 		{ lcd_settings_alert(&Sensor1); redraw = 1; }
					if(buttonIsClicked(&btnS1Conf, tag)) 		{ lcd_settings_conf(&Sensor1);  redraw = 1; }
					if(buttonIsClicked(&btnS1Name, tag)) 		{ lcd_settings_name(&Sensor1);  redraw = 1; }
					if(buttonIsClicked(&btnS2Alert, tag)) 		{ lcd_settings_alert(&Sensor2); redraw = 1; }
					if(buttonIsClicked(&btnS2Conf, tag)) 		{ lcd_settings_conf(&Sensor2);  redraw = 1; }
					if(buttonIsClicked(&btnS2Name, tag)) 		{ lcd_settings_name(&Sensor2);  redraw = 1; }
					if(buttonIsClicked(&btnS3Alert, tag)) 		{ lcd_settings_alert(&Sensor3); redraw = 1; }
					if(buttonIsClicked(&btnS3Conf, tag)) 		{ lcd_settings_conf(&Sensor3);  redraw = 1; }
					if(buttonIsClicked(&btnS3Name, tag)) 		{ lcd_settings_name(&Sensor3);  redraw = 1;}
					
					btnHome.pressed = 0;
					btnEnableAlerts.pressed = 0;
					btnS1Alert.pressed 	= 0;
					btnS1Conf.pressed 	= 0;
					btnS1Name.pressed 	= 0;
					btnS2Alert.pressed 	= 0;
					btnS2Conf.pressed 	= 0;
					btnS2Name.pressed 	= 0;
					btnS3Alert.pressed 	= 0;
					btnS3Conf.pressed 	= 0;
					btnS3Name.pressed 	= 0;
					
					if(redraw) { store_settings_default(); redraw = 0; }	/* we need to rewrite ft800 mem in case of return from submenu */
					draw_settings_screen(&btnHome, &btnEnableAlerts, &btnS1Alert, &btnS1Conf, &btnS1Name, &btnS2Alert, &btnS2Conf, &btnS2Name, &btnS3Alert, &btnS3Conf, &btnS3Name);
				}
			break;
		}
		
	} /* while */
	
}
示例#15
0
/*** SET DATE & TIME ***************************************************************/
void lcd_date(void)
{
	tag = 0;
	RTC_DateTypeDef newDate = Rdate;
	RTC_TimeTypeDef newTime = Rtime;
	
	ButtonStruct btnBack = TouchInit(5);
	ButtonStruct keys = TouchInit(0);
	
	/* write background into memory */
	store_date_defaults();
	
	/* display */
	draw_date_screen(&btnBack, &keys, &newDate, &newTime);
	
	while(1)
	{		
		tag = HOST_MEM_RD32(REG_TOUCH_TAG);
		
		/* Buttons */
		switch(tag)
		{
			case 5:
				if(!btnBack.pressed)
				{
					btnBack.pressed = 1;
					draw_date_screen(&btnBack, &keys, &newDate, &newTime);
				}
				break;
			
			case 10:
			case 11:
			case 20:
			case 21:
			case 30:
			case 31:
			case 40:
			case 41:
			case 50:
			case 51:
				if(!keys.pressed)
				{
					keys.pressed = 1;
					keys.tag = tag;
					draw_date_screen(&btnBack, &keys, &newDate, &newTime);
				}
			break;
			
			default:
				if( btnBack.pressed ||
				    keys.pressed )
				{
					if(buttonIsClicked(&btnBack, tag))
					{
						initRTC(1, &newDate, &newTime);
						RTC_GetTime(RTC_Format_BIN, &Rtime);
						RTC_GetDate(RTC_Format_BIN, &Rdate);
						return;
					}
					
					if(buttonIsClicked(&keys, tag))
					{
						if(keys.tag == 10 && newDate.RTC_Year  > 0)  { newDate.RTC_Year--; }
						if(keys.tag == 11 && newDate.RTC_Year  < 99) { newDate.RTC_Year++; }
						if(keys.tag == 20 && newDate.RTC_Month > 0)  { newDate.RTC_Month--; }
						if(keys.tag == 21 && newDate.RTC_Month < 12) { newDate.RTC_Month++; }
						if(keys.tag == 30 && newDate.RTC_Date > 0)   { newDate.RTC_Date--; }
						if(keys.tag == 31 && newDate.RTC_Date < 31)  { newDate.RTC_Date++; }
						
						if(keys.tag == 40 && newTime.RTC_Hours > 0)    { newTime.RTC_Hours--; }
						if(keys.tag == 41 && newTime.RTC_Hours < 23)   { newTime.RTC_Hours++; }
						if(keys.tag == 50 && newTime.RTC_Minutes > 0)  { newTime.RTC_Minutes--; }
						if(keys.tag == 51 && newTime.RTC_Minutes < 59) { newTime.RTC_Minutes++; }
						
						keys.tag = 0;
					}
					
					btnBack.pressed = 0;
					keys.pressed = 0;
					
					draw_date_screen(&btnBack, &keys, &newDate, &newTime);
				}
			break;
		}
		
	} /* while */
}
示例#16
0
/*****************************************************************************
* 
*  This is the main loop that runs the application.
* 
*****************************************************************************/
int
main(void)
{
    tRectangle sRect;
	
    MMUConfigAndEnable();
    
	/* Enable USB module clock */
	
	USB0ModuleClkConfig();
	
	/* Enable DM timer 3 module clock */
	
	DMTimer3ModuleClkConfig();
	
	/* Enbale touch screen module colock */
	
	TSCADCModuleClkConfig();
	
	/* Enable touch screen ADC pinmux */
	
	TSCADCPinMuxSetUp();    

	/* configures arm interrupt controller to generate raster interrupt  */
	
	USBInterruptEnable();        
	
	/* LCD Back light setup  */
	
	LCDBackLightEnable();	
	
	/* UPD Pin setup */
	
	UPDNPinControl();

	/* Delay timer setup */
	
	DelayTimerSetup();

	/* Configures raster to display image  */
	
	SetUpLCD();		

	/* Register touch scren interrupt */
	
	TouchIntRegister();

	IntSystemEnable(SYS_INT_TINT3);
    IntPrioritySet(SYS_INT_TINT3, 0, AINTC_HOSTINT_ROUTE_IRQ);
	IntSystemEnable(SYS_INT_ADC_TSC_GENINT);
	IntPrioritySet(SYS_INT_ADC_TSC_GENINT, 0, AINTC_HOSTINT_ROUTE_IRQ);
		
    
	/* Configures raster to display image  and Copy palette info into buffer */	
	LCDInit();
	
	GrOffScreen24BPPInit(&g_s35_480x272x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT);
	
	/* Initialize a drawing context. */
	GrContextInit(&g_sContext, &g_s35_480x272x24Display);

	/* enable End of frame interrupt */
	RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS);

	/* enable raster */
	RasterEnable(SOC_LCDC_0_REGS);

	
	/* Fill the top 24 rows of the screen with blue to create the banner. */
	
	sRect.sXMin = 0;
	sRect.sYMin = 0;
	sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
	sRect.sYMax = (MAX_ROW_NUM - 1);
	GrContextForegroundSet(&g_sContext, ClrDarkBlue);
	GrRectFill(&g_sContext, &sRect);

	/* Put a white box around the banner. */
	
	GrContextForegroundSet(&g_sContext, ClrWhite);
	GrRectDraw(&g_sContext, &sRect);

	
	/* Put the application name in the middle of the banner. */
	
	GrContextFontSet(&g_sContext, &g_sFontCm20);
	GrStringDrawCentered(&g_sContext, "usb-dev-composite", -1,
						 GrContextDpyWidthGet(&g_sContext) / 2, 10, 0);
    
    sRect.sXMin = 0;
    sRect.sYMin = (MAX_ROW_NUM + 1);
    sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
    sRect.sYMax = GrContextDpyHeightGet(&g_sContext) - BUTTON_HEIGHT - 2;
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrRectFill(&g_sContext, &sRect);


    
    /* Put a white box around the banner. */
    
    GrContextForegroundSet(&g_sContext, ClrRed);
    GrRectDraw(&g_sContext, &sRect);
	
    
    /* Draw the buttons in their initial (unpressed)state. */
    
    UpdateDisplay(g_ucButtons, true);	
		
    /*  Show the various static text elements on the color STN display. */
     
    GrContextFontSet(&g_sContext, TEXT_FONT);
    GrStringDraw(&g_sContext, "Tx bytes:", -1, CDC_STR_X_POSITION,
                  CDC_STR_Y_POSITION, false);
    GrStringDraw(&g_sContext, "Tx buffer:", -1, CDC_STR_X_POSITION,
                 (CDC_STR_Y_POSITION + CDC_STR_Y_DIFF), false);
    GrStringDraw(&g_sContext, "Rx bytes:", -1, CDC_STR_X_POSITION,
                  (CDC_STR_Y_POSITION + (CDC_STR_Y_DIFF * 3)), false);
    GrStringDraw(&g_sContext, "Rx buffer:", -1, CDC_STR_X_POSITION,
                  (CDC_STR_Y_POSITION + (CDC_STR_Y_DIFF * 4)), false);
    DrawBufferMeter(&g_sContext, BUFFER_METER_X_POS, BUFFER_METER_Y_POS);
    DrawBufferMeter(&g_sContext, BUFFER_METER_X_POS, 
                    (BUFFER_METER_Y_POS + CDC_BUF_METER_Y_DIFF));

    /* Tell the user what we are up to. */
     
    DisplayStatus(&g_sContext, " Waiting for host... ");

	/* Initialize touch screen */
	 
	TouchInit();

	/* Touch screen Interrupt enbale */
	
	TouchIntEnable();
	
	/* Touch Screen Enable */
	
	TouchEnable();	
	
	  
    /* Pass the USB library our device information, initialize the USB
       controller and connect the device to the bus.
    */
    
    g_psCompDevices[0].pvInstance =
        USBDHIDMouseCompositeInit(0, (tUSBDHIDMouseDevice *)&g_sMouseDevice);
    g_psCompDevices[1].pvInstance =
        USBDCDCCompositeInit(0, (tUSBDCDCDevice *)&g_sCDCDevice);

    
    /* Pass the device information to the USB library and place the device
       on the bus.
    */
    
    USBDCompositeInit(0, &g_sCompDevice, DESCRIPTOR_DATA_SIZE,
                      g_pucDescriptorData);

    
    /* Initialize the mouse and serial devices. */
    SerialInit();
    
    /* Drop into the main loop. */
    
    while(1)
    {
        
        /* Allow the main serial routine to run. */
        
        SerialMain();
        
        /* Allow the main mouse routine to run. */
        
        MouseMain();
    }
}
示例#17
0
文件: Main.c 项目: coastermike/Pager
/////////////////////////////////////////////////////////////////////////////
// Function: InitializeBoard()
// Input: none
// Output: none
// Overview: Initializes the hardware components including the PIC device
//           used.
/////////////////////////////////////////////////////////////////////////////
void InitializeBoard(void)
{    
     CLKDIVbits.RCDIV = 0;
     CLKDIVbits.DOZE = 0;
     CLKDIVbits.PLLEN = 1;
     CLKDIVbits.CPDIV = 0;
     OSCCONbits.COSC = 0b001;
     
     ANSA = 0x0000;
     ANSB = 0x0000;
     ANSC = 0x0010;		// RC4 as touch screen X+
     ANSD = 0x0000;
     ANSE = 0x0200;		// RE9 used as Y+
     ANSF = 0x0000;
     ANSG = 0x0000;
	
	LED_TRIS = 0;
	
    // Initialize graphics library and create default style scheme for GOL
    GOLInit();
	_DPTEST = 0b00;
	
	i2cInit();
	SPI1CON1 = 0b0000000100111110;
    SPI1STAT = 0x8000;
    
    RFIF = 0;
    if( RF_INT_PIN == 0 )
    {
        RFIF = 1;
    }

    //The following are PIC device specific settings for the SPI channel
    //used. 
    //Set IOs directions for SST25 SPI
        SST25_CS_LAT = 1;
        Nop();
        SST25_CS_TRIS = 0;

        SST25_SCK_TRIS = 0;
        Nop();
        SST25_SDO_TRIS = 0;
        Nop();
        SST25_SDI_TRIS = 1;

		//radio pins
		_RP11R = 8; // assign RP11 for SCK1
     	_RP2R = 7; // assign RP2 for SDO1
     	_SDI1R = 36; // assign RP36 for SDI1
     	_INT1R = 37;
    // set the peripheral pin select for the PSI channel used
        __builtin_write_OSCCONL(OSCCON & 0xbf); // unlock PPS
    	#if (SST25_SPI_CHANNEL == 1)
    	    RPOR3bits.RP6R = 8;                 // assign RP6 for SCK1
    	    RPOR9bits.RP18R = 7;                 // assign RP18 for SDO1
    	    RPINR20bits.SDI1R = 32;              // assign RP18 for SDI1
        #elif (SST25_SPI_CHANNEL == 2)
            _RP6R = 11;                // assign RP11 for SCK2
    	    _RP18R = 10;                // assign RP2 for SDO2
    	    _SDI2R = 32;              // assign RP36 for SDI2
    	#endif
		

     	
        __builtin_write_OSCCONL(OSCCON | 0x40); // lock   PPS
	
	//radio
	PHY_CS_TRIS = 0;
    Nop();
    PHY_CS = 1;
    Nop();
    PHY_RESETn_TRIS = 0;
    PHY_RESETn = 1;
    RF_INT_TRIS = 1;
    SDI_TRIS = 1;
    SDO_TRIS = 0;
    SCK_TRIS = 0;
    SPI_SDO = 0;        
    SPI_SCK = 0; 
    PHY_WAKE_TRIS = 0;
    PHY_WAKE = 1;
    
	LED = 1;
	TRISAbits.TRISA1 = 0;
	Nop();
	PORTAbits.RA1 = 1;
	
	// initialize the Flash Memory driver
    FlashInit(&SPI_Init_Data);
    LED = 0;
    // initialize the timer that manages the tick counter
    TickInit(); 
                     
    // initialize the components for Resistive Touch Screen
    TouchInit(NVMWrite, NVMRead, NVMSectorErase, TOUCH_INIT_VALUES);
    LED = 0;
}    
示例#18
0
uint8_t lcd_start_sd(void)
{
	tag = 0;
	
	u8 valid = 1;		/* variable for checking whether the data is valid on the uSD */
	u8 finished = 0;	/* variable for checking whether every row is readed correctly */
	char error_msg[33];
	memset(error_msg, '\0', sizeof(error_msg));
	
	FATFS FatFs;
	FIL fil;
	
	//microSD	
	char row[NAME_MAX+3];
		
	if( !f_mount(&FatFs, "", 1) )
	{	
		if( !f_open(&fil, "config.txt", FA_OPEN_EXISTING | FA_READ) )
		{
			u8 cntr = 0;			
			
			/* read MODE */
			f_gets(row, sizeof(row), &fil);
			removeCRLF(row);
			if(strstr(row, "HEATING")) 		{ Mode.type = HEATING; }
			else if(strstr(row, "COOLING")) { Mode.type = COOLING; }
			else { valid = 0; }
			
			/* read EnableAlerts */
			f_gets(row, sizeof(row), &fil);
			removeCRLF(row);
			if(strstr(row, "ALERT_ENABLE")) 		{ EnableAlerts = 1; }
			else if(strstr(row, "ALERT_DISABLE"))	{ EnableAlerts = 0; }
			else { valid = 0; }
			
			/* read Sensors Data */
			for(cntr=0; cntr<3; ++cntr) 
			{
				SensorStruct* sensor;
				switch(cntr)
				{
					case 0: sensor = &Sensor1; break;
					case 1: sensor = &Sensor2; break;
					case 2: sensor = &Sensor3; break;
				}
				
				memset(row, '\0', sizeof(row));
					   
				/* name */
				f_gets(row, sizeof(row), &fil);
				removeCRLF(row);
				strcpy(sensor->name, row);
				
				/* communication */
				f_gets(row, sizeof(row), &fil);
				removeCRLF(row);
				if(strstr(row, "COM_RF")) 		{ sensor->com = COM_RF; }
				else if(strstr(row, "COM_TP"))	{ sensor->com = COM_TP; }
				else if(strstr(row, "COM_OFF"))	{ sensor->com = COM_OFF; }
				else { valid = 0; }
				
				/* target temp */
				f_gets(row, sizeof(row), &fil);
				removeCRLF(row);
				if(atof(row)) { sensor->target = atof(row); }
				else { valid = 0; }
				
				/* alerts: T_H, T_L, H_H, H_L, CO, CO2 (6) */
				f_gets(row, sizeof(row), &fil);
				removeCRLF(row);
				if(atof(row)) { sensor->aTmax = atof(row); }
				else { valid = 0; }
				
				f_gets(row, sizeof(row), &fil);
				removeCRLF(row);
				if(atof(row)) { sensor->aTmin = atof(row); }
				else { valid = 0; }
				
				f_gets(row, sizeof(row), &fil);
				removeCRLF(row);
				if(atoi(row)) { sensor->aHmax = atoi(row); }
				else { valid = 0; }
				
				f_gets(row, sizeof(row), &fil);
				removeCRLF(row);
				if(atoi(row)) { sensor->aHmin = atoi(row); }
				else { valid = 0; }
				
				f_gets(row, sizeof(row), &fil);
				removeCRLF(row);
				if(atoi(row)) { sensor->aCO = atoi(row); }
				else { valid = 0; }
				
				f_gets(row, sizeof(row), &fil);
				removeCRLF(row);
				if(atoi(row)) { sensor->aCO2 = atoi(row); }
				else { valid = 0; }
				
				/* check valid */
				if(!valid)
				{
					strcpy(error_msg, "Config file is corrupt!");
					break;
				}			
			} /* sensors */
			
			//close file
			f_close(&fil);
			if(valid) { finished = 1; }
			
		} /* f_open */
		else
		{
			strcpy(error_msg, "Cannot open the config file!");
		}
		
		//dismount
		f_mount(NULL, "", 1);
	} /* f_mount */
	else
	{
		strcpy(error_msg, "No microSD card is inserted!");
	}

	//check if reading from uSD was successful
	if(finished) { return 1; }
	
	// force release SD ChipSelect
	sdc_deassert();
	
	//display warning
	ButtonStruct btnOk = TouchInit(1);
	draw_sd_warning_screen(error_msg, &btnOk);	
	
	while(1)
	{
		tag = HOST_MEM_RD32(REG_TOUCH_TAG);
		
		//button pressed
		if(tag == 1 && !btnOk.pressed)
		{
			btnOk.pressed = 1;
			draw_sd_warning_screen(error_msg, &btnOk);
		}
		
		//button released
		if(tag != 1 && btnOk.pressed)
		{
			if(buttonIsClicked(&btnOk, tag)) { return 0; }
			btnOk.pressed = 0;
			draw_sd_warning_screen(error_msg, &btnOk);
		}
	}
}