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

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

#include <oc_gpio.h>
#include <oc_gpio_lld.h>
#include <oc_compiler.h>
#include <oc_module.h>
#include <oc_intman.h>
#include <oc_null.h>
#include <string.h>
#include <oc_event.h>
#include <oc_driver.h>

Go to the source code of this file.

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
 

Detailed Description


Author
Patryk Kubiak - (Created on: 24-10-2015)
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 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.c.

Function Documentation

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.

bool oC_GPIO_IsTurnedOn ( void  )
Returns
true if driver is turned on

Definition at line 190 of file oc_gpio.c.

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_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_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.

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.

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.