天天看點

GPIO驅動初步

//=====================================================================

//TITLE:

//    GPIO驅動初步

//AUTHOR:

//    norains

//DATE:

//    Saturday  9-October-2010

//Environment:

//    KEIL MDK 4.0

//    .NET Micro Framework Porting 4.1

//    RedCow Board

//=====================================================================

    .NET Micro Framework Porting下所謂的驅動,其實際隻不過是實作微軟所留出來的接口函數。比如,以GPIO為例子,如果你想在.NET Micro Framework正常驅動GPIO,那麼作為開發者的你,必須要實作如下函數:

BOOL CPU_GPIO_Initialize ();

BOOL CPU_GPIO_Uninitialize ();

UINT32 CPU_GPIO_Attributes ( GPIO_PIN Pin );

void CPU_GPIO_DisablePin ( GPIO_PIN Pin, GPIO_RESISTOR ResistorState, UINT32 Direction, GPIO_ALT_MODE AltFunction );

void CPU_GPIO_EnableOutputPin( GPIO_PIN Pin, BOOL InitialState );

BOOL CPU_GPIO_EnableInputPin ( GPIO_PIN Pin, BOOL GlitchFilterEnable, GPIO_INTERRUPT_SERVICE_ROUTINE PIN_ISR, GPIO_INT_EDGE IntEdge, GPIO_RESISTOR ResistorState );

BOOL CPU_GPIO_EnableInputPin2( GPIO_PIN Pin, BOOL GlitchFilterEnable, GPIO_INTERRUPT_SERVICE_ROUTINE PIN_ISR, void* ISR_Param, GPIO_INT_EDGE IntEdge, GPIO_RESISTOR ResistorState );

BOOL CPU_GPIO_GetPinState ( GPIO_PIN Pin );

void CPU_GPIO_SetPinState ( GPIO_PIN Pin, BOOL PinState );

BOOL CPU_GPIO_PinIsBusy ( GPIO_PIN Pin );

BOOL CPU_GPIO_ReservePin ( GPIO_PIN Pin, BOOL fReserve );

UINT32 CPU_GPIO_GetDebounce ();

BOOL CPU_GPIO_SetDebounce ( INT64 debounceTimeMilliseconds );

INT32 CPU_GPIO_GetPinCount ();

void CPU_GPIO_GetPinsMap ( UINT8* pins, size_t size );

UINT8 CPU_GPIO_GetSupportedResistorModes(GPIO_PIN pin );

UINT8 CPU_GPIO_GetSupportedInterruptModes(GPIO_PIN pin );

    這些函數在.NET Micro Framework Porting隻有聲明,沒有實作,因為實作是我們所需要做的。這樣的開發模式,和Windows CE下的驅動有異曲同工之妙,基本上就類似于試卷上的填空題。

    為什麼文章起名為“初步”呢?因為本文的内容,隻實作了GPIO的一些基礎功能,比如初始化,輸出高低電平,讀取輸入的電平等等。雖然看起來内容不少,但有一個非常重要的功能還沒有實作,就是輸入中斷的處理。具體來說,也就是CPU_GPIO_EnableInputPin和CPU_GPIO_EnableInputPin2并沒有完全實作微軟規定的功能。不過呢,事情總是從簡單到複雜的,我們不妨先來看看雛形吧,至于更完整的,待我們後續再語。如果你是急性子,迫不及待想一窺全貌,那麼建議你看看葉帆的《【.Net Micro Framework PortingKit - 08】GPIO驅動》(http://blog.csdn.net/yefanqiu/archive/2010/01/20/5218846.aspx),該文已經有完整的解決思路。如果你不急,那麼我們現在就一步一步來看看雛形的實作吧!

    1.如果你的目錄沒有STUB_GPIO的話,那麼将./DeviceCode/Drivers/Stubs/Processor/stubs_gpio檔案夾拷貝到. /Solutions/STM32F103ZE_RedCow/DeviceCode,并按微軟的慣例,将這拷貝完成的檔案夾改名為GPIO_HAL。

    2.打開拷貝過來的dotNetMF.proj檔案,将内容更改如下:

<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>

    <AssemblyName>GPIO_HAL_STM32F103ZE_RedCow</AssemblyName>

    <ProjectGuid>{9fe65202-d536-4d38-a2bb-5948f020bf67}</ProjectGuid>

    <Size>

    </Size>

    <Description>GPIO stub library</Description>

    <Level>HAL</Level>

    <LibraryFile>GPIO_HAL_STM32F103ZE_RedCow.$(LIB_EXT)</LibraryFile>

    <ProjectPath>$(SPOCLIENT)/Solutions/STM32F103ZE_RedCow/DeviceCode/GPIO_HAL/dotNetMF.proj</ProjectPath>

    <ManifestFile>GPIO_HAL_STM32F103ZE_RedCow.$(LIB_EXT).manifest</ManifestFile>

    <Groups>Processor/stubs</Groups>

    <LibraryCategory>

      <MFComponent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="GPIO_HAL" Guid="{33AB74F7-8DD4-4766-95A8-E221B80F611C}" ProjectPath="" Conditional="" xmlns="">

        <VersionDependency xmlns="http://schemas.microsoft.com/netmf/InventoryFormat.xsd">

          <Major>4</Major>

          <Minor>0</Minor>

          <Revision>0</Revision>

          <Build>0</Build>

          <Extra />

          <Date>2009-04-30</Date>

        </VersionDependency>

        <ComponentType xmlns="http://schemas.microsoft.com/netmf/InventoryFormat.xsd">LibraryCategory</ComponentType>

      </MFComponent>

    </LibraryCategory>

    <Documentation>

    </Documentation>

    <PlatformIndependent>False</PlatformIndependent>

    <CustomFilter>

    </CustomFilter>

    <Required>False</Required>

    <IgnoreDefaultLibPath>False</IgnoreDefaultLibPath>

    <IsStub>True</IsStub>

    <Directory>Solutions/STM32F103ZE_RedCow/DeviceCode/GPIO_HAL</Directory>

    <OutputType>Library</OutputType>

    <PlatformIndependentBuild>false</PlatformIndependentBuild>

    <Version>4.0.0.0</Version>

  </PropertyGroup>

  <Import Project="$(SPOCLIENT)/tools/targets/Microsoft.SPOT.System.Settings" />

  <PropertyGroup />

  <ItemGroup>

    <Compile Include="stubs_functions_gpio.cpp" />

    <Compile Include="GPIO_Adapter.cpp" />

  </ItemGroup>

  <ItemGroup />

 <ItemGroup>  

    <DriverLibs Include="STM32F10x_StdPeriph_Driver.$(LIB_EXT)" />

    <RequiredProjects Include="$(SPOCLIENT)/Solutions/STM32F103ZE_RedCow/DeviceCode/Libraries/Libraries.proj" />

  </ItemGroup>   

  <ItemGroup>

    <IncludePaths Include="Solutions/STM32F103ZE_RedCow/DeviceCode/Libraries/Configure" />

  <IncludePaths Include="Solutions/STM32F103ZE_RedCow/DeviceCode/Libraries/STM32F10x_StdPeriph_Driver/inc" />

   <IncludePaths Include="Solutions/STM32F103ZE_RedCow/DeviceCode/Libraries/CMSIS/Core/CM3/" />    

  </ItemGroup>

  <Import Project="$(SPOCLIENT)/tools/targets/Microsoft.SPOT.System.Targets" />

</Project>

    3.打開拷貝過來的stubs_functions_gpio.cpp檔案,輸入如下内容:

// Copyright (c) Microsoft Corporation. All rights reserved.

#include <tinyhal.h>

#include "GPIO_Adapter.h"

//--//

BOOL CPU_GPIO_Initialize()

{

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |

RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |

RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF, ENABLE);

return TRUE;

}

BOOL CPU_GPIO_Uninitialize()

{

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |

RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |

RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF, DISABLE);

return TRUE;

}

UINT32 CPU_GPIO_Attributes( GPIO_PIN Pin )

{

if(IsValidPin(Pin) != FALSE)

{

return (GPIO_ATTRIBUTE_INPUT | GPIO_ATTRIBUTE_OUTPUT);

}

else

{

return GPIO_ATTRIBUTE_NONE;

}

}

void CPU_GPIO_DisablePin( GPIO_PIN Pin, GPIO_RESISTOR ResistorState, UINT32 Direction, GPIO_ALT_MODE AltFunction )

{

}

void CPU_GPIO_EnableOutputPin( GPIO_PIN Pin, BOOL InitialState )

{

GPIO_InitTypeDef GPIO_InitStructure;

//Set the pin index

GPIO_InitStructure.GPIO_Pin = PinToBit(Pin);

//Set the default frequency as 50MHz

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

//Output mode

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

//Initialize

GPIO_Init(PinToPort(Pin), &GPIO_InitStructure);

//Set the pin initial state

CPU_GPIO_SetPinState(Pin,InitialState);

}

BOOL CPU_GPIO_EnableInputPin( GPIO_PIN Pin, BOOL GlitchFilterEnable, GPIO_INTERRUPT_SERVICE_ROUTINE PIN_ISR, GPIO_INT_EDGE IntEdge, GPIO_RESISTOR ResistorState )

{

return CPU_GPIO_EnableInputPin2( Pin, GlitchFilterEnable, PIN_ISR, NULL, IntEdge, ResistorState );

}

BOOL CPU_GPIO_EnableInputPin2( GPIO_PIN Pin, BOOL GlitchFilterEnable, GPIO_INTERRUPT_SERVICE_ROUTINE PIN_ISR, void* ISR_Param, GPIO_INT_EDGE IntEdge, GPIO_RESISTOR ResistorState )

{

GPIO_InitTypeDef GPIO_InitStructure;

//Set the pin index

GPIO_InitStructure.GPIO_Pin = PinToBit(Pin);

//Set the default frequency as 50MHz

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

//Input mode

switch(ResistorState)

{

case RESISTOR_PULLDOWN:

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;

break;

case RESISTOR_PULLUP:

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;

break;

default:

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

}

//Initialize

GPIO_Init(PinToPort(Pin), &GPIO_InitStructure);

return TRUE;

}

BOOL CPU_GPIO_GetPinState( GPIO_PIN Pin )

{

return GPIO_ReadInputDataBit(PinToPort(Pin), PinToBit(Pin));

}

void CPU_GPIO_SetPinState( GPIO_PIN Pin, BOOL PinState )

{

if(PinState == FALSE)

{

//Output low level

GPIO_ResetBits(PinToPort(Pin), PinToBit(Pin));

}

else

{

//Output high level

GPIO_SetBits(PinToPort(Pin), PinToBit(Pin));

}

}

BOOL CPU_GPIO_PinIsBusy( GPIO_PIN Pin )

{

return FALSE;

}

BOOL CPU_GPIO_ReservePin( GPIO_PIN Pin, BOOL fReserve )

{

return FALSE;

}

UINT32 CPU_GPIO_GetDebounce()

{

return 0;

}

BOOL CPU_GPIO_SetDebounce( INT64 debounceTimeMilliseconds )

{

return FALSE;

}

INT32 CPU_GPIO_GetPinCount()

{

return 112; // 7 * 16

}

void CPU_GPIO_GetPinsMap( UINT8* pins, size_t size )

{

pins = NULL;

}

UINT8 CPU_GPIO_GetSupportedResistorModes( GPIO_PIN pin )

{

// as it is stub, return 0;

return 0;

}

UINT8 CPU_GPIO_GetSupportedInterruptModes( GPIO_PIN pin )

{

// as it is stub, return 0;

return 0;

}

    4. stubs_functions_gpio.cpp用到了GPIO_Adapter檔案,該檔案是作為.NET Micro Framework Porting和stm32f10x_stdperiph_lib連接配接的橋梁,其具體實作如下:

     頭檔案GPIO_Adapter.h:

#include <tinyhal.h>

#include "stm32f10x_conf.h"

//The gpio pin

#define GPIO_A00 ((GPIO_PIN)0x00000001)

#define GPIO_A01 ((GPIO_PIN)0x00000002)

#define GPIO_A02 ((GPIO_PIN)0x00000004)

#define GPIO_A03 ((GPIO_PIN)0x00000008)

#define GPIO_A04 ((GPIO_PIN)0x00000010)

#define GPIO_A05 ((GPIO_PIN)0x00000020)

#define GPIO_A06 ((GPIO_PIN)0x00000040)

#define GPIO_A07 ((GPIO_PIN)0x00000080)

#define GPIO_A08 ((GPIO_PIN)0x00000100)

#define GPIO_A09 ((GPIO_PIN)0x00000200)

#define GPIO_A10 ((GPIO_PIN)0x00000400)

#define GPIO_A11 ((GPIO_PIN)0x00000800)

#define GPIO_A12 ((GPIO_PIN)0x00001000)

#define GPIO_A13 ((GPIO_PIN)0x00002000)

#define GPIO_A14 ((GPIO_PIN)0x00004000)

#define GPIO_A15 ((GPIO_PIN)0x00008000)

#define GPIO_A_ALL ((GPIO_PIN)0x0000FFFF)

#define GPIO_B00 ((GPIO_PIN)0x00010001)

#define GPIO_B01 ((GPIO_PIN)0x00010002)

#define GPIO_B02 ((GPIO_PIN)0x00010004)

#define GPIO_B03 ((GPIO_PIN)0x00010008)

#define GPIO_B04 ((GPIO_PIN)0x00010010)

#define GPIO_B05 ((GPIO_PIN)0x00010020)

#define GPIO_B06 ((GPIO_PIN)0x00010040)

#define GPIO_B07 ((GPIO_PIN)0x00010080)

#define GPIO_B08 ((GPIO_PIN)0x00010100)

#define GPIO_B09 ((GPIO_PIN)0x00010200)

#define GPIO_B10 ((GPIO_PIN)0x00010400)

#define GPIO_B11 ((GPIO_PIN)0x00010800)

#define GPIO_B12 ((GPIO_PIN)0x00011000)

#define GPIO_B13 ((GPIO_PIN)0x00012000)

#define GPIO_B14 ((GPIO_PIN)0x00014000)

#define GPIO_B15 ((GPIO_PIN)0x00018000)

#define GPIO_B_ALL ((GPIO_PIN)0x0001FFFF)

#define GPIO_C00 ((GPIO_PIN)0x00020001)

#define GPIO_C01 ((GPIO_PIN)0x00020002)

#define GPIO_C02 ((GPIO_PIN)0x00020004)

#define GPIO_C03 ((GPIO_PIN)0x00020008)

#define GPIO_C04 ((GPIO_PIN)0x00020010)

#define GPIO_C05 ((GPIO_PIN)0x00020020)

#define GPIO_C06 ((GPIO_PIN)0x00020040)

#define GPIO_C07 ((GPIO_PIN)0x00020080)

#define GPIO_C08 ((GPIO_PIN)0x00020100)

#define GPIO_C09 ((GPIO_PIN)0x00020200)

#define GPIO_C10 ((GPIO_PIN)0x00020400)

#define GPIO_C11 ((GPIO_PIN)0x00020800)

#define GPIO_C12 ((GPIO_PIN)0x00021000)

#define GPIO_C13 ((GPIO_PIN)0x00022000)

#define GPIO_C14 ((GPIO_PIN)0x00024000)

#define GPIO_C15 ((GPIO_PIN)0x00028000)

#define GPIO_C_ALL ((GPIO_PIN)0x0002FFFF)

#define GPIO_D00 ((GPIO_PIN)0x00030001)

#define GPIO_D01 ((GPIO_PIN)0x00030002)

#define GPIO_D02 ((GPIO_PIN)0x00030004)

#define GPIO_D03 ((GPIO_PIN)0x00030008)

#define GPIO_D04 ((GPIO_PIN)0x00030010)

#define GPIO_D05 ((GPIO_PIN)0x00030020)

#define GPIO_D06 ((GPIO_PIN)0x00030040)

#define GPIO_D07 ((GPIO_PIN)0x00030080)

#define GPIO_D08 ((GPIO_PIN)0x00030100)

#define GPIO_D09 ((GPIO_PIN)0x00030200)

#define GPIO_D10 ((GPIO_PIN)0x00030400)

#define GPIO_D11 ((GPIO_PIN)0x00030800)

#define GPIO_D12 ((GPIO_PIN)0x00031000)

#define GPIO_D13 ((GPIO_PIN)0x00032000)

#define GPIO_D14 ((GPIO_PIN)0x00034000)

#define GPIO_D15 ((GPIO_PIN)0x00038000)

#define GPIO_D_ALL ((GPIO_PIN)0x0003FFFF)

#define GPIO_E00 ((GPIO_PIN)0x00040001)

#define GPIO_E01 ((GPIO_PIN)0x00040002)

#define GPIO_E02 ((GPIO_PIN)0x00040004)

#define GPIO_E03 ((GPIO_PIN)0x00040008)

#define GPIO_E04 ((GPIO_PIN)0x00040010)

#define GPIO_E05 ((GPIO_PIN)0x00040020)

#define GPIO_E06 ((GPIO_PIN)0x00040040)

#define GPIO_E07 ((GPIO_PIN)0x00040080)

#define GPIO_E08 ((GPIO_PIN)0x00040100)

#define GPIO_E09 ((GPIO_PIN)0x00040200)

#define GPIO_E10 ((GPIO_PIN)0x00040400)

#define GPIO_E11 ((GPIO_PIN)0x00040800)

#define GPIO_E12 ((GPIO_PIN)0x00041000)

#define GPIO_E13 ((GPIO_PIN)0x00042000)

#define GPIO_E14 ((GPIO_PIN)0x00044000)

#define GPIO_E15 ((GPIO_PIN)0x00048000)

#define GPIO_E_ALL ((GPIO_PIN)0x0004FFFF)

#define GPIO_F00 ((GPIO_PIN)0x00050001)

#define GPIO_F01 ((GPIO_PIN)0x00050002)

#define GPIO_F02 ((GPIO_PIN)0x00050004)

#define GPIO_F03 ((GPIO_PIN)0x00050008)

#define GPIO_F04 ((GPIO_PIN)0x00050010)

#define GPIO_F05 ((GPIO_PIN)0x00050020)

#define GPIO_F06 ((GPIO_PIN)0x00050040)

#define GPIO_F07 ((GPIO_PIN)0x00050080)

#define GPIO_F08 ((GPIO_PIN)0x00050100)

#define GPIO_F09 ((GPIO_PIN)0x00050200)

#define GPIO_F10 ((GPIO_PIN)0x00050400)

#define GPIO_F11 ((GPIO_PIN)0x00050800)

#define GPIO_F12 ((GPIO_PIN)0x00051000)

#define GPIO_F13 ((GPIO_PIN)0x00052000)

#define GPIO_F14 ((GPIO_PIN)0x00054000)

#define GPIO_F15 ((GPIO_PIN)0x00058000)

#define GPIO_F_ALL ((GPIO_PIN)0x0005FFFF)

#define GPIO_G00 ((GPIO_PIN)0x00060001)

#define GPIO_G01 ((GPIO_PIN)0x00060002)

#define GPIO_G02 ((GPIO_PIN)0x00060004)

#define GPIO_G03 ((GPIO_PIN)0x00060008)

#define GPIO_G04 ((GPIO_PIN)0x00060010)

#define GPIO_G05 ((GPIO_PIN)0x00060020)

#define GPIO_G06 ((GPIO_PIN)0x00060040)

#define GPIO_G07 ((GPIO_PIN)0x00060080)

#define GPIO_G08 ((GPIO_PIN)0x00060100)

#define GPIO_G09 ((GPIO_PIN)0x00060200)

#define GPIO_G10 ((GPIO_PIN)0x00060400)

#define GPIO_G11 ((GPIO_PIN)0x00060800)

#define GPIO_G12 ((GPIO_PIN)0x00061000)

#define GPIO_G13 ((GPIO_PIN)0x00062000)

#define GPIO_G14 ((GPIO_PIN)0x00064000)

#define GPIO_G15 ((GPIO_PIN)0x00068000)

#define GPIO_G_ALL ((GPIO_PIN)0x0006FFFF)

//--------------------------------------------------------

//Description:

// Convert the input pin to GPIO_TypeDef value.

//Parameters:

// pin : [in] The input GPIO pin value

//--------------------------------------------------------

GPIO_TypeDef* PinToPort(GPIO_PIN pin);

//--------------------------------------------------------

//Description:

// Convert the input pin to stm32f10x port bit value.

//Parameters:

// pin : [in] The input GPIO pin value

//--------------------------------------------------------

uint16_t PinToBit(GPIO_PIN pin);

//--------------------------------------------------------

//Description:

// To check the input GPIO_PIN is valid or not

//Parameters:

// pin : [in] The input GPIO pin value

//--------------------------------------------------------

BOOL IsValidPin(GPIO_PIN pin);

     實作檔案GPIO_Adapter.cpp:

#include "GPIO_Adapter.h"

GPIO_TypeDef* PinToPort(GPIO_PIN pin)

{

switch((pin >> 16) & 0xFF)

{

case 00:

return GPIOA;

case 01:

return GPIOB;

case 02:

return GPIOC;

case 03:

return GPIOD;

case 04:

return GPIOE;

case 05:

return GPIOF;

case 06:

return GPIOG;

default:

return NULL;

}

}

uint16_t PinToBit(GPIO_PIN pin)

{

return static_cast<uint16_t>(pin & 0xFFFF);

}

BOOL IsValidPin(GPIO_PIN pin)

{

if(IS_GPIO_ALL_PERIPH(PinToPort(pin)) != FALSE &&

IS_GPIO_PIN(PinToBit(pin)) != FALSE)

{

return TRUE;

}

else

{

return FALSE;

}

}

    5.為了測試這個GPIO,我們還需要對NativeSample.proj進行設定。

    原語句:

<ItemGroup>

<DriverLibs Include="cpu_gpio_stubs.$(LIB_EXT)" />

<RequiredProjects Include="$(SPOCLIENT)/DeviceCode/Drivers/stubs/processor/stubs_GPIO/dotNetMF.proj" />

  </ItemGroup>

    更改為:

<ItemGroup>

    <DriverLibs Include="GPIO_HAL_STM32F103ZE_RedCow.$(LIB_EXT)" />

<RequiredProjects Include="$(SPOCLIENT)/Solutions/STM32F103ZE_RedCow/DeviceCode/GPIO_HAL/dotNetMF.proj" />

</ItemGroup>

    在</Project>之前增加如下語句:

  <ItemGroup>  

   <IncludePaths Include="Solutions/STM32F103ZE_RedCow/DeviceCode/GPIO_HAL" />

  </ItemGroup> 

     6.萬事俱備,隻欠東風。我們現在要做的,就是修改NativeSample.cpp代碼,讓程式跑起來的時候,LED1不停地閃爍,而LED2隻有在USER1按鈕按下時,才會發亮。具體的代碼如下:

// Copyright (c) Microsoft Corporation. All rights reserved.

#include <tinyhal.h>

#include <Tests.h>

#include "nativesample.h"

#include "GPIO_Adapter.h"

//--//

HAL_DECLARE_NULL_HEAP();

void ApplicationEntryPoint()

{

//不要删除下面這個語句,否則會編譯出錯

UART usartTest ( COMTestPort, 9600, USART_PARITY_NONE, 8, USART_STOP_BITS_ONE, USART_FLOW_NONE );

//Initialize the GPIO

CPU_GPIO_Initialize();

//Enable the GPIO output pin

CPU_GPIO_EnableOutputPin(GPIO_F06,TRUE);

CPU_GPIO_EnableOutputPin(GPIO_F07,TRUE);

CPU_GPIO_EnableInputPin(GPIO_A08,FALSE,NULL,GPIO_INT_NONE,RESISTOR_DISABLED);

while(TRUE)

{

for(long i=0;i<1000000;i++);

CPU_GPIO_SetPinState(GPIO_F06,!CPU_GPIO_GetPinState(GPIO_F06));

CPU_GPIO_SetPinState(GPIO_F07,CPU_GPIO_GetPinState(GPIO_A08));

}

}

繼續閱讀