CubeMon-Vue-Demo-STM32F407VGT6U
di.c File Reference
#include <main.h>
#include <lib/uti/utility.h>
#include <lib/uti/swo.h>
#include <lib/di.h>

Data Structures

struct  digitalInputAction
 
struct  digitalInputDef
 

Typedefs

typedef enum digitalInputSM digitalInputSM
 
typedef struct digitalInputAction digitalInputAction
 
typedef struct digitalInputDef digitalInputDef
 

Enumerations

enum  digitalInputSM { INPUT_SM_WAITING_FOR_CHANGE , INPUT_SM_DEBOUNC , INPUT_SM_CONFIRMED , INPUT_SM_BUTTON_PRESS }
 

Functions

retStatus input_get (uint32_t input_name, uint16_t type, int32_t *value)
 Standardized getter function for digital input library. More...
 
retStatus input_set (uint32_t input_name, uint16_t type, int32_t value)
 Standardized setter function for digital input library. More...
 
retStatus input_get_init_data (digInputs input_name, digitalInputInitData *digital_input_init_data)
 Return input initialization data. More...
 
retStatus input_init (digInputs input_name, digitalInputInitData digital_input_init_data)
 Digital input initialization function. More...
 
dioStates input_logical_state_debounced (digInputs input_name)
 Return the input debounced logical state. More...
 
dioStates input_state_now (digInputs input_name)
 Return the input state read from HW at the moment the function is called. More...
 
void input_handle (void)
 Handles digital input logic. Call every 1ms. More...
 
uint8_t input_get_action (digInputs input_name, digitalInputActions action)
 
retStatus input_ack_action (digInputs input_name, digitalInputActions action)
 Acknowledge digital input action. More...
 
__weak GPIO_PinState input_get_hw_HAL (digInputs input_name)
 Get HW input state. In case you want to implement it differently (f.e. not using HAL) More...
 
void __attribute__ ((optimize("-O3")))
 

Detailed Description

Author
panvicka
Date
2.1.2022

Function Documentation

◆ input_ack_action()

retStatus input_ack_action ( digInputs  input_name,
digitalInputActions  action 
)

Acknowledge digital input action.

Digital input action digitalInputActions needs to be manually cleared before they are evaluated again.

Parameters
[in]input_nameinput identification, defined by digInputs
[out]actionaction to be cleared
Returns
EOK if the digital_input_init_data value is valid ENODEV if the input_name is out of range defined by digInputs

◆ input_get()

retStatus input_get ( uint32_t  input,
uint16_t  data,
int32_t *  value 
)

Standardized getter function for digital input library.

Parameters
[in]inputis the input name defined by digInputs
[in]datadata for /p input that can be read out of the module, available data digitalInputDateTypes
[out]valuegetter output
Note
/p input and /p data types are changed to uint32_t and uint16_t to keep the standard function prototype
In case you do not need this function footprint you are better of using input_is_short_press(), input_is_long_press() and input_get_action() functions.
Returns
ENODEV if the /p input is not defined or initialized, EINVAL if you are trying to read invalid data and EOK if the /p value contains valid value

◆ input_get_hw_HAL()

__weak GPIO_PinState input_get_hw_HAL ( digInputs  input_name)

Get HW input state. In case you want to implement it differently (f.e. not using HAL)

Parameters
[in]input_nameinput identification, defined by digInputs
Returns
GPIO_PinState (from the HAL library)

◆ input_get_init_data()

retStatus input_get_init_data ( digInputs  input_name,
digitalInputInitData digital_input_init_data 
)

Return input initialization data.

In case you want to re-initialize some values but keep the rest as it was

Parameters
[in]input_nameinput identification, defined by digInputs
[out]digital_input_init_datainput initialization data digitalInputInitData
Returns
EOK if the digital_input_init_data value is valid ENODEV if the input_name is out of range defined by digInputs

◆ input_handle()

void input_handle ( void  )

Handles digital input logic. Call every 1ms.

Note
can be called faster or slower but the initialization values are no longer in ms.
Returns
void

◆ input_init()

retStatus input_init ( digInputs  input_name,
digitalInputInitData  digital_input_init_data 
)

Digital input initialization function.

Parameters
[in]input_nameinput identification, defined by digInputs
[in]digital_input_init_datainput initialization data digitalInputInitData
Returns
EOK is the initialization completed OK ENODEV if the input_name is out of range defined by digInputs EINVAL if the digital_input_init_data contains invalid values (check SWO)

◆ input_logical_state_debounced()

dioStates input_logical_state_debounced ( digInputs  input_name)

Return the input debounced logical state.

Debounced input logical state is evaluated using the initialization data.

Parameters
[in]input_nameinput identification, defined by digInputs
Returns
DIO_OFF - if the logical state of the input is "0" (not active) DIO_ON - if the logical state of the input is "1" (active) ENODEV - if the /p input_name is out of range defined by digInputs

◆ input_set()

retStatus input_set ( uint32_t  input,
uint16_t  data,
int32_t  value 
)

Standardized setter function for digital input library.

Parameters
[in]inputinput identification, defined by digInputs
[in]datadata for /p input that can be read out of the module, available data digitalInputDateTypes
[in]valuevalue to be set

You can not set values that are read from HW or calculated from the HW value: INPUT_DAT_CURR and INPUT_DAT_DEBOUNCED

Note
input and /p data types are changed to uint32_t and uint16_t to keep the standard function prototype
In case you do not need this function footprint you are better of using input_ack_action()
Returns
returns EACCES in case you try setting HW dependent variables, EOVERFLOW if the set value is invalid, EINVAL if invalid data type is passed, ENODEV in case the input is not defined or initialized and EOK if the value was successfully set

◆ input_state_now()

dioStates input_state_now ( digInputs  input_name)

Return the input state read from HW at the moment the function is called.

Parameters
[in]input_nameinput identification, defined by digInputs
Note
the value is not converted to a logical state (you need to consider the INPUT_HW_ACTIVE_HIGH and INPUT_HW_ACTIVE_LOW in your logic *
Returns
DIO_OFF - if the value on HW is "0" DIO_ON - if the value on HW is "1 ENODEV - if the /p input_name is out of range defined by digInputs