Internal ROM

(2016.3.27 Created) 

 デバイス内部に設けられているROMへの読み書きを行うクラスです。こちらでダウロードできます。Arduinoの場合はEEPROM, STM32の場合はFlashが対象です。

The class provides reading and writing method to the device internal ROM. You can Download here. The ROM is EEPROM in case of arduino, and is Flash in case of STM32.

 Arduinoの場合は単純に読み書きするだけですが、STM32の場合は別ページを参照してください。

In case of arduino it can simply read / write, but in case of STM32, please refer another page.

Command Reference

コンストラクタ / Constructor

Declaration

InterRom();

Return

None

Parameter None
Note  

Read from ROM

Declaration

uint8_t ReadU8(const uint32_t &Address) const;

uint16_t ReadU16(const uint32_t &Address) const;

uint32_t ReadU32(const uint32_t &Address) const;

uint64_t ReadU64(const uint32_t &Address) const;

 

DKS::DKS_RESULT Read(  const uint32_t &Address,                                              uint8_t Data[],

                                     const uint32_t &Length) const;

Return

read value

Parameter Start address to read
Note

アドレスの範囲チェックは行いません。

Do not check the address.

Write to ROM

Declaration

DKS::DKS_RESULT Write(const uint32_t &Address,

                                      const uint8_t &Value) const;

DKS::DKS_RESULT Write(const uint32_t &Address,

                                     const uint16_t &Value) const;

DKS::DKS_RESULT Write(const uint32_t &Address,

                                      const uint32_t &Value) const;

DKS::DKS_RESULT Write(const uint32_t &Address,

                                     const uint64_t &Value) const;

 

DKS::DKS_RESULT Write(const uint32_t &Address,

                                     const uint8_t Data[],

                                   const uint32_t &Length) const; 

Return

None

Parameter Start address to write
Note

アドレスの範囲チェックは行いません。

Do not check the address.

Sample code

 Arduino用のサンプルコードです。STM32用はここにあります。

It is a sample code for arduino. STM32 code is here.

#include "DKS_InterRom_Arduino.h"
DKS::InterRom *rom;

void setup() {
  Serial.begin(9600);
  rom = new DKS::InterRom();

  Serial.print(F("int value read/write test : "));
  const uint32_t u32w = 0x12345;
  rom->Write(0x00, u32w);
  uint32_t u32r;
  u32r = rom->ReadU32(0x00);
  if (u32w == u32r) Serial.println(F("OK"));
  else Serial.println(F("NG"));

  Serial.print(F("array read/write test : "));
  const uint8_t arrayW[] = {0x12, 0x34};
  rom->Write(5U, arrayW, sizeof(arrayW));
  uint8_t arrayR[sizeof(arrayW)];
  rom->Read(5, arrayR, sizeof(arrayR));
  if ((arrayR[0] == arrayW[0]) && (arrayR[1] == arrayW[1]))Serial.println(F("OK"));
  else Serial.println(F("NG"));
}

void loop() {
}