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

📄 bsp.c

📁 ucos str912 dsfkdslalldllasdfs
💻 C
📖 第 1 页 / 共 3 页
字号:
             break;

        case 14:
             GPIO_WriteBit(GPIO6, 0x20, Bit_RESET);
             break;

        case 15:
             GPIO_WriteBit(GPIO6, 0x40, Bit_RESET);
             break;

        case 16:
             GPIO_WriteBit(GPIO6, 0x80, Bit_RESET);
             break;

        default:
             break;
    }
}

/*
*********************************************************************************************************
*                                                LED OFF
*
* Description : This function is used to control any or all the LEDs on the board.
*
* Arguments   : led    is the number of the LED to turn OFF
*                      0    indicates that you want to turn off all of the board's LEDs
*                      1    turn off LED1
*                      2    turn off LED2
*                      .
*                      16   turn off LED16
*********************************************************************************************************
*/

void  LED_Off (CPU_INT08U  led)
{
    switch (led) {
        case 0:
             GPIO_WriteBit(GPIO3, 0xFF, Bit_SET);
             GPIO_WriteBit(GPIO6, 0xFF, Bit_SET);
             break;

        case 1:
             GPIO_WriteBit(GPIO3, 0x01, Bit_SET);
             break;

        case 2:
             GPIO_WriteBit(GPIO3, 0x02, Bit_SET);
             break;

        case 3:
             GPIO_WriteBit(GPIO3, 0x04, Bit_SET);
             break;

        case 4:
             GPIO_WriteBit(GPIO3, 0x08, Bit_SET);
             break;

        case 5:
             GPIO_WriteBit(GPIO3, 0x10, Bit_SET);
             break;

        case 6:
             GPIO_WriteBit(GPIO3, 0x20, Bit_SET);
             break;

        case 7:
             GPIO_WriteBit(GPIO3, 0x40, Bit_SET);
             break;

        case 8:
             GPIO_WriteBit(GPIO3, 0x80, Bit_SET);
             break;

        case 9:
             GPIO_WriteBit(GPIO6, 0x01, Bit_SET);
             break;

        case 10:
             GPIO_WriteBit(GPIO6, 0x02, Bit_SET);
             break;

        case 11:
             GPIO_WriteBit(GPIO6, 0x04, Bit_SET);
             break;

        case 12:
             GPIO_WriteBit(GPIO6, 0x08, Bit_SET);
             break;

        case 13:
             GPIO_WriteBit(GPIO6, 0x10, Bit_SET);
             break;

        case 14:
             GPIO_WriteBit(GPIO6, 0x20, Bit_SET);
             break;

        case 15:
             GPIO_WriteBit(GPIO6, 0x40, Bit_SET);
             break;

        case 16:
             GPIO_WriteBit(GPIO6, 0x80, Bit_SET);
             break;

        default:
             break;
    }
}

/*
*********************************************************************************************************
*                                              LED TOGGLE
*
* Description : This function is used to alternate the state of an LED
*
* Arguments   : led    is the number of the LED to control
*                      0    indicates that you want ALL the LEDs to toggle
*                      1    toggle LED1
*                      2    toggle LED2
*                      .
*                      16   toggle LED16
*********************************************************************************************************
*/

void  LED_Toggle (CPU_INT08U  led)
{
    CPU_INT08U  led_status_upper;
    CPU_INT08U  led_status_lower;


    led_status_lower = GPIO_Read(GPIO3);             /* Read the current state of the LEDs             */
    led_status_upper = GPIO_Read(GPIO6);

    switch (led) {
        case 0:
             led_status_lower ^= 0xFF;
             led_status_upper ^= 0xFF;
             GPIO_Write(GPIO3, led_status_lower);
             GPIO_Write(GPIO6, led_status_upper);
             break;

        case 1:
             led_status_lower ^= 0x01;
             GPIO_Write(GPIO3, led_status_lower);
             break;

        case 2:
             led_status_lower ^= 0x02;
             GPIO_Write(GPIO3, led_status_lower);
             break;

        case 3:
             led_status_lower ^= 0x04;
             GPIO_Write(GPIO9, led_status_lower);
             break;

        case 4:
             led_status_lower ^= 0x08;
             GPIO_Write(GPIO9, led_status_lower);
             break;

        case 5:
             led_status_lower ^= 0x10;
             GPIO_Write(GPIO3, led_status_lower);
             break;

        case 6:
             led_status_lower ^= 0x20;
             GPIO_Write(GPIO3, led_status_lower);
             break;

        case 7:
             led_status_lower ^= 0x40;
             GPIO_Write(GPIO9, led_status_lower);
             break;

        case 8:
             led_status_lower ^= 0x80;
             GPIO_Write(GPIO9, led_status_lower);
             break;

        case 9:
             led_status_upper ^= 0x01;
             GPIO_Write(GPIO3, led_status_upper);
             break;

        case 10:
             led_status_upper ^= 0x02;
             GPIO_Write(GPIO3, led_status_upper);
             break;

        case 11:
             led_status_upper ^= 0x04;
             GPIO_Write(GPIO9, led_status_upper);
             break;

        case 12:
             led_status_upper ^= 0x08;
             GPIO_Write(GPIO9, led_status_upper);
             break;

        case 13:
             led_status_upper ^= 0x10;
             GPIO_Write(GPIO3, led_status_upper);
             break;

        case 14:
             led_status_upper ^= 0x20;
             GPIO_Write(GPIO3, led_status_upper);
             break;

        case 15:
             led_status_upper ^= 0x40;
             GPIO_Write(GPIO9, led_status_upper);
             break;

        case 16:
             led_status_upper ^= 0x80;
             GPIO_Write(GPIO9, led_status_upper);
             break;
        default:
             break;
    }
}

/*
*********************************************************************************************************
*                                           LCD LIGHT ON
*
* Description : This function is used to turn on the LCD's light.
*
* Arguments   : none
*
* Returns     : none
*********************************************************************************************************
*/
#ifdef DISP_MODULE_PRESENT
void  LCD_LightOn (void)
{
    GPIO_WriteBit(GPIO9, 0x20, Bit_SET);
}
#endif
/*
*********************************************************************************************************
*                                           LCD LIGHT OFF
*
* Description : This function is used to turn off the LCD's light.
*
* Arguments   : none
*
* Returns     : none
*********************************************************************************************************
*/
#ifdef DISP_MODULE_PRESENT
void  LCD_LightOff (void)
{
    GPIO_WriteBit(GPIO9, 0x20, Bit_RESET);
}
#endif
/*
*********************************************************************************************************
*                                        LCD LIGHT TOGGLE
*
* Description : This function is used to toggle the state of the LCD's light.
*
* Arguments   : none
*
* Returns     : none
*********************************************************************************************************
*/
#ifdef DISP_MODULE_PRESENT
void  LCD_LightToggle (void)
{
    CPU_INT08U  lcd_light_state;

    lcd_light_state  = GPIO_Read(GPIO9);
    lcd_light_state ^= 0x20;
    GPIO_Write(GPIO9, lcd_light_state);
}
#endif
/*
*********************************************************************************************************
*                                      WRITE DATA TO DISPLAY DEVICE
*
* Description : This function sends a single BYTE to the display device.
* Arguments   : 'data'  is the BYTE to send to the display device
* Returns     : none
*********************************************************************************************************
*/

#ifdef DISP_MODULE_PRESENT
void  DispDataWr (INT8U data)
{
    DispRW_Low();                                    /* Set R/W LOW to write to the LCD module         */

    DispE_High();

    GPIO_Write(GPIO8, data);

    DispDly_uS(100);

    DispE_Low();
}
#endif

/*
*********************************************************************************************************
*                                               DELAY
*
* Description : This function is called to delay for the specified number of microseconds.
*
* Arguments   : us      Number of microseconds
*
* Returns     : none
*********************************************************************************************************
*/

#ifdef DISP_MODULE_PRESENT
void  DispDly_uS (INT32U us)
{
    CPU_INT32U  tim1_freq;
    CPU_INT16U  dly_period;
    CPU_INT16U  tmr_start_val;
    CPU_INT16U  tmr_cur_val;
    CPU_INT16U  ms_dly;

    if (us < 1000) {
        tmr_start_val = TIM_GetCounterValue(TIM1);

        tim1_freq     = SCU_GetPCLKFreqValue();
        tim1_freq    /= 2;                           /* The default TIM1 divider of 2 is being used    */
        dly_period    = (CPU_INT16U)((tim1_freq / 1000) * us);

        tmr_cur_val   = TIM_GetCounterValue(TIM1);

        while (((CPU_INT16U)(tmr_cur_val - tmr_start_val)) < dly_period) {
            tmr_cur_val = TIM_GetCounterValue(TIM1);
        }
    } else {
        ms_dly = us / 1000;
        OSTimeDlyHMSM(0,0,0,ms_dly);
    }
}
#endif

/*
*********************************************************************************************************
*                                  INITIALIZE DISPLAY DRIVER I/O PORTS
*
* Description : This routine normally initializes the I/O ports used by the display driver.  However,
*               because these ports should have already been initialized in BSP_IO_Init(), this version
*               of DispInitPort() is used to initialize TIM1, which is needed by DispDly_uS().
*
* Arguments   : none
*
* Returns     : none
*********************************************************************************************************
*/

#ifdef DISP_MODULE_PRESENT
void  DispInitPort (void)
{
#if OS_VIEW_MODULE == 0
    TIM_DeInit(TIM1);                                /* Ensure that TIM1 registers are at reset values */
    TIM_CounterCmd(TIM1, TIM_START);                 /* Start the timer                                */
#endif
}
#endif

/*
*********************************************************************************************************
*                                   SELECT COMMAND OR DATA REGISTER
*
* Description : This changes the Register Select control line to the LCD controller.
* Arguments   : none
*********************************************************************************************************
*/

#ifdef DISP_MODULE_PRESENT
void  DispSel (INT8U sel)
{
    if (sel == DISP_SEL_CMD_REG) {
        GPIO_WriteBit(GPIO9, 0x80, Bit_RESET);        /* Select the command register (RS low)           */
    } else {
        GPIO_WriteBit(GPIO9, 0x80, Bit_SET);          /* Select the data    register (RS high)          */
    }
}
#endif

/*
*********************************************************************************************************
*                                      DISPLAY CONTROL LINE FUNCTIONS
*********************************************************************************************************
*/

#ifdef DISP_MODULE_PRESENT

⌨️ 快捷键说明

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