From 618972e944942d7c3b4dac1f7c769608ea1d897c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 4 Mar 2019 15:30:04 +0100 Subject: Add LM75 DFA model --- include/driver/lm75.h | 2 ++ model/driver/lm75.dfa | 35 +++++++++++++++++++++++++++++++++++ src/driver/lm75.cc | 14 ++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 model/driver/lm75.dfa diff --git a/include/driver/lm75.h b/include/driver/lm75.h index 5bb92fa..693578a 100644 --- a/include/driver/lm75.h +++ b/include/driver/lm75.h @@ -16,6 +16,8 @@ class LM75 { unsigned int getHyst(); void setOS(unsigned char os); void setHyst(unsigned char hyst); + void init(); + void shutdown(); }; extern LM75 lm75; diff --git a/model/driver/lm75.dfa b/model/driver/lm75.dfa new file mode 100644 index 0000000..5aadb8f --- /dev/null +++ b/model/driver/lm75.dfa @@ -0,0 +1,35 @@ +instance: lm75 + +parameters: + - os + - hyst + +states: + - UNINITIALIZED + - POWEROFF + - ACTIVE + +transition: + shutdown: + src: [UNINITIALIZED, POWEROFF, ACTIVE] + dst: POWEROFF + init: + src: [UNINITIALIZED, POWEROFF, ACTIVE] + dst: ACTIVE + getTemp: + src: [ACTIVE] + dst: ACTIVE + setOS: + src: [ACTIVE] + dst: ACTIVE + arguments: + - name: os + values: [30, 90] + parameter: os + setHyst: + src: [ACTIVE] + dst: ACTIVE + arguments: + - name: hyst + values: [29, 60] + parameter: hyst diff --git a/src/driver/lm75.cc b/src/driver/lm75.cc index 83b2dcf..2223137 100644 --- a/src/driver/lm75.cc +++ b/src/driver/lm75.cc @@ -49,4 +49,18 @@ void LM75::setHyst(unsigned char hyst) i2c.xmit(address, 3, txbuf, 0, rxbuf); } +void LM75::init() +{ + txbuf[0] = 0x01; + txbuf[1] = 0x00; + i2c.xmit(address, 2, txbuf, 0, rxbuf); +} + +void LM75::shutdown() +{ + txbuf[0] = 0x01; + txbuf[1] = 0x01; + i2c.xmit(address, 2, txbuf, 0, rxbuf); +} + LM75 lm75(0x48); -- cgit v1.2.3