dev/irq #8
6
Makefile
6
Makefile
@ -3,6 +3,11 @@
|
|||||||
APPLICATION ?= blinky
|
APPLICATION ?= blinky
|
||||||
|
|
||||||
PLATFORM ?= nrf52
|
PLATFORM ?= nrf52
|
||||||
|
|
||||||
|
ifneq "$(findstring $(PLATFORM), nrf52)" ""
|
||||||
|
CORE = cm4
|
||||||
|
endif
|
||||||
|
|
||||||
TARGET_FILE ?= $(APPLICATION).elf
|
TARGET_FILE ?= $(APPLICATION).elf
|
||||||
|
|
||||||
CC = $(CROSS_COMPILE)gcc
|
CC = $(CROSS_COMPILE)gcc
|
||||||
@ -25,6 +30,7 @@ C_SRCS += $(wildcard $(SRC_DIR)/application/$(APPLICATION)/*.c)
|
|||||||
C_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.c,%.c.o,$(C_SRCS)))
|
C_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.c,%.c.o,$(C_SRCS)))
|
||||||
|
|
||||||
CC_SRCS = $(wildcard $(SRC_DIR)/*.cc)
|
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)/platform/$(PLATFORM)/*.cc)
|
||||||
CC_SRCS += $(wildcard $(SRC_DIR)/application/$(APPLICATION)/*.cc)
|
CC_SRCS += $(wildcard $(SRC_DIR)/application/$(APPLICATION)/*.cc)
|
||||||
CC_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.cc,%.cc.o,$(CC_SRCS)))
|
CC_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.cc,%.cc.o,$(CC_SRCS)))
|
||||||
|
35
src/platform/cm4/SystemTick.cc
Normal file
35
src/platform/cm4/SystemTick.cc
Normal file
@ -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;
|
||||||
|
}
|
23
src/platform/cm4/SystemTick.h
Normal file
23
src/platform/cm4/SystemTick.h
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user