29#if HAL_USE_PAL || defined(__DOXYGEN__)
41#if (PAL_USE_WAIT == TRUE) || (PAL_USE_CALLBACKS == TRUE) || defined(__DOXYGEN__)
60 for (
int i = 0; i < 16; i++) {
61 if (flags & (1 << i)) {
72 PORT_TypeDef *portcfg = NULL;
75 else if (port == IOPORT2)
77 else if (port == IOPORT3)
79 else if (port == IOPORT4)
81 else if (port == IOPORT5)
103 return (port->PDIR & ((uint32_t) 1 <<
pad)) ? PAL_HIGH : PAL_LOW;
126 port->PDOR |= ((uint32_t) 1 <<
pad);
128 port->PDOR &= ~((uint32_t) 1 <<
pad);
149 osalDbgAssert(
pad < PADS_PER_PORT,
"pal_lld_setpadmode() #1, invalid pad");
151 if (mode == PAL_MODE_OUTPUT_PUSHPULL || mode == PAL_MODE_OUTPUT_OPENDRAIN)
152 port->PDDR |= ((uint32_t) 1 <<
pad);
154 port->PDDR &= ~((uint32_t) 1 <<
pad);
157 osalDbgAssert(portcfg != NULL,
"pal_lld_setpadmode() #2, invalid port");
162 case PAL_MODE_OUTPUT_PUSHPULL:
163 portcfg->PCR[
pad] = PIN_MUX_ALTERNATIVE(1);
165#if KINETIS_GPIO_HAS_OPENDRAIN
166 case PAL_MODE_OUTPUT_OPENDRAIN:
167 portcfg->PCR[
pad] = PIN_MUX_ALTERNATIVE(1) |
171#undef PAL_MODE_OUTPUT_OPENDRAIN
173 case PAL_MODE_INPUT_PULLUP:
174 portcfg->PCR[
pad] = PIN_MUX_ALTERNATIVE(1) |
178 case PAL_MODE_INPUT_PULLDOWN:
179 portcfg->PCR[
pad] = PIN_MUX_ALTERNATIVE(1) |
182 case PAL_MODE_UNCONNECTED:
183 case PAL_MODE_INPUT_ANALOG:
184 portcfg->PCR[
pad] = PIN_MUX_ALTERNATIVE(0);
186 case PAL_MODE_ALTERNATIVE_1:
187 portcfg->PCR[
pad] = PIN_MUX_ALTERNATIVE(1);
189 case PAL_MODE_ALTERNATIVE_2:
190 portcfg->PCR[
pad] = PIN_MUX_ALTERNATIVE(2);
192 case PAL_MODE_ALTERNATIVE_3:
193 portcfg->PCR[
pad] = PIN_MUX_ALTERNATIVE(3);
195 case PAL_MODE_ALTERNATIVE_4:
196 portcfg->PCR[
pad] = PIN_MUX_ALTERNATIVE(4);
198 case PAL_MODE_ALTERNATIVE_5:
199 portcfg->PCR[
pad] = PIN_MUX_ALTERNATIVE(5);
201 case PAL_MODE_ALTERNATIVE_6:
202 portcfg->PCR[
pad] = PIN_MUX_ALTERNATIVE(6);
204 case PAL_MODE_ALTERNATIVE_7:
205 portcfg->PCR[
pad] = PIN_MUX_ALTERNATIVE(7);
210 if (mode & PAL_STM32_PUPDR_PULLUP) {
211 portcfg->PCR[
pad] |= PAL_STM32_PUPDR_PULLUP;
215 if (mode & PAL_MODE_OUTPUT_PUSHPULL) {
240 PCC->CLKCFG[PCC_PORTA_INDEX] |= PCC_CLKCFG_CGC_MASK;
241 PCC->CLKCFG[PCC_PORTB_INDEX] |= PCC_CLKCFG_CGC_MASK;
242 PCC->CLKCFG[PCC_PORTC_INDEX] |= PCC_CLKCFG_CGC_MASK;
243 PCC->CLKCFG[PCC_PORTD_INDEX] |= PCC_CLKCFG_CGC_MASK;
244 PCC->CLKCFG[PCC_PORTE_INDEX] |= PCC_CLKCFG_CGC_MASK;
246 nvicEnableVector(PORTA_IRQn, KINETIS_GPIO_IRQ_PRIORITY);
247 nvicEnableVector(PORTB_IRQn, KINETIS_GPIO_IRQ_PRIORITY);
248 nvicEnableVector(PORTC_IRQn, KINETIS_GPIO_IRQ_PRIORITY);
249 nvicEnableVector(PORTD_IRQn, KINETIS_GPIO_IRQ_PRIORITY);
250 nvicEnableVector(PORTE_IRQn, KINETIS_GPIO_IRQ_PRIORITY);
258 SIM->SCGC5 |= SIM_SCGC5_PORTA |
265 for (i = 0; i < TOTAL_PORTS; i++) {
266 for (j = 0; j < PADS_PER_PORT; j++) {
267 pal_lld_setpadmode(
config->ports[i].port,
269 config->ports[i].pads[j]);
294 for (i = 0; i < PADS_PER_PORT; i++) {
295 pal_lld_setpadmode(port, i, mode);
299#if PAL_USE_CALLBACKS || PAL_USE_WAIT
306 case PAL_EVENT_MODE_RISING_EDGE:
309 case PAL_EVENT_MODE_FALLING_EDGE:
312 case PAL_EVENT_MODE_BOTH_EDGES:
315 case PAL_EVENT_MODE_DISABLED:
static constexpr persistent_config_s * config
void _pal_lld_setpadmode(ioportid_t port, uint8_t pad, iomode_t mode)
Pad mode setup.
void _pal_lld_writepad(ioportid_t port, uint8_t pad, uint8_t bit)
Writes a logical state on an output pad.
uint32_t ioeventmode_t
Type of an event mode.
uint32_t ioportmask_t
Digital I/O port sized unsigned type.
void _pal_lld_init(void)
Kinetis I/O ports configuration.
palevent_t _pal_events[KINETIS_GPIO_NUM_LINES]
Event records for the 16 GPIO EXTI channels.
uint8_t _pal_lld_readpad(ioportid_t port, uint8_t pad)
Reads a logical state from an I/O pad.
void _pal_lld_enablepadevent(ioportid_t port, iopadid_t pad, ioeventmode_t mode)
void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad)
void _pal_lld_setgroupmode(ioportid_t port, ioportmask_t mask, iomode_t mode)
Pads mode setup.
void _pal_lld_irq_handler(PORT_Type *base)
GPIO_TypeDef * ioportid_t
Port Identifier.
uint32_t iomode_t
Digital I/O modes.
uint32_t iopadid_t
Type of an pad identifier.
PORT_TypeDef * _pal_lld_get_port_config(ioportid_t port)
static void PORT_SetPinInterruptConfig(PORT_Type *base, uint32_t pin, port_interrupt_t config)
Configures the port pin interrupt/DMA request.
enum _port_interrupt port_interrupt_t
Configures the interrupt generation condition.
static void PORT_SetPinDriveStrength(PORT_Type *base, uint32_t pin, uint8_t strength)
Configures the port pin drive strength.
static uint32_t PORT_GetPinsInterruptFlags(PORT_Type *base)
Reads the whole port status flag.
static void PORT_ClearPinsInterruptFlags(PORT_Type *base, uint32_t mask)
Clears the multiple pin interrupt status flag.
@ kPORT_HighDriveStrength
@ kPORT_InterruptEitherEdge
@ kPORT_InterruptRisingEdge
@ kPORT_InterruptOrDMADisabled
@ kPORT_InterruptFallingEdge
Generic I/O ports static initializer.