Ejemplo n.º 1
0
/**
 *
 * @brief Perform basic hardware initialization
 *
 * Initialize the interrupt controller and UARTs present in the
 * platform.
 *
 * @return 0
 */
static int pc_init(struct sys_device *arg)
{
	ARG_UNUSED(arg);

	picInit();    /* NOP if not needed */
	loapicInit(); /* NOP if not needed */

	/*
	 * IOAPIC is initialized with empty interrupt list
	 * If there is a device connected to IOAPIC, the initialization
	 * has to be changed to _IoApicInit (1 << DEV1_IRQ | 1 << DEV2_IRQ)
	 */
	ioapicInit();   /* NOP if not needed */
	consoleInit(); /* NOP if not needed */
	bluetooth_init(); /* NOP if not needed */
	return 0;
}
Ejemplo n.º 2
0
/*************
 * DESCRIPTION:   Loads a image. Invokes the different handlers for the
 *    picture types. Checks the first 16 Byte of the image file.
 * INPUT:         filename    name of picture to load
 *                path        picture is searched at this paths
 * OUTPUT:        FALSE if failed
 *************/
BOOL IMAGE::Load(char *filename, char *path)
{
    char name[256];
    FILE *typefile;
    FILE *imagefile;
    char typebuf[18];
    char imagebuf[16];
    PICTURE pic;
#ifdef __AMIGA__
    char handlername[32];
    BPTR lock;
#else
    HINSTANCE hPicLib;
    READWRITEPROC picRead;
    char buf[256];
#endif
    int i;
    BOOL identok=FALSE;
    UWORD mask;

    /* expand path with BRUSHPATH */
    if(!ExpandPath(path, filename, name))
    {
        /* cannot open picture */
        return FALSE;
    }

    /* open image and read first 16 Bytes */
    imagefile = fopen(name,"rb");
    if(!imagefile)
        return FALSE;
    if(fread(imagebuf,1,16,imagefile) != 16)
    {
        fclose(imagefile);
        return FALSE;
    }
    fclose(imagefile);
#ifdef __AMIGA__
    // Amiga-version: get directory RayStorm was started from and
    // search file from there
    // get a lock to the program directory
    lock = GetProgramDir();
    // make program directory to current directory
    lock = CurrentDir(lock);
    typefile = fopen("modules/picture/types","rb");
    // change current dir to old dir
    lock = CurrentDir(lock);
#else
    strcpy(buf, WorkingDirectory);
    AddPart(buf, "modules", 256);
    AddPart(buf, "picture", 256);
    AddPart(buf, "types.dat", 256);
    typefile = fopen(buf, "rb");
#endif
    if(!typefile)
    {
        return FALSE;
    }

    while(!feof(typefile) && !identok)
    {
        // Read identification string
        // Format:
        // UWORD mask;    mask for bytes to test '1'->test; lowest bit -> first byte
        // UBYTE id[16];  bytes to compare
        // char name[8];  name of module
        if(fread(&mask,2,1,typefile) != 1)
        {
            fclose(typefile);
            return FALSE;
        }
#ifdef __SWAP__
        mask = SwapW(mask);
#endif
        if(fread(typebuf,1,16,typefile) != 16)
        {
            fclose(typefile);
            return FALSE;
        }

        // Compare first 16 bytes of image with identstring
        identok = TRUE;
        for(i=0; i<16; i++)
        {
            if(mask & 0x8000)
            {
                if(typebuf[i] != imagebuf[i])
                {
                    identok = FALSE;
                    break;
                }
            }
            mask = mask << 1;
        }
        // Read imagename (max. 8 chars)
        if(fread(typebuf,1,8,typefile) != 8)
        {
            fclose(typefile);
            return FALSE;
        }
    }

    fclose(typefile);

    if(identok)
    {
        typebuf[8] = 0;
#ifdef __AMIGA__
        // open picture handler library
        // make program directory current directory
        lock = CurrentDir(lock);
        strcpy(handlername,"modules/picture");
        AddPart(handlername,typebuf,32);
#ifdef __PPC__
        strcat(handlername, "ppc");
#endif

        // Load picture handler
        PicHandBase = OpenLibrary(handlername, 2L);
        if(!PicHandBase)
            return FALSE;

        // change current dir to old dir
        CurrentDir(lock);
#else
        // load corresponding DLL
        strcpy(buf, WorkingDirectory);
        AddPart(buf, "modules", 256);
        AddPart(buf, "picture", 256);
        AddPart(buf, typebuf, 256);
        strcat(buf, ".dll");

        if (!(hPicLib = LoadLibrary(buf)))
            return FALSE;
        if (!(picRead = (READWRITEPROC)GetProcAddress(hPicLib, "picRead_")))
            return FALSE;

        if (!picInit())
            return FALSE;
#endif
        pic.name = name;
        pic.caller = NULL;
        pic.param = NULL;
#ifdef __PPC__
        pic.malloc = PPC_malloc;
#else
        pic.malloc = malloc;
#endif // __PPC__
        pic.Progress = NULL;

        // invoke handler
        if(picRead(&pic))
        {
#ifdef __AMIGA__
            // failed to load it with own modules -> try it with datatypes
            if(!LoadAsDatatype(name))
            {
                // can't load it even with datatypes
                CloseLibrary(PicHandBase);
                return FALSE;
            }
#else
            FreeLibrary(hPicLib);
            return FALSE;
#endif // __AMIGA__
        }
        else
        {
            width = pic.width;
            height = pic.height;
            colormap = pic.colormap;
        }

        // free handler library
#ifdef __AMIGA__
        CloseLibrary(PicHandBase);
#else
        FreeLibrary(hPicLib);
#endif // __AMIGA__
    }
    else
    {
#ifdef __AMIGA__
        // there is no module for this picture type -> try it with datatypes
        if(!LoadAsDatatype(name))
        {
            // can't load it even with datatypes
            return FALSE;
        }
#else
        return FALSE;
#endif
    }
    return TRUE;
}
Ejemplo n.º 3
0
//**************************************************************************************
//***
//***
//***
//**************************************************************************************
void main()
{
	uchar cmd;
	schar j;
	uchar fname[14];
	unsigned i;
	long swtrig = 0;
	
	
	
	picInit();
	memInit();


	serSendString("\r\nxPIClog\r\n");	
	serSendString("=======\r\n");	
	
	serUsage();
	serSendString("\r\n\r\nCOLD START\r\n");	
	serSendString("CHECK TIME AND DATE!\r\n\r\n");


	SDPOW(1);			// SD card power on
	pinInitSD();	// other SD card pins
	filReadConfig("poweron");
	pinExitSD();	// prepare card shutdown
	SDPOW(0);			// SD card power on

	
	
	// a little ugly...
	for(;;)
	{

		// MENU LOOP
		for(;;)
		{
			// check serial commands
			cmd = cmdCheck(EXEC);
			
			// check pushbutton
			if( !SWITCH )
			{
				LED(1);
				if( swtrig++ > 120000 )
					cmd = CMD_OFF;
			}
			else
			{
				LED(1);	// new v0.8a -> dim LED light during menu operation
				
				if( ( swtrig < 120000)&&(swtrig > 1000) )
					cmd = CMD_START;
				swtrig = 0;
				LED(0);
			}

			if( cmd == CMD_START )
				break;

			// power off?
			if( cmd == CMD_OFF )
			{
				serSendString("\r\n\r\nGOING TO SLEEP\r\n\r\n");
				LED(0);
				swtrig = 0;
				for(i=0;i<2000;i++)
					LED(1);
				LED(0);
				
				POWOUT(0);
				pinExitSD();	// prepare card shutdown
				SDPOW(0);			// SD card power off
				BANDGAP(0);		// voltage reference off
				
				sleep();
				nop();
				nop();
				
				while( !SWITCH )
					LED(1);
				LED(0);
				serSendString("\r\n\r\nWOKE UP\r\n\r\n");
				cmd = CMD_LOAD;	// ;-)
			}

			// read config file?
			if( cmd == CMD_LOAD )
			{
				SDPOW(1);			// SD card power on
				pinInitSD();	// other SD card pins
				filReadConfig((uchar *)&sCfg.crdFName);
				pinExitSD();	// prepare card shutdown
				SDPOW(0);			// SD card power on
			}// END CMD load

			// read config file?
			if( cmd == CMD_SAVE )
			{
				SDPOW(1);			// SD card power on
				pinInitSD();	// other SD card pins
				filSaveConfig((uchar *)&sCfg.crdFName);
				pinExitSD();	// prepare card shutdown
				SDPOW(0);			// SD card power on
			}// END CMD load

			
		}// END for menu loop


		// PREPARE ACQUISITION
		for(j=0;j<10;j++)
		{
			for(i=0;i<20000;i++)
				LED(1);
			for(i=0;i<20000;i++)
				LED(0);
		}
		serSendString("\r\nSTART\r\n");

		measStorInit();	// new v0.8a; might be advantageous to clear the buffer first...
		
		rtcSetAlarm(sCfg.rtcSUnit,sCfg.rtcSRate);
		rtcEnableAlarm();


		// ACQUISITION LOOP
		for(;;)
		{
			if( sCfg.rtcActive == NO )
				break;
			
			if( sCfg.rtcSleep )
			{
				sleep();
				nop();
				nop();
			}
		}
		
		rtcDisableAlarm();

		SDPOW(1);			// SD card power on
		pinInitSD();	// other SD card pins
		LED(1);

		// just in case we left because of a serial transmission...
		serRXBufFlushIn();
		serRXBufInit();

		serSendString("\r\nWRITE PENDING DATA: ");
		strcpy((uchar *)&fname,(uchar*)&sCfg.crdFName);
		strcat((uchar *)&fname,".log");
		
		// TODO
		if( (j=filOpenAppendClose((uchar *)&fname)) < 0)
		{
			// flush buffer
			while( measStorReadVMeas() > 0 )
			{;}
			serSendString("ERROR\r\n");
		}
		else
		{
			sCfg.crdSamplesWritten+=(uchar)j;
			serSendString("OK\r\n");
		}
		
		pinExitSD();	// prepare card shutdown
		SDPOW(0);			// SD card power off
		
		
		serSendString("\r\nSTOP\r\n");
		
		// long->ulong might overflow (in years ;-)
		serSendStringDebug("SAMPLES WRITTEN: ",(long)sCfg.crdSamplesWritten,"\r\n");

		while( !SWITCH )
		{;}

		LED(0);
		
	}// END main for loop

}