Quartus II Ver.15.0以上 でプロジェクトファイル i2c_chr_oled/bemicro_max10/bemicro_max10_start.qpf を開いて「Start Compilation」、「Programmer」で転送して実行します。
ファイルの解説
bemicro_max10_start.v プロジェクト・トップ・モジュール
Sjr_I2C_OLED.java Hello,world!プログラム本体
ソースコード
これらのソースコードはBSD 2-Clauseライセンスで公開します。
Sjr_I2C_OLED.java : Hello,world!プログラム本体
/*
Copyright (c) 2015, miya
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
public class Sjr_I2C_OLED
{
private final OpenCoresI2CMasterSimpleIface i2c_if = new OpenCoresI2CMasterSimpleIface();
private final int SLAVE_ADDR = 0x3c;
private final int COMMAND = 0x00;
private final int DATA = 0x40; // システムクロック:50MHz I2Cクロック:100KHz // 50MHz / (5 * 100KHz) - 1 = 99
private final int CLOCK_PRESCALE = 99;
private void busy_wait(int loop)
{
for (int i = 0; i < loop; i++)
{
}
}
@auto
public void main()
{
busy_wait(10000);
// クロック設定
i2c_if.init(CLOCK_PRESCALE);
// このOLEDモジュールでは2バイトでコマンド or データを受け付ける。 // 1バイト目が0x00の時、続く1バイトをコマンドとみなす。 // 0x40の時、続く1バイトをデータとみなす。