From 438a2e92d0d7b099256e47fd28a2a646f4efa835 Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Mon, 17 Jan 2022 15:33:57 +0100 Subject: [PATCH 1/2] [ATSAMD21_ARDUINO] fix TX disabled pin configuration --- ATSAMD21_ARDUINO/luos_hal.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ATSAMD21_ARDUINO/luos_hal.c b/ATSAMD21_ARDUINO/luos_hal.c index 6d8815a..8c0f876 100644 --- a/ATSAMD21_ARDUINO/luos_hal.c +++ b/ATSAMD21_ARDUINO/luos_hal.c @@ -187,7 +187,8 @@ void LuosHAL_SetTxState(uint8_t Enable) { if (Enable == true) { - PORT->Group[COM_TX_PORT].PINCFG[COM_TX_PIN].reg &= ~PORT_PINCFG_PULLEN; // Tx push pull + PORT->Group[COM_TX_PORT].PINCFG[COM_TX_PIN].reg = PORT_PINCFG_RESETVALUE; // no pin mux / no input / no pull / low streght + PORT->Group[COM_TX_PORT].PINCFG[COM_TX_PIN].reg |= PORT_PINCFG_PMUXEN; // mux en if ((TX_EN_PIN != DISABLE) || (TX_EN_PORT != DISABLE)) { PORT->Group[TX_EN_PORT].OUTSET.reg = (1 << TX_EN_PIN); // enable Tx @@ -195,7 +196,9 @@ void LuosHAL_SetTxState(uint8_t Enable) } else { - PORT->Group[COM_TX_PORT].PINCFG[COM_TX_PIN].reg |= PORT_PINCFG_PULLEN; // Tx open drain + PORT->Group[COM_TX_PORT].PINCFG[COM_TX_PIN].reg = PORT_PINCFG_RESETVALUE; // no pin mux / no input / no pull / low streght + PORT->Group[COM_TX_PORT].PINCFG[COM_TX_PIN].reg |= PORT_PINCFG_PULLEN; // Enable Pull + PORT->Group[COM_TX_PORT].OUTSET.reg = (1 << COM_TX_PIN); // Pull up if ((TX_EN_PIN != DISABLE) || (TX_EN_PORT != DISABLE)) { PORT->Group[TX_EN_PORT].OUTCLR.reg = (1 << TX_EN_PIN); // disable Tx @@ -551,8 +554,8 @@ static void LuosHAL_GPIOInit(void) /*Configure GPIO pin : TxPin */ PORT->Group[COM_TX_PORT].PINCFG[COM_TX_PIN].reg = PORT_PINCFG_RESETVALUE; // no pin mux / no input / no pull / low streght - PORT->Group[COM_TX_PORT].PINCFG[COM_TX_PIN].reg |= PORT_PINCFG_PMUXEN; // mux en - PORT->Group[COM_TX_PORT].PINCFG[COM_TX_PIN].reg |= PORT_PINCFG_PULLEN; // Tx open drain + PORT->Group[COM_TX_PORT].PINCFG[COM_TX_PIN].reg |= PORT_PINCFG_PULLEN; // Enable Pull + PORT->Group[COM_TX_PORT].OUTSET.reg = (1 << COM_TX_PIN); // Pull up PORT->Group[COM_TX_PORT].PMUX[COM_TX_PIN >> 1].reg |= (COM_TX_AF << (4 * (COM_TX_PIN % 2))); // mux to sercom /*Configure GPIO pin : RxPin */ From dad9ab87da9fa7575c933e3729133272c354ef6e Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Mon, 17 Jan 2022 15:34:14 +0100 Subject: [PATCH 2/2] [ATSAMD21] fix TX disabled pin configuration --- ATSAMD21/luos_hal.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ATSAMD21/luos_hal.c b/ATSAMD21/luos_hal.c index 01134db..46b7f36 100644 --- a/ATSAMD21/luos_hal.c +++ b/ATSAMD21/luos_hal.c @@ -199,7 +199,8 @@ void LuosHAL_SetTxState(uint8_t Enable) { if (Enable == true) { - PORT_REGS->GROUP[COM_TX_PORT].PORT_PINCFG[COM_TX_PIN] &= ~PORT_PINCFG_PULLEN_Msk; // TX push pull + PORT->Group[COM_TX_PORT].PINCFG[COM_TX_PIN] = PORT_PINCFG_RESETVALUE_Msk; // no pin mux / no input / no pull / low streght + PORT->Group[COM_TX_PORT].PINCFG[COM_TX_PIN] |= PORT_PINCFG_PMUXEN_Msk; // mux en if ((TX_EN_PIN != DISABLE) || (TX_EN_PORT != DISABLE)) { PORT_REGS->GROUP[TX_EN_PORT].PORT_OUTSET = (1 << TX_EN_PIN); // enable Tx @@ -207,7 +208,9 @@ void LuosHAL_SetTxState(uint8_t Enable) } else { - PORT_REGS->GROUP[COM_TX_PORT].PORT_PINCFG[COM_TX_PIN] |= PORT_PINCFG_PULLEN_Msk; // Tx Open drain + PORT->Group[COM_TX_PORT].PINCFG[COM_TX_PIN] = PORT_PINCFG_RESETVALUE_Msk; // no pin mux / no input / no pull / low streght + PORT->Group[COM_TX_PORT].PINCFG[COM_TX_PIN] |= PORT_PINCFG_PULLEN_Msk; // Enable Pull + PORT->Group[COM_TX_PORT].OUTSET = (1 << COM_TX_PIN); // Pull up if ((TX_EN_PIN != DISABLE) || (TX_EN_PORT != DISABLE)) { PORT_REGS->GROUP[TX_EN_PORT].PORT_OUTCLR = (1 << TX_EN_PIN); // disable Tx @@ -563,9 +566,9 @@ static void LuosHAL_GPIOInit(void) } /*Configure GPIO pin : TxPin */ - PORT_REGS->GROUP[COM_TX_PORT].PORT_PINCFG[COM_TX_PIN] = PORT_PINCFG_RESETVALUE; // no pin mux / no input / no pull / low streght - PORT_REGS->GROUP[COM_TX_PORT].PORT_PINCFG[COM_TX_PIN] |= PORT_PINCFG_PULLEN_Msk; - PORT_REGS->GROUP[COM_TX_PORT].PORT_PINCFG[COM_TX_PIN] |= PORT_PINCFG_PMUXEN_Msk; // mux en + PORT_REGS->GROUP[COM_TX_PORT].PORT_PINCFG[COM_TX_PIN] = PORT_PINCFG_RESETVALUE; // no pin mux / no input / no pull / low streght + PORT->Group[COM_TX_PORT].PINCFG[COM_TX_PIN] |= PORT_PINCFG_PULLEN_Msk; // Enable Pull + PORT->Group[COM_TX_PORT].OUTSET = (1 << COM_TX_PIN); // Pull up PORT_REGS->GROUP[COM_TX_PORT].PORT_PMUX[COM_TX_PIN >> 1] |= (COM_TX_AF << (4 * (COM_TX_PIN % 2))); // mux to sercom /*Configure GPIO pin : RxPin */