色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          LM3S9B96 GPIO的讀寫

          作者: 時(shí)間:2016-11-11 來(lái)源:網(wǎng)絡(luò) 收藏
          GPIO:general purpose input output,無(wú)非設(shè)置成輸入模式和輸出模式。
          下面主函數(shù)中LED部分是將GPIO設(shè)置成輸出模式的例子,KEY部分是將GPIO設(shè)置成輸入模式的例子。

          #include "inc/hw_memmap.h"
          #include "inc/hw_types.h"
          #include "driverlib/gpio.h"
          #include "driverlib/sysctl.h"

          /* 寄存器地址 ---------------------------------------------------------------*/
          #define GPIO_PORTF_APB_DIR_R 0x40025400
          #define GPIO_PORTF_APB_DEN_R 0x4002551C

          /* 用于調(diào)試 PF1 <-> LED -----------------------------------------------------*/
          #define LED_PERIPH SYSCTL_PERIPH_GPIOF
          #define LED_PORT GPIO_PORTF_BASE
          #define LED_PIN GPIO_PIN_1
          #define LED_OFF 1 << 1
          #define LED_ON ~(1 << 1) // 低電平點(diǎn)亮LED

          void Delay(volatile signed long nCount)
          {
          for(; nCount != 0; nCount--);
          }


          long test;
          long clk;

          int main(void)
          {
          // Set the clocking to run directly from the crystal.
          /*SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
          clk = SysCtlClockGet();

          // LED------------------------------------------------------------------------------
          SysCtlPeripheralEnable(LED_PERIPH); // 使能LED所在的GPIO端口
          GPIOPinTypeGPIOOutput(LED_PORT, LED_PIN); // 設(shè)置LED所在管腳為輸出

          while (1)
          {
          GPIOPinWrite(LED_PORT, LED_PIN, LED_ON); //點(diǎn)亮LED
          Delay(0xfffff);
          GPIOPinWrite(LED_PORT, LED_PIN, LED_OFF); //熄滅LED
          Delay(0xfffff);
          }*/


          // Set the clocking to run directly from the crystal.
          SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

          // Key------------------------------------------------------------------------------
          SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ); // 使能GPIOJ端口
          GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_7);
          GPIOPadConfigSet(GPIO_PORTJ_BASE, GPIO_PIN_7, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

          while (1)
          {
          if (test = GPIOPinRead(GPIO_PORTJ_BASE, GPIO_PIN_7))
          {
          Delay(0xfffff);
          }
          }
          }

          本文引用地址:http://cafeforensic.com/article/201611/317007.htm



          關(guān)鍵詞: LM3S9B96GPIO讀

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉