Merge pull request #17 from vas-dav/essential-libs

Essential libs
This commit is contained in:
RedHawk 2023-04-18 14:27:26 +03:00 committed by GitHub
commit 43398065f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 133 additions and 49 deletions

View File

@ -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

View File

@ -47,6 +47,10 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_11u6x/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/freertos}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/freertos/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/master}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/peripherals}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/FreeRTOSCPP}&quot;"/>
</option>
<option id="com.crt.advproject.cpp.misc.dialect.4036734" name="Language standard" superClass="com.crt.advproject.cpp.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.cpp17" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.cpp.input.2005422649" superClass="com.crt.advproject.compiler.cpp.input"/>
@ -74,6 +78,10 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_11u6x/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/freertos}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/freertos/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/master}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/peripherals}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/FreeRTOSCPP}&quot;"/>
</option>
<option id="com.crt.advproject.c.misc.dialect.82852045" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c17" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.input.765511076" superClass="com.crt.advproject.compiler.input"/>
@ -89,6 +97,10 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_11u6x/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/freertos}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/freertos/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/master}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/peripherals}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/FreeRTOSCPP}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1836378919" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
<inputType id="com.crt.advproject.assembler.input.339410672" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
@ -181,6 +193,10 @@
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.include.paths.722676070" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_11u68/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_11u6x/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/master}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/peripherals}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/FreeRTOSCPP}&quot;"/>
</option>
<inputType id="com.crt.advproject.compiler.cpp.input.903614193" superClass="com.crt.advproject.compiler.cpp.input"/>
</tool>
@ -205,6 +221,10 @@
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.1942745624" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_11u68/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_11u6x/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/master}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/peripherals}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/FreeRTOSCPP}&quot;"/>
</option>
<option id="com.crt.advproject.c.misc.dialect.1008527937" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c17" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.input.246185412" superClass="com.crt.advproject.compiler.input"/>
@ -220,6 +240,10 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_11u6x/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/freertos}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/freertos/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/master}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/peripherals}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/FreeRTOSCPP}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1117166373" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
<inputType id="com.crt.advproject.assembler.input.2071009798" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
@ -276,31 +300,31 @@
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="com.crt.config">
<projectStorage>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;TargetConfig&gt;
&lt;Properties property_2="LPC11U6x_256K.cfx" property_3="NXP" property_4="LPC11U68" property_count="5" version="100300"/&gt;
&lt;infoList vendor="NXP"&gt;
&lt;info chip="LPC11U68" flash_driver="LPC11U6x_256K.cfx" match_id="0x0" name="LPC11U68" stub="crt_emu_cm3_gen"&gt;
&lt;chip&gt;
&lt;name&gt;LPC11U68&lt;/name&gt;
&lt;family&gt;LPC11U6x&lt;/family&gt;
&lt;vendor&gt;NXP (formerly Philips)&lt;/vendor&gt;
&lt;reset board="None" core="Real" sys="Real"/&gt;
&lt;clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/&gt;
&lt;memory can_program="true" id="Flash" is_ro="true" type="Flash"/&gt;
&lt;memory id="RAM" type="RAM"/&gt;
&lt;memory id="Periph" is_volatile="true" type="Peripheral"/&gt;
&lt;memoryInstance derived_from="Flash" id="MFlash256" location="0x0" size="0x40000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram0_32" location="0x10000000" size="0x8000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram1_2" location="0x20000000" size="0x800"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram2USB_2" location="0x20004000" size="0x800"/&gt;
&lt;/chip&gt;
&lt;processor&gt;
&lt;name gcc_name="cortex-m0"&gt;Cortex-M0&lt;/name&gt;
&lt;family&gt;Cortex-M&lt;/family&gt;
&lt;/processor&gt;
&lt;/info&gt;
&lt;/infoList&gt;
<projectStorage>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&#13;
&lt;TargetConfig&gt;&#13;
&lt;Properties property_2="LPC11U6x_256K.cfx" property_3="NXP" property_4="LPC11U68" property_count="5" version="100300"/&gt;&#13;
&lt;infoList vendor="NXP"&gt;&#13;
&lt;info chip="LPC11U68" flash_driver="LPC11U6x_256K.cfx" match_id="0x0" name="LPC11U68" stub="crt_emu_cm3_gen"&gt;&#13;
&lt;chip&gt;&#13;
&lt;name&gt;LPC11U68&lt;/name&gt;&#13;
&lt;family&gt;LPC11U6x&lt;/family&gt;&#13;
&lt;vendor&gt;NXP (formerly Philips)&lt;/vendor&gt;&#13;
&lt;reset board="None" core="Real" sys="Real"/&gt;&#13;
&lt;clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/&gt;&#13;
&lt;memory can_program="true" id="Flash" is_ro="true" type="Flash"/&gt;&#13;
&lt;memory id="RAM" type="RAM"/&gt;&#13;
&lt;memory id="Periph" is_volatile="true" type="Peripheral"/&gt;&#13;
&lt;memoryInstance derived_from="Flash" id="MFlash256" location="0x0" size="0x40000"/&gt;&#13;
&lt;memoryInstance derived_from="RAM" id="Ram0_32" location="0x10000000" size="0x8000"/&gt;&#13;
&lt;memoryInstance derived_from="RAM" id="Ram1_2" location="0x20000000" size="0x800"/&gt;&#13;
&lt;memoryInstance derived_from="RAM" id="Ram2USB_2" location="0x20004000" size="0x800"/&gt;&#13;
&lt;/chip&gt;&#13;
&lt;processor&gt;&#13;
&lt;name gcc_name="cortex-m0"&gt;Cortex-M0&lt;/name&gt;&#13;
&lt;family&gt;Cortex-M&lt;/family&gt;&#13;
&lt;/processor&gt;&#13;
&lt;/info&gt;&#13;
&lt;/infoList&gt;&#13;
&lt;/TargetConfig&gt;</projectStorage>
</storageModule>
<storageModule moduleId="com.crt.advproject">

View File

@ -3,8 +3,8 @@
#include "FreeRTOS.h"
#include "task.h"
#include <cr_section_macros.h>
#include "FreeRTOSCPP/Kernel.hpp"
#include "threads/master/Master.h"
#include "Kernel.hpp"
#include "Master.h"
int main(void)
{

View File

@ -61,4 +61,3 @@ DigitalIoPin::write (bool value)
assert (!(_io._input));
Chip_GPIO_SetPinState (LPC_GPIO, _io._port, _io._pin, ((_io._invert) ? !value : value));
}

View File

@ -7,6 +7,10 @@
#include <EEPROMWrapper.h>
// 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.

View File

@ -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_ */

View File

@ -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 */

View File

@ -9,6 +9,7 @@
#define I2C_H_
#include "chip.h"
#include "board.h"
struct I2C_config {
unsigned int device_number;

View File

@ -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 <cstring>
#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.

View File

@ -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 <cstddef>
#include <string>
@ -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 */

View File

@ -9,6 +9,10 @@
#include <mutex>
#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.

View File

@ -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_ */