aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal
diff options
context:
space:
mode:
authoredolomb <none@example.com>2017-09-21 16:07:49 +0000
committeredolomb <none@example.com>2017-09-21 16:07:49 +0000
commit32a8740a7c92fef75497779f31a940b2dbec436c (patch)
treec90d4fb4f9e0a28d5e9f70b99d67ee1781e24e1a /os/hal
parent4e19f446f39f2c56d233838dde9921689532f747 (diff)
downloadChibiOS-32a8740a7c92fef75497779f31a940b2dbec436c.tar.gz
ChibiOS-32a8740a7c92fef75497779f31a940b2dbec436c.tar.bz2
ChibiOS-32a8740a7c92fef75497779f31a940b2dbec436c.zip
Minor changes in hal_serial_lld driver
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10661 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal')
-rw-r--r--os/hal/ports/SAMA/LLD/USARTv1/hal_serial_lld.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/os/hal/ports/SAMA/LLD/USARTv1/hal_serial_lld.c b/os/hal/ports/SAMA/LLD/USARTv1/hal_serial_lld.c
index 62e5e260d..9b7735114 100644
--- a/os/hal/ports/SAMA/LLD/USARTv1/hal_serial_lld.c
+++ b/os/hal/ports/SAMA/LLD/USARTv1/hal_serial_lld.c
@@ -31,6 +31,32 @@
/*===========================================================================*/
/*===========================================================================*/
+/* Driver local macros. */
+/*===========================================================================*/
+
+/**
+ * @brief Enable write protection on SD registers block.
+ *
+ * @param[in] sdp pointer to a SD register block
+ *
+ * @notapi
+ */
+#define sdEnableWP(sdp) { \
+ sdp->UART_WPMR = UART_WPMR_WPKEY_PASSWD | UART_WPMR_WPEN; \
+}
+
+/**
+ * @brief Disable write protection on SD registers block.
+ *
+ * @param[in] sdp pointer to a SD register block
+ *
+ * @notapi
+ */
+#define sdDisableWP(sdp) { \
+ sdp->UART_WPMR = UART_WPMR_WPKEY_PASSWD; \
+}
+
+/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
@@ -46,7 +72,7 @@ SerialDriver SD1;
/** @brief UART2 serial driver identifier.*/
#if SAMA_SERIAL_USE_UART2 || defined(__DOXYGEN__)
-SerialDriver SD3;
+SerialDriver SD2;
#endif
/** @brief UART3 serial driver identifier.*/
@@ -125,6 +151,8 @@ static uint8_t sd_out_buf4[SAMA_SERIAL_UART4_IN_BUF_SIZE];
static void uart_init(SerialDriver *sdp, const SerialConfig *config) {
Uart *u = sdp->uart;
+ /* Disabling write protection */
+ sdDisableWP(u);
/* Baud rate setting.*/
u->UART_BRGR = UART_BRGR_CD(sdp->clock / (16 * config->speed));
@@ -136,6 +164,8 @@ static void uart_init(SerialDriver *sdp, const SerialConfig *config) {
u->UART_CR |= UART_CR_RSTSTA;
/* Enabling Tx and Rx */
u->UART_CR |= UART_CR_RXEN | UART_CR_TXEN;
+ /* Enabling write protection */
+ sdEnableWP(u);
}
@@ -147,8 +177,12 @@ static void uart_init(SerialDriver *sdp, const SerialConfig *config) {
*/
static void uart_deinit(Uart *u) {
+ /* Disabling write protection */
+ sdDisableWP(u);
u->UART_CR = 0;
u->UART_MR = 0;
+ /* Enabling write protection */
+ sdEnableWP(u);
}