Skip to content

Commit

Permalink
Dev (#23)
Browse files Browse the repository at this point in the history
* Add pin sense & drive strength to gpio pin configuration
Combine to single iopinctrl for nRF5x serie (including nRF52840 with multiport gpio)

* More comments

* Comments

* Fixes compile errors LPC17xx
Updated iopinctrl for LPC17xx

* Add restart condition for compatibility with LPC MCU

* Fixes LPC17xx I2C interface
  • Loading branch information
hnhoan authored Jun 26, 2017
1 parent a90f41d commit ad77254
Show file tree
Hide file tree
Showing 12 changed files with 423 additions and 166 deletions.
20 changes: 20 additions & 0 deletions ARM/NXP/LPC11xx/EHAL/.project
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@
<type>1</type>
<locationURI>PARENT-4-PROJECT_LOC/include/seep.h</locationURI>
</link>
<link>
<name>include/sensors</name>
<type>2</type>
<locationURI>virtual:/virtual</locationURI>
</link>
<link>
<name>include/spi.h</name>
<type>1</type>
Expand Down Expand Up @@ -420,6 +425,21 @@
<type>1</type>
<locationURI>PARENT-4-PROJECT_LOC/src/utf8cvt.cpp</locationURI>
</link>
<link>
<name>include/sensors/pth_bme280.h</name>
<type>1</type>
<locationURI>PARENT-4-PROJECT_LOC/include/sensors/pth_bme280.h</locationURI>
</link>
<link>
<name>include/sensors/pth_ms8607.h</name>
<type>1</type>
<locationURI>PARENT-4-PROJECT_LOC/include/sensors/pth_ms8607.h</locationURI>
</link>
<link>
<name>include/sensors/pth_sensor.h</name>
<type>1</type>
<locationURI>PARENT-4-PROJECT_LOC/include/sensors/pth_sensor.h</locationURI>
</link>
<link>
<name>include/sys/dirent.h</name>
<type>1</type>
Expand Down
54 changes: 54 additions & 0 deletions ARM/NXP/LPC11xx/EHAL/include/iopinctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ Modified by Date Description
#include <stdint.h>
#include "LPC11Uxx.h"

/**
* @brief Set gpio pin direction
*
* change pin direction only without changing any other settings
* for fast switching between In & Out
*
* @Param PortNo : Port number
* PinNo : Pin number
* Dir : I/O direction
*/
static inline void IOPinSetDir(int PortNo, int PinNo, IOPINDIR Dir)
{
if (Dir == IOPINDIR_OUTPUT)
Expand All @@ -48,31 +58,75 @@ static inline void IOPinSetDir(int PortNo, int PinNo, IOPINDIR Dir)
LPC_GPIO->DIR[PortNo] &= ~(1 << PinNo);
}

/**
* @brief Read pin state
*
* @Param PortNo : Port number
* PinNo : Pin number
*
* @return Pin state 1 or 0
*/
static inline int IOPinRead(int PortNo, int PinNo)
{
return ((LPC_GPIO->PIN[PortNo] >> PinNo ) & 1);
}

/**
* @brief Set pin to high (1 logic)
*
* @Param PortNo : Port number
* PinNo : Pin number
*/
static inline void IOPinSet(int PortNo, int PinNo)
{
LPC_GPIO->SET[PortNo] = (1 << PinNo);
}

/**
* @brief Set pin to low (0 logic)
*
* @Param PortNo : Port number
* PinNo : Pin number
*/
static inline void IOPinClear(int PortNo, int PinNo)
{
LPC_GPIO->CLR[PortNo] = (1 << PinNo);
}

/**
* @brief Toggle pin state (invert pin state)
*
* @Param PortNo : Port number
* PinNo : Pin number
*/
static inline void IOPinToggle(int PortNo, int PinNo)
{
LPC_GPIO->NOT[PortNo] = (1 << PinNo);
}

/**
* @brief Read all pins on port
*
* @Param PortNo : Port number
*
* @return Bit field pin states
*/
static inline uint32_t IOPinReadPort(int PortNo)
{
return LPC_GPIO->PIN[PortNo];
}

/**
* @brief Write state to all pin on port
*
* @Param PortNo : Port number
* Data : Bit field state of all pins on port
*/
static inline void IOPinWritePort(int PortNo, uint32_t Data)
{
LPC_GPIO->W[PortNo] = Data;
}

static inline void IOPinWrite8Port(int PortNo, uint8_t Data)
{
LPC_GPIO->B[PortNo] = Data;
Expand Down
79 changes: 41 additions & 38 deletions ARM/NXP/LPC17xx/EHAL/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,37 @@
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.1626239750" name="Cross ARM GNU Assembler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler">
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.747579802" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" value="true" valueType="boolean"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.include.paths.698626590" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../CMSIS/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../CMSIS/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../../../external/CMSIS//CMSIS/Core/Include&quot;"/>
</option>
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input.982719908" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input"/>
</tool>
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.1199841364" name="Cross ARM C Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler">
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths.829277325" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../CMSIS/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../CMSIS/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../../../external/CMSIS/CMSIS/Core/Include&quot;"/>
</option>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std.1603392780" name="Language standard" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std" useByScannerDiscovery="true" value="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std.gnu99" valueType="enumerated"/>
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.1411832780" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
</tool>
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.369507446" name="Cross ARM C++ Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler">
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.include.paths.1200543874" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../CMSIS/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../CMSIS/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../../../external/CMSIS/CMSIS/Core/Include&quot;"/>
</option>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std.117073940" name="Language standard" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std" useByScannerDiscovery="true" value="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std.gnucpp11" valueType="enumerated"/>
Expand Down Expand Up @@ -104,10 +104,13 @@
</tool>
</toolChain>
</folderInfo>
<fileInfo id="ilg.gnuarmeclipse.managedbuild.cross.config.lib.debug.1485623946.23043323" name="sha1.c" rcbsApplicability="disable" resourcePath="src/sha1.c" toolsToInvoke="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.1199841364.1257578861">
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.1199841364.1257578861" name="Cross ARM C Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.1199841364"/>
</fileInfo>
<sourceEntries>
<entry excluding="include|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="include"/>
<entry excluding="i2c_lpcxx.c|i2c_lpc17xx.c|sdcard.c|lpci2c.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry excluding="i2c_lpcxx.c|sdcard.c|lpci2c.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
Expand Down Expand Up @@ -158,37 +161,37 @@
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.389913293" name="Cross ARM GNU Assembler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler">
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.2066255043" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" value="true" valueType="boolean"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.include.paths.853392189" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../CMSIS/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../CMSIS/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../../../external/CMSIS//CMSIS/Core/Include&quot;"/>
</option>
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input.1501291622" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input"/>
</tool>
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.536967851" name="Cross ARM C Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler">
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths.1349418096" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../CMSIS/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../CMSIS/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../../../external/CMSIS/CMSIS/Core/Include&quot;"/>
</option>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std.1701467211" name="Language standard" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std" useByScannerDiscovery="true" value="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std.gnu99" valueType="enumerated"/>
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.445823643" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
</tool>
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.1326075952" name="Cross ARM C++ Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler">
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.include.paths.1749004181" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../CMSIS/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../../include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../CMSIS/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;../../../../../../external/CMSIS/CMSIS/Core/Include&quot;"/>
</option>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std.270835066" name="Language standard" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std" useByScannerDiscovery="true" value="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std.gnucpp11" valueType="enumerated"/>
Expand Down Expand Up @@ -219,7 +222,7 @@
<sourceEntries>
<entry excluding="include|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="include"/>
<entry excluding="i2c_lpcxx.c|i2c_lpc17xx.c|sdcard.c|lpci2c.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry excluding="i2c_lpcxx.c|sdcard.c|lpci2c.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
Expand Down
20 changes: 10 additions & 10 deletions ARM/NXP/LPC17xx/EHAL/.project
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@
<type>1</type>
<locationURI>PARENT-4-PROJECT_LOC/src/intelhex.c</locationURI>
</link>
<link>
<name>src/isha1.c</name>
<type>1</type>
<locationURI>PARENT-4-PROJECT_LOC/src/isha1.c</locationURI>
</link>
<link>
<name>src/isha256.c</name>
<type>1</type>
<locationURI>PARENT-4-PROJECT_LOC/src/isha256.c</locationURI>
</link>
<link>
<name>src/ledmx.c</name>
<type>1</type>
Expand Down Expand Up @@ -330,16 +340,6 @@
<type>1</type>
<locationURI>PARENT-4-PROJECT_LOC/src/seep_impl.cpp</locationURI>
</link>
<link>
<name>src/sha1.c</name>
<type>1</type>
<locationURI>PARENT-4-PROJECT_LOC/src/sha1.c</locationURI>
</link>
<link>
<name>src/sha256.c</name>
<type>1</type>
<locationURI>PARENT-4-PROJECT_LOC/src/sha256.c</locationURI>
</link>
<link>
<name>src/spi_lpcxx.c</name>
<type>1</type>
Expand Down
Loading

0 comments on commit ad77254

Please sign in to comment.