Choco OS
V.0.16.9.0
Join to the chocolate world
|
The file with interface for the GPIO driver. More...
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... | |
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 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.
enum oC_GPIO_Current_t |
enum oC_GPIO_IntTrigger_t |
Type represents GPIO interrupt trigger source.
enum oC_GPIO_Mode_t |
enum oC_GPIO_PinsState_t |
enum oC_GPIO_Protection_t |
enum oC_GPIO_Pull_t |
enum oC_GPIO_Speed_t |
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.
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.
Pins | One or more pins from the same port |
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.
Pins | variable with pins from the same port |
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.
Pins | variable with single or more pins from the same port |
outPinsUnused | destination for the output variable |
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.
Pins | variable with single or more pins from the same port |
outPinUsed | destination for the output variable |
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.
Config | Pointer to the configuration structure |
outContext | Destination for the driver context structure |
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
Name | Name of the pin to find (for example "PF4") |
outPin | [out] Destination for a pin |
Example of usage:
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.
Example of usage:
Pins | variable with single or more pins from the same port |
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.
Example of usage:
Pins | variable with single or more pins from the same port |
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.
Pin | Variable with single 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.
Pin | Variable with single 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:
Port | Port of the GPIO |
Pins | Mask of pins that should be included to the #oC_Pins_t |
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:
Pins | Variable with one or more pins |
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.
Port | Variable with a port value |
oC_Port_t oC_GPIO_GetPortOfPins | ( | oC_Pins_t | Pins | ) |
The function returns port of pins that are stored in the pins variable.
Pins | Variable with one or more 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.
Pins | Pin to check if is 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.
Example of usage:
Pins | variable with single or more pins from the same port |
ExpectedPinsState | expected state of pins |
oC_ErrorCode_t oC_GPIO_IsPortCorrect | ( | oC_Port_t | Port | ) |
The function checks if the port is correct
Port | Port of the GPIO (port) |
oC_ErrorCode_t oC_GPIO_IsPortIndexCorrect | ( | oC_PortIndex_t | PortIndex | ) |
The function checks if the given port index is correct in the GPIO module.
PortIndex | Index of the channel in the module |
bool oC_GPIO_IsSinglePin | ( | oC_Pins_t | Pins | ) |
The function checks if in the Pins variable is stored only one pin.
Pins | Variable with pins from the same port |
bool oC_GPIO_IsTurnedOn | ( | void | ) |
oC_Port_t oC_GPIO_PortIndexToPort | ( | oC_PortIndex_t | PortIndex | ) |
The function converts index of the port to port in the GPIO module
Channel | Channel of the GPIO (port) |
oC_PortIndex_t oC_GPIO_PortToPortIndex | ( | oC_Port_t | Port | ) |
The function converts port to index of the port in the GPIO module
Port | Port of the GPIO (port) |
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.
Pins | variable with single or more pins from the same port |
outCurrent | destination for current variable |
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.
Pins | variable with single or more pins from the same port |
outData | Destination for the return data |
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:
Pins | |
outDataReference |
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).
Pins | variable with single or more pins from the same port |
outInterruptTrigger | destination for the returned value |
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.
Pins | variable with single or more pins from the same port |
outMode | destination for the mode variable |
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.
Pins | variable with single or more pins from the same port |
outOutputCircuit | destination for the returned value |
oC_ErrorCode_t oC_GPIO_ReadPower | ( | oC_Pins_t | Pins, |
oC_Power_t * | outPower | ||
) |
The function reads power state in a port.
Pins | variable with single or more pins from the same port |
outPower | destination for the power state variable |
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).
Pins | variable with single or more pins from the same port |
outPull | destination for the pull variable |
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.
Pins | variable with single or more pins from the same port |
outSpeed | destination for the speed variable |
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.
Pins | variable with single or more pins from the same port |
Current | current limit to configure |
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).
Pins | variable with single or more pins from the same port |
InterruptTrigger | value to set |
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.
Pins | variable with single or more pins from the same port |
Mode | mode to configure |
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.
Pins | variable with single or more pins from the same port |
OutputCircuit | value to set |
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:
Pins | variable with single or more pins from the same port |
PinsState | state 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.
Pins | variable with single or more pins from the same port |
Power | power to configure |
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).
Pins | variable with single or more pins from the same port |
Pull | pull to configure |
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.
Pins | variable with single or more pins from the same port |
Speed | speed to set |
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:
Pins | variable with single or more pins from the same port |
oC_ErrorCode_t oC_GPIO_TurnOff | ( | void | ) |
oC_ErrorCode_t oC_GPIO_TurnOn | ( | void | ) |
oC_ErrorCode_t oC_GPIO_Unconfigure | ( | const oC_GPIO_Config_t * | Config, |
oC_GPIO_Context_t * | outContext | ||
) |
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.
Pins | variable with single or more pins from the same port |
Data | Data to write on port |