diff --git a/.vscode/tasks.json b/.vscode/tasks.json index a1d2299..ecfd878 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,21 +1,25 @@ { - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format "version": "2.0.0", "options": { "env": { - "PLATFORM": "nrf52", - // "PLATFORM": "posix", - "APPLICATION": "blinky", + // "APPLICATION": "blinky", // "APPLICATION": "spi", // "APPLICATION": "st7789_lcd", + "APPLICATION": "sys_tick", + "${BUILD_CMD}": "eval docker run --env PLATFORM=${PLATFORM} --env APPLICATION=${APPLICATION} -t --rm -v '${workspaceFolder}':/work --user $(id -u):$(id -g) arm-none-eabi.buildenv", }, }, + "presentation": { + "focus": true, + "reveal": "always", + "panel": "shared", + "clear": true, + }, "tasks": [ { "label": "all", "type":"shell", - "command": "make all -j8", + "command": "${BUILD_CMD} make all -j8", "problemMatcher": { "base": "$gcc", "owner": "gcc", @@ -49,7 +53,7 @@ { "label": "clean", "type":"shell", - "command": "make clean -j8", + "command": "${BUILD_CMD} make clean -j8", "problemMatcher": { "base": "$gcc", "owner": "gcc", @@ -66,7 +70,7 @@ { "label": "distclean", "type":"shell", - "command": "make distclean", + "command": "${BUILD_CMD} make distclean", "problemMatcher": { "base": "$gcc", "owner": "gcc", @@ -97,11 +101,5 @@ "isDefault": true } } - ], - "presentation": { - "focus": true, - "reveal": "always", - "panel": "shared", - "clear": true, - } + ] } diff --git a/Makefile b/Makefile index 240f85e..3e3bb7f 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,18 @@ APPLICATION ?= blinky PLATFORM ?= nrf52 + +ifneq "$(findstring $(PLATFORM), nrf52)" "" +CORE = cm4 +endif + TARGET_FILE ?= $(APPLICATION).elf CC = $(CROSS_COMPILE)gcc CPP = $(CROSS_COMPILE)cpp CXX = $(CROSS_COMPILE)g++ OBJCOPY = $(CROSS_COMPILE)objcopy +OBJDUMP = $(CROSS_COMPILE)objdump SIZE = $(CROSS_COMPILE)size CHECK = cppcheck @@ -24,6 +30,7 @@ C_SRCS += $(wildcard $(SRC_DIR)/application/$(APPLICATION)/*.c) C_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.c,%.c.o,$(C_SRCS))) CC_SRCS = $(wildcard $(SRC_DIR)/*.cc) +CC_SRCS += $(wildcard $(SRC_DIR)/platform/$(CORE)/*.cc) CC_SRCS += $(wildcard $(SRC_DIR)/platform/$(PLATFORM)/*.cc) CC_SRCS += $(wildcard $(SRC_DIR)/application/$(APPLICATION)/*.cc) CC_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.cc,%.cc.o,$(CC_SRCS))) @@ -75,9 +82,11 @@ check: $(C_SRCS) $(TARGET): $(OBJS) $(THIS_MAKEFILE) @mkdir -p $(dir $@) - $(CXX) $(CXX_FLAGS) $(LD_FLAGS) $(OBJS) $(addprefix -l,$(LIBS)) -o $@ + $(CXX) $(CXX_FLAGS) $(LD_FLAGS) $(OBJS) $(addprefix -l,$(LIBS)) -Wl,-Map=$@.map -o $@ + $(OBJDUMP) --disassemble-all --section=.text --source -EL -C --wide --line-numbers --inlines $@ > $@.text.disassemble ln -sf $(shell pwd)/$@ $(shell pwd)/bin/firmware.elf - $(SIZE) -x $@ + $(SIZE) -x $@ > $@.size + @cat $@.size $(TARGET_HEX): $(TARGET) $(THIS_MAKEFILE) $(OBJCOPY) -O ihex $(TARGET) $(TARGET_HEX) diff --git a/build_system/platform/nrf52/Makefile.nrf52 b/build_system/platform/nrf52/Makefile.nrf52 index 754513a..c947537 100644 --- a/build_system/platform/nrf52/Makefile.nrf52 +++ b/build_system/platform/nrf52/Makefile.nrf52 @@ -25,9 +25,9 @@ C_FLAGS += -DFLOAT_ABI_HARD C_FLAGS += -DNRF52 C_FLAGS += -DNRF52832_XXAA C_FLAGS += -DNRF52_PAN_74 -C_FLAGS += -DNRF_SD_BLE_API_VERSION=7 -C_FLAGS += -DS132 -C_FLAGS += -DSOFTDEVICE_PRESENT +# C_FLAGS += -DNRF_SD_BLE_API_VERSION=7 +# C_FLAGS += -DS132 +# C_FLAGS += -DSOFTDEVICE_PRESENT C_FLAGS += -mcpu=$(CPU) C_FLAGS += -mthumb -mabi=aapcs C_FLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 @@ -42,9 +42,9 @@ CXX_FLAGS += -DFLOAT_ABI_HARD CXX_FLAGS += -DNRF52 CXX_FLAGS += -DNRF52832_XXAA CXX_FLAGS += -DNRF52_PAN_74 -CXX_FLAGS += -DNRF_SD_BLE_API_VERSION=7 -CXX_FLAGS += -DS132 -CXX_FLAGS += -DSOFTDEVICE_PRESENT +# CXX_FLAGS += -DNRF_SD_BLE_API_VERSION=7 +# CXX_FLAGS += -DS132 +# CXX_FLAGS += -DSOFTDEVICE_PRESENT CXX_FLAGS += -mcpu=$(CPU) CXX_FLAGS += -mthumb -mabi=aapcs CXX_FLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 @@ -64,8 +64,8 @@ A_FLAGS += -DFLOAT_ABI_HARD A_FLAGS += -DNRF52 A_FLAGS += -DNRF52832_XXAA A_FLAGS += -DNRF52_PAN_74 -A_FLAGS += -DNRF_SD_BLE_API_VERSION=7 -A_FLAGS += -DS132 +# A_FLAGS += -DNRF_SD_BLE_API_VERSION=7 +# A_FLAGS += -DS132 # A_FLAGS += -DSOFTDEVICE_PRESENT A_FLAGS += -D__HEAP_SIZE=8192 A_FLAGS += -D__HEAP_SIZE=8192 diff --git a/interfaces/gpio_interface.h b/interfaces/gpio_interface.h index 097482e..e3df6cd 100644 --- a/interfaces/gpio_interface.h +++ b/interfaces/gpio_interface.h @@ -3,7 +3,7 @@ #include -namespace interfaces { +namespace pinetime::interfaces { class GpioInterface { diff --git a/interfaces/interrupt_interface.h b/interfaces/interrupt_interface.h new file mode 100644 index 0000000..f887f1b --- /dev/null +++ b/interfaces/interrupt_interface.h @@ -0,0 +1,16 @@ +#ifndef __INTERFACES_INTERRUPT_INTERFACE_H__ +#define __INTERFACES_INTERRUPT_INTERFACE_H__ + +namespace pinetime::interfaces { + +class InterruptInterface +{ + public: + virtual void handle() = 0; + virtual void enable() = 0; + virtual void disable() = 0; +}; + +} + +#endif diff --git a/interfaces/spi_interface.h b/interfaces/spi_interface.h index 15b6490..8187d5a 100644 --- a/interfaces/spi_interface.h +++ b/interfaces/spi_interface.h @@ -3,7 +3,7 @@ #include -namespace interfaces { +namespace pinetime::interfaces { class SpiInterface { diff --git a/src/application/blinky/main.cc b/src/application/blinky/main.cc index 9b7fb05..7e3aafc 100644 --- a/src/application/blinky/main.cc +++ b/src/application/blinky/main.cc @@ -1,7 +1,12 @@ #include #include "delay.h" -#include "platform/hal.h" + +#include "platform/nrf52/gpio.h" +#include "platform/nrf52/InterruptHandler.h" +#include "platform/nrf52/InterruptGuardian.h" + +using namespace pinetime::platform::nrf52; enum { PIN_NUMBER_LED_1 = 17, @@ -10,18 +15,20 @@ enum { PIN_NUMBER_LED_4 = 20 }; -hal::Gpio led_1(PIN_NUMBER_LED_1); -hal::Gpio led_2(PIN_NUMBER_LED_2); -hal::Gpio led_3(PIN_NUMBER_LED_3); -hal::Gpio led_4(PIN_NUMBER_LED_4); +Gpio led_1(PIN_NUMBER_LED_1); +Gpio led_2(PIN_NUMBER_LED_2); +Gpio led_3(PIN_NUMBER_LED_3); +Gpio led_4(PIN_NUMBER_LED_4); -std::array leds = {&led_1, &led_2, &led_3, &led_4}; +std::array leds = {&led_1, &led_2, &led_3, &led_4}; + +InterruptGuardian InterruptGuardian::instance; int main(void) { while(true) { for(auto it = std::begin(leds); it != std::end(leds); ++it) { - hal::Gpio * tmp = *it; + Gpio * tmp = *it; tmp->toggle(); delay_ms(500); } diff --git a/src/application/spi/main.cc b/src/application/spi/main.cc index 952e271..31eb0c9 100644 --- a/src/application/spi/main.cc +++ b/src/application/spi/main.cc @@ -1,11 +1,17 @@ #include "delay.h" -#include "platform/hal.h" -using namespace hal; +#include "platform/nrf52/gpio.h" +#include "platform/nrf52/spi.h" +#include "platform/nrf52/InterruptHandler.h" +#include "platform/nrf52/InterruptGuardian.h" + +using namespace pinetime::platform::nrf52; const uint8_t buf[] = "Test"; +InterruptGuardian InterruptGuardian::instance; + int main(void) { Gpio led_1(17); diff --git a/src/application/st7789_lcd/main.cc b/src/application/st7789_lcd/main.cc index 9afbbab..819d395 100644 --- a/src/application/st7789_lcd/main.cc +++ b/src/application/st7789_lcd/main.cc @@ -1,18 +1,25 @@ #include "delay.h" -#include "platform/hal.h" +#include "platform/nrf52/gpio.h" +#include "platform/nrf52/spi.h" +#include "platform/nrf52/InterruptHandler.h" +#include "platform/nrf52/InterruptGuardian.h" #include "st7789.h" -hal::Gpio led_1(17); +using namespace pinetime::platform::nrf52; -hal::Gpio lcd_reset(26); -hal::Gpio lcd_data_command(18); -hal::Gpio lcd_backlight(23); -hal::Gpio lcd_chip_select(25); -hal::Spi lcd_spi(0, 2, 3, 4, lcd_chip_select); +Gpio led_1(17); + +Gpio lcd_reset(26); +Gpio lcd_data_command(18); +Gpio lcd_backlight(23); +Gpio lcd_chip_select(25); +Spi lcd_spi(0, 2, 3, 4, lcd_chip_select); St7789 lcd(lcd_spi, lcd_reset, lcd_data_command, lcd_backlight); +InterruptGuardian InterruptGuardian::instance; + int main(void) { lcd.init(); diff --git a/src/application/sys_tick/main.cc b/src/application/sys_tick/main.cc new file mode 100644 index 0000000..21cadbf --- /dev/null +++ b/src/application/sys_tick/main.cc @@ -0,0 +1,47 @@ +#include + +extern "C" { + #include "nrf52.h" +} + +#include "platform/nrf52/gpio.h" +#include "platform/nrf52/InterruptHandler.h" +#include "platform/nrf52/InterruptGuardian.h" +#include "platform/cm4/SystemTick.h" + +using namespace pinetime::platform::nrf52; + +enum { + PIN_NUMBER_LED_1 = 17, + PIN_NUMBER_LED_2 = 18, + PIN_NUMBER_LED_3 = 19, + PIN_NUMBER_LED_4 = 20 +}; + +Gpio led_1(PIN_NUMBER_LED_1); +Gpio led_2(PIN_NUMBER_LED_2); +Gpio led_3(PIN_NUMBER_LED_3); +Gpio led_4(PIN_NUMBER_LED_4); + +std::array leds = {&led_1, &led_2, &led_3, &led_4}; + +InterruptGuardian InterruptGuardian::instance; + +pinetime::platform::cm4::SystemTick ticker; + +int main(void) +{ + ticker.enable(); + uint32_t last_tick = 0; + while(true) { + for(auto it = std::begin(leds); it != std::end(leds); ++it) { + uint32_t tick = ticker.tick() / 1000; + if(tick != last_tick) { + Gpio * tmp = *it; + tmp->toggle(); + last_tick = tick; + } + } + } + return 0; +} diff --git a/src/platform/cm4/SystemTick.cc b/src/platform/cm4/SystemTick.cc new file mode 100644 index 0000000..be2cc5b --- /dev/null +++ b/src/platform/cm4/SystemTick.cc @@ -0,0 +1,35 @@ +extern "C" { + #include "nrf52.h" +} + +#include "platform/cm4/SystemTick.h" +#include "platform/nrf52/InterruptGuardian.h" + +using namespace pinetime::platform::cm4; +using namespace pinetime::platform::nrf52; + +SystemTick::SystemTick() + : InterruptHandler(InterruptGuardian::Nrf52IrqN::SYS_TICK_IRQ) + , sys_tick(0) +{ +} + +void SystemTick::handle() +{ + this->sys_tick++; +} + +void SystemTick::enable() +{ + SysTick_Config(SystemCoreClock / 1000); +} + +void SystemTick::disable() +{ + SysTick->CTRL = 0; +} + +uint32_t SystemTick::tick() +{ + return this->sys_tick; +} diff --git a/src/platform/cm4/SystemTick.h b/src/platform/cm4/SystemTick.h new file mode 100644 index 0000000..0a52cbf --- /dev/null +++ b/src/platform/cm4/SystemTick.h @@ -0,0 +1,23 @@ +#ifndef __PLATFORM_CM4_SYSTEMTICK_H__ +#define __PLATFORM_CM4_SYSTEMTICK_H__ + +#include "platform/nrf52/InterruptHandler.h" + +namespace pinetime::platform::cm4 { + +class SystemTick : public pinetime::platform::nrf52::InterruptHandler +{ + public: + SystemTick(); + void handle(); + void enable(); + void disable(); + uint32_t tick(); + + private: + uint32_t sys_tick; +}; + +} + +#endif diff --git a/src/platform/hal.h b/src/platform/hal.h deleted file mode 100644 index d3f5234..0000000 --- a/src/platform/hal.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef __PLATFORM_GPIO_H__ -#define __PLATFORM_GPIO_H__ - -#if defined(PLATFORM_nrf52) - #include "platform/nrf52/gpio.h" - #include "platform/nrf52/spi.h" - - namespace hal = platform::nrf52; -#endif - -#endif diff --git a/src/platform/nrf52/InterruptGuardian.cc b/src/platform/nrf52/InterruptGuardian.cc new file mode 100644 index 0000000..fd9762d --- /dev/null +++ b/src/platform/nrf52/InterruptGuardian.cc @@ -0,0 +1,13 @@ +#include "platform/nrf52/InterruptHandler.h" +#include "platform/nrf52/InterruptGuardian.h" + +using namespace pinetime::platform::nrf52; + +InterruptGuardian::InterruptGuardian() +{ +} + +void InterruptGuardian::register_handler(Nrf52IrqN irq_nr, InterruptHandler &handler) +{ + this->nrf52_vector[irq_nr] = &handler; +} diff --git a/src/platform/nrf52/InterruptGuardian.h b/src/platform/nrf52/InterruptGuardian.h new file mode 100644 index 0000000..e884562 --- /dev/null +++ b/src/platform/nrf52/InterruptGuardian.h @@ -0,0 +1,82 @@ +#ifndef __PINETIME_PLATFORM_NRF52_INTERRUPTGUARDIAN_H__ +#define __PINETIME_PLATFORM_NRF52_INTERRUPTGUARDIAN_H__ + +#include + +extern "C" { + #include "nrf52.h" +} + +namespace pinetime::platform::nrf52 { + +class InterruptGuardian +{ +public: + InterruptGuardian(); + + enum Nrf52IrqN { + // CM4 interrupts + RESET_IRQ = 0, //!< -15 Reset Vector, invoked on Power up and warm reset + NON_MASKABLE_INT_IRQ, //!< -14 Non maskable Interrupt, cannot be stopped or preempted + HARD_FAULT_IRQ, //!< -13 Hard Fault, all classes of Fault + MEMORY_MANAGEMENT_IRQ, //!< -12 Memory Management, MPU mismatch, including Access Violation and No Match + BUS_FAULT_IRQ, //!< -11 Bus Fault, Pre-Fetch-, Memory Access Fault, other address/memory related Fault + USAGE_FAULT_IRQ, //!< -10 Usage Fault, i.e. Undef Instruction, Illegal State Transition + SV_CALL_IRQ, //!< -5 System Service Call via SVC instruction + DEBUG_MONITOR_IRQ, //!< -4 Debug Monitor + PEND_SV_IRQ, //!< -2 Pendable request for system service + SYS_TICK_IRQ, //!< -1 System Tick Timer + + // nrf52 interrupts + POWER_CLOCK_IRQn, //!< 0 POWER_CLOCK + RADIO_IRQn, //!< 1 RADIO + UARTE0_UART0_IRQn, //!< 2 UARTE0_UART0 + SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn, //!< 3 SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0 + SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn, //!< 4 SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1 + NFCT_IRQn, //!< 5 NFCT + GPIOTE_IRQn, //!< 6 GPIOTE + SAADC_IRQn, //!< 7 SAADC + TIMER0_IRQn, //!< 8 TIMER0 + TIMER1_IRQn, //!< 9 TIMER1 + TIMER2_IRQn, //!< 10 TIMER2 + RTC0_IRQn, //!< 11 RTC0 + TEMP_IRQn, //!< 12 TEMP + RNG_IRQn, //!< 13 RNG + ECB_IRQn, //!< 14 ECB + CCM_AAR_IRQn, //!< 15 CCM_AAR + WDT_IRQn, //!< 16 WDT + RTC1_IRQn, //!< 17 RTC1 + QDEC_IRQn, //!< 18 QDEC + COMP_LPCOMP_IRQn, //!< 19 COMP_LPCOMP + SWI0_EGU0_IRQn, //!< 20 SWI0_EGU0 + SWI1_EGU1_IRQn, //!< 21 SWI1_EGU1 + SWI2_EGU2_IRQn, //!< 22 SWI2_EGU2 + SWI3_EGU3_IRQn, //!< 23 SWI3_EGU3 + SWI4_EGU4_IRQn, //!< 24 SWI4_EGU4 + SWI5_EGU5_IRQn, //!< 25 SWI5_EGU5 + TIMER3_IRQn, //!< 26 TIMER3 + TIMER4_IRQn, //!< 27 TIMER4 + PWM0_IRQn, //!< 28 PWM0 + PDM_IRQn, //!< 29 PDM + MWU_IRQn, //!< 32 MWU + PWM1_IRQn, //!< 33 PWM1 + PWM2_IRQn, //!< 34 PWM2 + SPIM2_SPIS2_SPI2_IRQn, //!< 35 SPIM2_SPIS2_SPI2 + RTC2_IRQn, //!< 36 RTC2 + I2S_IRQn, //!< 37 I2S + FPU_IRQn //!< 38 FPU + }; + enum { + NRF52_HANDLER_COUNT = FPU_IRQn + 1, + }; + + void register_handler(Nrf52IrqN irq_nr, InterruptHandler &); + + static InterruptGuardian instance; + + std::array nrf52_vector; +}; + +} + +#endif diff --git a/src/platform/nrf52/InterruptHandler.cc b/src/platform/nrf52/InterruptHandler.cc new file mode 100644 index 0000000..b700663 --- /dev/null +++ b/src/platform/nrf52/InterruptHandler.cc @@ -0,0 +1,27 @@ +#include + +#include "platform/nrf52/InterruptHandler.h" +#include "platform/nrf52/InterruptGuardian.h" + +using namespace pinetime::platform::nrf52; + +InterruptHandler::InterruptHandler(uint32_t irq_nr) +{ + InterruptGuardian::instance.register_handler(static_cast(irq_nr), *this); +} + +void InterruptHandler::handle() +{ + asm volatile("nop"); + assert(false); +} + +void InterruptHandler::enable() +{ + assert(false); +} + +void InterruptHandler::disable() +{ + assert(false); +} diff --git a/src/platform/nrf52/InterruptHandler.h b/src/platform/nrf52/InterruptHandler.h new file mode 100644 index 0000000..1199bde --- /dev/null +++ b/src/platform/nrf52/InterruptHandler.h @@ -0,0 +1,22 @@ +#ifndef __PINETIME_PLATFORM_NRF52_INTERRUPTHANDLER_H__ +#define __PINETIME_PLATFORM_NRF52_INTERRUPTHANDLER_H__ + +#include + +#include "interrupt_interface.h" + +namespace pinetime::platform::nrf52 { + +class InterruptHandler : public pinetime::interfaces::InterruptInterface +{ + public: + InterruptHandler(uint32_t); + + void handle() override; + void enable() override; + void disable() override; +}; + +} + +#endif diff --git a/src/platform/nrf52/gpio.cc b/src/platform/nrf52/gpio.cc index eb70ac8..20e8a34 100644 --- a/src/platform/nrf52/gpio.cc +++ b/src/platform/nrf52/gpio.cc @@ -7,7 +7,7 @@ extern "C" { NRF_GPIO_Type *const GPIO_REGS = reinterpret_cast(NRF_P0_BASE); } -using namespace platform::nrf52; +using namespace pinetime::platform::nrf52; Gpio::Gpio(uint32_t pin) : pin_number(pin) diff --git a/src/platform/nrf52/gpio.h b/src/platform/nrf52/gpio.h index bc0e230..e16e536 100644 --- a/src/platform/nrf52/gpio.h +++ b/src/platform/nrf52/gpio.h @@ -3,9 +3,9 @@ #include "gpio_interface.h" -namespace platform::nrf52 { +namespace pinetime::platform::nrf52 { -class Gpio : public interfaces::GpioInterface +class Gpio : public pinetime::interfaces::GpioInterface { public: inline Gpio() {} diff --git a/src/platform/nrf52/low_level_interrupt.cc b/src/platform/nrf52/low_level_interrupt.cc new file mode 100644 index 0000000..7bf7ad3 --- /dev/null +++ b/src/platform/nrf52/low_level_interrupt.cc @@ -0,0 +1,66 @@ +#include + +#include "platform/nrf52/InterruptHandler.h" +#include "platform/nrf52/InterruptGuardian.h" + +extern "C" { + void NMI_Handler(void); + void HardFault_Handler(void); + void MemoryManagement_Handler(void); + void BusFault_Handler(void); + void UsageFault_Handler(void); + void SVC_Handler(void); + void DebugMon_Handler(void); + void PendSV_Handler(void); + void SysTick_Handler(void); + + void POWER_CLOCK_IRQHandler(void); + void RADIO_IRQHandler(void); + void UARTE0_UART0_IRQHandler(void); + void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void); + void SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler(void); + void NFCT_IRQHandler(void); + void GPIOTE_IRQHandler(void); + void SAADC_IRQHandler(void); + void TIMER0_IRQHandler(void); + void TIMER1_IRQHandler(void); + void TIMER2_IRQHandler(void); + void RTC0_IRQHandler(void); + void TEMP_IRQHandler(void); + void RNG_IRQHandler(void); + void ECB_IRQHandler(void); + void CCM_AAR_IRQHandler(void); + void WDT_IRQHandler(void); + void RTC1_IRQHandler(void); + void QDEC_IRQHandler(void); + void COMP_LPCOMP_IRQHandler(void); + void SWI0_EGU0_IRQHandler(void); + void SWI1_EGU1_IRQHandler(void); + void SWI2_EGU2_IRQHandler(void); + void SWI3_EGU3_IRQHandler(void); + void SWI4_EGU4_IRQHandler(void); + void SWI5_EGU5_IRQHandler(void); + void TIMER3_IRQHandler(void); + void TIMER4_IRQHandler(void); + void PWM0_IRQHandler(void); + void PDM_IRQHandler(void); + void MWU_IRQHandler(void); + void PWM1_IRQHandler(void); + void PWM2_IRQHandler(void); + void SPIM2_SPIS2_SPI2_IRQHandler(void); + void RTC2_IRQHandler(void); + void I2S_IRQHandler(void); + void FPU_IRQHandler(void); +} + +using namespace pinetime::platform::nrf52; + +void SysTick_Handler(void) +{ + uint32_t irq_nr = InterruptGuardian::Nrf52IrqN::SYS_TICK_IRQ; + InterruptHandler *h = InterruptGuardian::instance.nrf52_vector[irq_nr]; + + assert(h != nullptr); + + h->handle(); +} diff --git a/src/platform/nrf52/spi.cc b/src/platform/nrf52/spi.cc index adf6a69..1e6664a 100644 --- a/src/platform/nrf52/spi.cc +++ b/src/platform/nrf52/spi.cc @@ -9,9 +9,9 @@ extern "C" { NRF_SPI_Type *SPI_REGS = reinterpret_cast(NRF_SPI0_BASE); } -using namespace platform::nrf52; +using namespace pinetime::platform::nrf52; -Spi::Spi(uint32_t instance, uint32_t sck, uint32_t mosi, uint32_t miso, interfaces::GpioInterface & cs) +Spi::Spi(uint32_t instance, uint32_t sck, uint32_t mosi, uint32_t miso, pinetime::interfaces::GpioInterface & cs) : chip_select(cs) { assert(instance < 3); diff --git a/src/platform/nrf52/spi.h b/src/platform/nrf52/spi.h index 51913c4..13654a5 100644 --- a/src/platform/nrf52/spi.h +++ b/src/platform/nrf52/spi.h @@ -4,12 +4,12 @@ #include "gpio_interface.h" #include "spi_interface.h" -namespace platform::nrf52 { +namespace pinetime::platform::nrf52 { -class Spi : public interfaces::SpiInterface +class Spi : public pinetime::interfaces::SpiInterface { public: - Spi(uint32_t instance, uint32_t sck, uint32_t mosi, uint32_t miso, interfaces::GpioInterface & cs); + Spi(uint32_t instance, uint32_t sck, uint32_t mosi, uint32_t miso, pinetime::interfaces::GpioInterface & cs); ~Spi(); void send(const uint8_t * buffer, uint32_t len) override; void recv(uint8_t * buffer, uint32_t len) override; @@ -17,7 +17,7 @@ public: private: uint32_t transfer(uint32_t); - interfaces::GpioInterface & chip_select; + pinetime::interfaces::GpioInterface & chip_select; }; } diff --git a/src/st7789.cc b/src/st7789.cc index d7f1059..2412869 100644 --- a/src/st7789.cc +++ b/src/st7789.cc @@ -3,10 +3,10 @@ #include "delay.h" #include "st7789.h" -St7789::St7789(interfaces::SpiInterface & spi_if, - interfaces::GpioInterface & rst, - interfaces::GpioInterface & dc, - interfaces::GpioInterface & bl) +St7789::St7789(pinetime::interfaces::SpiInterface & spi_if, + pinetime::interfaces::GpioInterface & rst, + pinetime::interfaces::GpioInterface & dc, + pinetime::interfaces::GpioInterface & bl) : spi(spi_if) , reset(rst) , data_command(dc) diff --git a/src/st7789.h b/src/st7789.h index 7e9e94a..3a34c2c 100644 --- a/src/st7789.h +++ b/src/st7789.h @@ -8,19 +8,19 @@ class St7789 { public: - St7789(interfaces::SpiInterface &, - interfaces::GpioInterface &, - interfaces::GpioInterface &, - interfaces::GpioInterface &); + St7789(pinetime::interfaces::SpiInterface &, + pinetime::interfaces::GpioInterface &, + pinetime::interfaces::GpioInterface &, + pinetime::interfaces::GpioInterface &); void init(); void clear(uint16_t Color); private: - interfaces::SpiInterface & spi; - interfaces::GpioInterface & reset; - interfaces::GpioInterface & data_command; - interfaces::GpioInterface & backlight; + pinetime::interfaces::SpiInterface & spi; + pinetime::interfaces::GpioInterface & reset; + pinetime::interfaces::GpioInterface & data_command; + pinetime::interfaces::GpioInterface & backlight; void send_cmd(uint8_t); void send_data(uint8_t);