From 0e64099a56fcb6d77d8be8d2902c38e4582264fa Mon Sep 17 00:00:00 2001 From: RedHawk Date: Wed, 10 May 2023 13:45:47 +0300 Subject: [PATCH] DigitalIoPin: Added LPC11U68 specific pin functions *In order for pin to act as IO, it must be configured with according function. Usually it is IOCON_FUNC0, but some pins on port 0 are an exception (IOCON_FUNC1). --- source/shoh/src/peripherals/DigitalIoPin.cpp | 14 ++++++++++---- source/shoh/src/peripherals/DigitalIoPin.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/source/shoh/src/peripherals/DigitalIoPin.cpp b/source/shoh/src/peripherals/DigitalIoPin.cpp index 51d4021..1028d3c 100644 --- a/source/shoh/src/peripherals/DigitalIoPin.cpp +++ b/source/shoh/src/peripherals/DigitalIoPin.cpp @@ -18,6 +18,12 @@ DigitalIoPin::DigitalIoPin (int port, int pin, bool input, bool pullup, _io._invert = invert; _io.IOCON_mode = IOCON_MODE_INACT; _io.IOCON_inv = IOCON_FUNC0; + //Table 83 from UM10732-11u68.pdf + if(port == 0 && ((pin >= 10 && pin <= 15) || pin == 0)) + _io.IOFunction = IOCON_FUNC1; + else + _io.IOFunction = IOCON_FUNC0; + if (isr){ _io.isr_i = isr_index; setIsr(); @@ -48,7 +54,7 @@ DigitalIoPin::setIoPin () } } Chip_IOCON_PinMuxSet (LPC_IOCON, _io._port, _io._pin, - (_io.IOCON_mode | _io.DigitalEn | _io.IOCON_inv)); + (_io.IOFunction | _io.IOCON_mode | _io.DigitalEn | _io.IOCON_inv)); /** False direction equals input */ Chip_GPIO_SetPinDIR (LPC_GPIO, _io._port, _io._pin, direction); } @@ -75,9 +81,9 @@ DigitalIoPin::setIsr () Chip_Clock_SetIOCONFiltClockDiv(0, 64); Chip_IOCON_PinMuxSet (LPC_IOCON, _io._port, _io._pin, - (_io.IOCON_mode | _io.DigitalEn - | _io.IOCON_inv | IOCON_CLKDIV(0) - | IOCON_S_MODE(3))); + (_io.IOFunction | _io.IOCON_mode + | _io.DigitalEn | _io.IOCON_inv + | IOCON_CLKDIV(0) | IOCON_S_MODE(3))); /** False direction equals input */ Chip_GPIO_SetPinDIR (LPC_GPIO, _io._port, _io._pin, direction); diff --git a/source/shoh/src/peripherals/DigitalIoPin.h b/source/shoh/src/peripherals/DigitalIoPin.h index 19c6c7b..6241aa9 100644 --- a/source/shoh/src/peripherals/DigitalIoPin.h +++ b/source/shoh/src/peripherals/DigitalIoPin.h @@ -23,6 +23,7 @@ typedef struct DigitalIOConfigStruct uint32_t IOCON_mode; uint32_t IOCON_inv; uint32_t DigitalEn; + uint32_t IOFunction; IRQn_Type isr_i; } DigitalIOConfigStruct;