Mock GPIO when building tests
Add some conditional statements in gpio.h so that we can mock the GPIO registers when building tests.pull/41/head
parent
169665331e
commit
7c7aa95445
|
|
@ -1,6 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#ifdef __AVR__
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace hal {
|
namespace hal {
|
||||||
namespace gpio {
|
namespace gpio {
|
||||||
|
|
@ -74,6 +77,7 @@ __attribute__((always_inline)) inline void Init(const GPIO_pin portPin, GPIO_Ini
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __AVR__
|
||||||
#define GPIOA ((hal::gpio::GPIO_TypeDef *)&PINA)
|
#define GPIOA ((hal::gpio::GPIO_TypeDef *)&PINA)
|
||||||
#define GPIOB ((hal::gpio::GPIO_TypeDef *)&PINB)
|
#define GPIOB ((hal::gpio::GPIO_TypeDef *)&PINB)
|
||||||
#define GPIOC ((hal::gpio::GPIO_TypeDef *)&PINC)
|
#define GPIOC ((hal::gpio::GPIO_TypeDef *)&PINC)
|
||||||
|
|
@ -82,6 +86,37 @@ __attribute__((always_inline)) inline void Init(const GPIO_pin portPin, GPIO_Ini
|
||||||
#define GPIOF ((hal::gpio::GPIO_TypeDef *)&PINF)
|
#define GPIOF ((hal::gpio::GPIO_TypeDef *)&PINF)
|
||||||
#define GPIOG ((hal::gpio::GPIO_TypeDef *)&PING)
|
#define GPIOG ((hal::gpio::GPIO_TypeDef *)&PING)
|
||||||
#define GPIOH ((hal::gpio::GPIO_TypeDef *)&PINH)
|
#define GPIOH ((hal::gpio::GPIO_TypeDef *)&PINH)
|
||||||
|
#define GPIOI ((hal::gpio::GPIO_TypeDef *)&PINI)
|
||||||
#define GPIOJ ((hal::gpio::GPIO_TypeDef *)&PINJ)
|
#define GPIOJ ((hal::gpio::GPIO_TypeDef *)&PINJ)
|
||||||
#define GPIOK ((hal::gpio::GPIO_TypeDef *)&PINK)
|
#define GPIOK ((hal::gpio::GPIO_TypeDef *)&PINK)
|
||||||
#define GPIOL ((hal::gpio::GPIO_TypeDef *)&PINL)
|
#define GPIOL ((hal::gpio::GPIO_TypeDef *)&PINL)
|
||||||
|
#else
|
||||||
|
|
||||||
|
// stub entries
|
||||||
|
extern hal::gpio::GPIO_TypeDef _GPIOA;
|
||||||
|
extern hal::gpio::GPIO_TypeDef _GPIOB;
|
||||||
|
extern hal::gpio::GPIO_TypeDef _GPIOC;
|
||||||
|
extern hal::gpio::GPIO_TypeDef _GPIOD;
|
||||||
|
extern hal::gpio::GPIO_TypeDef _GPIOE;
|
||||||
|
extern hal::gpio::GPIO_TypeDef _GPIOF;
|
||||||
|
extern hal::gpio::GPIO_TypeDef _GPIOG;
|
||||||
|
extern hal::gpio::GPIO_TypeDef _GPIOH;
|
||||||
|
extern hal::gpio::GPIO_TypeDef _GPIOI;
|
||||||
|
extern hal::gpio::GPIO_TypeDef _GPIOJ;
|
||||||
|
extern hal::gpio::GPIO_TypeDef _GPIOK;
|
||||||
|
extern hal::gpio::GPIO_TypeDef _GPIOL;
|
||||||
|
|
||||||
|
#define GPIOA (&_GPIOB)
|
||||||
|
#define GPIOB (&_GPIOB)
|
||||||
|
#define GPIOC (&_GPIOB)
|
||||||
|
#define GPIOD (&_GPIOB)
|
||||||
|
#define GPIOE (&_GPIOB)
|
||||||
|
#define GPIOF (&_GPIOB)
|
||||||
|
#define GPIOG (&_GPIOB)
|
||||||
|
#define GPIOH (&_GPIOB)
|
||||||
|
#define GPIOI (&_GPIOB)
|
||||||
|
#define GPIOJ (&_GPIOB)
|
||||||
|
#define GPIOK (&_GPIOB)
|
||||||
|
#define GPIOL (&_GPIOB)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ add_executable(
|
||||||
../../modules/stubs/stub_adc.cpp
|
../../modules/stubs/stub_adc.cpp
|
||||||
../../modules/stubs/stub_eeprom.cpp
|
../../modules/stubs/stub_eeprom.cpp
|
||||||
../../modules/stubs/stub_shr16.cpp
|
../../modules/stubs/stub_shr16.cpp
|
||||||
|
../../modules/stubs/stub_gpio.cpp
|
||||||
../../modules/stubs/stub_timebase.cpp
|
../../modules/stubs/stub_timebase.cpp
|
||||||
../stubs/main_loop_stub.cpp
|
../stubs/main_loop_stub.cpp
|
||||||
../stubs/stub_motion.cpp
|
../stubs/stub_motion.cpp
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ add_executable(
|
||||||
../../modules/stubs/stub_eeprom.cpp
|
../../modules/stubs/stub_eeprom.cpp
|
||||||
../../modules/stubs/stub_shr16.cpp
|
../../modules/stubs/stub_shr16.cpp
|
||||||
../../modules/stubs/stub_timebase.cpp
|
../../modules/stubs/stub_timebase.cpp
|
||||||
|
../../modules/stubs/stub_gpio.cpp
|
||||||
../stubs/main_loop_stub.cpp
|
../stubs/main_loop_stub.cpp
|
||||||
../stubs/stub_motion.cpp
|
../stubs/stub_motion.cpp
|
||||||
test_eject_filament.cpp
|
test_eject_filament.cpp
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ add_executable(
|
||||||
../../modules/stubs/stub_adc.cpp
|
../../modules/stubs/stub_adc.cpp
|
||||||
../../modules/stubs/stub_eeprom.cpp
|
../../modules/stubs/stub_eeprom.cpp
|
||||||
../../modules/stubs/stub_shr16.cpp
|
../../modules/stubs/stub_shr16.cpp
|
||||||
|
../../modules/stubs/stub_gpio.cpp
|
||||||
../../modules/stubs/stub_timebase.cpp
|
../../modules/stubs/stub_timebase.cpp
|
||||||
../stubs/main_loop_stub.cpp
|
../stubs/main_loop_stub.cpp
|
||||||
../stubs/stub_motion.cpp
|
../stubs/stub_motion.cpp
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ add_executable(
|
||||||
../../modules/stubs/stub_adc.cpp
|
../../modules/stubs/stub_adc.cpp
|
||||||
../../modules/stubs/stub_eeprom.cpp
|
../../modules/stubs/stub_eeprom.cpp
|
||||||
../../modules/stubs/stub_shr16.cpp
|
../../modules/stubs/stub_shr16.cpp
|
||||||
|
../../modules/stubs/stub_gpio.cpp
|
||||||
../../modules/stubs/stub_timebase.cpp
|
../../modules/stubs/stub_timebase.cpp
|
||||||
../stubs/main_loop_stub.cpp
|
../stubs/main_loop_stub.cpp
|
||||||
../stubs/stub_motion.cpp
|
../stubs/stub_motion.cpp
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ add_executable(
|
||||||
../../modules/stubs/stub_adc.cpp
|
../../modules/stubs/stub_adc.cpp
|
||||||
../../modules/stubs/stub_eeprom.cpp
|
../../modules/stubs/stub_eeprom.cpp
|
||||||
../../modules/stubs/stub_shr16.cpp
|
../../modules/stubs/stub_shr16.cpp
|
||||||
|
../../modules/stubs/stub_gpio.cpp
|
||||||
../../modules/stubs/stub_timebase.cpp
|
../../modules/stubs/stub_timebase.cpp
|
||||||
../stubs/main_loop_stub.cpp
|
../stubs/main_loop_stub.cpp
|
||||||
../stubs/stub_motion.cpp
|
../stubs/stub_motion.cpp
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ add_executable(
|
||||||
../../modules/stubs/stub_adc.cpp
|
../../modules/stubs/stub_adc.cpp
|
||||||
../../modules/stubs/stub_eeprom.cpp
|
../../modules/stubs/stub_eeprom.cpp
|
||||||
../../modules/stubs/stub_shr16.cpp
|
../../modules/stubs/stub_shr16.cpp
|
||||||
|
../../modules/stubs/stub_gpio.cpp
|
||||||
../../modules/stubs/stub_timebase.cpp
|
../../modules/stubs/stub_timebase.cpp
|
||||||
../stubs/main_loop_stub.cpp
|
../stubs/main_loop_stub.cpp
|
||||||
../stubs/stub_motion.cpp
|
../stubs/stub_motion.cpp
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ add_executable(
|
||||||
../../modules/stubs/stub_adc.cpp
|
../../modules/stubs/stub_adc.cpp
|
||||||
../../modules/stubs/stub_eeprom.cpp
|
../../modules/stubs/stub_eeprom.cpp
|
||||||
../../modules/stubs/stub_shr16.cpp
|
../../modules/stubs/stub_shr16.cpp
|
||||||
|
../../modules/stubs/stub_gpio.cpp
|
||||||
../../modules/stubs/stub_timebase.cpp
|
../../modules/stubs/stub_timebase.cpp
|
||||||
../stubs/main_loop_stub.cpp
|
../stubs/main_loop_stub.cpp
|
||||||
../stubs/stub_motion.cpp
|
../stubs/stub_motion.cpp
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ add_executable(
|
||||||
../../modules/stubs/stub_adc.cpp
|
../../modules/stubs/stub_adc.cpp
|
||||||
../../modules/stubs/stub_eeprom.cpp
|
../../modules/stubs/stub_eeprom.cpp
|
||||||
../../modules/stubs/stub_shr16.cpp
|
../../modules/stubs/stub_shr16.cpp
|
||||||
|
../../modules/stubs/stub_gpio.cpp
|
||||||
../../modules/stubs/stub_timebase.cpp
|
../../modules/stubs/stub_timebase.cpp
|
||||||
../stubs/main_loop_stub.cpp
|
../stubs/main_loop_stub.cpp
|
||||||
../stubs/stub_motion.cpp
|
../stubs/stub_motion.cpp
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
#include "gpio.h"
|
||||||
|
|
||||||
|
hal::gpio::GPIO_TypeDef _GPIOA;
|
||||||
|
hal::gpio::GPIO_TypeDef _GPIOB;
|
||||||
|
hal::gpio::GPIO_TypeDef _GPIOC;
|
||||||
|
hal::gpio::GPIO_TypeDef _GPIOD;
|
||||||
|
hal::gpio::GPIO_TypeDef _GPIOE;
|
||||||
|
hal::gpio::GPIO_TypeDef _GPIOF;
|
||||||
|
hal::gpio::GPIO_TypeDef _GPIOG;
|
||||||
|
hal::gpio::GPIO_TypeDef _GPIOH;
|
||||||
|
hal::gpio::GPIO_TypeDef _GPIOI;
|
||||||
|
hal::gpio::GPIO_TypeDef _GPIOJ;
|
||||||
|
hal::gpio::GPIO_TypeDef _GPIOK;
|
||||||
|
hal::gpio::GPIO_TypeDef _GPIOL;
|
||||||
Loading…
Reference in New Issue