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

📄 bsp.c

📁 基于 Luminary Micro 公司的 Cortex-M3 (ARM)内核使用之 uC/OS-II 作业系统,此例程是移植于 LM3S811 上的应用,于 IAR EWARM V4.41A 工程编
💻 C
📖 第 1 页 / 共 2 页
字号:
            break;

        case 1:
             pins = GPIOPinRead(GPIO_PORTC_BASE, LED_USER);
             if ((pins & LED_USER) == 0) {
                 GPIOPinWrite(GPIO_PORTC_BASE, LED_USER, 1);
             } else {
                 GPIOPinWrite(GPIO_PORTC_BASE, LED_USER, 0);
             }
             break;

        default:
             break;
    }
}

/*
*********************************************************************************************************
*                                         PB INITIALIZATION
*
* Description : This function initializes the board's PB.
*
* Arguments   : none
*********************************************************************************************************
*/

static  void  PB_Init (void)
{
    GPIODirModeSet(GPIO_PORTC_BASE, PB_USER, GPIO_DIR_MODE_IN);
}

/*
*********************************************************************************************************
*                                         GET 'PUSH BUTTON' STATUS
*
* Description : This function is used to get the status of any push button on the board.
*
* Arguments   : push_button    is the number of the push button to probe
*                              1    probe the user push button
*********************************************************************************************************
*/

CPU_BOOLEAN  PB_GetStatus (CPU_INT08U pb)
{
    CPU_BOOLEAN  status;
    CPU_INT32U   pins;


    status              = DEF_FALSE;

    switch (pb) {
        case 1:
             pins       = GPIOPinRead(GPIO_PORTC_BASE, PB_USER);
             if (pins) {
                 status = DEF_FALSE;
             } else {
                 status = DEF_TRUE;
             }
             break;

        default:
             break;
    }

    return (status);
}

/*
*********************************************************************************************************
*                                         ADC INITIALIZATION
*
* Description : This function initializes the board's ADC.
*
* Arguments   : none
*********************************************************************************************************
*/

static  void  ADC_Init (void)
{
    ADCSequenceConfigure(ADC_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
    ADCSequenceStepConfigure(ADC_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_END);
    ADCSequenceEnable(ADC_BASE, 3);
}

/*
*********************************************************************************************************
*                                           ADC STATUS
*
* Description : This function initializes the board's ADC
*
* Arguments   : adc     is the number of the ADC to probe.  For this board, the only legitimate value is 1.
*
* Returns     : The numerator of the binary fraction representing the result of the latest ADC conversion.
*               This value will be a 10-bit value between 0x0000 and 0x03FF, inclusive.
*********************************************************************************************************
*/

CPU_INT32U  ADC_GetStatus (CPU_INT08U  adc)
{
    CPU_INT32U  result;


    result = 0;

    switch (adc) {
        case 1:
             ADCSequenceDataGet(ADC_BASE, 3, (unsigned long *)&result);
             ADCProcessorTrigger(ADC_BASE, 3);
             break;

        default:
             break;
    }

    return (result);
}


/*
******************************************************************************************************************************
******************************************************************************************************************************
**                                       uC/OS-View Functions
******************************************************************************************************************************
******************************************************************************************************************************
*/

/*
*********************************************************************************************************
*                                     INITIALIZE TIMER FOR uC/OS-View
*
* Description : This function is called to by uC/OS-View to initialize the free running timer that is
*               used to make time measurements.
*
* Arguments   : none
*
* Returns     ; none
*
* Note(s)     : This function is EMPTY because the timer is initialized elsewhere.
*********************************************************************************************************
*/

#if OS_VIEW_MODULE > 0
void  OSView_TmrInit (void)
{
}
#endif

/*
*********************************************************************************************************
*                                     READ TIMER FOR uC/OS-View
*
* Description : This function is called to read the current counts of a 32 bit free running timer.
*
*               Timer #0 of the LPC2000 is used.  This is an UP-timer.
*
* Arguments   : none
*
* Returns     ; The 32 bit counts of the timer assuming the timer (MUST be an UP counter).
*********************************************************************************************************
*/

#if OS_VIEW_MODULE > 0
CPU_INT32U  OSView_TmrRd (void)
{
    return ((CPU_INT32U)0);
}
#endif


/*
******************************************************************************************************************************
******************************************************************************************************************************
**                             uC/OS-II Timer Initialization & Handler
******************************************************************************************************************************
******************************************************************************************************************************
*/

/*
*********************************************************************************************************
*                                       TICKER INITIALIZATION
*
* Description : This function is called to initialize uC/OS-II's tick source (typically a timer generating
*               interrupts every 1 to 100 mS).
*
* Arguments   : none
*
* Returns     : none
*********************************************************************************************************
*/

static  void  Tmr_TickInit (void)
{
    CPU_INT32U  cnts;


    cnts = (CPU_INT32U)SysCtlClockGet() / OS_TICKS_PER_SEC;

    SysTickPeriodSet(cnts);
    SysTickEnable();
    SysTickIntEnable();
}

/*
*********************************************************************************************************
*                                         TIMER IRQ HANDLER
*
* Description : This function handles the timer interrupt that is used to generate TICKs for uC/OS-II.
*
* Arguments   : none
*
* Returns     : none
*********************************************************************************************************
*/

void  Tmr_TickISR_Handler (void)
{
    OS_CPU_SR  cpu_sr;


    OS_ENTER_CRITICAL();                         /* Tell uC/OS-II that we are starting an ISR          */
    OSIntNesting++;
    OS_EXIT_CRITICAL();

    OSTimeTick();                                /* Call uC/OS-II's OSTimeTick()                       */

    OSIntExit();                                 /* Tell uC/OS-II that we are leaving the ISR          */
}

⌨️ 快捷键说明

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