登录站点

用户名

密码

stm32应用例程

已有 784 次阅读  2010-11-03 15:22   标签例程  应用 
**
**--------------File Info---------------------------------------------------------------------------------
** File name:               demo.c
** Latest modified Date:    2008-01-03
** Latest Version:          1.0
** Descriptions:            GPIO控制LED演示程序,用短路环把EasyARM101的JP1的PB4-LED1短接,本程序控制LED4
**                          来闪烁
**
**--------------------------------------------------------------------------------------------------------
** Created by:              Zhao shimin
** Created date:            2008-01-03
** Version:                 1.0
** Descriptions:            The original version
**
**--------------------------------------------------------------------------------------------------------
** Modified by:            
** Modified date:          
** Version:                
** Descriptions:           
**
*********************************************************************************************************/
#include "hw_ints.h"
#include "hw_memmap.h"
#include "hw_types.h"
#include "gpio.h"
#include "sysctl.h"
#include "cpu.h"
#include "interrupt.h"
#define     PIN4        GPIO_PIN_4                                      /*  PB4控制LED1                 */

/*********************************************************************************************************
** Function name:           delay
**
** Descriptions:            延时程序
**
** input parameters:        a 延时初值,值越大延时时间越长
** output parameters:       NONE
**
** Returned value:          NONE
**
** Created by:              Zhao shimin
** Created Date:            2008/01/03
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void delay (int a)

    for (; a > 0; a--); 
}
/*********************************************************************************************************
** Function name:           main
**
** Descriptions:            GPIO控制LED演示程序
**
** input parameters:        NONE
** output parameters:       NONE
**
** Returned value:          NONE
**
** Created by:              Zhao shimin
** Created Date:            2008/01/03
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
int main(void)

    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_6MHZ);
   
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
   
    GPIODirModeSet(GPIO_PORTB_BASE, PIN4, GPIO_DIR_MODE_OUT);
    GPIOPadConfigSet(GPIO_PORTB_BASE,  PIN4, GPIO_STRENGTH_8MA,
                     GPIO_PIN_TYPE_STD_WPU);  
  
    for (;;)
    { 
      
       GPIOPinWrite(GPIO_PORTB_BASE, PIN4,  PIN4);
       delay(1000000);
       GPIOPinWrite(GPIO_PORTB_BASE, PIN4,  ~PIN4);
       delay(1000000);
    }
  
}
/*********************************************************************************************************
  END FILE
*********************************************************************************************************/

没有了 下一篇: 单片机和嵌入式系统linux的区别

分享 举报