示例#1
0
int main(void) {
	e_iap_status iap_status;

	/* Fill the flash with payload and hash data */
	iap_status = (e_iap_status) generator_init();
	if (iap_status != CMD_SUCCESS)
		while (1)
			;   // Error !!!

	Details d;

	initButton();
    initDMA();
	initDetails(&d, getNumberOfChunks(), getSizeOfChunk());

	while (buttonIterrupt) {
	}

	int res = mainFunction(&d, 32);

	if(res==0) {
		blinkLed(1000000);
	}
	else {
		blinkLed(100);
	}


	return 0;
}
示例#2
0
文件: main.c 项目: icblnk/avr
void main()
{
    // Pin to measure impulse time
    //DDRB |= (0 << PINB0);
    //PORTB = (0 << PINB0);
    // LED pin
    DDRD |= (1 << PIND7);
    PORTD |= (0 << PIND7);

    // Trig pin
    PORTD |= (1 << PIND6);
    DDRD |= (1 << PIND6);

    blinkLed(5);
    initUSART();
    initTimer();

    USART_print("Main started\n");

    while(1) {
        PORTD |= 1 << PIND6;
        _delay_us(12);
        PORTD &= ~(1 << PIND6);
        _delay_ms(2000);
    }
}
示例#3
0
文件: main.cpp 项目: item28/tosqa-ssb
static void sendReq(uint8_t header, uint16_t index, uint8_t subindex, const uint8_t* data, int length) {
    txMsg.data[1] = index;
    txMsg.data[2] = index >> 8;
    txMsg.data[3] = subindex;
    for (int i = 0; i < 4; ++i)
        txMsg.data[4+i] = i < length ? *data++ : 0;
    sendAndWait(header, 8);
    
    if (txMsg.data[7] & 0x08)
        blinkLed(3);
}
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
void UIFileWatcherLeds::triggerUpdate(const int flags)
{
    BigInteger bi(flags);

    for (int i=0; i<16; i++)
    {
        if (bi[i])
        {
            blinkLed(i, true);
        }
    }
}
示例#5
0
文件: main.cpp 项目: item28/tosqa-ssb
static void sendAndWait(uint8_t header, int length) {
    txMsg.mode_id = 0x67D;
    txMsg.mask = 0x00;
    txMsg.dlc = length;
    txMsg.msgobj = 8;
    txMsg.data[0] = header;

    ready = false;
    LPC_CCAN_API->can_transmit(&txMsg);
    for (int i = 0; i < 100000; ++i) {
        LPC_CCAN_API->isr();
        if (ready)
            return;
    }
    blinkLed(2);
}
示例#6
0
//////////////////////////////////////////////////////////////////////////
// Method function:  put_light_blink
//////////////////////////////////////////////////////////////////////////
static int handle_put_light_blink(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)
{
    int i,nblink;
    if (inpkt->payload.len == 0)
    {
        return coap_make_response(scratch, outpkt, NULL, 0, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_BAD_REQUEST, COAP_CONTENTTYPE_TEXT_PLAIN);
    }
    if(inpkt->payload.len<9)
    {
        strcpy(light,(const char *)&inpkt->payload.p[0]);
    }
    if(numbers_only(light)) {
        nblink = atoi(inpkt->payload);
        blinkLed(nblink); //Blink Led nblink times using non-blocking timer
    }
    return coap_make_response(scratch, outpkt, (const uint8_t *)&light[0], inpkt->payload.len, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CHANGED, COAP_CONTENTTYPE_TEXT_PLAIN);
}
示例#7
0
void hmcoreSetup(void)
{
  pinMode(PIN_WIRELESS_LED, OUTPUT);
  blinkLed();
  
#ifdef HEATERMETER_SERIAL
  Serial.begin(HEATERMETER_SERIAL);
  // don't use SerialX because we don't want any preamble
  Serial.write('\n');
  reportVersion();
#endif  /* HEATERMETER_SERIAL */
#ifdef USE_EXTERNAL_VREF  
  analogReference(EXTERNAL);
#endif  /* USE_EXTERNAL_VREF */
  // Disable Analog Comparator
  ACSR = bit(ACD);
  // Disable Digital Input on ADC pins
  DIDR0 = bit(ADC5D) | bit(ADC4D) | bit(ADC3D) | bit(ADC2D) | bit(ADC1D) | bit(ADC0D);
  // And other unused units
  power_twi_disable();

  // Switch the pin mode first to INPUT with internal pullup
  // to take it to 5V before setting the mode to OUTPUT. 
  // If we reverse this, the pin will go OUTPUT,LOW and reboot.
  // SoftReset and WiShield are mutually exlusive, but it is HIGH/OUTPUT too
  digitalWrite(PIN_SOFTRESET, HIGH);
  pinMode(PIN_SOFTRESET, OUTPUT);
  
  pinMode(PIN_ALARM, OUTPUT);

  pid.Probes[TEMP_PIT] = &probe0;
  pid.Probes[TEMP_FOOD1] = &probe1;
  pid.Probes[TEMP_FOOD2] = &probe2;
  pid.Probes[TEMP_AMB] = &probe3;
  pid.init();

  eepromLoadConfig(0);
  lcdDefineChars();
#ifdef HEATERMETER_RFM12
  checkInitRfManager();
#endif

  Menus.setState(ST_HOME_NOPROBES);
}
示例#8
0
文件: main.cpp 项目: item28/tosqa-ssb
int main () {
    LPC_GPIO0->DIR |= 1<<7;     // LED is PIO0_7 on the LPCxpresso 11C24
    LPC_GPIO0->DATA &= ~(1<<7); // turn LED off

    delay(1000); // wait 1s after power-up before uploading to target

    initCan();

    /* Configure message object 1 to receive all 11-bit messages 0x5FD */
    static CCAN_MSG_OBJ_T msg;
    msg.msgobj = 1;
    msg.mode_id = 0x5FD;
    msg.mask = 0x7FF;
    LPC_CCAN_API->config_rxmsgobj(&msg);

    // read device type ("LPC1")
    uint32_t devType = sdoReadSegmented(0x1000, 0);
    if (memcmp(&devType, "LPC1", 4) != 0)
        blinkLed(4);

    // read 16-byte serial number
    // uint32_t uid[4];
    // uid[0] = sdoReadSegmented(0x5100, 1);
    // uid[1] = sdoReadSegmented(0x5100, 2);
    // uid[2] = sdoReadSegmented(0x5100, 3);
    // uid[3] = sdoReadSegmented(0x5100, 4);
    
    // unlock for upload
    uint16_t unlock = 23130;
    sdoWriteExpedited(0x5000, 0, unlock, sizeof unlock);    
    // prepare sectors
    sdoWriteExpedited(0x5020, 0, 0x0000, 2);
    // erase sectors
    sdoWriteExpedited(0x5030, 0, 0x0000, 2);

    if (getBootConfigByte() != 0) {
        // copy code to RAM buffer and add the boot config byte
        memset(codeBuf, 0xFF, sizeof codeBuf);
        memcpy(codeBuf, bootData, sizeof bootData);
        codeBuf[sizeof codeBuf-1] = getBootConfigByte();

        // start write to RAM
        sdoWriteExpedited(0x5015, 0, 0x10000800, 4); // ram address
        // upload code to RAM
        sdoWriteSegmented(0x1F50, 1, 0x1000);
        uint8_t toggle = 0;
        for (size_t i = 0; i < sizeof codeBuf; i += 7) {
            sdoWriteDataSegment(toggle, codeBuf + i, 7);
            toggle ^= 0x10;
        }

        // prepare sectors
        sdoWriteExpedited(0x5020, 0, 0x0000, 2);
        // copy ram to flash
        sdoWriteExpedited(0x5050, 1, 0x00000000, 4);    // flash address
        sdoWriteExpedited(0x5050, 2, 0x10000800, 4);    // ram address
        sdoWriteExpedited(0x5050, 3, 0x1000, 2);        // 4096 bytes
    }
    
    // G 0000
    sdoWriteExpedited(0x5070, 0, 0, 4);
    sdoWriteExpedited(0x1F51, 1, 1, 1);

    // 5 quick blips if there has been any CAN error, or steady blink if all ok
    blinkLed(error ? 5 : 0);

    return 0;
}
void UIFileWatcherLeds::timerCallback (int timerID)
{
    blinkLed (timerID, false);
}
示例#10
0
void LorrisProgrammer::initMenus()
{
    // top menu bar
    QMenu *chipBar = new QMenu(tr("Chip"), this);
    addTopMenu(chipBar);

    m_start_act = chipBar->addAction(QIcon(":/actions/start"), tr("Start chip"));
    m_stop_act = chipBar->addAction(QIcon(":/actions/stop"), tr("Stop chip"));
    m_restart_act = chipBar->addAction(QIcon(":/actions/refresh"), tr("Restart chip"));

    m_start_act->setEnabled(false);
    m_stop_act->setEnabled(false);
    m_restart_act->setShortcut(QKeySequence("R"));
    m_restart_act->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    m_restart_act->setEnabled(false);

    connect(m_start_act,  SIGNAL(triggered()), SLOT(startChip()));
    connect(m_stop_act,   SIGNAL(triggered()), SLOT(stopChip()));
    connect(m_restart_act, SIGNAL(triggered()), SLOT(restartChip()));

    m_modeBar = new QMenu(tr("Mode"), this);
    addTopMenu(m_modeBar);

    QMenu *verifyMenu = m_modeBar->addMenu(tr("Verify write"));
    QSignalMapper *verifyMap = new QSignalMapper(this);

    for(quint8 i = 0; i < VERIFY_MAX; ++i)
    {
        static const QString verifyText[] =
        {
            tr("None"),
            tr("Verify only non-empty pages"),
            tr("Verify all")
        };

        m_verify[i] = verifyMenu->addAction(verifyText[i]);
        m_verify[i]->setCheckable(true);
        verifyMap->setMapping(m_verify[i], i);

        connect(m_verify[i], SIGNAL(triggered()), verifyMap, SLOT(map()));
    }

    connect(verifyMap, SIGNAL(mapped(int)), SLOT(verifyChanged(int)));
    verifyChanged(sConfig.get(CFG_QUINT32_SHUPITO_VERIFY));

    m_set_tunnel_name_act = m_modeBar->addAction(tr("Set RS232 tunnel name..."));
    m_set_tunnel_name_act->setVisible(false);
    connect(m_set_tunnel_name_act, SIGNAL(triggered()), SLOT(setTunnelName()));

    m_enableHardwareButton = m_modeBar->addAction(tr("Enable hardware button"));
    m_enableHardwareButton->setCheckable(true);
    m_enableHardwareButton->setChecked(sConfig.get(CFG_BOOL_SHUPITO_ENABLE_HW_BUTTON));
    connect(m_enableHardwareButton, SIGNAL(toggled(bool)), this, SLOT(enableHardwareButtonToggled(bool)));

    m_load_flash = new QAction(QIcon(":/actions/open"), tr("Load..."), this);
    m_load_flash->setShortcut(QKeySequence("Ctrl+O"));
    m_load_flash->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    connect(m_load_flash,  SIGNAL(triggered()), this, SLOT(loadFromFile()));
    addTopAction(m_load_flash);

    m_save_flash = new QAction(QIcon(":/actions/save"), tr("Save..."), this);
    m_save_flash->setShortcut(QKeySequence("Ctrl+S"));
    m_save_flash->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    connect(m_save_flash,  SIGNAL(triggered()), this, SLOT(saveToFile()));
    addTopAction(m_save_flash);

    m_blink_led = new QAction(tr("Blink LED"), this);
    m_blink_led->setEnabled(false);
    connect(m_blink_led, SIGNAL(triggered()), this, SLOT(blinkLed()));
    addTopAction(m_blink_led);

    m_miniUi = new QAction(tr("Minimal UI"), this);
    m_miniUi->setCheckable(true);
    addTopAction(m_miniUi);

    connect(m_miniUi, SIGNAL(triggered(bool)), SLOT(setMiniUi(bool)));
}
void errorBlink() {
    blinkLed(SHORT_BLINK);
}
示例#12
0
int main(void)
{
    int pwm;
    int adc_on;
    int adc_off;
    uint16_t i;
    element elem;

    robot.rotation_target = 0;
    robot.right_motor_pos =0;
    robot.left_motor_pos =0;
    robot.right_motor_target =0;
    robot.left_motor_target =0;
	SysTick_Config(168000000/8/1000000); // interrupr 1000000 per secound

    
   initTimer3(1);
   initMotors();
   initEncoders();
   initUsart3();
//   enableUSART3RXNEInterrupt();
   initADC();
   initIRSensors();
   initLED();
   initSPI2();

   LED_OFF;
   waitMs(1000);
   LED_ON;

   initPIDStructures();
   stopMotors();
   resetEncoders();
   updateRobotState();
   robot.left_ir_sensor_target = measures.left_ir_sensor;
   robot.right_ir_sensor_target = measures.right_ir_sensor;

   initQueue(&robot_queue);
   //addMove(&robot_queue,FORWARD,2000);
   addMove(&robot_queue,ROTATE,20000);
//   addMove(&robot_queue,FORWARD,9000);
//   addMove(&robot_queue,ROTATE,0);
//   addMove(&robot_queue,ROTATE,6000);
//   addMove(&robot_queue,FORWARD,9000);
//   addMove(&robot_queue,ROTATE,6000);
//   addMove(&robot_queue,ROTATE,12000);
//   addMove(&robot_queue,FORWARD,9000);
//   addMove(&robot_queue,ROTATE,12000);
//   addMove(&robot_queue,ROTATE,3000);
//   nextMove();
   

   LED_ON;
    while(1)
    {
        if ( isBatteryWeak() ){
            stopMotors();
            blinkLed();
        }
        if (flags.update_robot == 1){
            moveRobot();
            updateRobotState(); 
            flags.update_robot =0;
        }

        if (flags.usart_custom == 1){


            USART3_transmitString(itoa((int) robot.rotation, buf,10));
            USART3_transmitString(" ");
            USART3_transmitString(itoa((int) robot.rotation_target, buf,10));
            USART3_transmitString("\n");


        }
    }
//        flags.usart_custom == 0;
//        USART3_transmitString("lewe_kolo_diff ");
//        USART3_transmitString(itoa((int) robot.left_motor_target - robot.left_motor_pos , buf,10));
//        USART3_transmitByte('\n');
//        USART3_transmitString("lewe kolo pwm ");
//        USART3_transmitString(itoa((int) getTranslation(LEFT_MOTOR) , buf,10));
//        USART3_transmitByte('\n');
//    
//        USART3_transmitString("prawe kolo diff ");
//        USART3_transmitString(itoa((int) robot.right_motor_target - robot.right_motor_pos , buf,10));
//        USART3_transmitByte('\n');
//        USART3_transmitString("prawe kolo pwm ");
//        USART3_transmitString(itoa((int) getTranslation(RIGHT_MOTOR) , buf,10));
//        USART3_transmitByte('\n');
//    }
//
//    if (flags.usart_graph == 1){
//        static uint8_t usart_start = 1;
//        if (usart_start ){
//            usart_start=0;
//            USART3_transmitString("\n");
//            USART3_transmitString("\n");
//            USART3_transmitString("\n");
//            USART3_transmitString("__start__\n");
//            USART3_transmitString("lewe_kolo_pozycja ");
//            USART3_transmitString("lewe_kolo_cel ");
//            USART3_transmitString("lewe_kolo_diff ");
//            USART3_transmitString("lewe_kolo_pwm_T ");
//            USART3_transmitString("prawe_kolo_pozycja ");
//            USART3_transmitString("prawe_kolo_cel ");
//            USART3_transmitString("prawe_kolo_diff ");
//            USART3_transmitString("prawe_kolo_pwm_T \n");
//            USART3_transmitString(" \n");
//        }
//
//        USART3_transmitString(itoa((int) robot.right_motor_pos , buf,10));
//        USART3_transmitString(" ");
//        USART3_transmitString(itoa((int) robot.right_motor_target , buf,10));
//        USART3_transmitString(" ");
//        USART3_transmitString(itoa((int) robot.right_motor_target - robot.right_motor_pos , buf,10));
//        USART3_transmitString(" ");
//        USART3_transmitString(itoa((int) getTranslation(RIGHT_MOTOR) , buf,10));
//        USART3_transmitString(" ");
//        USART3_transmitString(itoa((int) robot.left_motor_pos , buf,10));
//        USART3_transmitString(" ");
//        USART3_transmitString(itoa((int) robot.left_motor_target , buf,10));
//        USART3_transmitString(" ");
//        USART3_transmitString(itoa((int) robot.left_motor_target - robot.left_motor_pos , buf,10));
//        USART3_transmitString(" ");
//        USART3_transmitString(itoa((int) getTranslation(LEFT_MOTOR) , buf,10));
//        USART3_transmitByte('\n');
//        flags.usart_graph = 0;
//    }
//    }
//


return 0;
}
示例#13
0
void loop() {
  int ledBlinkTimes(3);
  _mainNode.loop();
  blinkLed(ledBlinkTimes);
  delay(1000 - ledBlinkTimes * 320);
}
示例#14
0
int main() {

    char i = 0x00;
    
    ADCTRIS |= ADCPIN;
    i = 0;
    SNSTRIS |= LVLONE|LVLTWO;
    LEDTRIS &= ~(POWLED|ALMLED);
    ALMTRIS &= ~(LGTOUT|ALMOUT);

    
    init_sensor(&levelSensors[0]);
    init_sensor(&levelSensors[1]);



    timer0_init();
    timer1_init();
    timer2_init();
    adc_init_CH0();
   
    LEDPORT |= POWLED;
    ALMPORT &= ~(ALMOUT|LGTOUT);

    timer0_start(); //Blinking Timer
    timer2_start(); //Start Timer Counting  TODO: Shutoff if Both Sensors dont use
    
    
   while(1)
   {
       levelSensors[0].sensorRead = (SNSPORT & LVLONE);
       levelSensors[1].sensorRead = (SNSPORT & LVLTWO);

       for(i = 0; i < 2;i++)
       {
           checkTankStatus(&levelSensors[i]);

       checkSensorState(&levelSensors[i]);

       checkAlarmState(&levelSensors[i], &theAlarm);
       }
       

//       checkTankStatus(&levelSensors[0]);
//       checkTankStatus(&levelSensors[1]);
//
//       checkSensorState(&levelSensors[0]);
//       checkSensorState(&levelSensors[1]);
//
//       checkAlarmState(&levelSensors[0], &theAlarm);
//       checkAlarmState(&levelSensors[1], &theAlarm);

       blinkLed(&(levelSensors[0].LEVEL_STATE), &(levelSensors[1].LEVEL_STATE), &(theAlarm.ALARM_STATE), &blinkState);

    }


    //NOT A GOOD SIGNAL!! ERROR!

    while(1)
    {
        LEDPORT^=POWLED;
        for(int i=0;i<10000;i++);

    }
    return (EXIT_SUCCESS);
}