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

SN32: SERIAL updates #405

Merged
merged 2 commits into from
Jun 11, 2024
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
11 changes: 11 additions & 0 deletions os/hal/ports/SN32/LLD/SN32F2xx/UART/hal_serial_lld.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static const SerialConfig default_config = {SERIAL_DEFAULT_BITRATE,
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
#if SN32_UART_USE_FD || defined(__DOXYGEN__)
void UART_divisor_CAL(uint32_t baudrate,uint32_t UART_PCLK,uint8_t Oversampling,uint8_t *dlm,uint8_t *dll,uint8_t *d_divaddval,uint8_t *d_mulval)
{
float expected_val;
Expand Down Expand Up @@ -156,6 +157,8 @@ void UART_divisor_CAL(uint32_t baudrate,uint32_t UART_PCLK,uint8_t Oversampling,
*d_divaddval = divaddval[0];
}
}
#endif

/**
* @brief UART initialization.
* @details This function must be invoked with interrupts disabled.
Expand All @@ -173,7 +176,15 @@ static void uart_init(SerialDriver *sdp, const SerialConfig *config) {
apbclock = (SN32_HCLK);

// Calculate divider
#if SN32_UART_USE_FD || defined(__DOXYGEN__)
UART_divisor_CAL(config->speed,apbclock,oversampling,&dlm,&dll,&divaddval,&mulval);
#else
uint32_t divisor = (uint32_t)(apbclock/oversampling/config->speed);
dlm = (divisor>>8)&0xff;
dll = divisor&0xff;
divaddval = 0;
mulval = 1;
#endif // SN32_UART_USE_FD

// Update the registers
u->LC = UART_Divisor_Latch_Access_Enable;
Expand Down
1 change: 0 additions & 1 deletion os/hal/ports/SN32/SN32F260/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ include ${CHIBIOS_CONTRIB}/os/hal/ports/SN32/LLD/SN32F2xx/SysTick/driver.mk
include ${CHIBIOS_CONTRIB}/os/hal/ports/SN32/LLD/SN32F2xx/SPI/driver.mk
include ${CHIBIOS_CONTRIB}/os/hal/ports/SN32/LLD/SN32F2xx/I2C/driver.mk
include ${CHIBIOS_CONTRIB}/os/hal/ports/SN32/LLD/SN32F2xx/WDT/driver.mk
include ${CHIBIOS_CONTRIB}/os/hal/ports/SN32/LLD/SN32F2xx/UART/driver.mk

# Shared variables
ALLCSRC += $(PLATFORMSRC_CONTRIB)
Expand Down
Loading