Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix samd TX pin config, fix #35 #36

Merged
merged 2 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions ATSAMD21/luos_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,18 @@ 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
}
}
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
Expand Down Expand Up @@ -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 */
Expand Down
11 changes: 7 additions & 4 deletions ATSAMD21_ARDUINO/luos_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,18 @@ 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
}
}
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
Expand Down Expand Up @@ -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 */
Expand Down