Beispiel #1
0
//............................................................................
void QK::onIdle(void) {
    // toggle the User LED on and then off, see NOTE01
    QF_INT_LOCK(dummy);
    GPIOC->DATA_Bits[USER_LED] = USER_LED;            // turn the User LED on
    GPIOC->DATA_Bits[USER_LED] = 0;                   // turn the User LED off
    QF_INT_UNLOCK(dummy);

#ifdef Q_SPY
    if ((UART0->FR & UART_FR_TXFE) != 0) {                         // TX done?
        uint16_t fifo = UART_TXFIFO_DEPTH;          // max bytes we can accept
        uint8_t const *block;
        QF_INT_LOCK(dummy);
        block = QS::getBlock(&fifo);      // try to get next block to transmit
        QF_INT_UNLOCK(dummy);
        while (fifo-- != 0) {                       // any bytes in the block?
            UART0->DR = *block++;                         // put into the FIFO
        }
    }
#elif defined NDEBUG
    // put the CPU and peripherals to the low-power mode
    // you might need to customize the clock management for your application,
    // see the datasheet for your particular Cortex-M3 MCU.
    __WFI();                                             // Wait-For-Interrupt
#endif
}
Beispiel #2
0
/*..........................................................................*/
void QK_onIdle(void) {

    /* toggle the User LED on and then off, see NOTE02 */
    QF_INT_LOCK(dummy);
    GPIOC->DATA_Bits[USER_LED] = USER_LED;         /* turn the User LED on  */
    GPIOC->DATA_Bits[USER_LED] = 0;                /* turn the User LED off */
    QF_INT_UNLOCK(dummy);

#ifdef Q_SPY
    if ((UART0->FR & UART_FR_TXFE) != 0) {                      /* TX done? */
        uint16_t fifo = UART_TXFIFO_DEPTH;       /* max bytes we can accept */
        uint8_t const *block;
        QF_INT_LOCK(dummy);
        block = QS_getBlock(&fifo);    /* try to get next block to transmit */
        QF_INT_UNLOCK(dummy);
        while (fifo-- != 0) {                    /* any bytes in the block? */
            UART0->DR = *block++;                      /* put into the FIFO */
        }
    }
#elif defined NDEBUG
    /* Put the CPU and peripherals to the low-power mode.
    * you might need to customize the clock management for your application,
    * see the datasheet for your particular Cortex-M3 MCU.
    */
    __WFI();                                          /* Wait-For-Interrupt */
#endif
}
/*..........................................................................*/
void QK_onIdle(void) {
    QF_INT_KEY_TYPE key;

                     /* toggle the LED number 7 on and then off, see NOTE01 */
    QF_INT_LOCK(key);
    LED_ON(7);
    LED_OFF(7);
    QF_INT_UNLOCK(key);

#ifdef Q_SPY                     /* use the idle cycles for QS transmission */

    if ((UCSR0A & (1 << UDRE0)) != 0) {

        uint16_t b = QS_getByte();
        QF_INT_UNLOCK(key);                            /* unlock interrupts */
        if (b != QS_EOD) {
            UDR0 = (uint8_t)b;              /* stick the byte to the TX UDR */
        }
    }

#elif defined NDEBUG

    SMCR = (0 << SM0) | (1 << SE);/*idle sleep mode, adjust to your project */

    __sleep();             /* execute before entering any pending interrupt */
                                                 /* see Atmel AVR Datasheet */
    SMCR = 0;                                           /* clear the SE bit */

#endif                                                             /* Q_SPY */
}
Beispiel #4
0
/*..........................................................................*/
void Q_onAssert(char const * const file, int line) {
    (void)file;                                   /* avoid compiler warning */
    (void)line;                                   /* avoid compiler warning */
    QF_INT_LOCK();            /* make sure that all interrupts are disabled */
    for (;;) {       /* NOTE: replace the loop with reset for final version */
    }
}
Beispiel #5
0
//------------------------------------------------------------------------------
/// Handler for PIT interrupt. Increments the timestamp counter.
//------------------------------------------------------------------------------
void ISR_Pit(void)
{
    unsigned int status;

    // Read the PIT status register
    status = PIT_GetStatus() & AT91C_PITC_PITS;



    if (status != 0) {

        // Read the PIVR to acknowledge interrupt and get number of ticks
        timestamp += (PIT_GetPIVR() >> 20);
		#ifdef QF_TICK
#ifdef QK
 	__disable_irq(); 
  	  ++QK_intNest_; 
#endif  

	QF_INT_UNLOCK();
	QF_tick();

	QF_INT_LOCK(); 
#ifdef QK 
	   --QK_intNest_;
	   if (   QK_intNest_ ==0) 
	   		QK_schedule_();
#endif
		 
#endif 
    }
Beispiel #6
0
/*..........................................................................*/
void QF_onStartup(void) {
                                      /* save the origingal DOS vectors ... */
    l_dosTmrISR   = getvect(TMR_VECTOR);

    QF_INT_LOCK();
    setvect(TMR_VECTOR, &tmrISR);
    QF_INT_UNLOCK();
}
Beispiel #7
0
/* case 1: Interrupt Controller available,
* "unconditional interrupt unlocking" critical section policy
* (nesting of critical sections _not_ allowed)
*/
interrupt void ISR_timer() {  /* entered with interrupts locked in hardware */
    QF_INT_UNLOCK(ignore);                             /* unlock interrupts */

    QF_tick();                            /*<-- call the QF tick processing */

    QF_INT_LOCK(ignore);                           /* lock interrupts again */
    /* send the EOI instruction to the Interrupt Controller */
}
Beispiel #8
0
/*..........................................................................*/
void QF_stop(void) {
                                    /* restore the original DOS vectors ... */
    if (l_dosTmrISR != (void interrupt (*)(void))0) { /* DOS vectors saved? */
        QF_INT_LOCK();
        setvect(TMR_VECTOR, l_dosTmrISR);
        QF_INT_UNLOCK();
    }
    _exit(0);                                                /* exit to DOS */
}
Beispiel #9
0
//............................................................................
void QF::onCleanup(void) {             // restore the original DOS vectors ...
    QF_INT_LOCK(dummy);
    _dos_setvect(TMR_VECTOR, l_dosTmrISR);
    _dos_setvect(KBD_VECTOR, l_dosKbdISR);
    QF_INT_UNLOCK(dummy);

    QS_EXIT();                                                      // exit QS
    _exit(0);                                                   // exit to DOS
}
Beispiel #10
0
//............................................................................
void QF::onStartup(void) {
                                         // save the origingal DOS vectors ...
    l_dosTmrISR = _dos_getvect(TMR_VECTOR);
    l_dosKbdISR = _dos_getvect(KBD_VECTOR);

    QF_INT_LOCK(dummy);
    _dos_setvect(TMR_VECTOR, &ISR_tmr);
    _dos_setvect(KBD_VECTOR, &ISR_kbd);
    QF_INT_UNLOCK(dummy);
}
Beispiel #11
0
/*..........................................................................*/
void QF_stop(void) {
                                    /* restore the original DOS vectors ... */
    if (l_dosTmrISR != (void interrupt (*)(void))0) { /* DOS vectors saved? */
        QF_INT_LOCK();
        setvect(TMR_VECTOR, l_dosTmrISR);
        setvect(KBD_VECTOR, l_dosKbdISR);
        QF_INT_UNLOCK();
    }
                                                       /* clear the display */
    //Video_clearScreen(VIDEO_BGND_BLACK | VIDEO_FGND_LIGHT_GRAY);
    _exit(0);                                                /* exit to DOS */
}
Beispiel #12
0
int main(int argc, char **argv)
{
	uint8_t mcusr;
	char startupmsg[17];

 startmain:
	cli();
	mcusr = MCUSR;
	MCUSR = 0;
	TOGGLE_BEGIN();
	BSP_startmain();	/* Disables the watchdog timer. */
	serial_init();
	serial_send_rom(startup_message);
	serial_drain();
	SERIALSTR("*** Reset reason:");
	if (mcusr & (1 << WDRF)) SERIALSTR(" WD");
	if (mcusr & (1 << BORF)) SERIALSTR(" BO");
	if (mcusr & (1 << EXTRF)) SERIALSTR(" EXT");
	if (mcusr & (1 << PORF)) SERIALSTR(" PO");
	SERIALSTR("\r\n");
	twi_ctor();
	timekeeper_ctor();
	lcd_init();
	// Show the startup reason on the LCD.
	strcpy(startupmsg, "Startup: ----");
	if (mcusr & (1<<3)) startupmsg[9] = 'W';
	if (mcusr & (1<<2)) startupmsg[10] = 'B';
	if (mcusr & (1<<1)) startupmsg[11] = 'X';
	if (mcusr & (1<<0)) startupmsg[12] = 'P';
	lcd_line1(startupmsg);
	_delay_ms(500);
	buttons_ctor();
	alarm_ctor();
	timedisplay_ctor();
	timesetter_ctor();

	/* Drain the serial output just before the watchdog timer is
	   reenabled. */
	serial_drain();
	/* Turn off interrrupts until we have initialised the rest of the
	   hardware, and after QF_run() has properly initialised the active
	   objects.  Interrupts go back on in QF_onStartup() */
	QF_INT_LOCK();
	/* Initialize the BSP.  Enables the watchdog timer. */
	BSP_init();

	QF_run();

	goto startmain;
}
/*..........................................................................*/
#pragma INTERRUPT ta0_isr (vect = 12)              /* system clock tick ISR */
void ta0_isr(void) {
    QF_INT_UNLOCK(dummy);                                     /* see NOTE01 */

#ifdef Q_SPY
    if (ir_ta1ic != 0) {                          /* interrupt request set? */
        ++l_nTimerA1Underflows; /* account for 16-bit underflow (0->0xFFFF) */
        ir_ta1ic = 0;                            /* clear the overflow flag */
    }
#endif

    QF_tick();                             /* process all armed time events */

    QF_INT_LOCK(dummy);                                       /* see NOTE01 */
}
Beispiel #14
0
   //.........................................................................
void QK::onIdle(void) {
#ifdef Q_SPY
    if ((inp(l_uart_base + 5) & (1 << 5)) != 0) {            // Tx FIFO empty?
        uint16_t fifo = UART_16550_TXFIFO_DEPTH;        // 16550 Tx FIFO depth
        uint8_t const *block;
        QF_INT_LOCK(dummy);
        block = QS::getBlock(&fifo);      // try to get next block to transmit
        QF_INT_UNLOCK(dummy);
        while (fifo-- != 0) {                       // any bytes in the block?
            outp(l_uart_base + 0, *block++);
        }
    }
#endif
}
Beispiel #15
0
static int idleThread(void *arg)
{
	complete(&idle_done);
	while (idle_running) {
		QF_INT_KEY_TYPE dummy;
		uint8_t const *block;
		uint16_t nBytes = QS_SPY_BLOCK;
		QF_INT_LOCK(dummy);
		block = QS_getBlock(&nBytes);
		QF_INT_UNLOCK(dummy);

		QS_send(block, nBytes);
		schedule_timeout(HZ);
	}
	complete(&idle_done);

	return 0;
}
Beispiel #16
0
void poll_phydev(void )  {

	QF_INT_LOCK(); 			// does this have any effect
        phy_dev_read();
   	QF_INT_UNLOCK(); 
}