Beispiel #1
0
/*
 *  Hotpluger signal handler
 */
void hotPluglerHandler(int signo)
{
#if defined CONFIG_RALINKAPP_MPLAYER
	cleanup_musiclist();
#endif
	initUSB();
}
Beispiel #2
0
/* goform/storageAdm */
static void storageAdm(webs_t wp, char_t *path, char_t *query)
{
	char_t *submit;

	submit = websGetVar(wp, T("hiddenButton"), T(""));

	if (0 == strcmp(submit, "delete"))
	{
		char_t *user_select;
		char feild[20];

		feild[0] = '\0';
		user_select = websGetVar(wp, T("storage_user_select"), T(""));
		sprintf(feild, "User%s", user_select);
		nvram_bufset(RT2860_NVRAM, feild, "");
		doSystem("rm -rf \"%s/home/%s\"", first_part, nvram_bufget(RT2860_NVRAM, feild));
		sprintf(feild, "User%sPasswd", user_select);
		nvram_bufset(RT2860_NVRAM, feild, "");
		sprintf(feild, "FtpUser%s", user_select);
		nvram_bufset(RT2860_NVRAM, feild, "");
		sprintf(feild, "SmbUser%s", user_select);
		nvram_bufset(RT2860_NVRAM, feild, "");
		nvram_commit(RT2860_NVRAM);
		doSystem("storage.sh admin");
	}
	else if (0 == strcmp(submit, "apply"))
	{
		initUSB();
	}
	websRedirect(wp, "usb/STORAGEuser_admin.asp");
}
void init() {
   // In case disabled by boot-loader
   __enable_irq();

   initPorts();
   initTimers();
   bdm_interfaceOff();
   initUSB();

#ifdef VDD_ON_INITIALLY
   // For compatibility with original board s/w
   // The board is powered when initially plugged in
   #if (VDD_ON_INITIALLY == 3)
      bdm_option.targetVdd = BDM_TARGET_VDD_3V3;
   #elif (VDD_ON_INITIALLY == 5)
      bdm_option.targetVdd = BDM_TARGET_VDD_5;
   #else
      bdm_option.targetVdd = BDM_TARGET_VDD_OFF;
   #endif
   bdm_setTargetVdd();
   RESET_LOW();
   WAIT_MS(100);
   RESET_3STATE();
#endif
}
bool mavlink_usb_importer::isValidFD(int fd) {
#ifdef __APPLE__
    // Try to read message
    char _buffer = 0;
    int result = read(usb_fd, &_buffer, 1);
    
    if(result == 1) {
        return true;
    }
#else
    /// Sende Anfrage damit ioctl errno neu setzt
    int rc = ioctl(fd, USBDEVFS_CONNECTINFO, 0);
    
    /// Wenn rc != 0 gab es einen Fehler
    if (rc == 0){
        return true;
    }
#endif
    
    logger.perror("is_valid_fd") << "Error in ioctl: Trying to reconnect";
    /// Haben wir einen Input/Output error? -> usb neu initialisieren
    if(errno == EIO || errno == EBADF || errno == ENXIO) {
        close(fd);
        while(!initUSB()) {
            usleep(100);
        }
    }

    return false;
}
void main(void)
{
	initSysClock();

	initUartDebug();

	initLeds();

	initLaunchpadSW1();

	initSysTick();

	initBluetooth();

	initUSB();

	initRfModule(false);

	setRfTxAddress(RF_DESTINATION_ADDR);

	Network_setSelfAddress(RF_CONTOLBOARD_ADDR);

	while (true)
	{
		if ((g_bConnected == false) || (g_bSuspended == true))
		{
			GPIOPinWrite(LED_PORT_BASE, LED_ALL, LED_RED);
			continue;
		}

		GPIOPinWrite(LED_PORT_BASE, LED_ALL, LED_GREEN);

		if (g_USBRxState == USB_RX_DATA_AVAILABLE)
		{
			GPIOPinWrite(LED_PORT_BASE, LED_ALL, LED_BLUE);

			switch (usbBufferHostToDevice[0])
			{
			//-----------------Bootloader Handle-------------------

			case BOOTLOADER_BROADCAST_PACKET:
				broadcastBslData();
				break;

			case BOOTLOADER_SCAN_JAMMING:
				scanJammingSignal();
				break;

			default:
				normalPacketHandle();
				break;
			}

			g_USBRxState = USB_RX_IDLE;

			turnOffLED(LED_BLUE);
		}
	}
}
Beispiel #6
0
int main()
{
	initStatusLED();
	initUSB();

	// Globally enable interrupts
	sei();

	init_modules();
	// Endless loop
	for (;;) {

		/* Regularly restart watchdog timer to prevent it from elapsing. */
		wdt_reset();
		usbPoll();
		
		if (usbInterruptIsReady()) {
      if (isSendingSysExMsg) {
        handleMidiSend();
      } else {
        switch (module_type) {
          case ANALOG_INPUT:
            analog_input_device_main_loop(uADC);
            break;

          case ANALOG_OUTPUT:
            analog_output_device_main_loop();
            break;

          case DIGITAL_INPUT:
            digital_input_device_main_loop(uADC);
            break;

          case DIGITAL_OUTPUT:
            digital_output_device_main_loop();
            break;

          case I2C_DEVICE:
            /* Not implemented yet. */
            break;

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

}
static void testMode() {
   // In case disabled by boot-loader
   __enable_irq();

   initPorts();
   initTimers();
   bdm_interfaceOff();
   initUSB();
   ledEnable();
   testEnable();
   bootInputEnable();
   for(;;) {
      WAIT_MS(100);
      ledToggle();
      testToggle();
      if (bootInputActive() == 0) {
         reboot();
      }
   }
}
bool mavlink_usb_importer::initialize() {

    paths = config().getArray<std::string>("path");

    // Setup datachannels
    inChannel = writeChannel<Mavlink::Data>("MAVLINK_IN");
    outChannel = writeChannel<Mavlink::Data>("MAVLINK_OUT");

    lms::Time initStart = lms::Time::now();
    while(initStart.since().toFloat() < config().get<float>("init_timeout", 10)) {
        if(initUSB()){
            return true;
        }

        // Wait 50msec
        lms::Time::fromMillis(config().get<int>("init_timeout_sleep", 50)).sleep();
    }

    return false;
}
void main (void)
{
    initBoard();
    initUSB();
    blink(300,300);

    init_RF();
    appMainInit();

    usb_up();

    /* Enable interrupts */
    EA = 1;

    while (1)
    {  
        usbProcessEvents();
        appMainLoop();
    }

}
void main (void)
{
    initBoard();
    initDMA();  // do this early so peripherals that use DMA can allocate channels correctly
    initAES();
    initUSB();
    blink(300,300);

    init_RF();
    appMainInit();

    usb_up();

    /* Enable interrupts */
    EA = 1;

    while (1)
    {  
        usbProcessEvents();
        appMainLoop();
    }

}
Beispiel #12
0
/**
 * Main program.
 */
int main()
{   
    uchar i;
    
    /* Disable the watchdog */
    MCUSR = 0;
    wdt_disable();

    /* Read the flash checksum from EEPROM */
    readFlashChecksum();
            
    /* Initialize USB and enable global interrupts */
    initUSB();

    /* First initialize the PWM so all LEDs are off. */
    pwmInit(0);
    pwmSet(CHANNEL0, 0, 0);
    pwmSet(CHANNEL1, 0, 0);
    pwmSet(CHANNEL2, 255, 0);
    pwmSet(CHANNEL3, 0, 0);
    pwmSet(CHANNEL4, 0, 0);
    pwmSet(CHANNEL5, 0, 0);
    
    /* Initialize the blinks memory from eeprom */
    eeprom_busy_wait();
    eeprom_read_block(memory, (uint8_t*) 1, MEM_SIZE);
    
    /* Make sure bits 7 is cleared and bit 6 is set */
    memory[0] &= 0x7f;
    memory[0] |= 0x40;
    
    /* Infinite program loop */
    i = 0;
    while (memory[0] & 0x40)
    {
        restart = 50;
        while (restart)
        {
            /* Process USB events */
            usbPoll();
            
            int len = buffer_write_index - buffer_read_index;
            if (len > 0 && usbInterruptIsReady())
            {           
                if (len > 8) len = 8;
                usbSetInterrupt(&buffer[buffer_read_index], len);
                buffer_read_index += len;
                to_read -= len;
                if (!to_read)
                {
                    buffer_read_index = 0;
                    buffer_write_index = 0;
                }
            }
            
            if (restart < 50) restart--;

            /* When this loop has been executed for 100 times then
               mark the flash as OK */
            if ((flashChecksum != FLASH_CHECKSUM) && (i < 100))
            {
                i++;
                if (i == 100)
                {
                    flashChecksum = FLASH_CHECKSUM;
                    writeFlashChecksum();
                }
            }
        }
        reenumerate(500);
    }

    enterBootloader();

    return 0;
}
Beispiel #13
0
int main( void )
{
	/* MTJ: initialize syscalls -- *must* be first */
	// syscalls.c contains the files upon which the standard (and portable) C libraries rely
	init_syscalls();

	// Set up the LED ports and turn them off
	vtInitLED();

	/* Configure the hardware for use by this demo. */
	prvSetupHardware();

	#if USE_WEB_SERVER == 1
	// Not a standard demo -- but also not one of mine (MTJ)
	/* Create the uIP task.  The WEB server runs in this task. */
    xTaskCreate( vuIP_Task, ( signed char * ) "uIP", mainBASIC_WEB_STACK_SIZE, ( void * ) NULL, mainUIP_TASK_PRIORITY, NULL );
	#endif

	vStartLCDTask(&vtLCDdata,mainLCD_TASK_PRIORITY);
	// LCD Task creates a queue to receive messages -- what it does with those messages will depend on how the task is configured (see LCDtask.c)
	// Here we set up a timer that will send messages to the LCD task.  You don't have to have this timer for the LCD task, it is just showing
	//  how to use a timer and how to send messages from that timer.

	// First, start up an I2C task and associate it with the I2C0 hardware on the ARM (there are 3 I2C devices, we need this one)
	// See vtI2C.h & vtI2C.c for more details on this task and the API to access the task
	// Initialize I2C0 for I2C0 at an I2C clock speed of 100KHz
	if (vtI2CInit(&vtI2C0,0,mainI2CMONITOR_TASK_PRIORITY,100000) != vtI2CInitSuccess) {
		VT_HANDLE_FATAL_ERROR(0);
	}

	// start up a "conductor" task that will move messages around
	vStartConductorTask(&conductorData,mainCONDUCTOR_TASK_PRIORITY,&vtI2C0,&i2cData,&motorControl,&irData,&speedData,&powerData,&vtLCDdata);

    // Start the I2C task
    starti2cTask(&i2cData,mainI2C_TASK_PRIORITY,&vtI2C0);
    // Start the Motor Control task
    vStartMotorControlTask(&motorControl,mainMOTOR_CONTROL_TASK_PRIORITY,&i2cData,&webData,&vtLCDdata);
    // Start the Navigation task
    vStartNavigationTask(&navData,mainNAVIGATION_TASK_PRIORITY,&motorControl,&vtLCDdata);
    // Start the IR Control task
    vStartIRTask(&irData,mainIR_CONTROL_TASK_PRIORITY,&navData);
    // Start the Speed Limit task
    vStartSpeedLimitTask(&speedData,mainSPEED_LIMIT_TASK_PRIORITY,&motorControl,&navData,&webData);

    startTimerFori2c(&i2cData);
    //startTimerForMotor(&motorControl);

    /* Create the USB task. MTJ: This routine has been modified from the original example (which is not a FreeRTOS standard demo) */
	#if USE_MTJ_USE_USB == 1
	initUSB();  // MTJ: This is my routine used to make sure we can do printf() with USB
    xTaskCreate( vUSBTask, ( signed char * ) "USB", configMINIMAL_STACK_SIZE, ( void * ) NULL, mainUSB_TASK_PRIORITY, NULL );
	#endif

	/* Start the scheduler. */
	// IMPORTANT: Once you start the scheduler, any variables on the stack from main (local variables in main) can be (will be...) written over
	//            because the stack is used by the interrupt handler
	vTaskStartScheduler();

    /* Will only get here if there was insufficient memory to create the idle
    task.  The idle task is created within vTaskStartScheduler(). */
	for( ;; );
}
Beispiel #14
0
void setup(){
    
    // A visual Queue that the System is in
    // Setup Mode.
        // Pin 14 -> LED ON
    
    digitalWrite(SetupLED, HIGH);
    
// ----- PRELIMINARY PROCEDURES ------

//    -> init serial Connection to LCD
    
    initLCD();
    LCDprintln("***** Starting Up *****");
    delay(100);
    LCDprintln("  [OK]    ");

    
// ----- SPLASH SCREEN PROCEDURES ------
    
//    -> splash Screen
//      -> ask for connections 
//      -> Store USB?
    
#ifdef MEGA
    toggleSplashScreen();
    delay(1000);

    askForConnectionTypes();
    askToStoreData();
#endif
    
// ----- DEBUG STARTUP PROCEDURES ------
    
#ifdef DEBUG
    toggleSplashScreen();
    delay(1000);
    
    LCDprintln("***** DEBUG MODE *****");
    
    startDebugSequence();
#endif  

// ----- PINS // INT // ISR PROCEDURES ------    
    
    //    -> init buttons
    //    -> init LED pins
    //    -> init Digital pins
    //    -> init Sensors
    
    //    -> attach interrupts
    
#ifdef MEGA
    initbuttons();
#else
    LCDprintln("In DEBUG mode no input required");
#endif
    
#ifdef MEGA
    initLEDPins();
    initDigitalPins();
    initSensors();
#else
    LCDprintln("No need for inputs random numbers\n
             sent to the PC/XBee.");
#endif
    
    attachInterrupts();

    

// ----- COMMS STARTUP PROCEDURES ------
    
//    -> init Keyboard  
//    -> init serial Connection to XBee
//    -> init serial Connection to PC
    
#ifdef XBeeConnected
    initXbee();
    LCDdisplayConnectedIcon(Connection);
#endif

#ifdef USBConnected
    initUSB();
    LCDdisplayConnectedIcon(Connection);
#endif
    
#ifdef StoreUSB
    initVDIP();
    LCDdisplayConnectedIcon(Connection);
    printHeaders();
#endif

// ----- MEM. & MENUS STARTUP PROCEDURES ------
    
//    -> init EEPROM
//      -> +1 to session ID
//      -> Verify Version ID
//    -> init Menu System
//    -> Startup
    
    initEEPROM();
    initMenus();
    
    // A visual Queue that the System is now past
    // the Setup Mode.
    // Pin 14 -> LED OFF
    
    digitalWrite(SetupLED, LOW);
}
Beispiel #15
0
int main() {
    
    struct timeval now,next,diff,delay;
    int success;
    
    printf("%s: Starting dmx deamon\n", ProgName);

    // intialize USB device
    
    success = initUSB();
    
    if ( !success ) {
        printf ( "%s: Error initializing USB interface\n" , ProgName );
        (*exitAddr)++;
        return ( -1 );
    }
    
    // initialize shared memory segment
    
    success = initSHM();
    
    if ( !success  ) {
        printf ( "%s: Error initializing shared memory\n" , ProgName );
        (*exitAddr)++;
        return ( -2 );
    }
    
    
    // start timer
    
    delay.tv_sec = 0;
    delay.tv_usec= UpdateInt;
    
    gettimeofday ( &next , NULL );
    
    printf("%s: Init done. Entering loop cycle...\n", ProgName);
    
    // loop until commanded to shutdown
    
    while( !*exitAddr ) {
        
        
        // send DMX data
       
        success = sendDMX();
        
        if ( !success ) {
            printf  ( "%s: DMX send error\n" , ProgName );
            (*exitAddr)++;
        }
        
        // wait for update interval

        timeadd ( &next , &next , &delay );
        gettimeofday ( &now , NULL );
        timediff ( &diff, &next , &now );
        
        while (diff.tv_sec || diff.tv_usec) {
            
            select ( 0, NULL, NULL, NULL, &diff );
            gettimeofday ( &now, NULL );
            timediff ( &diff, &next, &now );
        };
        
    }
    
    printf ( "%s: dmx deamon is shutting down\n" , ProgName );
    
    // on shutdown reset all DMX channels
    
    memset ( chanData , 0, 512 * sizeof (ubyte) );
    
    sendDMX();
    
    
    // exit the system
    
    exitUSB();
    exitSHM();
    
    return ( 0 );
}
int main( void )
{
	/* MTJ: initialize syscalls -- *must* be first */
	// syscalls.c contains the files upon which the standard (and portable) C libraries rely 
	init_syscalls();

	// Set up the LED ports and turn them off
	vtInitLED();

	/* Configure the hardware for use by this demo. */
	prvSetupHardware();

	#if USE_FREERTOS_DEMO == 1
	/* Start the standard demo tasks.  These are just here to exercise the
	kernel port and provide examples of how the FreeRTOS API can be used. */
	vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
    vCreateBlockTimeTasks();
    vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
    vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
    vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
    vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
    vStartQueuePeekTasks();
    vStartRecursiveMutexTasks();
	vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );
	#endif

	// Not a standard demo -- but also not one of mine (MTJ)
	/* Create the uIP task.  The WEB server runs in this task. */
    xTaskCreate( vuIP_Task, ( signed char * ) "uIP", mainBASIC_WEB_STACK_SIZE, ( void * ) NULL, mainUIP_TASK_PRIORITY, NULL );

	// MTJ: My LCD demonstration task
	#if USE_MTJ_LCD == 1
	vStartLCDTask( mainLCD_TASK_PRIORITY,&vtLCDdata);
	#endif

	// MTJ: My i2cTemp demonstration task
	#if USE_MTJ_V4Temp_Sensor == 1
	vtI2C0.devNum = 0;
	vtI2C0.taskPriority = mainI2CMONITOR_TASK_PRIORITY;
	// Initialize I2C0 
	int retVal;
	if ((retVal = vtI2CInit(&vtI2C0,100000)) != vtI2CInitSuccess) {
		VT_HANDLE_FATAL_ERROR(retVal);
	}
	tempSensorParams.dev = &vtI2C0;
	#if USE_MTJ_LCD == 1
	tempSensorParams.lcdData = &vtLCDdata;
	#else
	tempSensorParams.lcdData = NULL;
	#endif
	//vStarti2cTempTask(mainI2CTEMP_TASK_PRIORITY,&tempSensorParams);
	vStartSomeTask(mainI2CTEMP_TASK_PRIORITY, &tempSensorParams);
	#endif

    /* Create the USB task. MTJ: This routine has been modified from the original example (which is not a FreeRTOS standard demo) */
	#if USE_MTJ_USE_USB == 1
	initUSB();  // MTJ: This is my routine used to make sure we can do printf() with USB
    xTaskCreate( vUSBTask, ( signed char * ) "USB", configMINIMAL_STACK_SIZE, ( void * ) NULL, mainUSB_TASK_PRIORITY, NULL );
	#endif
	
	/* Start the scheduler. */
	// IMPORTANT: Once you start the scheduler, any variables on the stack from main (local variables in main) can be (will be...) writtenover
	//            because the stack is used by the interrupt handler
	vTaskStartScheduler();

    /* Will only get here if there was insufficient memory to create the idle
    task.  The idle task is created within vTaskStartScheduler(). */
	for( ;; );
}
Beispiel #17
0
/*! \brief Initialise the system.
 *
 *  Initialisation of the following:
 *  \li  Default port values
 *  \li  Watchdog (off),
 *  \li  Stack,
 *  \li  BDM interface,
 *  \li  USB interface.
 *  \li  Configure Clock for 48MHz operation
 */
static void init(void) {

   // Default ports to inputs
   PTADD = 0x00;
   PTBDD = 0x00;
#if (CPU==JMxx)
   PTCDD = 0x00;
   PTDDD = 0x00;
   PTEDD = 0x00;
   PTFDD = 0x00;
   PTGDD = 0x00;
#endif

//    Turn off important things
#if ((HW_CAPABILITY & CAP_FLASH) != 0)
   (void)bdmSetVpp(BDM_TARGET_VPP_OFF);
#endif
   VDD_OFF();
   
   // Default to Ports have PUPs
   // Note - this doesn't affect outputs
   PTAPE = 0xFF;
   PTBPE = 0xFF;
#if (CPU==JMxx)
   PTCPE = 0xFF;
   PTDPE = 0xFF;
   PTEPE = 0xFF;
   PTFPE = 0xFF;
   PTGPE = 0xFF;
#endif

   EnableInterrupts;

#ifndef SOPT1_BKGDPE_MASK
#define SOPT1_BKGDPE_MASK (0)
#endif
   SOPT1 = SOPT1_STOPE_MASK|SOPT1_BKGDPE_MASK; // Disable COP, enable STOP instr. & BKGD pin
   
#if (HW_CAPABILITY&CAP_VDDSENSE)
   SPMSC1_BGBE = 1;                // Enable Bandgap Reference
#endif
   
   LED_INIT();
   clearStack();
   initUSB();  // Assumes clock already done
   
   (void)bdm_init();
   (void)bdm_off();
   
#ifdef VDD_ON_INITIALLY
   // For compatibility with original board s/w
   // The board is powered when initially plugged in
#if (VDD_ON_INITIALLY == 3)
   bdm_option.targetVdd = BDM_TARGET_VDD_3V3;
#elif (VDD_ON_INITIALLY == 5)
   bdm_option.targetVdd = BDM_TARGET_VDD_5;
#else
#error "Illegal VDD_ON_INITIALLY value"   
#endif
   (void)bdm_interfaceOff();
   (void)bdm_setTargetVdd();
#endif
   
#if (DEBUG&SCI_DEBUG) != 0)   
   debugSCIInit();
#endif
}
Beispiel #18
0
/**
 * Main program.
 */
int main()
{   
    uchar i, errorCode;
    uint8_t oldRunning = 0, running;

    /* Disable the watchdog */
    MCUSR = 0;
    wdt_disable();

    /* Read the serial number from flash */
    readSerial();
  
    /* Read the flash checksum from EEPROM */
    readFlashChecksum();

    /* Initialize USB and enable global interrupts */
    initUSB();

    /* First initialize the PWM so all LEDs are off. */
    pwmInit(prescalingIndex);
    pwmSet(CHANNEL0, 0, 0);
    pwmSet(CHANNEL1, 0, 0);
    pwmSet(CHANNEL2, 0, 0);
    pwmSet(CHANNEL3, 0, 0);
    pwmSet(CHANNEL4, 0, 0);
    pwmSet(CHANNEL5, 0, 0);

    /* Initialize the blinks memory from eeprom */
    eeprom_busy_wait();
    eeprom_read_block(memory, (uint8_t*) 1, BLINKS_MEM_SIZE);

    /* Make sure bits 7 is cleared and bit 6 is set */
    memory[0] &= 0x7f;
    memory[0] |= 0x40;

    /* Initialize blinks */
    blinksScript.data = BLINKS_SCRIPT(memory);
    blinksScript.size = BLINKS_SCRIPT_SIZE;
    errorCode = 1;

    /* Infinite program loop */
    i = 0;
    uint16_t shutdown = 0;
    while ((memory[0] & 0x40) || (--shutdown))
    {
        /* Re-init PWM if needed */
        if (prescalingIndex != getPrescalingIndex())
        {
            prescalingIndex = getPrescalingIndex();
            pwmInit(prescalingIndex);
        }
        
        /* Process USB events */
        usbPoll();

        /* Execute special commands */
        switch (command)
        {
            case CMD_SAVE:
                eeprom_busy_wait();
                eeprom_write_block(memory, (uint8_t*) 1, BLINKS_MEM_SIZE);
                break;
        }
        command = 0;

        /* Reset script when running flag has changed or an error occurred */
        running = BLINKS_FLAGS(memory) & BLINKS_FLAG_RUNNING;
        if (running != oldRunning || errorCode)
        {
            errorCode = blinksReset(blinksScript);
            oldRunning = running;
        }

        /* Execute next step in program when program is running an no error
           occurred. */
        if (running && !errorCode)
            errorCode = blinksStep(blinksScript);
        
        /* Apply channel values */
        if (!errorCode)
        {
            unsigned char outputs = blinksCountOutputs(blinksScript);
            unsigned char invert = isInverted();
            if (outputs > 0) pwmSet(CHANNEL0, blinksGetOutput(blinksScript, 0), invert);
            if (outputs > 1) pwmSet(CHANNEL1, blinksGetOutput(blinksScript, 1), invert);
            if (outputs > 2) pwmSet(CHANNEL2, blinksGetOutput(blinksScript, 2), invert);
            if (outputs > 3) pwmSet(CHANNEL3, blinksGetOutput(blinksScript, 3), invert);
            if (outputs > 4) pwmSet(CHANNEL4, blinksGetOutput(blinksScript, 4), invert);
            if (outputs > 5) pwmSet(CHANNEL5, blinksGetOutput(blinksScript, 5), invert);
        }

        /* When this loop has been executed for 100 times then
           mark the flash as OK */
        if ((flashChecksum != FLASH_CHECKSUM) && (i < 100))
        {
            i++;
            if (i == 100)
            {
                flashChecksum = FLASH_CHECKSUM;
                writeFlashChecksum();
            }
        }
    }

    enterBootloader();

    return 0;
}
Beispiel #19
0
int main( void )
{
	/* MTJ: initialize syscalls -- *must* be first */
	// syscalls.c contains the files upon which the standard (and portable) C libraries rely 
	init_syscalls();

	// Set up the LED ports and turn them off
	vtInitLED();

	/* Configure the hardware for use by this demo. */
	prvSetupHardware();

	#if USE_FREERTOS_DEMO == 1
	/* Start the standard demo tasks.  These are just here to exercise the
	kernel port and provide examples of how the FreeRTOS API can be used. */
	vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
    vCreateBlockTimeTasks();
    vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
    vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
    vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
    vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
    vStartQueuePeekTasks();
    vStartRecursiveMutexTasks();
	vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );
	#endif

	#if USE_WEB_SERVER == 1
	// Not a standard demo -- but also not one of mine (MTJ)
	/* Create the uIP task.  The WEB server runs in this task. */
    xTaskCreate( vuIP_Task, ( signed char * ) "uIP", mainBASIC_WEB_STACK_SIZE, ( void * ) NULL, mainUIP_TASK_PRIORITY, NULL );
	#endif

	#if USE_MTJ_LCD == 1
	// MTJ: My LCD demonstration task
	StartLCDTask(&vtLCDdata,mainLCD_TASK_PRIORITY);
	// LCD Task creates a queue to receive messages -- what it does with those messages will depend on how the task is configured (see LCDtask.c)
	// Here we set up a timer that will send messages to the LCD task.  You don't have to have this timer for the LCD task, it is just showing
	//  how to use a timer and how to send messages from that timer.

	//Commented out by Matthew Ibarra 2/2/2013
	//startTimerForLCD(&vtLCDdata);
	#endif
	
	#if USE_MTJ_V4Temp_Sensor == 1
	// MTJ: My i2cTemp demonstration task
	// First, start up an I2C task and associate it with the I2C0 hardware on the ARM (there are 3 I2C devices, we need this one)
	// See vtI2C.h & vtI2C.c for more details on this task and the API to access the task
	// Initialize I2C0 for I2C0 at an I2C clock speed of 100KHz
	if (vtI2CInit(&vtI2C0,0,mainI2CMONITOR_TASK_PRIORITY,100000) != vtI2CInitSuccess) {
		VT_HANDLE_FATAL_ERROR(0);
	}
	// Now, start up the task that is going to handle the temperature sensor sampling (it will talk to the I2C task and LCD task using their APIs)
	#if USE_MTJ_LCD == 1
	vStarti2cTempTask(&tempSensorData,mainI2CTEMP_TASK_PRIORITY,&vtI2C0,&vtLCDdata);
	#else
	vStarti2cTempTask(&tempSensorData,mainI2CTEMP_TASK_PRIORITY,&vtI2C0,NULL);
	#endif
	// Here we set up a timer that will send messages to the Temperature sensing task.  The timer will determine how often the sensor is sampled
	startTimerForTemperature(&tempSensorData);
	// start up a "conductor" task that will move messages around
	vStartConductorTask(&conductorData,mainCONDUCTOR_TASK_PRIORITY,&vtI2C0,&tempSensorData);
	#endif

    /* Create the USB task. MTJ: This routine has been modified from the original example (which is not a FreeRTOS standard demo) */
	#if USE_MTJ_USE_USB == 1
	initUSB();  // MTJ: This is my routine used to make sure we can do printf() with USB
    xTaskCreate( vUSBTask, ( signed char * ) "USB", configMINIMAL_STACK_SIZE, ( void * ) NULL, mainUSB_TASK_PRIORITY, NULL );
	#endif
	
	/* Start the scheduler. */
	// IMPORTANT: Once you start the scheduler, any variables on the stack from main (local variables in main) can be (will be...) written over
	//            because the stack is used by the interrupt handler
	vTaskStartScheduler();

    /* Will only get here if there was insufficient memory to create the idle
    task.  The idle task is created within vTaskStartScheduler(). */
	for( ;; );
}