forked from trocache/RefKEIL
Added read/write functions and toggle.
This commit is contained in:
parent
bfa10cb61f
commit
66b6dcad8b
3 changed files with 83 additions and 41 deletions
|
@ -3,11 +3,16 @@
|
||||||
|
|
||||||
int main ( void )
|
int main ( void )
|
||||||
{
|
{
|
||||||
int returnValue=0;
|
int returnValue;
|
||||||
MyGPIO_Struct_TypeDef gpioA_test = {GPIOB,8,In_PullDown};
|
MyGPIO_Struct_TypeDef gpioB8_test = {GPIOB,8,In_PullDown};
|
||||||
MyGPIO_Init(&gpioA_test);
|
MyGPIO_Struct_TypeDef gpioB4_test = {GPIOB,4,Out_PullUp};
|
||||||
|
MyGPIO_Init(&gpioB8_test);
|
||||||
returnValue = MyGPIO_Read(GPIOB,8);
|
returnValue = MyGPIO_Read(GPIOB,8);
|
||||||
returnValue = returnValue;
|
MyGPIO_Init(&gpioB4_test);
|
||||||
|
MyGPIO_Set(GPIOB,4);
|
||||||
|
MyGPIO_Toggle(GPIOB,4);
|
||||||
|
MyGPIO_Toggle(GPIOB,4);
|
||||||
|
MyGPIO_Reset(GPIOB,4);
|
||||||
do{
|
do{
|
||||||
}while(1) ;
|
}while(1) ;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ void MyGPIO_Init(MyGPIO_Struct_TypeDef * GPIOStructPtr)
|
||||||
uint8_t voyons = GPIOStructPtr->GPIO_Pin;
|
uint8_t voyons = GPIOStructPtr->GPIO_Pin;
|
||||||
RCC->APB2ENR |= GPIO2Int(GPIOStructPtr->GPIO);
|
RCC->APB2ENR |= GPIO2Int(GPIOStructPtr->GPIO);
|
||||||
//We get the pointer of the CRH/CRL depending on the IO_Pin number
|
//We get the pointer of the CRH/CRL depending on the IO_Pin number
|
||||||
volatile uint32_t * CRAny = GPIOStructPtr->GPIO_Pin > 0x08 ? &(GPIOStructPtr->GPIO->CRH):&(GPIOStructPtr->GPIO->CRL);
|
volatile uint32_t * CRAny = GPIOStructPtr->GPIO_Pin >= 0x08 ? &(GPIOStructPtr->GPIO->CRH):&(GPIOStructPtr->GPIO->CRL);
|
||||||
//setup high or low
|
//setup high or low
|
||||||
*CRAny &= ~(0xF << (GPIOStructPtr->GPIO_Pin%8)*4); //reset
|
*CRAny &= ~(0xF << (GPIOStructPtr->GPIO_Pin%8)*4); //reset
|
||||||
//for input pull or push
|
//for input pull or push
|
||||||
|
@ -30,17 +30,22 @@ int MyGPIO_Read(GPIO_TypeDef * GPIO, uint8_t GPIO_Pin)
|
||||||
|
|
||||||
void MyGPIO_Set(GPIO_TypeDef * GPIO, uint8_t GPIO_Pin)
|
void MyGPIO_Set(GPIO_TypeDef * GPIO, uint8_t GPIO_Pin)
|
||||||
{
|
{
|
||||||
|
GPIO->BSRR = (1 << GPIO_Pin); //BSX set register
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyGPIO_Reset(GPIO_TypeDef * GPIO, uint8_t GPIO_Pin)
|
void MyGPIO_Reset(GPIO_TypeDef * GPIO, uint8_t GPIO_Pin)
|
||||||
{
|
{
|
||||||
|
GPIO->BSRR = (1 << (GPIO_Pin+0x16)); //BRX = BSX+16 reset register
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyGPIO_Toggle(GPIO_TypeDef * GPIO, uint8_t GPIO_Pin)
|
void MyGPIO_Toggle(GPIO_TypeDef * GPIO, uint8_t GPIO_Pin)
|
||||||
{
|
{
|
||||||
|
if((GPIO->ODR = GPIO->ODR & (1 << GPIO_Pin)) > 0)
|
||||||
|
{
|
||||||
|
GPIO->BSRR = (1 << (GPIO_Pin+0x16)); //reset
|
||||||
|
} else {
|
||||||
|
GPIO->BSRR = (1 << GPIO_Pin); //set
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int GPIO2Int(GPIO_TypeDef * GPIOX)
|
int GPIO2Int(GPIO_TypeDef * GPIOX)
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
<OPTFL>
|
<OPTFL>
|
||||||
<tvExp>1</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<IsCurrentTarget>0</IsCurrentTarget>
|
<IsCurrentTarget>1</IsCurrentTarget>
|
||||||
</OPTFL>
|
</OPTFL>
|
||||||
<CpuCode>18</CpuCode>
|
<CpuCode>18</CpuCode>
|
||||||
<DebugOpt>
|
<DebugOpt>
|
||||||
|
@ -125,7 +125,7 @@
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Key>DLGDARM</Key>
|
<Key>DLGDARM</Key>
|
||||||
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=1499,115,1920,542,1)(121=-1,-1,-1,-1,0)(122=875,109,1296,536,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)</Name>
|
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=1468,53,1889,480,1)(121=1469,437,1890,864,1)(122=875,109,1296,536,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)</Name>
|
||||||
</SetRegEntry>
|
</SetRegEntry>
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
|
@ -142,9 +142,9 @@
|
||||||
<Bp>
|
<Bp>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Type>0</Type>
|
<Type>0</Type>
|
||||||
<LineNumber>10</LineNumber>
|
<LineNumber>15</LineNumber>
|
||||||
<EnabledFlag>1</EnabledFlag>
|
<EnabledFlag>1</EnabledFlag>
|
||||||
<Address>134218742</Address>
|
<Address>134218832</Address>
|
||||||
<ByteObject>0</ByteObject>
|
<ByteObject>0</ByteObject>
|
||||||
<HtxType>0</HtxType>
|
<HtxType>0</HtxType>
|
||||||
<ManyObjects>0</ManyObjects>
|
<ManyObjects>0</ManyObjects>
|
||||||
|
@ -153,14 +153,14 @@
|
||||||
<BreakIfRCount>1</BreakIfRCount>
|
<BreakIfRCount>1</BreakIfRCount>
|
||||||
<Filename>.\Source\Principale.c</Filename>
|
<Filename>.\Source\Principale.c</Filename>
|
||||||
<ExecCommand></ExecCommand>
|
<ExecCommand></ExecCommand>
|
||||||
<Expression>\\cool_Simule\Source/Principale.c\10</Expression>
|
<Expression>\\cool_Simule\Source/Principale.c\15</Expression>
|
||||||
</Bp>
|
</Bp>
|
||||||
<Bp>
|
<Bp>
|
||||||
<Number>1</Number>
|
<Number>1</Number>
|
||||||
<Type>0</Type>
|
<Type>0</Type>
|
||||||
<LineNumber>9</LineNumber>
|
<LineNumber>13</LineNumber>
|
||||||
<EnabledFlag>1</EnabledFlag>
|
<EnabledFlag>1</EnabledFlag>
|
||||||
<Address>134218734</Address>
|
<Address>134218816</Address>
|
||||||
<ByteObject>0</ByteObject>
|
<ByteObject>0</ByteObject>
|
||||||
<HtxType>0</HtxType>
|
<HtxType>0</HtxType>
|
||||||
<ManyObjects>0</ManyObjects>
|
<ManyObjects>0</ManyObjects>
|
||||||
|
@ -169,14 +169,14 @@
|
||||||
<BreakIfRCount>1</BreakIfRCount>
|
<BreakIfRCount>1</BreakIfRCount>
|
||||||
<Filename>.\Source\Principale.c</Filename>
|
<Filename>.\Source\Principale.c</Filename>
|
||||||
<ExecCommand></ExecCommand>
|
<ExecCommand></ExecCommand>
|
||||||
<Expression>\\cool_Simule\Source/Principale.c\9</Expression>
|
<Expression>\\cool_Simule\Source/Principale.c\13</Expression>
|
||||||
</Bp>
|
</Bp>
|
||||||
<Bp>
|
<Bp>
|
||||||
<Number>2</Number>
|
<Number>2</Number>
|
||||||
<Type>0</Type>
|
<Type>0</Type>
|
||||||
<LineNumber>6</LineNumber>
|
<LineNumber>14</LineNumber>
|
||||||
<EnabledFlag>1</EnabledFlag>
|
<EnabledFlag>1</EnabledFlag>
|
||||||
<Address>134218718</Address>
|
<Address>134218824</Address>
|
||||||
<ByteObject>0</ByteObject>
|
<ByteObject>0</ByteObject>
|
||||||
<HtxType>0</HtxType>
|
<HtxType>0</HtxType>
|
||||||
<ManyObjects>0</ManyObjects>
|
<ManyObjects>0</ManyObjects>
|
||||||
|
@ -185,39 +185,23 @@
|
||||||
<BreakIfRCount>1</BreakIfRCount>
|
<BreakIfRCount>1</BreakIfRCount>
|
||||||
<Filename>.\Source\Principale.c</Filename>
|
<Filename>.\Source\Principale.c</Filename>
|
||||||
<ExecCommand></ExecCommand>
|
<ExecCommand></ExecCommand>
|
||||||
<Expression>\\cool_Simule\Source/Principale.c\6</Expression>
|
<Expression>\\cool_Simule\Source/Principale.c\14</Expression>
|
||||||
</Bp>
|
</Bp>
|
||||||
<Bp>
|
<Bp>
|
||||||
<Number>3</Number>
|
<Number>3</Number>
|
||||||
<Type>0</Type>
|
<Type>0</Type>
|
||||||
<LineNumber>22</LineNumber>
|
<LineNumber>12</LineNumber>
|
||||||
<EnabledFlag>1</EnabledFlag>
|
<EnabledFlag>1</EnabledFlag>
|
||||||
<Address>134218326</Address>
|
<Address>134218808</Address>
|
||||||
<ByteObject>0</ByteObject>
|
<ByteObject>0</ByteObject>
|
||||||
<HtxType>0</HtxType>
|
<HtxType>0</HtxType>
|
||||||
<ManyObjects>0</ManyObjects>
|
<ManyObjects>0</ManyObjects>
|
||||||
<SizeOfObject>0</SizeOfObject>
|
<SizeOfObject>0</SizeOfObject>
|
||||||
<BreakByAccess>0</BreakByAccess>
|
<BreakByAccess>0</BreakByAccess>
|
||||||
<BreakIfRCount>1</BreakIfRCount>
|
<BreakIfRCount>1</BreakIfRCount>
|
||||||
<Filename>.\gpiodriver.c</Filename>
|
<Filename>.\Source\Principale.c</Filename>
|
||||||
<ExecCommand></ExecCommand>
|
<ExecCommand></ExecCommand>
|
||||||
<Expression>\\cool_Simule\gpiodriver.c\22</Expression>
|
<Expression>\\cool_Simule\Source/Principale.c\12</Expression>
|
||||||
</Bp>
|
|
||||||
<Bp>
|
|
||||||
<Number>4</Number>
|
|
||||||
<Type>0</Type>
|
|
||||||
<LineNumber>4</LineNumber>
|
|
||||||
<EnabledFlag>1</EnabledFlag>
|
|
||||||
<Address>134218164</Address>
|
|
||||||
<ByteObject>0</ByteObject>
|
|
||||||
<HtxType>0</HtxType>
|
|
||||||
<ManyObjects>0</ManyObjects>
|
|
||||||
<SizeOfObject>0</SizeOfObject>
|
|
||||||
<BreakByAccess>0</BreakByAccess>
|
|
||||||
<BreakIfRCount>1</BreakIfRCount>
|
|
||||||
<Filename>.\gpiodriver.c</Filename>
|
|
||||||
<ExecCommand></ExecCommand>
|
|
||||||
<Expression>\\cool_Simule\gpiodriver.c\4</Expression>
|
|
||||||
</Bp>
|
</Bp>
|
||||||
</Breakpoint>
|
</Breakpoint>
|
||||||
<WatchWindow1>
|
<WatchWindow1>
|
||||||
|
@ -279,6 +263,10 @@
|
||||||
<Name>System Viewer\GPIOA</Name>
|
<Name>System Viewer\GPIOA</Name>
|
||||||
<WinId>35905</WinId>
|
<WinId>35905</WinId>
|
||||||
</Entry>
|
</Entry>
|
||||||
|
<Entry>
|
||||||
|
<Name>System Viewer\GPIOB</Name>
|
||||||
|
<WinId>35904</WinId>
|
||||||
|
</Entry>
|
||||||
</SystemViewers>
|
</SystemViewers>
|
||||||
<DebugDescription>
|
<DebugDescription>
|
||||||
<Enable>1</Enable>
|
<Enable>1</Enable>
|
||||||
|
@ -344,7 +332,7 @@
|
||||||
<OPTFL>
|
<OPTFL>
|
||||||
<tvExp>1</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<IsCurrentTarget>1</IsCurrentTarget>
|
<IsCurrentTarget>0</IsCurrentTarget>
|
||||||
</OPTFL>
|
</OPTFL>
|
||||||
<CpuCode>18</CpuCode>
|
<CpuCode>18</CpuCode>
|
||||||
<DebugOpt>
|
<DebugOpt>
|
||||||
|
@ -422,13 +410,51 @@
|
||||||
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM))</Name>
|
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM))</Name>
|
||||||
</SetRegEntry>
|
</SetRegEntry>
|
||||||
</TargetDriverDllRegistry>
|
</TargetDriverDllRegistry>
|
||||||
<Breakpoint/>
|
<Breakpoint>
|
||||||
|
<Bp>
|
||||||
|
<Number>0</Number>
|
||||||
|
<Type>0</Type>
|
||||||
|
<LineNumber>6</LineNumber>
|
||||||
|
<EnabledFlag>1</EnabledFlag>
|
||||||
|
<Address>134218782</Address>
|
||||||
|
<ByteObject>0</ByteObject>
|
||||||
|
<HtxType>0</HtxType>
|
||||||
|
<ManyObjects>0</ManyObjects>
|
||||||
|
<SizeOfObject>0</SizeOfObject>
|
||||||
|
<BreakByAccess>0</BreakByAccess>
|
||||||
|
<BreakIfRCount>1</BreakIfRCount>
|
||||||
|
<Filename>.\Source\Principale.c</Filename>
|
||||||
|
<ExecCommand></ExecCommand>
|
||||||
|
<Expression>\\cool_reel\Source/Principale.c\6</Expression>
|
||||||
|
</Bp>
|
||||||
|
<Bp>
|
||||||
|
<Number>1</Number>
|
||||||
|
<Type>0</Type>
|
||||||
|
<LineNumber>10</LineNumber>
|
||||||
|
<EnabledFlag>1</EnabledFlag>
|
||||||
|
<Address>134218808</Address>
|
||||||
|
<ByteObject>0</ByteObject>
|
||||||
|
<HtxType>0</HtxType>
|
||||||
|
<ManyObjects>0</ManyObjects>
|
||||||
|
<SizeOfObject>0</SizeOfObject>
|
||||||
|
<BreakByAccess>0</BreakByAccess>
|
||||||
|
<BreakIfRCount>1</BreakIfRCount>
|
||||||
|
<Filename>.\Source\Principale.c</Filename>
|
||||||
|
<ExecCommand></ExecCommand>
|
||||||
|
<Expression>\\cool_reel\Source/Principale.c\10</Expression>
|
||||||
|
</Bp>
|
||||||
|
</Breakpoint>
|
||||||
<WatchWindow1>
|
<WatchWindow1>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>0</count>
|
<count>0</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>quelquechose</ItemText>
|
<ItemText>quelquechose</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>1</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>returnValue</ItemText>
|
||||||
|
</Ww>
|
||||||
</WatchWindow1>
|
</WatchWindow1>
|
||||||
<Tracepoint>
|
<Tracepoint>
|
||||||
<THDelay>0</THDelay>
|
<THDelay>0</THDelay>
|
||||||
|
@ -472,6 +498,12 @@
|
||||||
<pszMrulep></pszMrulep>
|
<pszMrulep></pszMrulep>
|
||||||
<pSingCmdsp></pSingCmdsp>
|
<pSingCmdsp></pSingCmdsp>
|
||||||
<pMultCmdsp></pMultCmdsp>
|
<pMultCmdsp></pMultCmdsp>
|
||||||
|
<SystemViewers>
|
||||||
|
<Entry>
|
||||||
|
<Name>System Viewer\GPIOB</Name>
|
||||||
|
<WinId>35905</WinId>
|
||||||
|
</Entry>
|
||||||
|
</SystemViewers>
|
||||||
<DebugDescription>
|
<DebugDescription>
|
||||||
<Enable>1</Enable>
|
<Enable>1</Enable>
|
||||||
<EnableFlashSeq>0</EnableFlashSeq>
|
<EnableFlashSeq>0</EnableFlashSeq>
|
||||||
|
|
Loading…
Reference in a new issue