Choco OS  V.0.16.9.0
Join to the chocolate world
oc_gpio.h File Reference

The file with interface for the GPIO driver. More...

#include <oc_driver.h>
#include <oc_gpio_lld.h>

Go to the source code of this file.

Data Structures

struct  oC_GPIO_Config_t
 GPIO driver configuration structure. More...
 

Typedefs

typedef oC_Pins_t * oC_GPIO_Context_t
 The GPIO context structure. More...
 

Enumerations

Functions

oC_ErrorCode_t oC_GPIO_TurnOn (void)
 turns on the module More...
 
oC_ErrorCode_t oC_GPIO_TurnOff (void)
 Turns off the GPIO driver. More...
 
bool oC_GPIO_IsTurnedOn (void)
 checks if the driver is turned on More...
 
oC_ErrorCode_t oC_GPIO_Configure (const oC_GPIO_Config_t *Config, oC_GPIO_Context_t *outContext)
 configures GPIO pins to work More...
 
oC_ErrorCode_t oC_GPIO_Unconfigure (const oC_GPIO_Config_t *Config, oC_GPIO_Context_t *outContext)
 Restores default state on pins. More...
 
oC_ErrorCode_t oC_GPIO_SetSpeed (oC_Pins_t Pins, oC_GPIO_Speed_t Speed)
 configures speed of pin(s) More...
 
oC_ErrorCode_t oC_GPIO_ReadSpeed (oC_Pins_t Pins, oC_GPIO_Speed_t *outSpeed)
 reads configured speed More...
 
oC_ErrorCode_t oC_GPIO_SetCurrent (oC_Pins_t Pins, oC_GPIO_Current_t Current)
 configures current of pin(s) More...
 
oC_ErrorCode_t oC_GPIO_ReadCurrent (oC_Pins_t Pins, oC_GPIO_Current_t *outCurrent)
 reads configured current More...
 
oC_ErrorCode_t oC_GPIO_SetMode (oC_Pins_t Pins, oC_GPIO_Mode_t Mode)
 configures mode of pin(s) More...
 
oC_ErrorCode_t oC_GPIO_ReadMode (oC_Pins_t Pins, oC_GPIO_Mode_t *outMode)
 reads mode configuration More...
 
oC_ErrorCode_t oC_GPIO_SetPull (oC_Pins_t Pins, oC_GPIO_Pull_t Pull)
 configures pull for pin(s) More...
 
oC_ErrorCode_t oC_GPIO_ReadPull (oC_Pins_t Pins, oC_GPIO_Pull_t *outPull)
 reads pull configuration More...
 
oC_ErrorCode_t oC_GPIO_SetOutputCircuit (oC_Pins_t Pins, oC_GPIO_OutputCircuit_t OutputCircuit)
 configures output circuit More...
 
oC_ErrorCode_t oC_GPIO_ReadOutputCircuit (oC_Pins_t Pins, oC_GPIO_OutputCircuit_t *outOutputCircuit)
 reads output circuit configuration More...
 
oC_ErrorCode_t oC_GPIO_SetInterruptTrigger (oC_Pins_t Pins, oC_GPIO_IntTrigger_t InterruptTrigger)
 configures interrupt for pin(s) More...
 
oC_ErrorCode_t oC_GPIO_ReadInterruptTrigger (oC_Pins_t Pins, oC_GPIO_IntTrigger_t *outInterruptTrigger)
 reads interrupt trigger More...
 
oC_ErrorCode_t oC_GPIO_FindPinByName (const char *Name, oC_Pin_t *outPin)
 searching pin by its name More...
 
oC_ErrorCode_t oC_GPIO_WaitForPins (oC_Pins_t Pins, oC_Time_t Timeout)
 waits for interrupt in the pins
 
const char * oC_GPIO_GetPinName (oC_Pin_t Pin)
 returns name of the pin More...
 
oC_ErrorCode_t oC_GPIO_IsPortCorrect (oC_Port_t Port)
 checks if the GPIO port is correct More...
 
oC_ErrorCode_t oC_GPIO_IsPortIndexCorrect (oC_PortIndex_t PortIndex)
 checks if the GPIO port index is correct More...
 
oC_PinsMask_t oC_GPIO_GetPinsMaskOfPins (oC_Pins_t Pins)
 returns pins mask of pins More...
 
oC_Port_t oC_GPIO_GetPortOfPins (oC_Pins_t Pins)
 returns port of pins More...
 
oC_PortIndex_t oC_GPIO_PortToPortIndex (oC_Port_t Port)
 converts port to port index More...
 
oC_Port_t oC_GPIO_PortIndexToPort (oC_PortIndex_t PortIndex)
 converts port index to port More...
 
bool oC_GPIO_IsPinDefined (oC_Pins_t Pin)
 checks if the pin is defined (only one pin) More...
 
bool oC_GPIO_ArePinsDefined (oC_Pins_t Pins)
 checks if pins are defined More...
 
bool oC_GPIO_ArePinsCorrect (oC_Pins_t Pins)
 checks if pins are correct More...
 
bool oC_GPIO_IsSinglePin (oC_Pins_t Pins)
 checks if there is only one pin in pins variable More...
 
oC_Pins_t oC_GPIO_GetPinsFor (oC_Port_t Port, oC_PinsMask_t Pins)
 connect port and pins to one variable More...
 
const char * oC_GPIO_GetPortName (oC_Port_t Port)
 returns name of the port More...
 
const char * oC_GPIO_GetPinName (oC_Pins_t Pin)
 returns name of the pin More...
 
oC_ErrorCode_t oC_GPIO_SetPower (oC_Pins_t Pins, oC_Power_t Power)
 sets power for a port More...
 
oC_ErrorCode_t oC_GPIO_ReadPower (oC_Pins_t Pins, oC_Power_t *outPower)
 reads power state in a port More...
 
oC_ErrorCode_t oC_GPIO_CheckIsPinUsed (oC_Pins_t Pins, bool *outPinUsed)
 checks if the pin is used More...
 
oC_ErrorCode_t oC_GPIO_ArePinsUnused (oC_Pins_t Pins, bool *outPinsUnused)
 checks if all of pins are not used More...
 
oC_ErrorCode_t oC_GPIO_WriteData (oC_Pins_t Pins, oC_PinsMask_t Data)
 write data in port More...
 
oC_ErrorCode_t oC_GPIO_ReadData (oC_Pins_t Pins, oC_PinsMask_t *outData)
 reads data from port More...
 
oC_ErrorCode_t oC_GPIO_ReadDataReference (oC_Pins_t Pins, oC_UInt_t **outDataReference)
 reads reference to the GPIO data More...
 
oC_Pins_t oC_GPIO_GetHighStatePins (oC_Pins_t Pins)
 returns pins that are set to high state More...
 
oC_Pins_t oC_GPIO_GetLowStatePins (oC_Pins_t Pins)
 returns pins that are set to low state More...
 
bool oC_GPIO_IsPinsState (oC_Pins_t Pins, oC_GPIO_PinsState_t ExpectedPinsState)
 checks if all pins are set to state More...
 
void oC_GPIO_SetPinsState (oC_Pins_t Pins, oC_GPIO_PinsState_t PinsState)
 sets pins to the selected state More...
 
void oC_GPIO_TogglePinsState (oC_Pins_t Pins)
 toggles pins state More...
 

Detailed Description


Author
Patryk Kubiak - (Created on: 27 05 2015 21:03:16)
Note
Copyright (C) 2015 Patryk Kubiak patry.nosp@m.k.ku.nosp@m.biak9.nosp@m.0@gm.nosp@m.ail.c.nosp@m.om
           This program is free software; you can redistribute it and/or modify
           it under the terms of the GNU General Public License as published by
           the Free Software Foundation; either version 2 of the License, or
           (at your option) any later version.

           This program is distributed in the hope that it will be useful,
           but WITHOUT ANY WARRANTY; without even the implied warranty of
           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
           GNU General Public License for more details.

           You should have received a copy of the GNU General Public License
           along with this program; if not, write to the Free Software
           Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

Definition in file oc_gpio.h.

Typedef Documentation

typedef oC_Pins_t* oC_GPIO_Context_t

This is the structure with dynamic allocated data for the GPIO. It stores a HANDLE for a driver and it can be used to identify the driver context. You should get this pointer from the oC_GPIO_Configure function, but note, that not all drivers use it. In many cases it is just not needed, and it just will store NULL then. You should keep this pointer as long as it is necessary for you, and when it will not be anymore, you should call oC_GPIO_Unconfigure function to destroy it.

Definition at line 212 of file oc_gpio.h.

Enumeration Type Documentation

Type represents maximum output current for GPIO pin.

Enumerator
oC_GPIO_Current_Default 

Pin works with default current (not changed)

oC_GPIO_Current_Minimum 

Pin works with minimum current

oC_GPIO_Current_Medium 

Pin works with medium current

oC_GPIO_Current_Maximum 

Pin works with maximum current

Definition at line 82 of file oc_gpio.h.

Type represents GPIO interrupt trigger source.

Enumerator
oC_GPIO_IntTrigger_Default 

Pin works in default interrupt mode (not changed)

oC_GPIO_IntTrigger_Off 

Interrupts on this pin are turned off

oC_GPIO_IntTrigger_RisingEdge 

Interrupt on rising edge

oC_GPIO_IntTrigger_FallingEdge 

Interrupt on falling edge

oC_GPIO_IntTrigger_BothEdges 

Interrupt on both edges

oC_GPIO_IntTrigger_HighLevel 

Interrupt on high level

oC_GPIO_IntTrigger_LowLevel 

Interrupt on low level

oC_GPIO_IntTrigger_BothLevels 

Interrupt on both levels

Definition at line 141 of file oc_gpio.h.

Enumerator
oC_GPIO_Ioctl_Command_TogglePins 

Toggles pins state.

oC_GPIO_Ioctl_Command_SetPinsState 

set new pins state

oC_GPIO_Ioctl_Command_GetHighPinsState 

reads pins in high state

oC_GPIO_Ioctl_Command_GetLowPinsState 

reads pins in low state

Definition at line 172 of file oc_gpio.h.

Type represents mode of works for GPIO pin.

Enumerator
oC_GPIO_Mode_Default 

Pin works in default mode (not changed)

oC_GPIO_Mode_Input 

Pin works as input

oC_GPIO_Mode_Output 

Pin works as output

oC_GPIO_Mode_Alternate 

Pin works in alternative mode

Definition at line 97 of file oc_gpio.h.

Type represents GPIO output circuit mode ( Open Drain / PushPull )

Enumerator
oC_GPIO_OutputCircuit_OpenDrain 

open drain mode

oC_GPIO_OutputCircuit_PushPull 

push-pull mode

Definition at line 126 of file oc_gpio.h.

The type is for storing state of pins. This type is similar to the #oC_PinsMask_t type, and every bit in the variable is reserved for some pins.

Enumerator
oC_GPIO_PinsState_AllLow 

all pins are set to low state

oC_GPIO_PinsState_AllHigh 

all pins are set to high state

Definition at line 161 of file oc_gpio.h.

The type is for protection for configure special pins, like JTAG and NMI pins

Enumerator
oC_GPIO_Protection_DontUnlockProtectedPins 

Do not configure special pins

oC_GPIO_Protection_UnlockProtectedPins 

Configure special pins

Definition at line 52 of file oc_gpio.h.

Type represents GPIO pull mode, when the pin work as input.

Enumerator
oC_GPIO_Pull_Default 

Pin works with default pull mode (not changed)

oC_GPIO_Pull_Up 

Pull-up

oC_GPIO_Pull_Down 

Pull-down

Definition at line 112 of file oc_gpio.h.

The type represents maximum speed, that GPIO pins can be switched. When you do not need to very often switch you pin, you can use oC_GPIO_Speed_Minimum, and thanks to that, you can save some current.

Enumerator
oC_GPIO_Speed_Default 

Default value for oC_GPIO_Speed_t

oC_GPIO_Speed_Minimum 

Pin works with minimum speed

oC_GPIO_Speed_Medium 

Pin works with medium speed

oC_GPIO_Speed_Maximum 

Pin works with maximum speed

oC_GPIO_Speed_NumberOfElements 

Number of elements in oC_GPIO_Speed_t enum

Definition at line 66 of file oc_gpio.h.

Function Documentation

bool oC_GPIO_ArePinsCorrect ( oC_Pins_t  Pins)

The function checks if pins are correct, but not checks if each pin in the variable is defined.

Parameters
PinsOne or more pins from the same port
Returns
true if pins are correct
bool oC_GPIO_ArePinsDefined ( oC_Pins_t  Pins)

The function checks if all pins that are stored in the Pins argument are defined. It is important, that each pin should be from the same port. If any of pins will be from different port, then the function will return, that pins are not defined.

Parameters
Pinsvariable with pins from the same port
Returns
true if each pin stored in the Pins argument is defined
oC_ErrorCode_t oC_GPIO_ArePinsUnused ( oC_Pins_t  Pins,
bool *  outPinsUnused 
)

The function is for checking if the pin (or pins) are not in use. It is for protection before reconfiguration in the future. Note, that none of GPIO-LLD functions checks if pin is used during configuration - on this layer it is only a feature. The main driver should provide an interface to protect pins when it is necessary. To set pin as used see #oC_GPIO_SetPinUsed function.

Parameters
Pinsvariable with single or more pins from the same port
outPinsUnuseddestination for the output variable
See also
oC_GPIO_CheckIsPinUsed
Returns
code of error or #oC_ErrorCode_None if success
oC_ErrorCode_t oC_GPIO_CheckIsPinUsed ( oC_Pins_t  Pins,
bool *  outPinUsed 
)

The function is for checking if the pin is in use. It is for protection before reconfiguration in the future. Note, that none of GPIO-LLD functions checks if pin is used during configuration - on this layer it is only a feature. The main driver should provide an interface to protect pins when it is necessary. To set pin as used see #oC_GPIO_SetPinUsed function.

Parameters
Pinsvariable with single or more pins from the same port
outPinUseddestination for the output variable
Returns
code of error or #oC_ErrorCode_None if success
oC_ErrorCode_t oC_GPIO_Configure ( const oC_GPIO_Config_t Config,
oC_GPIO_Context_t outContext 
)

The function is for configuration of the driver. Look at the oC_GPIO_Config_t structure description and fields list to get more info.

Parameters
ConfigPointer to the configuration structure
outContextDestination for the driver context structure
Returns
code of error

Definition at line 207 of file oc_gpio.c.

oC_ErrorCode_t oC_GPIO_FindPinByName ( const char *  Name,
oC_Pin_t *  outPin 
)

The function is for searching a pin definition according to its name

Parameters
NameName of the pin to find (for example "PF4")
outPin[out] Destination for a pin
Returns
code of error

Example of usage:

oC_Pin_t pin = 0;
if(oC_GPIO_FindPinByName( "PF4" , &pin) == oC_ErrorCode_None")
{
printf("Found pin PF4!\n\r");
}
else
{
printf("Pin PF4 does not exist!\n\r");
}

Definition at line 1065 of file oc_gpio.c.

oC_Pins_t oC_GPIO_GetHighStatePins ( oC_Pins_t  Pins)

The function is for reading state of pins without arguments checking. It is little faster then the oC_GPIO_ReadData function, and can be more comfortable in use, but there is a risk, that if the Pins argument is not set correctly, then it can cause the hard fault on the machine. This function should be used only when the pins argument is correct.

Warning
This function does not check arguments, so it is important to set it properly, because if the port will be set incorrectly, there is a risk that it will cause a hard fault. You must call oC_GPIO_ArePinsCorrect function before it to ensure, that it will not happen.

Example of usage:

oC_Pins_t pins = oC_Pins_PA2 | oC_Pins_PA3;
if ( oC_GPIO_GetHighStatePins( pins ) == oC_Pins_PA2 )
{
// only the oC_Pins_PA2 pin is set to high!
}
Warning
This function returns list of pins, that are set to high state. If you want to simply check if all pins that are defined in the Pins argument are set to the given state - low or high, use oC_GPIO_IsPinsState function.
Parameters
Pinsvariable with single or more pins from the same port
Returns
pins that set from the Pins argument
oC_Pins_t oC_GPIO_GetLowStatePins ( oC_Pins_t  Pins)

The function is for reading state of pins without arguments checking. It is little faster then the oC_GPIO_ReadData function, and can be more comfortable in use, but there is a risk, that if the Pins argument is not set correctly, then it can cause the hard fault on the machine. This function should be used only when the pins argument is correct.

Warning
This function does not check arguments, so it is important to set it properly, because if the port will be set incorrectly, there is a risk that it will cause a hard fault. You must call oC_GPIO_ArePinsCorrect function before it to ensure, that it will not happen.

Example of usage:

oC_Pins_t pins = oC_Pins_PA2 | oC_Pins_PA3;
if ( oC_GPIO_GetLowStatePins( pins ) == oC_Pins_PA2 )
{
// only the oC_Pins_PA2 pin is set to low!
}
Warning
This function returns list of pins, that are set to low state. If you want to simply check if all pins that are defined in the Pins argument are set to the given state - low or high, use oC_GPIO_IsPinsState function.
Parameters
Pinsvariable with single or more pins from the same port
Returns
pins that set from the Pins argument
const char* oC_GPIO_GetPinName ( oC_Pin_t  Pin)

The function is for reading printable name of the given pin, or "unknown" if the pin is not correct. Note, that it works only for single pin and will not return correct value for more than one pin.

Parameters
PinVariable with single pin
Returns
constant string with name of a pin
const char* oC_GPIO_GetPinName ( oC_Pins_t  Pin)

The function is for reading printable name of the given pin, or "unknown" if the pin is not correct. Note, that it works only for single pin and will not return correct value for more than one pin.

Parameters
PinVariable with single pin
Returns
constant string with name of a pin
oC_Pins_t oC_GPIO_GetPinsFor ( oC_Port_t  Port,
oC_PinsMask_t  Pins 
)

The function is for connecting pins definitions and port to the one, special type #oC_Pins_t that stores this both informations.

Example of usage:

oC_Port_t port = oC_Port_PORTA;
oC_Pins_Mask_t pinsMask = oC_Pins_Mask_All;
oC_Pins_t pins = oC_GPIO_GetPinsFor( port , pinsMask );
Parameters
PortPort of the GPIO
PinsMask of pins that should be included to the #oC_Pins_t
Returns
connected port and pins definitions
oC_PinsMask_t oC_GPIO_GetPinsMaskOfPins ( oC_Pins_t  Pins)

The function returns pins mask from the #oC_Pins_t type. The pins mask is a mask with bits of port, that are used in this variable.

Example of usage:

1 oC_Pins_t pins = oC_Pins_PA2 | oC_Pins_PA3;
2 
3 oC_PinsMask_t pinsMask = oC_GPIO_GetPinsMaskOfPins(pins); // pinsMask = 0b00001100
Parameters
PinsVariable with one or more pins
Returns
bit mask
const char* oC_GPIO_GetPortName ( oC_Port_t  Port)

The function is for reading printable name of the given port. If the port is not correct, then it should return "unknown" string.

Parameters
PortVariable with a port value
Returns
constant string with name of a port
oC_Port_t oC_GPIO_GetPortOfPins ( oC_Pins_t  Pins)

The function returns port of pins that are stored in the pins variable.

Parameters
PinsVariable with one or more pins
Returns
port of pins
bool oC_GPIO_IsPinDefined ( oC_Pins_t  Pin)

The function checks if the given pin is defined in the machine definition list for this processor.

Warning
this function is correct only for single selection pin link. It return false if the pin link will contain more than one pin.
Parameters
PinsPin to check if is defined
Returns
true if defined.
bool oC_GPIO_IsPinsState ( oC_Pins_t  Pins,
oC_GPIO_PinsState_t  ExpectedPinsState 
)

The function checks if all pins that are set in the Pins argument are set to the selected state.

Warning
This function does not check arguments, so it is important to set it properly, because if the port will be set incorrectly, there is a risk that it will cause a hard fault. You must call oC_GPIO_ArePinsCorrect function before it to ensure, that it will not happen.

Example of usage:

oC_Pins_t pins = oC_Pins_PA2 | oC_Pins_PA3;
{
// oC_Pins_PA2 and oC_Pins_PA3 pins are set to high state
}
{
// oC_Pins_PA2 and oC_Pins_PA3 pins are set to low state
}
else
{
// pins are not in the same state
}
Parameters
Pinsvariable with single or more pins from the same port
ExpectedPinsStateexpected state of pins
Returns
true if all pins are in the expected state
oC_ErrorCode_t oC_GPIO_IsPortCorrect ( oC_Port_t  Port)

The function checks if the port is correct

Parameters
PortPort of the GPIO (port)
Returns
true if correct
oC_ErrorCode_t oC_GPIO_IsPortIndexCorrect ( oC_PortIndex_t  PortIndex)

The function checks if the given port index is correct in the GPIO module.

Parameters
PortIndexIndex of the channel in the module
Returns
true if correct
bool oC_GPIO_IsSinglePin ( oC_Pins_t  Pins)

The function checks if in the Pins variable is stored only one pin.

Parameters
PinsVariable with pins from the same port
Returns
true if there is only one pin
bool oC_GPIO_IsTurnedOn ( void  )
Returns
true if driver is turned on

Definition at line 190 of file oc_gpio.c.

oC_Port_t oC_GPIO_PortIndexToPort ( oC_PortIndex_t  PortIndex)

The function converts index of the port to port in the GPIO module

Parameters
ChannelChannel of the GPIO (port)
Returns
index of the port in the GPIO
oC_PortIndex_t oC_GPIO_PortToPortIndex ( oC_Port_t  Port)

The function converts port to index of the port in the GPIO module

Parameters
PortPort of the GPIO (port)
Returns
index of the port in the GPIO
oC_ErrorCode_t oC_GPIO_ReadCurrent ( oC_Pins_t  Pins,
oC_GPIO_Current_t outCurrent 
)

The function is for reading configuration of current that is set on the port. This parameter is for output mode, and it defines strong of the current source. If it is set to oC_GPIO_Current_Minimum, it will be in low energy mode.

Warning
it is recommended to use this function for single pin, because if some of pins will be set to different value than others, the function will return error.
Parameters
Pinsvariable with single or more pins from the same port
outCurrentdestination for current variable
Returns
code of error or #oC_ErrorCode_None if success

Definition at line 582 of file oc_gpio.c.

oC_ErrorCode_t oC_GPIO_ReadData ( oC_Pins_t  Pins,
oC_PinsMask_t *  outData 
)

The function is for reading data from the selected pins. This function checks if arguments are correct, and it is useful for example, when all port is configured and used, and there is a need to read data from it (not pins state). Note, that there are also functions oC_GPIO_GetHighStatePins, oC_GPIO_GetLowStatePins and oC_GPIO_IsPinsState that should be little faster.

Parameters
Pinsvariable with single or more pins from the same port
outDataDestination for the return data
Returns
code of error or #oC_ErrorCode_None if success
oC_ErrorCode_t oC_GPIO_ReadDataReference ( oC_Pins_t  Pins,
oC_UInt_t **  outDataReference 
)

This function allows to read the pointer to the DATA of GPIO. It can be useful for speeding up operations based on the writing or reading state of a GPIO port.

Example of usage:

// (with assumption, that it was correctly configured before)
oC_PinsMask_t * keysPortData = NULL;
oC_PinsMask_t * ledsPortData = NULL;
oC_GPIO_ReadDataReference( ledPins , &ledsPortData );
oC_GPIO_ReadDataReference( keysPins , &keysPortData );
while(1)
{
// If at least one of keys is pressed
if(*keysPortData)
{
// Turn on LEDs
*ledsPortData = 0xff;
}
else
{
// Turn off LEDs if none of keys is turned on
*ledsPortData = 0;
}
}
Parameters
Pins
outDataReference
Returns
oC_ErrorCode_t oC_GPIO_ReadInterruptTrigger ( oC_Pins_t  Pins,
oC_GPIO_IntTrigger_t outInterruptTrigger 
)

The function is for reading configuration of interrupt trigger. The parameter defines trigger source for interrupts in input mode. The trigger can be also set to oC_GPIO_IntTrigger_Off, and in this case it will disable any interrupts on this pin(s).

Warning
it is recommended to use this function for single pin, because if some of pins will be set to different value than others, the function will return error.
Parameters
Pinsvariable with single or more pins from the same port
outInterruptTriggerdestination for the returned value
Returns
code of error or #oC_ErrorCode_None if success

Definition at line 858 of file oc_gpio.c.

oC_ErrorCode_t oC_GPIO_ReadMode ( oC_Pins_t  Pins,
oC_GPIO_Mode_t outMode 
)

The function is for reading pin mode. This parameter helps to choose if it is output or input mode.

Warning
it is recommended to use this function for single pin, because if some of pins will be set to different value than others, the function will return error.
Parameters
Pinsvariable with single or more pins from the same port
outModedestination for the mode variable
Returns
code of error or #oC_ErrorCode_None if success

Definition at line 650 of file oc_gpio.c.

oC_ErrorCode_t oC_GPIO_ReadOutputCircuit ( oC_Pins_t  Pins,
oC_GPIO_OutputCircuit_t outOutputCircuit 
)

The function is for reading configuration of the output circuit parameter. This parameter is for output mode, and helps to select between open drain and push-pull mode.

Warning
it is recommended to use this function for single pin, because if some of pins will be set to different value than others, the function will return error.
Parameters
Pinsvariable with single or more pins from the same port
outOutputCircuitdestination for the returned value
Returns
code of error or #oC_ErrorCode_None if success

Definition at line 788 of file oc_gpio.c.

oC_ErrorCode_t oC_GPIO_ReadPower ( oC_Pins_t  Pins,
oC_Power_t outPower 
)

The function reads power state in a port.

Note
this function does not require calling of #oC_GPIO_BeginConfiguration and #oC_GPIO_FinishConfiguration functions before and after usage
Parameters
Pinsvariable with single or more pins from the same port
outPowerdestination for the power state variable
Returns
code of error or #oC_ErrorCode_None if success
oC_ErrorCode_t oC_GPIO_ReadPull ( oC_Pins_t  Pins,
oC_GPIO_Pull_t outPull 
)

The function is for reading pull configuration. This parameter is for input mode, and defines default state for pin(s).

Warning
it is recommended to use this function for single pin, because if some of pins will be set to different value than others, the function will return error.
Parameters
Pinsvariable with single or more pins from the same port
outPulldestination for the pull variable
Returns
code of error or #oC_ErrorCode_None if success

Definition at line 718 of file oc_gpio.c.

oC_ErrorCode_t oC_GPIO_ReadSpeed ( oC_Pins_t  Pins,
oC_GPIO_Speed_t outSpeed 
)

The function is for reading current configuration of speed that is set on the port. It is parameter, that defines maximum speed of pin state changing. In most of cases, more speed choice means more current consumption.

Warning
it is recommended to use this function for single pin, because if some of pins will be set to different value than others, the function will return error.
Parameters
Pinsvariable with single or more pins from the same port
outSpeeddestination for the speed variable
Returns
code of error or #oC_ErrorCode_None if success

Definition at line 510 of file oc_gpio.c.

oC_ErrorCode_t oC_GPIO_SetCurrent ( oC_Pins_t  Pins,
oC_GPIO_Current_t  Current 
)

The function is for configuration of the current on selected port and pin(s). This parameter is for output mode, and it defines strong of the current source. If it is set to oC_GPIO_Current_Minimum, it will be in low energy mode.

Note
this function require usage of #oC_GPIO_BeginConfiguration and #oC_GPIO_FinishConfiguration functions before and after configuration
Parameters
Pinsvariable with single or more pins from the same port
Currentcurrent limit to configure
Returns
code of error or #oC_ErrorCode_None if success

Definition at line 545 of file oc_gpio.c.

oC_ErrorCode_t oC_GPIO_SetInterruptTrigger ( oC_Pins_t  Pins,
oC_GPIO_IntTrigger_t  InterruptTrigger 
)

The function is for configuration of the interrupt for pins in GPIO input mode. The parameter defines trigger source for interrupts in input mode. The trigger can be also set to oC_GPIO_IntTrigger_Off, and in this case it will disable any interrupts on this pin(s).

Note
this function require usage of #oC_GPIO_BeginConfiguration and #oC_GPIO_FinishConfiguration functions before and after configuration
Parameters
Pinsvariable with single or more pins from the same port
InterruptTriggervalue to set
Returns
code of error or #oC_ErrorCode_None if success

Definition at line 822 of file oc_gpio.c.

oC_ErrorCode_t oC_GPIO_SetMode ( oC_Pins_t  Pins,
oC_GPIO_Mode_t  Mode 
)

The function is for configuration of pins mode. This parameter helps to choose if it is output or input mode.

Note
this function require usage of #oC_GPIO_BeginConfiguration and #oC_GPIO_FinishConfiguration functions before and after configuration
Parameters
Pinsvariable with single or more pins from the same port
Modemode to configure
Returns
code of error or #oC_ErrorCode_None if success

Definition at line 615 of file oc_gpio.c.

oC_ErrorCode_t oC_GPIO_SetOutputCircuit ( oC_Pins_t  Pins,
oC_GPIO_OutputCircuit_t  OutputCircuit 
)

The function if for configuration of output circuit for pin(s). This parameter is for output mode, and helps to select between open drain and push-pull mode.

Note
this function require usage of #oC_GPIO_BeginConfiguration and #oC_GPIO_FinishConfiguration functions before and after configuration
Parameters
Pinsvariable with single or more pins from the same port
OutputCircuitvalue to set
Returns
code of error or #oC_ErrorCode_None if success

Definition at line 752 of file oc_gpio.c.

void oC_GPIO_SetPinsState ( oC_Pins_t  Pins,
oC_GPIO_PinsState_t  PinsState 
)

The function is for setting a state for all pins that are defined in the Pins argument.

Example of usage:

oC_Pins_t pins = oC_Pins_PA2 | oC_Pins_PA3;
Warning
This function does not check arguments, so it is important to set it properly, because if the port will be set incorrectly, there is a risk that it will cause a hard fault. You must call oC_GPIO_ArePinsCorrect function before it to ensure, that it will not happen.
Parameters
Pinsvariable with single or more pins from the same port
PinsStatestate of pins to set
oC_ErrorCode_t oC_GPIO_SetPower ( oC_Pins_t  Pins,
oC_Power_t  Power 
)

The function configures power for the port that is given in the Pins argument. This function should power up all registers that are needed to configure GPIO pins.

Note
this function does not require calling of #oC_GPIO_BeginConfiguration and #oC_GPIO_FinishConfiguration functions before and after usage
Parameters
Pinsvariable with single or more pins from the same port
Powerpower to configure
Returns
code of error or #oC_ErrorCode_None if success
oC_ErrorCode_t oC_GPIO_SetPull ( oC_Pins_t  Pins,
oC_GPIO_Pull_t  Pull 
)

The function is for configuration of pull for pins. This parameter is for input mode, and defines default state for pin(s).

Note
this function require usage of #oC_GPIO_BeginConfiguration and #oC_GPIO_FinishConfiguration functions before and after configuration
Parameters
Pinsvariable with single or more pins from the same port
Pullpull to configure
Returns
code of error or #oC_ErrorCode_None if success

Definition at line 683 of file oc_gpio.c.

oC_ErrorCode_t oC_GPIO_SetSpeed ( oC_Pins_t  Pins,
oC_GPIO_Speed_t  Speed 
)

The function is for configuration of pin(s) speed. It is parameter, that defines maximum speed of pin state changing. In most of cases, more speed choice means more current consumption.

Note
this function require usage of #oC_GPIO_BeginConfiguration and #oC_GPIO_FinishConfiguration functions before and after configuration
Parameters
Pinsvariable with single or more pins from the same port
Speedspeed to set
Returns
code of error or #oC_ErrorCode_None if success

Definition at line 474 of file oc_gpio.c.

void oC_GPIO_TogglePinsState ( oC_Pins_t  Pins)

The function toggles each pins state to opposite. This function is for make basic operation faster, so it not checks arguments.

Example of usage:

oC_Pins_t pins = oC_Pins_PA2 | oC_Pins_PA3;
// pins oC_Pins_PA2 and oC_Pins_PA3 are now in high state
// pins oC_Pins_PA2 and oC_Pins_PA3 are now in low state
// pin oC_Pins_PA2 is in high state, but oC_Pins_PA3 is in low state
// pin oC_Pins_PA2 is in low state, but oC_Pins_PA3 is in high state
Warning
This function does not check arguments, so it is important to set it properly, because if the port will be set incorrectly, there is a risk that it will cause a hard fault. You must call oC_GPIO_ArePinsCorrect function before it to ensure, that it will not happen.
Parameters
Pinsvariable with single or more pins from the same port
oC_ErrorCode_t oC_GPIO_TurnOff ( void  )

The function for turning off the GPIO driver. If the driver not started yet, it will return oC_ErrorCode_ModuleNotStartedYet error code. It also turns off the LLD.

Returns
code of error

Definition at line 154 of file oc_gpio.c.

oC_ErrorCode_t oC_GPIO_TurnOn ( void  )

The function is for turning on the GPIO module. If the module is already turned on, it will return oC_ErrorCode_ModuleIsTurnedOn error. It also turns on the LLD layer.

Returns
code of error

Definition at line 108 of file oc_gpio.c.

oC_ErrorCode_t oC_GPIO_Unconfigure ( const oC_GPIO_Config_t Config,
oC_GPIO_Context_t outContext 
)
Parameters
ConfigPointer to the configuration
outContextDestination for the context structure
Returns
code of error

Definition at line 281 of file oc_gpio.c.

oC_ErrorCode_t oC_GPIO_WriteData ( oC_Pins_t  Pins,
oC_PinsMask_t  Data 
)

The function is for writing data on the selected pins. This function checks if arguments are correct, and it is useful for example, when all port is configured and used, and there is a need to write data on it, because it sets both - high and low states on each pin from the Pins argument. Note, that if you need to set all pins to the same state, the oC_GPIO_SetPinsState function will be more useful and faster.

Parameters
Pinsvariable with single or more pins from the same port
DataData to write on port
Returns
code of error or #oC_ErrorCode_None if success