ODeV framework  v2
NucleoDriver.h
Go to the documentation of this file.
1 
31 #ifndef INCLUDE_DRIVERS_NUCLEODRIVER_H_
32 #define INCLUDE_DRIVERS_NUCLEODRIVER_H_
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 
39 #include "IDriver.h"
40 #include "IDriverVtbl.h"
41 #include "FreeRTOS.h"
42 #include "semphr.h"
43 
44 
45 #define LD4_Pin GPIO_PIN_5
46 #define LD4_GPIO_Port GPIOA
47 #define B1_Pin GPIO_PIN_13
48 #define B1_GPIO_Port GPIOC
49 
50 
54 typedef struct _NucleoDriver NucleoDriver;
55 
59 struct _NucleoDriver {
64 
65  // Driver variables should be added here.
66 
70  volatile boolean_t m_bPB1Pressed;
71 
75  SemaphoreHandle_t m_xSyncObj;
76 };
77 
81 typedef struct _NucleoDriverParams {
82  uint32_t nParam;
84 
85 
86 // Public API declaration
87 //***********************
88 
97 
105 inline sys_error_code_t NucleoDriverSetLed(NucleoDriver *this, boolean_t bON);
106 
114 
121 inline boolean_t NucleoDriverIsButtonPressed(NucleoDriver *this);
122 
130 sys_error_code_t NucleoDriverWaitForButtonEvent(NucleoDriver *this, boolean_t *pbButtonPressed);
131 
132 
133 // Inline functions definition
134 // ***************************
135 
136 SYS_DEFINE_INLINE
138  assert_param(this);
139  sys_error_code_t xRes = SYS_NO_ERROR_CODE;
140  UNUSED(this);
141 
142  HAL_GPIO_WritePin(LD4_GPIO_Port, LD4_Pin, (GPIO_PinState)bON);
143 
144  return xRes;
145 }
146 
147 SYS_DEFINE_INLINE
149  assert_param(this);
150  sys_error_code_t xRes = SYS_NO_ERROR_CODE;
151  UNUSED(this);
152 
153  HAL_GPIO_TogglePin(LD4_GPIO_Port, LD4_Pin);
154 
155  return xRes;
156 }
157 
158 SYS_DEFINE_INLINE
160  assert_param(this);
161 
162  return this->m_bPB1Pressed;
163 }
164 
165 
166 #ifdef __cplusplus
167 }
168 #endif
169 
170 #endif /* INCLUDE_DRIVERS_NUCLEODRIVER_H_ */
Private API for the Driver Interface.
Public API for the Driver Interface.
#define assert_param(expr)
Include module's header file.
Definition: stm32l4xx_hal_conf.h:359
boolean_t NucleoDriverIsButtonPressed(NucleoDriver *this)
Definition: NucleoDriver.h:159
IDriver super
Definition: NucleoDriver.h:63
Definition: NucleoDriver.h:59
SemaphoreHandle_t m_xSyncObj
Definition: NucleoDriver.h:75
volatile boolean_t m_bPB1Pressed
Definition: NucleoDriver.h:70
struct _NucleoDriverParams NucleoDriverParams
sys_error_code_t NucleoDriverToggleLed(NucleoDriver *this)
Definition: NucleoDriver.h:148
sys_error_code_t NucleoDriverWaitForButtonEvent(NucleoDriver *this, boolean_t *pbButtonPressed)
IDriver * NucleoDriverAlloc()
Definition: IDriverVtbl.h:59
Definition: NucleoDriver.h:81
unsigned short sys_error_code_t
Definition: syserror.h:45
sys_error_code_t NucleoDriverSetLed(NucleoDriver *this, boolean_t bON)
Definition: NucleoDriver.h:137