Skip to content

Commit

Permalink
Merge pull request #405 from dexter93/sn32_uart
Browse files Browse the repository at this point in the history
SN32: SERIAL updates
  • Loading branch information
fpoussin committed Jun 11, 2024
2 parents 052a4a2 + 1496db3 commit 729528d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit 729528d

Please sign in to comment.