⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bsp.c

📁 事件驱动程序设计很好的框架
💻 C
📖 第 1 页 / 共 2 页
字号:
}/*..........................................................................*/void BSP_drawBitmap(uint8_t const *bitmap, uint8_t width, uint8_t height) {    OSRAMImageDraw(bitmap, 0, 0, width, (height >> 3));}/*..........................................................................*/void BSP_drawNString(uint8_t x, uint8_t y, char const *str) {    OSRAMStringDraw(str, x, y);}/*..........................................................................*/void BSP_updateScore(uint16_t score) {    /* not implemented on the EV-LM3S811 board */}/*..........................................................................*/void BSP_driveLED(uint8_t state) {    GPIOPinWrite(GPIO_PORTC_BASE, USER_LED, (state ? USER_LED : 0));}/*..........................................................................*/void QF_onStartup(void) {    /* Set up and enable the SysTick timer.  It will be used as a reference    * for delay loops in the interrupt handlers.  The SysTick timer period    * will be set up for BSP_TICKS_PER_SEC.    */    SysTickPeriodSet(SysCtlClockGet() / BSP_TICKS_PER_SEC);    SysTickEnable();    IntPrioritySet(FAULT_SYSTICK, 0xC0);     /* set the priority of SysTick */    SysTickIntEnable();                    /* Enable the SysTick interrupts */    ADCIntEnable(ADC_BASE, 3);    IntEnable(INT_ADC3);    TimerEnable(TIMER1_BASE, TIMER_A);    QF_INT_UNLOCK(dummy);              /* set the interrupt flag in PRIMASK */}/*..........................................................................*/void QF_onCleanup(void) {}/*..........................................................................*/void QF_onIdle(void) {        /* entered with interrupts LOCKED, see NOTE01 */    /* toggle the User LED on and then off, see NOTE02 */    GPIOPinWrite(GPIO_PORTC_BASE, USER_LED, USER_LED);       /* User LED on */    GPIOPinWrite(GPIO_PORTC_BASE, USER_LED, 0);             /* User LED off */#ifdef Q_SPY    QF_INT_UNLOCK(dummy);    if ((HWREG(UART0_BASE + UART_O_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? */            HWREG(UART0_BASE + UART_O_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.    */    __asm("WFI");                                     /* Wait-For-Interrupt */#endif    QF_INT_UNLOCK(dummy);                   /* always unlock the interrupts */}/*..........................................................................*/void Q_onAssert(char const Q_ROM * const Q_ROM_VAR file, int line) {    (void)file;                                   /* avoid compiler warning */    (void)line;                                   /* avoid compiler warning */    QF_INT_LOCK(dummy);      /* make sure that all interrupts are disabled */    for (;;) {       /* NOTE: replace the loop with reset for final version */    }}/* error routine that is called if the Luminary library encounters an error */void __error__(char *pcFilename, unsigned long ulLine) {    Q_onAssert(pcFilename, ulLine);}/*--------------------------------------------------------------------------*/#ifdef Q_SPY/*..........................................................................*/uint8_t QS_onStartup(void const *arg) {    static uint8_t qsBuf[6*256];                  /* buffer for Quantum Spy */    QS_initBuf(qsBuf, sizeof(qsBuf));                                 /* enable the peripherals used by the UART */    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);                         /* configure the UART for 115,200, 8-N-1 operation */    UARTConfigSet(UART0_BASE, 115200, (UART_CONFIG_WLEN_8 |                                       UART_CONFIG_STOP_ONE |                                       UART_CONFIG_PAR_NONE));    UARTEnable(UART0_BASE);        /* set UARTEN, TXE, RXE and enable FIFOs */    QS_tickPeriod_ = (QSTimeCtr)(SysCtlClockGet() / BSP_TICKS_PER_SEC);    QS_tickTime_ = QS_tickPeriod_;        /* to start the timestamp at zero */                                                 /* setup the QS filters... */    QS_FILTER_ON(QS_ALL_RECORDS);//    QS_FILTER_OFF(QS_QEP_STATE_EMPTY);//    QS_FILTER_OFF(QS_QEP_STATE_ENTRY);//    QS_FILTER_OFF(QS_QEP_STATE_EXIT);//    QS_FILTER_OFF(QS_QEP_STATE_INIT);//    QS_FILTER_OFF(QS_QEP_INIT_TRAN);//    QS_FILTER_OFF(QS_QEP_INTERN_TRAN);//    QS_FILTER_OFF(QS_QEP_TRAN);//    QS_FILTER_OFF(QS_QEP_dummyD);    QS_FILTER_OFF(QS_QF_ACTIVE_ADD);    QS_FILTER_OFF(QS_QF_ACTIVE_REMOVE);    QS_FILTER_OFF(QS_QF_ACTIVE_SUBSCRIBE);    QS_FILTER_OFF(QS_QF_ACTIVE_UNSUBSCRIBE);    QS_FILTER_OFF(QS_QF_ACTIVE_POST_FIFO);    QS_FILTER_OFF(QS_QF_ACTIVE_POST_LIFO);    QS_FILTER_OFF(QS_QF_ACTIVE_GET);    QS_FILTER_OFF(QS_QF_ACTIVE_GET_LAST);    QS_FILTER_OFF(QS_QF_EQUEUE_INIT);    QS_FILTER_OFF(QS_QF_EQUEUE_POST_FIFO);    QS_FILTER_OFF(QS_QF_EQUEUE_POST_LIFO);    QS_FILTER_OFF(QS_QF_EQUEUE_GET);    QS_FILTER_OFF(QS_QF_EQUEUE_GET_LAST);    QS_FILTER_OFF(QS_QF_MPOOL_INIT);    QS_FILTER_OFF(QS_QF_MPOOL_GET);    QS_FILTER_OFF(QS_QF_MPOOL_PUT);    QS_FILTER_OFF(QS_QF_PUBLISH);    QS_FILTER_OFF(QS_QF_NEW);    QS_FILTER_OFF(QS_QF_GC_ATTEMPT);    QS_FILTER_OFF(QS_QF_GC);//    QS_FILTER_OFF(QS_QF_TICK);    QS_FILTER_OFF(QS_QF_TIMEEVT_ARM);    QS_FILTER_OFF(QS_QF_TIMEEVT_AUTO_DISARM);    QS_FILTER_OFF(QS_QF_TIMEEVT_DISARM_ATTEMPT);    QS_FILTER_OFF(QS_QF_TIMEEVT_DISARM);    QS_FILTER_OFF(QS_QF_TIMEEVT_REARM);    QS_FILTER_OFF(QS_QF_TIMEEVT_POST);    QS_FILTER_OFF(QS_QF_INT_LOCK);    QS_FILTER_OFF(QS_QF_INT_UNLOCK);    QS_FILTER_OFF(QS_QF_ISR_ENTRY);    QS_FILTER_OFF(QS_QF_ISR_EXIT);    return (uint8_t)1;                                    /* return success */}/*..........................................................................*/void QS_onCleanup(void) {}/*..........................................................................*/QSTimeCtr QS_onGetTime(void) {            /* invoked with interrupts locked */    if ((HWREG(NVIC_ST_CTRL) & NVIC_ST_CTRL_COUNT) == 0) { /* COUNT no set? */        return QS_tickTime_ - (QSTimeCtr)HWREG(NVIC_ST_CURRENT);    }    else {     /* the rollover occured, but the SysTick_ISR did not run yet */        return QS_tickTime_ + QS_tickPeriod_               - (QSTimeCtr)HWREG(NVIC_ST_CURRENT);    }}/*..........................................................................*/void QS_onFlush(void) {    uint16_t fifo = UART_TXFIFO_DEPTH;                     /* Tx FIFO depth */    uint8_t const *block;    QF_INT_LOCK(dummy);    while ((block = QS_getBlock(&fifo)) != (uint8_t *)0) {        QF_INT_UNLOCK(dummy);                                           /* busy-wait until TX FIFO empty */        while ((HWREG(UART0_BASE + UART_O_FR) & UART_FR_TXFE) == 0) {        }        while (fifo-- != 0) {                    /* any bytes in the block? */            HWREG(UART0_BASE + UART_O_DR) = *block++;  /* put into the FIFO */        }        fifo = UART_TXFIFO_DEPTH;              /* re-load the Tx FIFO depth */        QF_INT_LOCK(dummy);    }    QF_INT_UNLOCK(dummy);}#endif                                                             /* Q_SPY *//*--------------------------------------------------------------------------*//****************************************************************************** NOTE01:* The QF_onIdle() callback is called with interrupts locked, because the* determination of the idle condition might change by any interrupt posting* an event. QF::onIdle() must internally unlock interrupts, ideally* atomically with putting the CPU to the power-saving mode.** NOTE02:* The User LED is used to visualize the idle loop activity. The brightness* of the LED is proportional to the frequency of invcations of the idle loop.* Please note that the LED is toggled with interrupts locked, so no interrupt* execution time contributes to the brightness of the User LED.*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -