Library for LCD ACM1602NI connected using I2C on Nucleo F401 is not to be found. Using I2C class offered by mbed, I cannot program for this LCD on Nucleo F401. So I programmed for this LCD to control by direct accsessing registors for I2C in STM32F401RE. Nucleo F401 で使用できる,I2C 接続の LCD ACM1602NI 用のライブラリ.このライブラリでは,I2C クラスのコンストラクタとクロック周波数設定のメンバ関数は使っているが,その他のメンバ関数などは使っていない.その理由は,タイミングの関係だと思うが,I2C クラスのメンバ関数では正常に動くプログラムを,どうしても作れないことによる.しょうがないので,MCU の I2C 関係のレジスタに直接アクセスするようなプログラムを作ったたところ,動くようになった.Nucleo の F401RE 以外については確認していない.動かない場合は,I2C 用のレジスタのアドレスを,使っている MCU に応じて書きかえる必要がある.
Dependents: ACM1602NI_Nucleo_Demo
Revision 1:cace20837286, committed 2014-09-13
- Comitter:
- MikamiUitOpen
- Date:
- Sat Sep 13 08:01:47 2014 +0000
- Parent:
- 0:8167316a0a40
- Child:
- 2:edf345c86b3b
- Commit message:
- 2
Changed in this revision
ACM1602NI.cpp | Show annotated file Show diff for this revision Revisions of this file |
ACM1602NI.hpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/ACM1602NI.cpp Thu Aug 28 08:53:52 2014 +0000 +++ b/ACM1602NI.cpp Sat Sep 13 08:01:47 2014 +0000 @@ -16,17 +16,17 @@ uint32_t i2cAddr = 0; if ( ((sda == PB_9) || (sda == PB_7)) && ((scl == PB_8) || (scl == PB_6)) ) - i2cAddr = I2C_1; // I2C1 used + i2cAddr = I2C_1; // I2C1 will be used if ( (sda == PB_3) && (scl == PB_10) ) - i2cAddr = I2C_2; // I2C2 used + i2cAddr = I2C_2; // I2C2 will be used if ( ((sda == PC_9) || (sda == PB_4)) && (scl == PA_8) ) - i2cAddr = I2C_3; // I2C3 used + i2cAddr = I2C_3; // I2C3 will be used - i2c_cr1_ = (uint16_t *)i2cAddr; - i2c_dr_ = (uint16_t *)(i2cAddr + 0x10); - i2c_sr1_ = (uint16_t *)(i2cAddr + 0x14); - i2c_sr2_ = (uint16_t *)(i2cAddr + 0x18); + i2c_cr1_ = (uint32_t *)i2cAddr; + i2c_dr_ = (uint32_t *)(i2cAddr + 0x10); + i2c_sr1_ = (uint32_t *)(i2cAddr + 0x14); + i2c_sr2_ = (uint32_t *)(i2cAddr + 0x18); connected_ = Clear(); // Clear display if (!connected_) return; @@ -107,5 +107,3 @@ return true; } } - -
--- a/ACM1602NI.hpp Thu Aug 28 08:53:52 2014 +0000 +++ b/ACM1602NI.hpp Sat Sep 13 08:01:47 2014 +0000 @@ -55,19 +55,19 @@ bool LcdTx(uint8_t cmdData, uint8_t data); bool Start(); - // Forbit to use copy constructor + // Forbid to use copy constructor Acm1602Ni(const Acm1602Ni&); - // Forbit to use substitution operator + // Forbid to use substitution operator Acm1602Ni& operator=(const Acm1602Ni&); - uint16_t* i2c_cr1_; // pointer to I2C_CR1 (control register 1) - uint16_t* i2c_dr_; // pointer to I2C_DR (data register) - uint16_t* i2c_sr1_; // pointer to I2C_SR1 (status register 1) - uint16_t* i2c_sr2_; // pointer to I2C_SR2 (status register 2) + uint32_t* i2c_cr1_; // pointer to I2C_CR1 (control register 1) + uint32_t* i2c_dr_; // pointer to I2C_DR (data register) + uint32_t* i2c_sr1_; // pointer to I2C_SR1 (status register 1) + uint32_t* i2c_sr2_; // pointer to I2C_SR2 (status register 2) I2C i2c_; // Object of I2C // For check contents of register - bool Check(uint16_t* rg, uint16_t value) + bool Check(uint32_t* rg, uint16_t value) { return value == ((*rg) & value); } void TxDR(uint8_t data) { *i2c_dr_ = data; }