void main (void)
{
    initBoard();
    initUSB();
    //sleepMillis(500);
    appMainInit();
    while (1)
    {  
#ifndef BUSYBLINK
        do_blink();
#endif
        usbProcessEvents();
        appMainLoop();
    }

}
Exemple #2
0
int main(void) {
	//rcc_clock_setup_in_hsi_out_48mhz();
	rcc_clock_setup_in_hse_8mhz_out_72mhz();
    rcc_periph_clock_enable(RCC_GPIOB);
    gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO10);
    do_blink();

    GPIO_BRR(GPIOB) = GPIO10;

	struct UjClass* mainClass = NULL;
	struct UjClass* objectClass;
	UInt32 threadH;

	UInt8 ret = ujInit(&objectClass);
	if(ret != UJ_ERR_NONE){
	    GPIO_BSRR(GPIOB) = GPIO10;
	    while (true) {}
	}

	ret = ujRegisterNativeClass(&nativeCls_UC, objectClass, NULL);
	if(ret != UJ_ERR_NONE){
		GPIO_BSRR(GPIOB) = GPIO10;
		while (true) {}
	}

	ret = ujLoadClass(0, &mainClass);
	if(ret != UJ_ERR_NONE){
		GPIO_BSRR(GPIOB) = GPIO10;
		while (true) {}
	}

	ret = ujInitAllClasses();
	if(ret != UJ_ERR_NONE){
		GPIO_BSRR(GPIOB) = GPIO10;
		while (true) {}
	}

	//now classes are loaded, time to call the entry point

	threadH = ujThreadCreate(0);
	if(!threadH) {
		GPIO_BSRR(GPIOB) = GPIO10;
		while (true) {}
	}

	UInt8 h = ujThreadGoto(threadH, mainClass, "main", "()V");
	if(h == UJ_ERR_METHOD_NONEXISTENT) {
		GPIO_BSRR(GPIOB) = GPIO10;
		while (true) {}
	}

	while(ujCanRun()) {
		h = ujInstr();
		if(h != UJ_ERR_NONE) {
			GPIO_BSRR(GPIOB) = GPIO10;
			while (true) {}
		}
	}


	GPIO_BSRR(GPIOB) = GPIO10;
	while (true) {}
}