mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[ion] Implement Log::print using SWO on the device
Change-Id: I17e024535cc0f0daf74953c7221e2b98959e6c47
This commit is contained in:
@@ -8,6 +8,8 @@ set pagination off
|
||||
load
|
||||
|
||||
# Tell OpenOCD to reset and halt
|
||||
monitor itm ports on
|
||||
monitor tpiu config internal swo.log.bin uart off 16000000
|
||||
monitor reset halt
|
||||
|
||||
break init
|
||||
|
||||
@@ -7,6 +7,7 @@ objs += $(addprefix ion/src/device/, \
|
||||
display.o\
|
||||
keyboard.o\
|
||||
led.o\
|
||||
log.o\
|
||||
power.o\
|
||||
sd_card.o\
|
||||
)
|
||||
|
||||
15
ion/src/device/log.cpp
Normal file
15
ion/src/device/log.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <ion/log.h>
|
||||
#include "regs/itm.h"
|
||||
|
||||
// We're printing using SWO.
|
||||
// This is achieved by writing to the ITM register, which is sent through the
|
||||
// Cortex Debug bus
|
||||
|
||||
void Ion::Log::print(const char * message) {
|
||||
char character = 0;
|
||||
while ((character = *message++) != 0) {
|
||||
if (ITM.TER()->get(0)) {
|
||||
ITM.STIM(0)->set(character);
|
||||
}
|
||||
}
|
||||
}
|
||||
32
ion/src/device/regs/itm.h
Normal file
32
ion/src/device/regs/itm.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef REGS_ITM_H
|
||||
#define REGS_ITM_H
|
||||
|
||||
#include "register.h"
|
||||
|
||||
// See ARM Cortex M4 TRM
|
||||
|
||||
class ITM {
|
||||
public:
|
||||
class STIM : public Register8 {
|
||||
};
|
||||
|
||||
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0314h/Chdbicac.html
|
||||
class TER : Register32 {
|
||||
public:
|
||||
bool get(int index) volatile { return (bool)getBitRange(index, index); }
|
||||
};
|
||||
|
||||
constexpr ITM() {};
|
||||
volatile STIM * STIM(int i) const {
|
||||
return (class STIM *)(Base() + 4*i);
|
||||
};
|
||||
REGS_REGISTER_AT(TER, 0xE00);
|
||||
private:
|
||||
constexpr uint32_t Base() const {
|
||||
return 0xE0000000;
|
||||
}
|
||||
};
|
||||
|
||||
constexpr ITM ITM;
|
||||
|
||||
#endif
|
||||
@@ -37,6 +37,7 @@ private:
|
||||
T m_value;
|
||||
};
|
||||
|
||||
typedef Register<uint8_t> Register8;
|
||||
typedef Register<uint16_t> Register16;
|
||||
typedef Register<uint32_t> Register32;
|
||||
typedef Register<uint64_t> Register64;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "flash.h"
|
||||
#include "fsmc.h"
|
||||
#include "gpio.h"
|
||||
#include "itm.h"
|
||||
#include "pwr.h"
|
||||
#include "rcc.h"
|
||||
#include "sdio.h"
|
||||
|
||||
Reference in New Issue
Block a user