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).
This commit is contained in:
RedHawk 2023-05-10 13:45:47 +03:00
parent 356b3ebbe9
commit 0e64099a56
2 changed files with 11 additions and 4 deletions

View File

@ -18,6 +18,12 @@ DigitalIoPin::DigitalIoPin (int port, int pin, bool input, bool pullup,
_io._invert = invert; _io._invert = invert;
_io.IOCON_mode = IOCON_MODE_INACT; _io.IOCON_mode = IOCON_MODE_INACT;
_io.IOCON_inv = IOCON_FUNC0; _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){ if (isr){
_io.isr_i = isr_index; _io.isr_i = isr_index;
setIsr(); setIsr();
@ -48,7 +54,7 @@ DigitalIoPin::setIoPin ()
} }
} }
Chip_IOCON_PinMuxSet (LPC_IOCON, _io._port, _io._pin, 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 */ /** False direction equals input */
Chip_GPIO_SetPinDIR (LPC_GPIO, _io._port, _io._pin, direction); Chip_GPIO_SetPinDIR (LPC_GPIO, _io._port, _io._pin, direction);
} }
@ -75,9 +81,9 @@ DigitalIoPin::setIsr ()
Chip_Clock_SetIOCONFiltClockDiv(0, 64); Chip_Clock_SetIOCONFiltClockDiv(0, 64);
Chip_IOCON_PinMuxSet (LPC_IOCON, _io._port, _io._pin, Chip_IOCON_PinMuxSet (LPC_IOCON, _io._port, _io._pin,
(_io.IOCON_mode | _io.DigitalEn (_io.IOFunction | _io.IOCON_mode
| _io.IOCON_inv | IOCON_CLKDIV(0) | _io.DigitalEn | _io.IOCON_inv
| IOCON_S_MODE(3))); | IOCON_CLKDIV(0) | IOCON_S_MODE(3)));
/** False direction equals input */ /** False direction equals input */
Chip_GPIO_SetPinDIR (LPC_GPIO, _io._port, _io._pin, direction); Chip_GPIO_SetPinDIR (LPC_GPIO, _io._port, _io._pin, direction);

View File

@ -23,6 +23,7 @@ typedef struct DigitalIOConfigStruct
uint32_t IOCON_mode; uint32_t IOCON_mode;
uint32_t IOCON_inv; uint32_t IOCON_inv;
uint32_t DigitalEn; uint32_t DigitalEn;
uint32_t IOFunction;
IRQn_Type isr_i; IRQn_Type isr_i;
} DigitalIOConfigStruct; } DigitalIOConfigStruct;