Пример #1
0
FUNC(int, OS_APPL_CODE) main(void)
{
#if NUMBER_OF_CORES > 1
    StatusType rv;

    switch(GetCoreID()){
      case OS_CORE_ID_MASTER :
        initLed();
        setLed(0, led_state1);
        /* Wakeup core 1 */
        StartCore(OS_CORE_ID_1, &rv);
        if(rv == E_OK)
          StartOS(OSDEFAULTAPPMODE);
        break;
      case OS_CORE_ID_1 :
        /* Core 1 : leds were already initialized by the core 0 at this step */
        setLed(1, led_state2);
        StartOS(OSDEFAULTAPPMODE);
        break;
      default :
        /* Should not happen */
        break;
    }
#else
    initLed();
    setLed(0, led_state1);
    StartOS(OSDEFAULTAPPMODE);
#endif

    return 0;
}
Пример #2
0
Файл: main.c Проект: z80/IPM
int main(void)
{
    halInit();
    chSysInit();

    initLed();
    setLeds( 7 );
    initRead();
    initWrite();
    initI2c();
    initUsb();


    /*IWDGConfig cfg;
    cfg.div = IWDG_DIV_256;
    cfg.counter = (40000 / 256 / 2 );
    iwdgInit();
    iwdgStart( &IWDGD, &cfg );
    iwdgReset( &IWDGD );*/

    while (TRUE)
    {
        //iwdgReset( &IWDGD );
        processShell();
        chThdSleepMilliseconds( 250 );
    }
    return 0;
}
Пример #3
0
#include <3048fone.h>
#include "h8_3048fone.h"

volatile int count1=-1;/*LED0用カウンタ -1の時は休止中*/
volatile int count2=-1;/*LED1用カウンタ -1の時は休止中*/
main()
{
	initLed();
	initPushSW();/*PushSWの初期化*/
	initTimer1Int(10000); /*時間割り込み10000μsec=10msec ch1使用*/
	E_INT();        /*CPU割り込み許可*/
	startTimer1();  /*時間割り込みタイマスタートch1*/
	while(1) {
		if ((count1==-1 || 50<count1) && checkPushSW(0)==1) {
			count1=0;
			turnOnLed(0);
		} else if (100<count1 && count1<200) {
			turnOffLed(0);
		} else if (200<count1 && count1<300) { /*200カウントで2秒経過*/
			turnOnLed(0);
		} else if (300<count1) {
			count1=-1;
			turnOffLed(0);
		}
		
		if ((count2==-1 || 50<count2) && checkPushSW(1)==1) {
			count2=0;
			turnOnLed(1);
		} else if (100<count2 && count2<200) {
			turnOffLed(1);
		} else if (200<count2 && count2<300) { /*200カウントで2秒経過*/
			turnOnLed(1);
		} else if (200<count2) { /*200カウントで2秒経過*/
			count2=-1;
			turnOffLed(1);
		}
	}
}
Пример #4
0
int main(void)
{ 
	UINT32 startAddr, endAddr, lenght;
    
    initLed(LED_BIT);

    SystemInit();
    SystemCoreClockUpdate();
    
    /* Generate interrupt each 1 ms   */
    SysTick_Config(SystemCoreClock/1000 - 1);


	/** Please see the ranges in LPC1114 or LPC1227 linker script !! */
	startAddr = 0x10000000;
	endAddr = 0x10000014;
	lenght = endAddr - startAddr;

    while(1)
    {
		
		/* note that for the sake of demonstration the table is pointing to unused ram */
		/* if used ram needs to be tested, user must backup content first ! */      
		if(IEC60335_RAMtest_BIST(startAddr, lenght) == IEC60335_testFailed)
		{
		  /* RAM BIST test failed */
		  while (1);
		}  
		
		Delay(500);
		toggleLed(LED_BIT);
	}
}
Пример #5
0
FUNC(int, OS_APPL_CODE) main(void)
{
    initLed();
    setLed(0, 1);

    StartOS(OSDEFAULTAPPMODE);
    return 0;
}
Пример #6
0
main()
{
	int i;
	initLed(); /*LEDの初期化*/
	while(1) {
		turnOnLed(1); /*LED1のON*/
		waitmsec(11);
		turnOffLed(1); /*LED1のOFF*/
		waitmsec(11);
	}
}
Пример #7
0
int main(int argc,char* argv[])
{

	dj_vm * vm;
	dj_object * obj;

	conio_init();

	// initialise timer
	dj_timer_init();

	initLed();

	// initialise memory manager
	dj_mem_init(mem, HEAPSIZE);

	// Create a new VM
	vm = dj_vm_create();

	// tell the execution engine to use the newly created VM instance
	dj_exec_setVM(vm);

	dj_named_native_handler handlers[] = {
			{ "base", &base_native_handler },
			{ "darjeeling2", &darjeeling2_native_handler },
		};

	int length = sizeof(handlers)/ sizeof(handlers[0]);
	dj_archive archive;
	archive.start = (dj_di_pointer)di_archive_data;
	archive.end = (dj_di_pointer)di_archive_data_end;

	dj_vm_loadInfusionArchive(vm, &archive, handlers, length);
	
	// pre-allocate an OutOfMemoryError object
	obj = dj_vm_createSysLibObject(vm, BASE_CDEF_java_lang_OutOfMemoryError);
	dj_mem_setPanicExceptionObject(obj);

	// start the main execution loop
	while (dj_vm_countLiveThreads(vm)>0)
	{
		dj_vm_schedule(vm);
		if (vm->currentThread!=NULL)
			if (vm->currentThread->status==THREADSTATUS_RUNNING)
				dj_exec_run(RUNSIZE);
	}

	dj_vm_schedule(vm);
	dj_mem_gc();
	dj_vm_destroy(vm);

	conio_shutdown();
	return 0;
}
Пример #8
0
main()
{
	initLed();
	while(1) {
		turnOnLed(0); 
		turnOffLed(1); 
		waitmsec(1000);
		turnOffLed(0); 
		turnOnLed(1); 
		waitmsec(1000);
	}
}
Пример #9
0
int main( void ){

	disableWDT();// Stop watchdog timer
	initQueue();
	initScheduler();

	initButton();
	initLed();
	initComUart();

	initInfo();

	mainTask.cmdName = cmdNameMain;
	mainTask.user = main_user;
	mainTask.handler = &mainHandler;
	registerTask( &mainTask );

	setDCOCLK( DCO_1M );
	setSMCLK( SMCLK_DCO, CLK_DIV_1 );

	if( getFreeMessage( &mainMessage ) == queue_ok ){
		mainMessage->source = main_user;
		mainMessage->destination = led_user;
		mainMessage->id = MSG_ID_LED_GREEN;
		mainMessage->priority = normal_priority;
		mainMessage->event = undef_event;
		putMessage( mainMessage );
	}

	if( getFreeMessage( &mainMessage ) == queue_ok){
		mainMessage->destination = com_uart_user;
		mainMessage->source = main_user;
		mainMessage->id = MSG_ID_UART_WELCOME;
		putMessage( mainMessage );
	}

	initCli();

	enableTimerA0CCInterrupt();
	setTimerA0Mode( TAMODE_CONT );
	setTimerA0ClockSource( TA_SMCLK );
	setTimerA0Divider( TA_DIV_1 );

	__enable_interrupt();

	__bis_SR_register( 0x18 );

	//__bis_SR_register( 0x18 ); // LPM0 with interrupts enabled

	while( 1 ){};

	return 0;
}
Пример #10
0
int main(void){
	initLed();
	initButton();
	while(!isPressed()){
		setLed(1,0,0);
		delayLoop();
		setLed(0,0,0);
		delayLoop();
	}
	setLed(1,1,1);
	DelayMs(1000);
	SoftReset();
}
Пример #11
0
int main() 
{
	UART0_Init(57600);
	UART0_PrintString("Hello, world!\n");

	initLed();
	while (1) {
		toggleLed();
		UART0_Sendchar('+');
		wasteSomeTime(500);
	}

	return 0;
}
Пример #12
0
int main(void)
{
    initLed(LED_BIT);

    SystemInit();
    SystemCoreClockUpdate();

	/* Generate IRQ each 10 ms */
	SysTick_Config(SystemCoreClock/100);

	/* generate Timer32_0 interrput every 1 msec */
    CT32B0_Init(12000);

	/*********************************************
	void IEC60335_InitInterruptTest(type_InterruptTest *pIRQ, UINT32 lowerBound, UINT32 upperBound, UINT32 individualValue)

	  Used:
	    SysTick timer  : every 10 msec
		Timer32_0:       every 1 msec (this is the interrupt we want to test)

	  Main loop Timer32_0 Interrupt check is called every ~100 msec (derived from SysTick)
	  Within 100 msec, 100 Timer32_0 interrupts should have occurred
	  So:
	    lowerBound      = 99  (check for more interrupts than lower bound)
	    upperBound      = 101 (check for less interrupts than upper bound)
	    individualValue = 1   (interrupt up-counting value)

	********************************************/
    IEC60335_InitInterruptTest(&CT32B0_IntTest, 99, 101, 1);

    while (1)
    {
	    if (clock_100ms)
        {
            clock_100ms = 0;
            /* toggle green LED P0.7 */
			toggleLed(LED_BIT);

            /* Periodic IEC60335 Class B testing */
            if (IEC60335_InterruptCheck(&CT32B0_IntTest) == IEC60335_testFailed)
            {
                setLed(LED_BIT);
				while(1);
            }
        }
    }
}
Пример #13
0
int main(void)
{
	initLed(LED_BIT);

    SystemInit();
    SystemCoreClockUpdate();

    /* Generate interrupt each 1 ms   */
    SysTick_Config(SystemCoreClock/1000 - 1);

    /* code will get here if test passed */
    while(1)
    {
		Delay(500);
		toggleLed(LED_BIT);
    };
}
Пример #14
0
int main(void)
{
    halInit();
    chSysInit();

    initLed();
    dacInit();
    initAdc();
    initRelay();
    cpu_io_init();

    while (TRUE)
    {
    	cpu_io_process();

    	/*
    	DacCfg dac;
        setLeds( 1 );
    	dac.dac1 = 0;
    	dac.dac2 = 0;
        dacSet( &dac );
    	chThdSleepMilliseconds( 3000 );
        setLeds( 2 );
    	dac.dac1 = 2047;
    	dac.dac2 = 2047;
        dacSet( &dac );
    	chThdSleepMilliseconds( 3000 );

    	setLeds( 4 );
    	dac.dac1 = 3063;
    	dac.dac2 = 3063;
        dacSet( &dac );
    	chThdSleepMilliseconds( 3000 );

    	setLeds( 4 );
    	dac.dac1 = 4095;
    	dac.dac2 = 4095;
        dacSet( &dac );
    	chThdSleepMilliseconds( 3000 );
		*/
    }
    return 0;
}
Пример #15
0
int main(void)
{
    halInit();
    chSysInit();

    initCpuIo();
    initLed();
    initDfu( 5000 );

    setLeds( 3 );

    // Use virtual timer to execute regular firmware within
    // some time if nothing happens.
    while ( 1 )
    {
    	processCpuIo();
    }
    return 0;
}
Пример #16
0
int main(void)
{
	/* PLEASE NOTE! **
	 * The _CPUregTestPOST() function is called from the ResetISR function
	 * in the cr_startup_lpc11.c file
	 */

	initLed(LED_BIT);

    SystemInit();
    SystemCoreClockUpdate();

    /* Generate interrupt each 1 ms   */
    SysTick_Config(SystemCoreClock/1000 - 1);

    /* code will get here if test passed */
    while(1)
    {
        Delay(500);
        toggleLed(LED_BIT);
    };
}
Пример #17
0
int main(void)
{ 
#ifdef LPC1114
    UINT32  begin, *end;
    UINT32 length;
#endif
  
    SystemInit();
    SystemCoreClockUpdate();
  
    /* Initialize the LED indicator */  
    initLed(LED_BIT);
    
    /* Generate interrupt each 1 ms   */
    SysTick_Config(SystemCoreClock/1000 - 1);
    
#ifdef LPC1114
    end = IEC60335_TOP_ROM_POST;
    begin = (UINT32) &IEC60335_BOTTOM_ROM_POST;
    length = (UINT32) end - begin;
    StartSoftSignatureGen( begin,                         /* Start address */
                           length, /* Length */
                           &SoftflashSignature );         /* Result structure pointer */
#endif
    
    /* code will get here if test passed */
    while(1)
    {
      /* Execute the ASM version of the Flash BIST test 
       * If the test fails, it will hook to _flashPostTestFailureHook
       */
      _FLASHTestBIST();
     
      Delay(500);
      toggleLed(LED_BIT);     
    };
}
Пример #18
0
int main(void) {
	static uint8_t buffer[BufferSize + 1];
	int8_t   i;
	uint8_t  message[4] = { 0, 0, CID, P2CID };
	uint16_t received;
	snesIO   port0 = 0xffff, port1 = 0xffff;


	// Initialise basic I/O.
	initLed();
	initInput();
	initOutput();


	// Switched mode: B + Y.
	port0 = recvInput();
	if (port0 == 0xfffc) {
		switchedMode = Enabled;
		ledSignal(5);
	}
	ledOnRed();


	// Initialise network interface.
	enc28j60Init(mymac);
	_delay_ms(100);
	// Magjack leds configuration, see enc28j60 datasheet, page 11
	// LEDB=yellow LEDA=green
	// 0x476 is PHLCON LEDA=links status, LEDB=receive/transmit
	// enc28j60PhyWrite(PHLCON,0b0000 0100 0111 01 10);
	enc28j60PhyWrite(PHLCON, 0x476);
	_delay_ms(100);


	// Get the initial IP via DHCP and configure network.
	init_mac(mymac);
	while (i != 1) {
		received = enc28j60PacketReceive(BufferSize, buffer);
		buffer[BufferSize] = '\0';
		i = packetloop_dhcp_initial_ip_assignment(buffer, received, mymac[5]);
	}
	dhcp_get_my_ip(myip, netmask, gwip);
	client_ifconfig(myip, netmask);


	// Resolve MAC address from server IP.
	if (route_via_gw(serverip)) // Must be routed via gateway.
		get_mac_with_arp(gwip, TransNumGwmac, &arpresolverResultCallback);
	else                        // Server is on local network.
		get_mac_with_arp(serverip, TransNumGwmac, &arpresolverResultCallback);

	while (get_mac_with_arp_wait()) {
		received = enc28j60PacketReceive(BufferSize, buffer);
		// Call packetloop to process ARP reply.
		packetloop_arp_icmp_tcp(buffer, received);
	}


	// Lookup DNS of the server hostname.
	while (dnslkup_haveanswer() != 1) {
		uint16_t tmp;
		received = enc28j60PacketReceive(BufferSize, buffer);
		tmp      = packetloop_arp_icmp_tcp(buffer, received);

		if (received == 0) {
			if (!enc28j60linkup()) continue;
			dnslkup_request(buffer, ServerVHost, gwmac);
			_delay_ms(100);
			continue;
		}

		if (tmp == 0)
			udp_client_check_for_dns_answer(buffer, received);
	}
	dnslkup_get_ip(serverip);


	ledOnGreen(); // Connected.


	while (1) { // Main loop start.
		received = enc28j60PacketReceive(BufferSize, buffer);


		// Software reset: L + R + Select + Start.
		if (port0 == 0xf3f3) reset();


		// Do something while no packet in queue.
		if (received == 0) {
			port0 = recvInput();

			// Prepare message and send it to the server.
			for (i = 0; i < 8; i++) { // Lo-Byte.
				char *c = message;

				*c = port0 & (1 << i)
					? *c |  (1 << i)
					: *c & ~(1 << i);
			}

			for (i = 0; i < 8; i++) { // Hi-Byte.
				char *c = message + 1;

				*c = port0 & (1 << i + 8)
					? *c |  (1 << i)
					: *c & ~(1 << i);
			}

			send_udp(buffer, message, sizeof(message), 57351, serverip, 57350, gwmac);


			// Send controller data to SNES.
			if (switchedMode == Disabled)
				sendOutput(port0, port1);
			else
				sendOutput(port1, port0);

			continue;
		}


		// Answer to ARP requests.
		if (eth_type_is_arp_and_my_ip(buffer, received)) {
			make_arp_answer_from_request(buffer, received);
			continue;
		}


		// Check if IP packets (ICMP or UDP) are for us.
		if (eth_type_is_ip_and_my_ip(buffer, received) == 0)
			continue;


		// Answer ping with pong.
		if (
			buffer[IP_PROTO_P]  == IP_PROTO_ICMP_V &&
			buffer[ICMP_TYPE_P] == ICMP_TYPE_ECHOREQUEST_V) {

			make_echo_reply_from_request(buffer, received);
			continue;
		}


		// Listen for UDP packets on port 57351 (0xe007) and process
		// received data.
		if (
			buffer[IP_PROTO_P]       == IP_PROTO_UDP_V &&
			buffer[UDP_DST_PORT_H_P] == 0xe0 &&
			buffer[UDP_DST_PORT_L_P] == 0x07) {

			for (i = 0; i < 8; i++) {
				uint16_t *c = &port1;

				*c = buffer[UDP_DATA_P] & (1 << i)
					? *c |  (1 << i)
					: *c & ~(1 << i);
			}

			for (i = 0; i < 8; i++) {
				uint16_t *c = &port1;

				*c = buffer[UDP_DATA_P + 1] & (1 << i)
					? *c |  (1 << i + 8)
					: *c & ~(1 << i + 8);
			}
		}
	} // Main loop end.


	return (0);
}
Пример #19
0
#ifndef LED_H
#define LED_H

#include "led.h"
#include "vm.h"
#include <stdbool.h>
#include <avr/io.h>

Led led = initLed();

void setupLed()
{
    DDRB |= (1 << 7);
}    

int turnOn(Led* self, int dummy)
{
    PORTB |= (1 << 7);
    return 1;
}

int turnOff(Led* self, int dummy)
{
    PORTB &= ~(1 << 7);
    return 1;
}

int toggle(Led* self, int dummy)
{
    PORTB ^= (1 << 7);
    return 1;