1 /*------------------------------------------------------------------------------------------------*/
2 /* UNICENS V2.1.0-3491 */
3 /* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
5 /* This program is free software: you can redistribute it and/or modify */
6 /* it under the terms of the GNU General Public License as published by */
7 /* the Free Software Foundation, either version 2 of the License, or */
8 /* (at your option) any later version. */
10 /* This program is distributed in the hope that it will be useful, */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
13 /* GNU General Public License for more details. */
15 /* You should have received a copy of the GNU General Public License */
16 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 /* You may also obtain this software under a propriety license from Microchip. */
19 /* Please contact Microchip for further information. */
20 /*------------------------------------------------------------------------------------------------*/
24 * \brief Internal header file of the GPIO module.
26 * \defgroup G_UCS_GPIO_TYPES GPIO Referred Types
27 * \brief Referred types used by the Extended Resource Manager.
30 * \cond UCS_INTERNAL_DOC
39 /*------------------------------------------------------------------------------------------------*/
41 /*------------------------------------------------------------------------------------------------*/
43 #include "ucs_ret_pb.h"
45 #include "ucs_gpio_pb.h"
52 /*------------------------------------------------------------------------------------------------*/
53 /* Type definitions */
54 /*------------------------------------------------------------------------------------------------*/
55 /*! \brief Function signature used for GPIO results in case error.
56 * \param self Reference to CGpio instance
57 * \param msg_ptr Pointer to received message
59 typedef void (*Gpio_ErrResultCb_t)(void *self, void *result_ptr);
61 /*------------------------------------------------------------------------------------------------*/
63 /*------------------------------------------------------------------------------------------------*/
64 /*! \brief Stores data required by GPIO during initialization. */
65 typedef struct Gpio_InitData_
67 /*!< \brief Reference to INIC instance */
69 /*!< \brief Reference to NSM instance */
70 CNodeScriptManagement *nsm_ptr;
71 /*!< \brief GPIO Trigger event status function pointer */
72 Ucs_Gpio_TriggerEventResultCb_t trigger_event_status_fptr;
76 /*! \brief Stores data required by GPIO during initialization. */
77 typedef struct Gpio_UserData_
79 /*!< \brief PinState Result callback */
80 Ucs_Gpio_PinStateResCb_t pinstate_res_cb;
81 /*!< \brief PinMode Result callback */
82 Ucs_Gpio_ConfigPinModeResCb_t pinmode_res_cb;
83 /*!< \brief PortCreate Result callback */
84 Ucs_Gpio_CreatePortResCb_t portcreate_res_cb;
85 /*!< \brief GPIO Trigger event status function pointer */
86 Ucs_Gpio_TriggerEventResultCb_t trigger_event_status_fptr;
90 /*! \brief Script structure of the GPIO module */
91 typedef struct Gpio_Script_
94 /*! \brief script used for transmitting commands */
95 Ucs_Ns_Script_t script;
96 /*! \brief config messages used for transmitting commands */
97 Ucs_Ns_ConfigMsg_t cfg_msg;
100 /*! \brief Class structure of the GPIO module */
101 typedef struct CGpio_
103 /*! \brief Reference to an INIC instance */
105 /*!< \brief Reference to NSM instance */
106 CNodeScriptManagement *nsm_ptr;
107 /*! \brief Current user data */
108 Gpio_UserData_t curr_user_data;
109 /*! \brief Indicates the address of the target device */
110 uint16_t device_address;
111 /*! \brief Observer used for GPIO TriggerEvents */
112 CObserver triggerevent_observer;
113 /*!< \brief Current script to be looked for */
114 Gpio_Script_t curr_script;
115 /*!< \brief Current reference to the result callback function */
116 Gpio_ErrResultCb_t curr_res_cb;
120 /*------------------------------------------------------------------------------------------------*/
121 /* Prototypes of class CGpio */
122 /*------------------------------------------------------------------------------------------------*/
123 extern void Gpio_Ctor(CGpio * self, Gpio_InitData_t * init_ptr);
124 extern Ucs_Return_t Gpio_CreatePort(CGpio * self, uint8_t index, uint16_t debounce_time, Ucs_Gpio_CreatePortResCb_t res_fptr);
125 extern Ucs_Return_t Gpio_SetPinModeConfig(CGpio * self, uint16_t gpio_port_handle, uint8_t pin, Ucs_Gpio_PinMode_t mode, Ucs_Gpio_ConfigPinModeResCb_t res_fptr);
126 extern Ucs_Return_t Gpio_GetPinModeConfig(CGpio * self, uint16_t gpio_port_handle, Ucs_Gpio_ConfigPinModeResCb_t res_fptr);
127 extern Ucs_Return_t Gpio_SetPinStateConfig(CGpio * self, uint16_t gpio_port_handle, uint16_t mask, uint16_t data, Ucs_Gpio_PinStateResCb_t res_fptr);
128 extern Ucs_Return_t Gpio_GetPinStateConfig(CGpio * self, uint16_t gpio_port_handle, Ucs_Gpio_PinStateResCb_t res_fptr);
134 #endif /* #ifndef UCS_GPIO_H */
141 /*------------------------------------------------------------------------------------------------*/
143 /*------------------------------------------------------------------------------------------------*/