Compare commits
1 Commits
605c422c39
...
645ded6c58
Author | SHA1 | Date | |
---|---|---|---|
|
645ded6c58 |
26
.vscode/tasks.json
vendored
26
.vscode/tasks.json
vendored
@ -1,25 +1,21 @@
|
||||
{
|
||||
// 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": "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": "${BUILD_CMD} make all -j8",
|
||||
"command": "make all -j8",
|
||||
"problemMatcher": {
|
||||
"base": "$gcc",
|
||||
"owner": "gcc",
|
||||
@ -53,7 +49,7 @@
|
||||
{
|
||||
"label": "clean",
|
||||
"type":"shell",
|
||||
"command": "${BUILD_CMD} make clean -j8",
|
||||
"command": "make clean -j8",
|
||||
"problemMatcher": {
|
||||
"base": "$gcc",
|
||||
"owner": "gcc",
|
||||
@ -70,7 +66,7 @@
|
||||
{
|
||||
"label": "distclean",
|
||||
"type":"shell",
|
||||
"command": "${BUILD_CMD} make distclean",
|
||||
"command": "make distclean",
|
||||
"problemMatcher": {
|
||||
"base": "$gcc",
|
||||
"owner": "gcc",
|
||||
@ -101,5 +97,11 @@
|
||||
"isDefault": true
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"presentation": {
|
||||
"focus": true,
|
||||
"reveal": "always",
|
||||
"panel": "shared",
|
||||
"clear": true,
|
||||
}
|
||||
}
|
||||
|
6
Makefile
6
Makefile
@ -3,11 +3,6 @@
|
||||
APPLICATION ?= blinky
|
||||
|
||||
PLATFORM ?= nrf52
|
||||
|
||||
ifneq "$(findstring $(PLATFORM), nrf52)" ""
|
||||
CORE = cm4
|
||||
endif
|
||||
|
||||
TARGET_FILE ?= $(APPLICATION).elf
|
||||
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
@ -30,7 +25,6 @@ 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)))
|
||||
|
@ -1,12 +1,7 @@
|
||||
#include <array>
|
||||
|
||||
#include "delay.h"
|
||||
|
||||
#include "platform/nrf52/gpio.h"
|
||||
#include "platform/nrf52/InterruptHandler.h"
|
||||
#include "platform/nrf52/InterruptGuardian.h"
|
||||
|
||||
using namespace pinetime::platform::nrf52;
|
||||
#include "platform/hal.h"
|
||||
|
||||
enum {
|
||||
PIN_NUMBER_LED_1 = 17,
|
||||
@ -15,20 +10,18 @@ enum {
|
||||
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);
|
||||
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);
|
||||
|
||||
std::array<Gpio *, 4> leds = {&led_1, &led_2, &led_3, &led_4};
|
||||
|
||||
InterruptGuardian InterruptGuardian::instance;
|
||||
std::array<hal::Gpio *, 4> leds = {&led_1, &led_2, &led_3, &led_4};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
while(true) {
|
||||
for(auto it = std::begin(leds); it != std::end(leds); ++it) {
|
||||
Gpio * tmp = *it;
|
||||
hal::Gpio * tmp = *it;
|
||||
tmp->toggle();
|
||||
delay_ms(500);
|
||||
}
|
||||
|
@ -1,17 +1,11 @@
|
||||
|
||||
#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"
|
||||
|
||||
using namespace pinetime::platform::nrf52;
|
||||
using namespace hal;
|
||||
|
||||
const uint8_t buf[] = "Test";
|
||||
|
||||
InterruptGuardian InterruptGuardian::instance;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Gpio led_1(17);
|
||||
|
@ -1,25 +1,18 @@
|
||||
#include "delay.h"
|
||||
|
||||
#include "platform/nrf52/gpio.h"
|
||||
#include "platform/nrf52/spi.h"
|
||||
#include "platform/nrf52/InterruptHandler.h"
|
||||
#include "platform/nrf52/InterruptGuardian.h"
|
||||
#include "platform/hal.h"
|
||||
#include "st7789.h"
|
||||
|
||||
using namespace pinetime::platform::nrf52;
|
||||
hal::Gpio led_1(17);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
St7789 lcd(lcd_spi, lcd_reset, lcd_data_command, lcd_backlight);
|
||||
|
||||
InterruptGuardian InterruptGuardian::instance;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcd.init();
|
||||
|
@ -1,47 +0,0 @@
|
||||
#include <array>
|
||||
|
||||
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<Gpio *, 4> 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;
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
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;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
#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
|
11
src/platform/hal.h
Normal file
11
src/platform/hal.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef __PLATFORM_GPIO_H__
|
||||
#define __PLATFORM_GPIO_H__
|
||||
|
||||
#if defined(PLATFORM_nrf52)
|
||||
#include "platform/nrf52/gpio.h"
|
||||
#include "platform/nrf52/spi.h"
|
||||
|
||||
namespace hal = pinetime::platform::nrf52;
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,5 +1,3 @@
|
||||
#include <cassert>
|
||||
|
||||
#include "platform/nrf52/InterruptHandler.h"
|
||||
#include "platform/nrf52/InterruptGuardian.h"
|
||||
|
||||
@ -57,10 +55,6 @@ 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);
|
||||
|
||||
InterruptHandler *h = InterruptGuardian::instance.nrf52_vector[InterruptGuardian::Nrf52IrqN::SYS_TICK_IRQ];
|
||||
h->handle();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user