Beispiel #1
0
void ButtonInit()
{
	B_UNSET(BUTTON_PORT_DIR, BUTTON_PIN_BIT);		// set as input
	B_UNSET( BUTTON_PORT_IFG, BUTTON_PIN_BIT);		// IFG cleared
	B_SET( BUTTON_PORT_IES, BUTTON_PIN_BIT);		// high-to-low transition

	char printf_buff[140];
	snprintf(printf_buff, sizeof(printf_buff), "Button released...%s", ICT_TAB_STRING);
	UartXmitString(printf_buff);
	int timeout = 200;
	while( !ButtonState() &&  timeout)
	{
		timeout--;
		delay_ms(1);
	}
	if ( timeout == 0 )
	{
		snprintf(printf_buff, sizeof(printf_buff), "OK\n\r");

	}
	else// button pressed or floating pin
	{
		snprintf(printf_buff, sizeof(printf_buff), "FAIL\n\r");
	}
	UartXmitString(printf_buff);
}
Beispiel #2
0
int VTable::getFrameNum(int index){
	unsigned int x = vTable[index];
	B_UNSET(x, 31);
	B_UNSET(x, 30);
	B_UNSET(x, 29);
	B_UNSET(x, 28);

	int pageNum = x;
	return pageNum;
}
Beispiel #3
0
interrupt(BUTTON_PORT_VECTOR) Button_ISR(void)
{
	B_UNSET(BUTTON_PORT_IFG, BUTTON_PIN_BIT);		// clear IFG
	PowerExitUltraLowPower();		// resume system main loop
/*	ChargePumpStart();
	if (B_IS_SET(BUTTON_PORT_IFG, BUTTON_PIN_BIT))		// Button pressed interrupt
	{
		B_UNSET(BUTTON_PORT_IFG, BUTTON_PIN_BIT);		// clear IFG
		delay_ms(100);
		BuzzerSetBlocking(600,120);
		int timeout = SINK_ENTER_SINK_SETTING_TIMEOUT_MS;
		while(ButtonState() && timeout--)
		{
			delay_ms(1);
		}
		if ( !ButtonState() ) 			// button release, regular startup
		{
			ButtonDisableInterrupt();
			PowerExitUltraLowPower();		// resume system main loop
		}
		else// timeout = enter sink setting
		{
			SinkSetting();
			// then return to low power
			ButtonDisableInterrupt();
			ButtonEnableInterrupt();
			ChargePumpStop();
		}
	}
	*/
}
Beispiel #4
0
interrupt(SENSOR_PORT_VECTOR) Sensor_ISR(void)
{
	if (B_IS_SET(MS5607_EOC_IFG, MS5607_EOC_PIN))	//End Of Conversion Interrupt
	{
		B_UNSET(MS5607_EOC_IFG, MS5607_EOC_PIN); 	// clear IFG
		PowerExitLowPower();
	}
}
Beispiel #5
0
void MS5607WaitEOC(void)
{
	while(!B_IS_SET(MS5607_EOC_IN, MS5607_EOC_PIN))	// PIN low: conversion not over
	{
#ifdef 	SENSOR_EOC_INTERRUPT
		__disable_interrupt();
		B_UNSET(MS5607_EOC_IFG, MS5607_EOC_PIN);
		B_SET(MS5607_EOC_IE, MS5607_EOC_PIN);
		__enable_interrupt();
		PowerEnterLowPower();
		__disable_interrupt();
		B_UNSET(MS5607_EOC_IE, MS5607_EOC_PIN);
		__enable_interrupt();
#else
		__no_operation();
#endif // SENSOR_EOC_INTERRUPT
	}
}
Beispiel #6
0
void VTable::unsetReferenced(int index){
	B_UNSET(vTable[index], 29);
}
Beispiel #7
0
void VTable::unsetModified(int index){
	B_UNSET(vTable[index], 30);
}
Beispiel #8
0
void VTable::unsetPresent(int index){
	B_UNSET(vTable[index], 31);
}
Beispiel #9
0
void ButtonDisableInterrupt()
{
	B_UNSET(BUTTON_PORT_IE, BUTTON_PIN_BIT);			// interrupt enabled
}
Beispiel #10
0
void ButtonEnableInterrupt()
{
	B_UNSET(BUTTON_PORT_IFG, BUTTON_PIN_BIT);		// clear IFG
	B_SET(BUTTON_PORT_IE, BUTTON_PIN_BIT);			// interrupt enabled
}
Beispiel #11
0
Datei: main.c Projekt: 173210/VHL
_start(UVL_Context *ctx)
{
    void * const vhlStubTop = getVhlStubTop();
    void * const vhlPrimaryStubTop = (void *)((uintptr_t)vhlStubTop + 16);
    void * const vhlPrimaryStubBtm = (void *)((uintptr_t)vhlPrimaryStubTop + vhlPrimaryStubSize);

    const SceModuleImports * cachedImports[CACHED_IMPORTED_MODULE_NUM];
    nidTable_entry libkernelBase;
    SceModuleInfo *libkernelInfo;
    SceUID uid;
    void *p;
    int err;

    ctx->logline("Starting VHL...");

    /* It may get wrong if you change the order of nid_table_resolveVhl*
       See stub.S to know what imports will be resolved with those functions. */
    ctx->logline("Resolving VHL puts");
    nid_table_resolveVhlPuts(vhlStubTop, ctx);
    ctx->psvFlushIcache(vhlStubTop, 16);

    DEBUG_LOG_("Searching for SceLibKernel");
    if (nid_table_analyzeStub(ctx->libkernel_anchor, 0, &libkernelBase) != ANALYZE_STUB_OK) {
        DEBUG_LOG_("Failed to find the base of SceLibKernel");
        return -1;
    }

    libkernelBase.value.i = B_UNSET(libkernelBase.value.i, 0);

    libkernelInfo = nid_table_findModuleInfo(libkernelBase.value.p, KERNEL_MODULE_SIZE, "SceLibKernel");
    if (libkernelInfo == NULL) {
        DEBUG_LOG_("Failed to find the module information of SceLibKernel");
        return -1;
    }

    DEBUG_LOG_("Searching for cached imports");
    nidCacheFindCachedImports(libkernelInfo, cachedImports);

    DEBUG_LOG_("Resolving VHL primary imports");
    nid_table_resolveVhlPrimaryImports(vhlPrimaryStubTop, vhlPrimaryStubSize,
                                       libkernelInfo, cachedImports, ctx);
    ctx->psvFlushIcache(vhlPrimaryStubTop, vhlPrimaryStubSize);

    DEBUG_LOG_("Allocating memory for VHL");
    uid = sceKernelAllocMemBlock("vhlGlobals", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW,
                                 FOUR_KB_ALIGN(sizeof(globals_t)), NULL);
    if (uid < 0) {
        DEBUG_LOG("Failed to allocate memory block 0x%08X", uid);
        return uid;
    }

    err = sceKernelGetMemBlockBase(uid, &p);
    if (err < 0) {
        DEBUG_LOG("Failed to retrive memory block 0x%08X", err);
        return uid;
    }

    ctx->psvUnlockMem();
    globals = p;
    ctx->psvLockMem();

    DEBUG_LOG_("Initializing table");
    nid_storage_initialize();

    DEBUG_LOG_("Searching and Adding stubs to table...");
    nid_table_addAllStubs();

    DEBUG_LOG_("Resolving VHL secondary imports");
    nid_table_resolveVhlSecondaryImports(vhlPrimaryStubBtm, vhlSecondaryStubSize,
                                         libkernelInfo, cachedImports, ctx);
    ctx->psvFlushIcache(vhlPrimaryStubBtm, vhlSecondaryStubSize);

    DEBUG_LOG_("Adding stubs to table with cache");
    if (nid_table_addNIDCacheToTable(cachedImports) < 0)
        return -1;

    DEBUG_LOG_("Adding hooks to table");
    nid_table_addAllHooks();

    //TODO find a way to free unused memory

    block_manager_initialize();  //Initialize the elf block slots

    //TODO decide how to handle plugins

    config_initialize();

    DEBUG_LOG_("Loading menu...");

    if(elf_parser_load(globals->allocatedBlocks, "pss0:/top/Documents/homebrew.self", NULL) < 0) {
        internal_printf("Load failed!");
        return -1;
    }
    puts("Load succeeded! Launching!");

    elf_parser_start(globals->allocatedBlocks, 0);

    while(1) {
        //Delay thread and check for flags and things to update every once in a while, check for exit combination
        //calls.LogLine("Menu exited! Relaunching...");
        sceKernelDelayThread(16000);  //Update stuff once every 16 ms
    }

    return 0;
}