mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-22 15:30:09 +00:00
41bdcd4aed
* Update logging * Remove duplicate code * Update unit tests * Clean up includes * Merge ProtobufSerializer into protobuf_util namespace * Precompile regex * Add const * Add Split() convenience method, update log level/ID parsing * Move log.h to legacy folder * Elimininate gotos * Fixes for gcc 13 * Update compiler flags * Update default folder handling * Use references instead of pointers * Move code for better encapsulation * Move code * Remove unused method argument * Move device logger * Remove redundant to_string * Rename for consistency * Update handling of protobuf pointers * Simplify protobuf usage * Memory handling update * Add hasher
66 lines
1.6 KiB
C++
66 lines
1.6 KiB
C++
//---------------------------------------------------------------------------
|
|
//
|
|
// SCSI Target Emulator PiSCSI
|
|
// for Raspberry Pi
|
|
//
|
|
// Powered by XM6 TypeG Technology.
|
|
// Copyright (C) 2016-2020 GIMONS
|
|
// Copyright (C) 2022 akuker
|
|
//
|
|
// [ High resolution timer ]
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
#include "hal/systimer.h"
|
|
#include "hal/systimer_allwinner.h"
|
|
#include "hal/systimer_raspberry.h"
|
|
#include <spdlog/spdlog.h>
|
|
#include <sys/mman.h>
|
|
|
|
#include "hal/gpiobus.h"
|
|
#include "hal/sbc_version.h"
|
|
|
|
bool SysTimer::initialized = false;
|
|
bool SysTimer::is_allwinnner = false;
|
|
bool SysTimer::is_raspberry = false;
|
|
|
|
std::unique_ptr<PlatformSpecificTimer> SysTimer::systimer_ptr;
|
|
|
|
void SysTimer::Init()
|
|
{
|
|
spdlog::trace(__PRETTY_FUNCTION__);
|
|
|
|
if (!initialized) {
|
|
if (SBC_Version::IsRaspberryPi()) {
|
|
systimer_ptr = make_unique<SysTimer_Raspberry>();
|
|
is_raspberry = true;
|
|
} else if (SBC_Version::IsBananaPi()) {
|
|
systimer_ptr = make_unique<SysTimer_AllWinner>();
|
|
is_allwinnner = true;
|
|
}
|
|
systimer_ptr->Init();
|
|
initialized = true;
|
|
}
|
|
}
|
|
|
|
// Get system timer low byte
|
|
uint32_t SysTimer::GetTimerLow()
|
|
{
|
|
return systimer_ptr->GetTimerLow();
|
|
}
|
|
// Get system timer high byte
|
|
uint32_t SysTimer::GetTimerHigh()
|
|
{
|
|
return systimer_ptr->GetTimerHigh();
|
|
}
|
|
// Sleep for N nanoseconds
|
|
void SysTimer::SleepNsec(uint32_t nsec)
|
|
{
|
|
systimer_ptr->SleepNsec(nsec);
|
|
}
|
|
// Sleep for N microseconds
|
|
void SysTimer::SleepUsec(uint32_t usec)
|
|
{
|
|
systimer_ptr->SleepUsec(usec);
|
|
}
|