Esempio n. 1
0
byte LLAPSerial::sleepForaWhile (word msecs) {
    byte ok = 1;
    word msleft = msecs;
    // only slow down for periods longer than the watchdog granularity
    while (msleft >= 16) {
        char wdp = 0; // wdp 0..9 corresponds to roughly 16..8192 ms
        // calc wdp as log2(msleft/16), i.e. loop & inc while next value is ok
        for (word m = msleft; m >= 32; m >>= 1)
            if (++wdp >= 9)
                break;
        watchdogCounter = 0;
        watchdogInterrupts(wdp);
        powerDown();
        watchdogInterrupts(-1); // off
        // when interrupted, our best guess is that half the time has passed
        word halfms = 8 << wdp;
        msleft -= halfms;
        if (watchdogCounter == 0) {
            ok = 0; // lost some time, but got interrupted
            break;
        }
        msleft -= halfms;
    }
    // adjust the milli ticks, since we will have missed several
#if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny85__) || defined (__AVR_ATtiny44__) || defined (__AVR_ATtiny45__)
    extern volatile unsigned long millis_timer_millis;
    millis_timer_millis += msecs - msleft;
#else
    extern volatile unsigned long timer0_millis;
    timer0_millis += msecs - msleft;
#endif
    return ok; // true if we lost approx the time planned
}
Esempio n. 2
0
void initializeAudio(){
	powerDown();

	*(uint32_t *)(h2p_lw_I2C_DATA_addr)=0x340ecd;//master
	waitForChanges();

	*(uint32_t *)(h2p_lw_I2C_DATA_addr)=0x340815;//sound select
	waitForChanges();

	*(uint32_t *)(h2p_lw_I2C_DATA_addr)=0x340A00;//
	waitForChanges();

	*(uint32_t *)(h2p_lw_I2C_DATA_addr)=0x341002;//mclk
	waitForChanges();

	*(uint32_t *)(h2p_lw_I2C_DATA_addr)=0x340017;//
	waitForChanges();

	*(uint32_t *)(h2p_lw_I2C_DATA_addr)=0x340217;//
	waitForChanges();

	leftSideVol(volumeLvl);
	rightSideVol(volumeLvl);

	*(uint32_t *)(h2p_lw_I2C_DATA_addr)=0x341e00;//reset
	waitForChanges();

	powerOn();
}
Esempio n. 3
0
uint8_t BayRF24::sendPayload(void) {
	if (_powerdown)
		powerUp();
	else
		stopListening();
	openWritingPipe (_pipe);
	uint8_t res;

	res = RF24::write(getPayload(), getPacketLength());
	uint8_t curr_pa = 0;
	while (!res && curr_pa < 4) {
		setPALevel((rf24_pa_dbm_e) curr_pa);
		delayMicroseconds(random(2000));
		res = RF24::write(getPayload(), getPacketLength());
		curr_pa++;
	}

	if (_powerdown)
		powerDown();
	else {
		txStandBy();
		startListening();
	}

	return !res;
}
Esempio n. 4
0
/*!
 * \brief Entry point for RDF_CARD_POWER.<br>
 * <br>
 * The RDF_CARD_POWER callback function resets or turns off an inserted smart card.
 * <br>
 * \param [in] pSmartcardExtension A pointer to the smart card extension,
		SMARTCARD_EXTENSION, of the device.
 *
 * \retval STATUS_SUCCESS the routine successfully end.
 * \retval STATUS_INVALID_DEVICE_REQUEST The MinorIoControlCode is an unknown code.
 */
NTSTATUS VR_RDF_PowerCard(IN PSMARTCARD_EXTENSION pSmartcardExtension)
{
	dbg_log("VR_RDF_PowerCard start");
	NTSTATUS status;

	switch (pSmartcardExtension->MinorIoControlCode) {
		case SCARD_POWER_DOWN :
			dbg_log("SCARD_POWER_DOWN");
			status = powerDown(pSmartcardExtension);
			break;
		case SCARD_COLD_RESET :
			dbg_log("SCARD_COLD_RESET");
			status = resetCard(pSmartcardExtension);
			break;
		case SCARD_WARM_RESET :
			dbg_log("SCARD_WARM_RESET");
			status = resetCard(pSmartcardExtension);
			break;
		default :
			dbg_log("SCARD_XXXXX(unknown): 0x%08X", pSmartcardExtension->MinorIoControlCode);
			status = STATUS_INVALID_DEVICE_REQUEST;
			break;
	}

	dbg_log("VR_RDF_PowerCard end - status: 0x%08X", status);
	return status;
}
Esempio n. 5
0
/*
 * 读取相关寄存器判断模块是否工作正常
 */
void checkId(void)
{
    uchar tmpCnt;
    uchar p0Addr[TX_ADR_WIDTH];
    uchar p1Addr[TX_ADR_WIDTH];
    uchar txAddr[TX_ADR_WIDTH];

    for (tmpCnt = 0; tmpCnt < TX_ADR_WIDTH; tmpCnt ++)
    {
        p0Addr[tmpCnt] = 0;
        p1Addr[tmpCnt] = 0;
        txAddr[tmpCnt] = 0;
    }

    printf ("Checking ID ...\n");

    powerDown();

    CE_CLR;
    //这三个寄存器的数值在本芯片中不是固定的
    //所以不能够用来验证NRF芯片是否工作正常
    spiReadBuf (READ_REG + RX_ADDR_P0, p0Addr, TX_ADR_WIDTH);
    spiReadBuf (READ_REG + RX_ADDR_P1, p1Addr, TX_ADR_WIDTH);
    spiReadBuf (READ_REG + TX_ADDR, txAddr, TX_ADR_WIDTH);

    CE_EN;

    printf ("RX_ADDR_P0 = ");
    printAddr (p0Addr);
    printf ("RX_ADDR_P1 = ");
    printAddr (p1Addr);
    printf ("TX_ADDR = ");
    printAddr (txAddr);
}
Esempio n. 6
0
void decreaseVolume(){
	if(volumeLvl>volumeMin){
			volumeLvl-=increment;
			powerDown();

			leftSideVol(volumeLvl);
			rightSideVol(volumeLvl);
			powerOn();
		}
}
Esempio n. 7
0
void increaseVolume(){
	if(volumeLvl<volumeMax){
		volumeLvl+=increment;
		powerDown();

		leftSideVol(volumeLvl);
		rightSideVol(volumeLvl);
		powerOn();
	}
}
Esempio n. 8
0
void Radio::stopListening(void) {
  if (read_register(FEATURE) & _BV(EN_ACK_PAY)) {
    _delay_us(155);
    flush_tx();
  }

  write_register(CONFIG, (read_register(CONFIG)) & ~_BV(PRIM_RX));

  // for 3 pins solution TX mode is only left with additional powerDown/powerUp cycle.
  powerDown();
  powerUp();
}
Esempio n. 9
0
void TMR1isr(void)
{
    PIR1bits.TMR1IF = 0;
    shut_off_timer_count--;
    if (shut_off_timer_count == 0)
    {
        powerDown();
    }

    TMR1H = 0x0B;
    TMR1L = 0xDB;
}
Esempio n. 10
0
void main(void)
{
    // Initialise system
    setup();
    // used for debugging.
    TRISBbits.RB4 = 0;
    PORTBbits.RB4 = 0;

    // Loop until the system is turned off
    while (req_state & POWER_ON)
    {
        int serial_data;
        switch (cur_state)
        {
            case ST_WEIGH: weigh(); break;
            case ST_COUNT_I:
            case ST_COUNT_F: count(); break;
            case ST_CALIBRATE: calibrate(); break;
        }
        serial_data = parseSerial();

        if (serial_data != RS232_NO_DATA)
        {
            RS232writeByte(COMM_DEBUG);
            RS232writeByte(cur_state);
            RS232writeByte(disp_type);
            //RS232writeByte(serial_data);
        }

        if (req_state != ST_NONE)
        {
//            int timeout = 0xFFFF;
//            int serial_return;
            cur_state = req_state;
            // Send Change to GUI.
            if (!st_chng_rs232_flag)
            {
                if (cur_state == ST_COUNT_F)
                {
                    RS232sendData_b_i(COMM_CHANGE_STATE, cur_state, number_items);
                }
                else
                {
                    RS232sendData_b(COMM_CHANGE_STATE, cur_state);
                }
            }
            st_chng_rs232_flag = 0;
            req_state = ST_NONE;
        }
    }

    powerDown();            // Save state and power down.
}
Esempio n. 11
0
void BH1750FVI::reset(void)
{

  if (_powerDown == false)
  {
    write8(BH1750_RESET);
  }
  else
  {
    powerOn();
    write8(BH1750_RESET);
    powerDown();
  }
}
Esempio n. 12
0
void MainWindow::setup(){
    cntnumber = 1;
    QWidget *widget = new QWidget(this);
    QHBoxLayout *layout = new QHBoxLayout(widget);
    layout->addStretch(20);
    layout->addWidget(formheadl);
    layout->addStretch(20);
#if DUAL_SYSTEM
    layout->addWidget(formheadr);
    layout->addStretch(20);
    widget->setFixedSize(780,280);
    widget->move(10,80);
#else
    widget->setFixedSize(460,280);
    widget->move(170,80);
#endif

    connect(&hmiData,SIGNAL(time1sOuted()),this,SLOT(Timeout1s()));
    connect(&hmiData,SIGNAL(clothFinishCountChanged(int)),label_FinishCount,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(clothSetCountChanged(int)),label_setCount,SLOT(setNum(int)));
    connect(&patternData,SIGNAL(patternChanged(QString,QString)), SLOT(onpatternChange(QString,QString)));
    connect(&hmiData,SIGNAL(hmi_loopend(int)),label_loopEnd,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(hmi_loopleft(int)),label_loopLeft,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(hmi_loopStart(int)),label_loopStart,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(hmi_loopend(int)),label_loopEnd,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(hmi_loopTatal(int)),label_loopCount,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(hmi_cntNumber(unsigned short)),SLOT(runPatternRowChange(unsigned short)));
    connect(&hmiData,SIGNAL(hmi_jitouxiangduizhengshu(int)),label_zwz,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(xtGuilingError()),SLOT(onXtGuilingError()));
    connect(&hmiData,SIGNAL(xtRunOrGuiling(bool)),qMdPushButton_5,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(lineLock(bool)),qMdPushButton_6,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(speedLimit(bool)),qMdPushButton_8,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(stopPerOne(bool)),qMdPushButton_9,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(alarmLimit(bool)),qMdPushButton_10,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(shazuiUp(bool)),qMdPushButton_11,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(runing(bool)),SLOT(onHmidataRuning(bool)));
    connect(&hmiData,SIGNAL(powerDown()),SLOT(onPowerDown()));
    connect(&paramaData,SIGNAL(changed()),SLOT(onParamChanded()));
    azllist<<tr("空")<<tr("翻针")<<tr("编织");
    hzllist<<tr("空")<<tr("吊目")<<tr("接针")<<tr("吊目2")<<tr("编松2");
#if DUAL_SYSTEM
    connect(&hmiData,SIGNAL(sigDankouLock(bool)),SLOT(onDankouLock(bool)));
    label_dankoulock->setText(hmiData.dankouLock()?tr("锁定"):tr("不锁定"));
#else
    frame_dankoulock->hide();
#endif

}
Esempio n. 13
0
/*
 * 进入到Rx接收模式
 */
void enterRxMode(uchar* rxAddr)
{
    powerDown();

    CE_CLR;

    spiWriteBuf(WRITE_REG + RX_ADDR_P0, rxAddr, TX_ADR_WIDTH);

    spiRwReg(WRITE_REG + EN_AA, 0x01);
    spiRwReg(WRITE_REG + EN_RXADDR, 0x01);
    spiRwReg(WRITE_REG + RF_CH, 40);
    spiRwReg(WRITE_REG + RX_PW_P0, TX_PLOAD_WIDTH);
    spiRwReg(WRITE_REG + RF_SETUP, 0x07);
    spiRwReg(WRITE_REG + CONFIG, 0x0f);

    CE_EN;
}
Esempio n. 14
0
void BayRF24::init(uint64_t address, uint8_t c = 0x71, rf24_pa_dbm_e pa_level =
		RF24_PA_HIGH, rf24_datarate_e rate = RF24_250KBPS) {
	_pipe = address;
	RF24::begin();
	setChannel(c);
	setPayloadSize(32);
	enableDynamicPayloads();
	setCRCLength (RF24_CRC_16);
	setDataRate(rate);
	setPALevel(pa_level);
	_pa_level = pa_level;
//changed 0.1.2 - as we normally have a storage on board
//User can call client.setRetries(15,15) after client.init
	setRetries(15, 8);
	setAutoAck(true);
	if (_powerdown)
		powerDown();
}
Esempio n. 15
0
void highISR()
{
    if (PIR1bits.RCIF)                // check for Rx interrupt
        rx232isr();
    if (PIR1bits.TXIF)
        tx232isr();
    if (PIR1bits.ADIF)
        ADCisr();
    if (PIR1bits.TMR1IF)
        TMR1isr();
    if (INTCON1bits.INT0IF)
        numpadISR();
    if (PIR1bits.SSPIF)
        SPIisr();
    if (INTCON3bits.INT2IF)
        powerDown();
    return;
}
Esempio n. 16
0
/*
 * 进入到Tx发送模式
 */
void enterTxMode(uchar * txAddr, volatile uchar* txBuf)
{
    powerDown();

    CE_CLR;

    spiWriteBuf(WRITE_REG + TX_ADDR, txAddr, TX_ADR_WIDTH);
    spiWriteBuf(WRITE_REG + RX_ADDR_P0, txAddr, TX_ADR_WIDTH);
    spiWriteBuf(WR_TX_PLOAD, (uchar *)txBuf, TX_PLOAD_WIDTH);

    spiRwReg(WRITE_REG + EN_AA, 0x01);
    spiRwReg(WRITE_REG + EN_RXADDR, 0x01);
    spiRwReg(WRITE_REG + SETUP_RETR, 0x01);
    spiRwReg(WRITE_REG + RF_CH, 40);
    spiRwReg(WRITE_REG + RF_SETUP, 0x07);
    spiRwReg(WRITE_REG + CONFIG, 0x0e);

    CE_EN;
}
Esempio n. 17
0
void Hacklace_AppEngine::enterPowerDown()
{
	resetApp();										// terminate current app
	printChar(SAD_SMILEY);  _delay_ms(500);
	clearDisplay();
	while ((PIN(BTN_PORT) & BUTTON1) == 0) {}		// wait for button to be released
	_delay_ms(20);									// wait until bouncing has decayed
	powerDown();									// ---------- sleeping ----------
	while ((PIN(BTN_PORT) & BUTTON1) == 0) {}		// wait for button to be released
	_delay_ms(20);									// wait until bouncing has decayed
	
	printChar(HAPPY_SMILEY);
	if (PIN(BTN_PORT) & BUTTON2) {					// button2 not pressed
		_delay_ms(500);
		nextApp();									// start app
	} else {										// button2 pressed
		while ((PIN(BTN_PORT) & BUTTON2) == 0) {}	// wait for button to be released
		_delay_ms(20);								// wait until bouncing has decayed
		clearDisplay();
		app = (Hacklace_App*) DownloadApp_ptr;
		app->setup(EE_START_ADDR);					// enter download mode
	}
}
Esempio n. 18
0
bool QRF24::write( const void* buf, quint8 len )
{
    bool result = false;

    // Begin the write
    startWrite(buf,len);

    // ------------
    // At this point we could return from a non-blocking write, and then call
    // the rest after an interrupt

    // Instead, we are going to block here until we get TX_DS (transmission completed and ack'd)
    // or MAX_RT (maximum retries, transmission failed).  Also, we'll timeout in case the radio
    // is flaky and we get neither.

    // IN the end, the send should be blocking.  It comes back in 60ms worst case, or much faster
    // if I tighted up the retry logic.  (Default settings will be 1500us.
    // Monitor the send
    quint8 observe_tx;
    quint8 status;
    uint32_t sent_at = millis();
    const unsigned long timeout = 500; //ms to wait for timeout

    do
    {
        status = readRegister(OBSERVE_TX,&observe_tx,1);

        if (debug)
            printf("%02X", observe_tx);
    }
    while( ! ( status & ( _BV(TX_DS) | _BV(MAX_RT) ) ) && ( millis() - sent_at < timeout ) );


    // The part above is what you could recreate with your own interrupt handler,
    // and then call this when you got an interrupt
    // ------------

    // Call this when you get an interrupt
    // The status tells us three things
    // * The send was successful (TX_DS)
    // * The send failed, too many retries (MAX_RT)
    // * There is an ack packet waiting (RX_DR)
    bool tx_ok, tx_fail;

    whatHappened(tx_ok,tx_fail,ack_payload_available);

    //printf("%u%u%u\r\n",tx_ok,tx_fail,ack_payload_available);

    result = tx_ok;
    if (debug)
        printf(result?"...OK.":"...Failed");

    // Handle the ack packet
    if ( ack_payload_available )
    {
        ack_payload_length = getDynamicPayloadSize();
        if (debug )
            printf("[AckPacket]/%d", ack_payload_length);
    }

    // Yay, we are done.

    // Power down
    powerDown();

    // Flush buffers (Is this a relic of past experimentation, and not needed anymore??)
    flushTx();

    return result;
}
Esempio n. 19
0
File: os345.c Progetto: sdo91/os345
// **********************************************************************
// **********************************************************************
// OS startup
//
// 1. Init OS
// 2. Define reset longjmp vector
// 3. Define global system semaphores
// 4. Create CLI task
// 5. Enter scheduling/idle loop
//
int main(int argc, char* argv[])
{
	// save context for restart (a system reset would return here...)
	int resetCode = setjmp(reset_context);
	superMode = TRUE;						// supervisor mode

	switch (resetCode)
	{
		case POWER_DOWN_QUIT:				// quit
			powerDown(0);
			printf("\nGoodbye!!");
			return 0;

		case POWER_DOWN_RESTART:			// restart
			powerDown(resetCode);
			printf("\nRestarting system...\n");

		case POWER_UP:						// startup
			break;

		default:
			printf("\nShutting down due to error %d", resetCode);
			powerDown(resetCode);
			return resetCode;
	}

	// output header message
	printf("%s", STARTUP_MSG);

	// initalize OS
	if ( resetCode = initOS()) return resetCode;

	// create global/system semaphores here
	//?? vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

	charReady = createSemaphore("charReady", BINARY, 0);
	inBufferReady = createSemaphore("inBufferReady", BINARY, 0);
	keyboard = createSemaphore("keyboard", BINARY, 1);
	tics1sec = createSemaphore("tics1sec", BINARY, 0);
	tics10thsec = createSemaphore("tics10thsec", BINARY, 0);

	tics10secs = createSemaphore("tics10secs", COUNTING, 0);

	//?? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

	// schedule CLI task
	createTask("myShell",			// task name
					P1_shellTask,	// task
					MED_PRIORITY,	// task priority
					argc,			// task arg count
					argv);			// task argument pointers

	// HERE WE GO................

	// Scheduling loop
	// 1. Check for asynchronous events (character inputs, timers, etc.)
	// 2. Choose a ready task to schedule
	// 3. Dispatch task
	// 4. Loop (forever!)

	while(1)									// scheduling loop
	{
		// check for character / timer interrupts
		pollInterrupts();

		// schedule highest priority ready task
		if ((curTask = scheduler()) < 0) continue;

		// dispatch curTask, quit OS if negative return
		if (dispatcher() < 0) break;
	}											// end of scheduling loop

	// exit os
	longjmp(reset_context, POWER_DOWN_QUIT);
	return 0;
} // end main
Esempio n. 20
0
/**
 * Configure the LCD controller.
 *
 * A lot of this is coming from the Catalog Demo (POS Demo)
 * by Bluescreen SUN (ThaiEasyElec)
 *
 * @param config LCD controller configuration
 */
void LCDControllerDriver::configure(LCDConfiguration config) {
	uint32_t regVal;

	// Save the information
	this->bufferBase = config.bufferBaseAddress;
	this->lcdHeight = config.height;
	this->lcdWidth = config.width;

	/*
	 * IMPORTANT NOTICE
	 *
	 * The LCD controller clock divider is set in lowlevel/target.c
	 * This is where all the clocking work is done.
	 */

	/*
	 * If don't know if this is required, but I prefer to have the
	 * LCD powered down when playing with the controller timings.
	 *
	 * Note that there is not mention in the datasheet that this
	 * should be done.
	 */
	if(lcdState == Up) {
		powerDown();
	}

	// Set pixel per line
	regVal = lcdRegisters->LCD_TIMH;
	regVal &= 0xFFFFFF03;
	regVal |= (((config.width >> 4)-1) & 0x3F) << 2;
	lcdRegisters->LCD_TIMH = regVal;

	// Set line per panel
	regVal = lcdRegisters->LCD_TIMV;
	regVal &= 0xFFFFFC00;
	regVal |= ((config.height-1) & 0x3FF);
	lcdRegisters->LCD_TIMV = regVal;

	regVal = 0;
	regVal |= (1 << 11);	//invert vertical sync
	regVal |= (1 << 12);	//invert horizontal sync
	regVal |= ((config.width-1) << 16);	//clock per line
	regVal |= (1 << 26);	//bypass pixel clock divider
	lcdRegisters->LCD_POL = regVal;

	lcdRegisters->LCD_LE = 0;	//disable LE pin

	lcdRegisters->LCD_UPBASE = config.bufferBaseAddress;

	regVal = 0;
	regVal |= (5 << 1); //24 bpp
	regVal |= (1 << 5); //TFT type
	//regVal |= (0 << 8); //RGB format
	//regVal |= (0 << 12); //vertical compare interrupt generated at start of vertical sync
	//regVal |= (0 << 16); //DMA FIFO watermark level : 4 or more
	lcdRegisters->LCD_CTRL = regVal;

	lcdRegisters->LCD_INTMSK = 0;

	/*
	 * The BlueScreen SUN team change the default round-robin
	 * AHB1 access scheduler to a priority based one with
	 * LCD getting the highest priority. I'll try using the
	 * default stuff and we'll see how it goes.
	 */
	//AHBCFG1 = 0x12340144;
	AHBCFG1 = 0x51243144;
}
Esempio n. 21
0
// **********************************************************************
// **********************************************************************
// OS startup
//
// 1. Init OS
// 2. Define reset longjmp vector
// 3. Define global system semaphores
// 4. Create CLI task
// 5. Enter scheduling/idle loop
//
int main(int argc, char* argv[])
{
	// All the 'powerDown' invocations must occur in the 'main'
	// context in order to facilitate 'killTask'.  'killTask' must
	// free any stack memory associated with current known tasks.  As
	// such, the stack context must be one not associated with a task.
	// The proper method is to longjmp to the 'reset_context' that
	// restores the stack for 'main' and then invoke the 'powerDown'
	// sequence.

	// save context for restart (a system reset would return here...)
	int resetCode = setjmp(reset_context);
	superMode = TRUE;						// supervisor mode

	switch (resetCode)
	{
	case POWER_DOWN_QUIT:				// quit
		powerDown(0);
		printf("\nGoodbye!!");
		return 0;

	case POWER_DOWN_RESTART:			// restart
		powerDown(resetCode);
		printf("\nRestarting system...\n");
		break;

	case POWER_UP:						// startup
		break;

	default:
		printf("\nShutting down due to error %d", resetCode);
		powerDown(resetCode);
		return 0;
	}

	// output header message
	printf("%s", STARTUP_MSG);

	// initalize OS
	initOS();

	// create global/system semaphores here
	//?? vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

	charReady = createSemaphore("charReady", BINARY, 0);
	inBufferReady = createSemaphore("inBufferReady", BINARY, 0);
	keyboard = createSemaphore("keyboard", BINARY, 1);
	tics1sec = createSemaphore("tics1sec", COUNTING, 0);
	tics10thsec = createSemaphore("tics10thsec", COUNTING, 0);
	tics10sec = createSemaphore("tics10sec", COUNTING, 0);
	dcChange = createSemaphore("dcChange", BINARY, 0);

	//?? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

	// schedule CLI task
	createTask("myShell",			// task name
			P1_shellTask,	// task
			MED_PRIORITY	,	// task priority
			argc,			// task arg count
			argv);			// task argument pointers

	// HERE WE GO................

	// Scheduling loop
	// 1. Check for asynchronous events (character inputs, timers, etc.)
	// 2. Choose a ready task to schedule
	// 3. Dispatch task
	// 4. Loop (forever!)

	while(1)									// scheduling loop
	{
		// check for character / timer interrupts
		pollInterrupts();

		// schedule highest priority ready task
		if ((curTask = scheduler()) < 0) continue;

		// dispatch curTask, quit OS if negative return
		if (dispatcher() < 0) break;
	}											// end of scheduling loop

	// exit os
	longjmp(reset_context, POWER_DOWN_QUIT);
	return 0;
} // end main