diff --git a/source/.mcuxpressoide_packages_support/info.properties b/source/.mcuxpressoide_packages_support/info.properties
index 34605a1..e923eaa 100644
--- a/source/.mcuxpressoide_packages_support/info.properties
+++ b/source/.mcuxpressoide_packages_support/info.properties
@@ -1,5 +1,5 @@
#MCUXpresso IDE
-#Tue Apr 04 17:46:16 EEST 2023
+#Thu Apr 06 10:42:38 EEST 2023
product.name=MCUXpresso IDE v11.5.1 [Build 7266] [2022-04-13]
product.version=11.5.1
product.build=7266
diff --git a/source/shoh/.cproject b/source/shoh/.cproject
index a864a24..12a087c 100644
--- a/source/shoh/.cproject
+++ b/source/shoh/.cproject
@@ -47,6 +47,10 @@
+
+
+
+
@@ -74,6 +78,10 @@
+
+
+
+
@@ -89,6 +97,10 @@
+
+
+
+
@@ -181,6 +193,10 @@
@@ -205,6 +221,10 @@
@@ -220,6 +240,10 @@
+
+
+
+
@@ -276,31 +300,31 @@
- <?xml version="1.0" encoding="UTF-8"?>
-<TargetConfig>
-<Properties property_2="LPC11U6x_256K.cfx" property_3="NXP" property_4="LPC11U68" property_count="5" version="100300"/>
-<infoList vendor="NXP">
-<info chip="LPC11U68" flash_driver="LPC11U6x_256K.cfx" match_id="0x0" name="LPC11U68" stub="crt_emu_cm3_gen">
-<chip>
-<name>LPC11U68</name>
-<family>LPC11U6x</family>
-<vendor>NXP (formerly Philips)</vendor>
-<reset board="None" core="Real" sys="Real"/>
-<clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/>
-<memory can_program="true" id="Flash" is_ro="true" type="Flash"/>
-<memory id="RAM" type="RAM"/>
-<memory id="Periph" is_volatile="true" type="Peripheral"/>
-<memoryInstance derived_from="Flash" id="MFlash256" location="0x0" size="0x40000"/>
-<memoryInstance derived_from="RAM" id="Ram0_32" location="0x10000000" size="0x8000"/>
-<memoryInstance derived_from="RAM" id="Ram1_2" location="0x20000000" size="0x800"/>
-<memoryInstance derived_from="RAM" id="Ram2USB_2" location="0x20004000" size="0x800"/>
-</chip>
-<processor>
-<name gcc_name="cortex-m0">Cortex-M0</name>
-<family>Cortex-M</family>
-</processor>
-</info>
-</infoList>
+ <?xml version="1.0" encoding="UTF-8"?>
+<TargetConfig>
+<Properties property_2="LPC11U6x_256K.cfx" property_3="NXP" property_4="LPC11U68" property_count="5" version="100300"/>
+<infoList vendor="NXP">
+<info chip="LPC11U68" flash_driver="LPC11U6x_256K.cfx" match_id="0x0" name="LPC11U68" stub="crt_emu_cm3_gen">
+<chip>
+<name>LPC11U68</name>
+<family>LPC11U6x</family>
+<vendor>NXP (formerly Philips)</vendor>
+<reset board="None" core="Real" sys="Real"/>
+<clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/>
+<memory can_program="true" id="Flash" is_ro="true" type="Flash"/>
+<memory id="RAM" type="RAM"/>
+<memory id="Periph" is_volatile="true" type="Peripheral"/>
+<memoryInstance derived_from="Flash" id="MFlash256" location="0x0" size="0x40000"/>
+<memoryInstance derived_from="RAM" id="Ram0_32" location="0x10000000" size="0x8000"/>
+<memoryInstance derived_from="RAM" id="Ram1_2" location="0x20000000" size="0x800"/>
+<memoryInstance derived_from="RAM" id="Ram2USB_2" location="0x20004000" size="0x800"/>
+</chip>
+<processor>
+<name gcc_name="cortex-m0">Cortex-M0</name>
+<family>Cortex-M</family>
+</processor>
+</info>
+</infoList>
</TargetConfig>
diff --git a/source/shoh/src/main.cpp b/source/shoh/src/main.cpp
index 9bd3574..fb5ea66 100644
--- a/source/shoh/src/main.cpp
+++ b/source/shoh/src/main.cpp
@@ -3,8 +3,8 @@
#include "FreeRTOS.h"
#include "task.h"
#include
-#include "FreeRTOSCPP/Kernel.hpp"
-#include "threads/master/Master.h"
+#include "Kernel.hpp"
+#include "Master.h"
int main(void)
{
diff --git a/source/shoh/src/peripherals/DigitalIoPin.cpp b/source/shoh/src/peripherals/DigitalIoPin.cpp
index 13f7d87..8255644 100644
--- a/source/shoh/src/peripherals/DigitalIoPin.cpp
+++ b/source/shoh/src/peripherals/DigitalIoPin.cpp
@@ -61,4 +61,3 @@ DigitalIoPin::write (bool value)
assert (!(_io._input));
Chip_GPIO_SetPinState (LPC_GPIO, _io._port, _io._pin, ((_io._invert) ? !value : value));
}
-
diff --git a/source/shoh/src/peripherals/EEPROMWrapper.cpp b/source/shoh/src/peripherals/EEPROMWrapper.cpp
index 4f9f160..3f6a28f 100644
--- a/source/shoh/src/peripherals/EEPROMWrapper.cpp
+++ b/source/shoh/src/peripherals/EEPROMWrapper.cpp
@@ -7,6 +7,10 @@
#include
+// Remove this when code will be reworked.
+#ifndef EEPROMWRAPPER_NOT_FIXED
+// Remove this when code will be reworked.
+
EEPROM_Wrapper::EEPROM_Wrapper ()
{
/* Enable EEPROM clock and reset EEPROM controller */
@@ -93,3 +97,7 @@ EEPROM_Wrapper::write_to (uint32_t addr, void *data, uint32_t size_of_data)
e_memcpy (data, buffer, size_of_data);
eeprom_use (buffer, addr, size_of_data, WRITE);
}
+
+// Remove this when code will be reworked.
+#endif /* EEPROMWRAPPER_NOT_FIXED */
+// Remove this when code will be reworked.
diff --git a/source/shoh/src/peripherals/EEPROMWrapper.h b/source/shoh/src/peripherals/EEPROMWrapper.h
index b0aed9b..94d0278 100644
--- a/source/shoh/src/peripherals/EEPROMWrapper.h
+++ b/source/shoh/src/peripherals/EEPROMWrapper.h
@@ -8,6 +8,12 @@
#ifndef EEPROMWRAPPER_H_
#define EEPROMWRAPPER_H_
+// Remove this when code will be reworked.
+#define EEPROMWRAPPER_NOT_FIXED
+#ifndef EEPROMWRAPPER_NOT_FIXED
+// Remove this when code will be reworked.
+
+
#include "FreeRTOS.h"
#include "task.h"
#include "chip.h"
@@ -80,4 +86,8 @@ private:
uint8_t buffer[EEPROM_MAX_BUFER_SIZE] = { 0 };
};
+// Remove this when code will be reworked.
+#endif /* EEPROMWRAPPER_NOT_FIXED */
+// Remove this when code will be reworked.
+
#endif /* EEPROMWRAPPER_H_ */
diff --git a/source/shoh/src/peripherals/I2C.cpp b/source/shoh/src/peripherals/I2C.cpp
index 19a0b6f..2104c06 100644
--- a/source/shoh/src/peripherals/I2C.cpp
+++ b/source/shoh/src/peripherals/I2C.cpp
@@ -43,12 +43,22 @@
I2C::I2C (const I2C_config &cfg) : device (nullptr)
{
// if(cfg.device_number == 0) {
- device = LPC_I2C0;
- // board init must have been called before the pins can be configured
- Chip_IOCON_PinMuxSet (LPC_IOCON, 0, 22, IOCON_DIGMODE_EN | cfg.i2c_mode);
- Chip_IOCON_PinMuxSet (LPC_IOCON, 0, 23, IOCON_DIGMODE_EN | cfg.i2c_mode);
- Chip_SWM_EnableFixedPin (SWM_FIXED_I2C0_SCL);
- Chip_SWM_EnableFixedPin (SWM_FIXED_I2C0_SDA);
+ this->device = LPC_I2C0;
+
+ /*
+ Pins
+ The pin requires an external pull-up to provide output functionality.
+ When power is switched off, this pin is floating and does not disturb the I2C lines.
+
+ I2C0_SCL (0, 4). (Available for Fast Mode Plus)
+ I2C1_SCL (0, 7), (1, 11), (1, 30). (Not open-drain)
+ I2C0_SDA (0, 5). (Available for Fast Mode Plus)
+ I2C1_SDA (1, 3), (1, 14), (1, 24). (Not open-drain)
+ */
+ //Manual: Table 83 & 90
+ Chip_SYSCTL_PeriphReset(RESET_I2C0);
+ Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 4, IOCON_FUNC1 | IOCON_DIGMODE_EN | cfg.i2c_mode);
+ Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 5, IOCON_FUNC1 | IOCON_DIGMODE_EN | cfg.i2c_mode);
//}
// else {
// currently we support only I2C number 0
@@ -58,23 +68,21 @@ I2C::I2C (const I2C_config &cfg) : device (nullptr)
{
/* Enable I2C clock and reset I2C peripheral - the boot ROM does not
do this */
- Chip_I2C_Init (LPC_I2C0);
+ Chip_I2CM_Init(this->device);
/* Setup clock rate for I2C */
- Chip_I2C_SetClockDiv (LPC_I2C0, cfg.clock_divider);
+ //No clock divider requiered?
/* Setup I2CM transfer rate */
- Chip_I2CM_SetBusSpeed (LPC_I2C0, cfg.speed);
+ //Bus speed (Determines required amount of clockcyckles for LOW and HIGH signals itself)
+ Chip_I2CM_SetBusSpeed(this->device, cfg.speed);
/* Enable Master Mode */
- Chip_I2CM_Enable (LPC_I2C0);
+ //Enabled by Chip_I2CM_SendStart()
}
}
-I2C::~I2C ()
-{
- // TODO Auto-generated destructor stub
-}
+I2C::~I2C () {}
bool
I2C::write (uint8_t devAddr, uint8_t *txBuffPtr, uint16_t txSize)
@@ -95,8 +103,7 @@ I2C::transaction (uint8_t devAddr, uint8_t *txBuffPtr, uint16_t txSize,
I2CM_XFER_T i2cmXferRec;
// make sure that master is idle
- while (!Chip_I2CM_IsMasterPending (LPC_I2C0))
- ;
+ while (Chip_I2CM_StateChanged(this->device) == 0);
/* Setup I2C transfer record */
i2cmXferRec.slaveAddr = devAddr;
@@ -106,7 +113,7 @@ I2C::transaction (uint8_t devAddr, uint8_t *txBuffPtr, uint16_t txSize,
i2cmXferRec.txBuff = txBuffPtr;
i2cmXferRec.rxBuff = rxBuffPtr;
- I2CM_XferBlocking (LPC_I2C0, &i2cmXferRec);
+ I2CM_XferBlocking (this->device, &i2cmXferRec);
// Chip_I2CM_XferBlocking returns before stop condition is fully completed
// therefore we need to wait for master to be idle when doing back-to-back
// transactions (see beginning of the function)
@@ -136,7 +143,8 @@ I2C::I2CM_XferBlocking (LPC_I2C_T *pI2C, I2CM_XFER_T *xfer)
/* set the transfer status as busy */
xfer->status = I2CM_STATUS_BUSY;
/* Clear controller state. */
- Chip_I2CM_ClearStatus (pI2C, I2C_STAT_MSTRARBLOSS | I2C_STAT_MSTSTSTPERR);
+ Chip_I2CM_ResetControl(pI2C);
+
/* Write Address and RW bit to data register */
// Chip_I2CM_WriteByte(pI2C, (xfer->slaveAddr << 1) | (xfer->txSz == 0)); //
// original NXP version
@@ -150,7 +158,7 @@ I2C::I2CM_XferBlocking (LPC_I2C_T *pI2C, I2CM_XFER_T *xfer)
while (ret == 0)
{
/* wait for status change interrupt */
- while (!Chip_I2CM_IsMasterPending (pI2C))
+ while (Chip_I2CM_StateChanged(pI2C) == 0)
{
}
/* call state change handler */
diff --git a/source/shoh/src/peripherals/I2C.h b/source/shoh/src/peripherals/I2C.h
index 910a596..34a856b 100644
--- a/source/shoh/src/peripherals/I2C.h
+++ b/source/shoh/src/peripherals/I2C.h
@@ -9,6 +9,7 @@
#define I2C_H_
#include "chip.h"
+#include "board.h"
struct I2C_config {
unsigned int device_number;
diff --git a/source/shoh/src/peripherals/LiquidCrystal.cpp b/source/shoh/src/peripherals/LiquidCrystal.cpp
index 234f925..6fe05ef 100644
--- a/source/shoh/src/peripherals/LiquidCrystal.cpp
+++ b/source/shoh/src/peripherals/LiquidCrystal.cpp
@@ -1,5 +1,10 @@
#include "LiquidCrystal.h"
+// Remove this when code will be reworked.
+#ifndef LiquidCrystal_NOT_FIXED
+// Remove this when code will be reworked.
+
+
#include
#include "chip.h"
@@ -287,3 +292,6 @@ void LiquidCrystal::write4bits(uint8_t value) {
pulseEnable();
}
+// Remove this when code will be reworked.
+#endif /* LiquidCrystal_NOT_FIXED */
+// Remove this when code will be reworked.
diff --git a/source/shoh/src/peripherals/LiquidCrystal.h b/source/shoh/src/peripherals/LiquidCrystal.h
index 7c4dcee..546565e 100644
--- a/source/shoh/src/peripherals/LiquidCrystal.h
+++ b/source/shoh/src/peripherals/LiquidCrystal.h
@@ -1,6 +1,10 @@
#ifndef LiquidCrystal_h
#define LiquidCrystal_h
+// Remove this when code will be reworked.
+#define LiquidCrystal_NOT_FIXED
+#ifndef LiquidCrystal_NOT_FIXED
+// Remove this when code will be reworked.
#include
#include
@@ -94,4 +98,8 @@ private:
uint8_t _numlines,_currline;
};
-#endif
+// Remove this when code will be reworked.
+#endif /* LiquidCrystal_NOT_FIXED */
+// Remove this when code will be reworked.
+
+#endif /* LiquidCrystal_h */
diff --git a/source/shoh/src/peripherals/LpcUart.cpp b/source/shoh/src/peripherals/LpcUart.cpp
index e90bcc0..7e4e08d 100644
--- a/source/shoh/src/peripherals/LpcUart.cpp
+++ b/source/shoh/src/peripherals/LpcUart.cpp
@@ -9,6 +9,10 @@
#include
#include "LpcUart.h"
+// Remove this when code will be reworked.
+#ifndef LPCUART_NOT_FIXED
+// Remove this when code will be reworked.
+
static LpcUart *u0;
static LpcUart *u1;
@@ -313,3 +317,7 @@ bool LpcUart::txempty()
return (RingBuffer_GetCount(&txring) == 0);
}
+
+// Remove this when code will be reworked.
+#endif /* LPCUART_NOT_FIXED */
+// Remove this when code will be reworked.
diff --git a/source/shoh/src/peripherals/LpcUart.h b/source/shoh/src/peripherals/LpcUart.h
index 2e7e799..38a88ac 100644
--- a/source/shoh/src/peripherals/LpcUart.h
+++ b/source/shoh/src/peripherals/LpcUart.h
@@ -8,6 +8,12 @@
#ifndef LPCUART_H_
#define LPCUART_H_
+// Remove this when code will be reworked.
+#define LPCUART_NOT_FIXED
+#ifndef LPCUART_NOT_FIXED
+// Remove this when code will be reworked.
+
+
#include "chip.h"
#include "FreeRTOS.h"
#include "task.h"
@@ -69,4 +75,8 @@ private:
Fmutex write_mutex;
};
+// Remove this when code will be reworked.
+#endif /* LPCUART_NOT_FIXED */
+// Remove this when code will be reworked.
+
#endif /* LPCUART_H_ */