Skip to content

Commit

Permalink
track simulated pin levels
Browse files Browse the repository at this point in the history
  • Loading branch information
joeycastillo committed Oct 7, 2024
1 parent 17d34e5 commit e294a11
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dummy/common/hal_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdint.h>
#include <stdbool.h>

#pragma once

Expand All @@ -53,24 +54,30 @@
#define HAL_GPIO_PMUX_M 12
#define HAL_GPIO_PMUX_N 13

static bool pin_levels[3][32];

#define HAL_GPIO_PIN(name, port, pin) \
static inline void HAL_GPIO_##name##_set(void) \
{ \
pin_levels[HAL_GPIO_PORT##port][pin] = true; \
(void)HAL_GPIO_##name##_set; \
} \
\
static inline void HAL_GPIO_##name##_clr(void) \
{ \
pin_levels[HAL_GPIO_PORT##port][pin] = false; \
(void)HAL_GPIO_##name##_clr; \
} \
\
static inline void HAL_GPIO_##name##_toggle(void) \
{ \
pin_levels[HAL_GPIO_PORT##port][pin] = !pin_levels[HAL_GPIO_PORT##port][pin]; \
(void)HAL_GPIO_##name##_toggle; \
} \
\
static inline void HAL_GPIO_##name##_write(int value) \
{ \
pin_levels[HAL_GPIO_PORT##port][pin] = !!value; \
(void)HAL_GPIO_##name##_write; \
} \
\
Expand Down Expand Up @@ -106,7 +113,7 @@
\
static inline int HAL_GPIO_##name##_read(void) \
{ \
return 0; \
return pin_levels[HAL_GPIO_PORT##port][pin]; \
(void)HAL_GPIO_##name##_read; \
} \
\
Expand Down

0 comments on commit e294a11

Please sign in to comment.