|
|
1.1 root 1: //
2: // nono
1.1.1.3 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
1.1.1.2 root 7: // MPU 共通部
8:
1.1 root 9: #include "mpu.h"
1.1.1.5 root 10: #include "config.h"
1.1 root 11:
1.1.1.2 root 12: std::unique_ptr<MPUDevice> gMPU;
1.1 root 13:
14: // コンストラクタ
1.1.1.7 root 15: MPUDevice::MPUDevice(const std::string& objname_)
16: : inherited(objname_)
1.1 root 17: {
1.1.1.7 root 18: ClearAlias();
19: AddAlias("MPU");
1.1 root 20: }
21:
22: // デストラクタ
23: MPUDevice::~MPUDevice()
24: {
25: }
1.1.1.4 root 26:
1.1.1.5 root 27: bool
28: MPUDevice::Init()
29: {
30: // MPU クロック
31: const ConfigItem& item = gConfig->Find("mpu-clock");
32: const std::string& val = item.AsString();
33: if (val.empty()) {
34: item.Err();
35: return false;
36: }
37: // 文字列を double に変換
38: char *end;
39: errno = 0;
40: double f = strtod(val.c_str(), &end);
41: if (end == val.c_str() || end[0] != '\0' || errno == ERANGE) {
42: item.Err();
43: return false;
44: }
45: // 設定の "mpu-clock" は MHz 単位だが、変数 clock_khz は kHz 単位。
46: clock_khz = (int)(f * 1000);
1.1.1.7 root 47: // 1MHz 未満はエラー。実際 10MHz 未満でもいい気がするけど
1.1.1.5 root 48: if (clock_khz < 1000) {
49: item.Err();
50: return false;
51: }
52:
53: return true;
54: }
1.1.1.8 ! root 55:
! 56: // Round Mode (モニタ表示用)
! 57: /*static*/ const char * const
! 58: MPUDevice::rmstr[4] = {
! 59: "Near",
! 60: "Zero",
! 61: "Minus",
! 62: "Plus",
! 63: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.