1+ #ifndef MOCK_STUBS_H
2+ #define MOCK_STUBS_H
3+
4+ #include <stdint.h>
5+ #include <math.h>
6+
7+ // clang-format off
8+
9+ #define osWaitForever 0xFFFFFFFFU
10+ #define osTimerPeriodic 0
11+ #define osTimerOnce 1
12+
13+ typedef enum {
14+ HAL_OK = 0x00U ,
15+ HAL_ERROR = 0x01U ,
16+ HAL_BUSY = 0x02U ,
17+ HAL_TIMEOUT = 0x03U
18+ } HAL_StatusTypeDef ;
19+
20+ typedef enum {
21+ osOK = 0 , ///< Operation completed successfully.
22+ osError =
23+ -1 , ///< Unspecified RTOS error: run-time error but no other error message fits.
24+ osErrorTimeout =
25+ -2 , ///< Operation not completed within the timeout period.
26+ osErrorResource = -3 , ///< Resource not available.
27+ osErrorParameter = -4 , ///< Parameter error.
28+ osErrorNoMemory =
29+ -5 , ///< System is out of memory: it was impossible to allocate or reserve memory for the operation.
30+ osErrorISR =
31+ -6 , ///< Not allowed in ISR context: the function cannot be called from interrupt service routines.
32+ osStatusReserved =
33+ 0x7FFFFFFF ///< Prevents enum down-size compiler optimization.
34+ } osStatus_t ;
35+
36+ typedef enum {
37+ osPriorityLow ,
38+ osPriorityBelowNormal ,
39+ osPriorityNormal ,
40+ osPriorityHigh ,
41+ osPriorityRealtime ,
42+ osPriorityRealtime1 ,
43+ osPriorityRealtime2 ,
44+ osPriorityRealtime3 ,
45+ osPriorityRealtime4 ,
46+ osPriorityRealtime5 ,
47+ osPriorityRealtime6 ,
48+ osPriorityRealtime7 ,
49+ } osPriority_t ;
50+
51+ typedef void * ADC_HandleTypeDef ;
52+ typedef void * I2C_HandleTypeDef ;
53+ typedef void * CAN_HandleTypeDef ;
54+ typedef void * SPI_HandleTypeDef ;
55+ typedef void * TIM_HandleTypeDef ;
56+ typedef void * IWDG_HandleTypeDef ;
57+
58+ typedef void * osMutexId_t ;
59+ typedef void * osTimerId_t ;
60+ typedef void * osThreadId_t ;
61+ typedef void * osMessageQueueId_t ;
62+ typedef void (* osTimerFunc_t )(void * );
63+
64+ #define osTimerId osTimerId_t
65+ #define osMutexId osMutexId_t
66+ #define osThreadId osThreadId_t
67+ #define osMessageQueueId osMessageQueueId_t
68+
69+ typedef struct {
70+ const char * name ;
71+ uint32_t stack_size ;
72+ osPriority_t priority ;
73+ } osThreadAttr_t ;
74+
75+ typedef struct {
76+ const char * name ;
77+ } osTimerAttr_t ;
78+
79+ typedef struct {
80+ const char * name ;
81+ } osMutexAttr_t ;
82+
83+ typedef struct {
84+ uint32_t StdId ;
85+ uint32_t ExtId ;
86+ uint32_t IDE ;
87+ uint32_t RTR ;
88+ uint32_t DLC ;
89+ } CAN_RxHeaderTypeDef ;
90+
91+ typedef struct {
92+ volatile uint32_t ODR ;
93+ } GPIO_TypeDef ;
94+
95+ uint32_t HAL_GetTick (void );
96+
97+
98+ osMutexId_t osMutexNew (const osMutexAttr_t * attr );
99+ uint32_t osMutexAcquire (osMutexId_t mutex , uint32_t timeout );
100+ uint32_t osMutexRelease (osMutexId_t mutex );
101+ osTimerId_t osTimerNew (osTimerFunc_t func , uint32_t type , void * arg ,
102+ void * attr );
103+ uint32_t osTimerStart (osTimerId_t timer_id , uint32_t ticks );
104+ uint32_t osTimerStop (osTimerId_t timer_id );
105+ void osDelay (uint32_t ms );
106+ osMessageQueueId_t osMessageQueueNew (uint32_t msg_count , uint32_t msg_size ,
107+ void * attr );
108+ uint32_t osMessageQueuePut (osMessageQueueId_t queue_id , const void * msg_ptr ,
109+ uint8_t msg_prio , uint32_t timeout );
110+ uint32_t osMessageQueueGet (osMessageQueueId_t queue_id , void * msg_ptr ,
111+ uint8_t * msg_prio , uint32_t timeout );
112+ uint32_t osThreadFlagsWait (uint32_t flags , uint32_t options , uint32_t timeout );
113+ uint32_t osThreadFlagsSet (osThreadId_t thread_id , uint32_t flags );
114+ int HAL_CAN_GetRxMessage (CAN_HandleTypeDef * hcan , uint32_t fifo ,
115+ CAN_RxHeaderTypeDef * rx_header , uint8_t * rx_data );
116+ uint32_t pdMS_TO_TICKS (uint32_t ms );
117+ HAL_StatusTypeDef HAL_ADC_Start_DMA (void * hadc , uint32_t * pData ,
118+ uint32_t Length );
119+
120+ HAL_StatusTypeDef HAL_I2C_Mem_Write (void * hi2c , uint16_t devAddress ,
121+ uint16_t memAddress , uint16_t memAddSize ,
122+ uint8_t * pData , uint16_t size ,
123+ uint32_t timeout );
124+
125+ HAL_StatusTypeDef HAL_I2C_Mem_Read (void * hi2c , uint16_t devAddress ,
126+ uint16_t memAddress , uint16_t memAddSize ,
127+ uint8_t * pData , uint16_t size ,
128+ uint32_t timeout );
129+ HAL_StatusTypeDef HAL_GPIO_WritePin (GPIO_TypeDef * GPIOx , uint16_t GPIO_Pin ,
130+ uint32_t PinState );
131+ HAL_StatusTypeDef HAL_CAN_GetTxMailboxesFreeLevel (CAN_HandleTypeDef * hcan );
132+ void HAL_GPIO_TogglePin (GPIO_TypeDef * GPIOx , uint16_t GPIO_Pin );
133+ uint32_t HAL_GetTick (void );
134+ HAL_StatusTypeDef HAL_I2C_Master_Transmit (I2C_HandleTypeDef * hi2c ,
135+ uint16_t DevAddress , uint8_t * pData ,
136+ uint16_t Size , uint32_t Timeout );
137+ HAL_StatusTypeDef HAL_I2C_Master_Receive (I2C_HandleTypeDef * hi2c ,
138+ uint16_t DevAddress , uint8_t * pData ,
139+ uint16_t Size , uint32_t Timeout );
140+ int HAL_GPIO_ReadPin (GPIO_TypeDef * GPIOx , uint16_t GPIO_Pin );
141+ int __HAL_TIM_GET_COUNTER (TIM_HandleTypeDef * htim );
142+ int HAL_Delay (int delay );
143+
144+ #define I2C_MEMADD_SIZE_8BIT 1
145+ #define HAL_MAX_DELAY 0xFFFFFFFFU
146+
147+ #define GPIO_PIN_RESET 0
148+ #define GPIO_PIN_SET 1
149+ #define GPIO_PIN_1 1
150+ #define GPIO_PIN_2 2
151+ #define GPIO_PIN_3 3
152+ #define GPIO_PIN_4 4
153+ #define GPIO_PIN_5 5
154+ #define GPIO_PIN_6 6
155+ #define GPIO_PIN_7 7
156+ #define GPIO_PIN_8 8
157+ #define GPIO_PIN_9 9
158+ #define GPIO_PIN_10 10
159+ #define GPIO_PIN_11 11
160+ #define GPIO_PIN_12 12
161+ #define GPIO_PIN_13 13
162+ #define GPIO_PIN_14 14
163+ #define GPIO_PIN_15 15
164+ #define GPIO_PIN_16 16
165+
166+ #define CAN_RX_FIFO0 0
167+ #define CAN_ID_EXT 1
168+
169+ #define GPIOA ((GPIO_TypeDef *)0x40020000)
170+ #define GPIOB ((GPIO_TypeDef *)0x40020400)
171+ #define GPIOC ((GPIO_TypeDef *)0x40020800)
172+
173+ #define osFlagsWaitAny 0x00000001U
174+
175+ // clang-format on
176+
177+ #endif
0 commit comments