@@ -94,14 +94,14 @@ typedef enum {
94
94
*/
95
95
FORCE_INLINE_ATTR bool uart_ll_is_enabled (uint32_t uart_num )
96
96
{
97
- uint32_t uart_clk_config_reg = (( uart_num == 0 ) ? PCR_UART0_CONF_REG :
98
- ( uart_num == 1 ) ? PCR_UART1_CONF_REG : 0 );
99
- uint32_t uart_rst_bit = (( uart_num == 0 ) ? PCR_UART0_RST_EN :
100
- ( uart_num == 1 ) ? PCR_UART1_RST_EN : 0 );
101
- uint32_t uart_en_bit = (( uart_num == 0 ) ? PCR_UART0_CLK_EN :
102
- ( uart_num == 1 ) ? PCR_UART1_CLK_EN : 0 );
103
- return REG_GET_BIT ( uart_clk_config_reg , uart_rst_bit ) == 0 &&
104
- REG_GET_BIT ( uart_clk_config_reg , uart_en_bit ) != 0 ;
97
+ switch ( uart_num ) {
98
+ case 0 :
99
+ return PCR . uart0_conf . uart0_clk_en && ! PCR . uart0_conf . uart0_rst_en ;
100
+ case 1 :
101
+ return PCR . uart1_conf . uart1_clk_en && ! PCR . uart1_conf . uart1_rst_en ;
102
+ default :
103
+ return false;
104
+ }
105
105
}
106
106
107
107
/**
@@ -194,18 +194,18 @@ FORCE_INLINE_ATTR void uart_ll_sclk_disable(uart_dev_t *hw)
194
194
FORCE_INLINE_ATTR void uart_ll_set_sclk (uart_dev_t * hw , soc_module_clk_t source_clk )
195
195
{
196
196
switch (source_clk ) {
197
- case UART_SCLK_PLL_F48M :
198
- UART_LL_PCR_REG_SET (hw , sclk_conf , sclk_sel , 1 );
199
- break ;
200
- case UART_SCLK_RTC :
201
- UART_LL_PCR_REG_SET (hw , sclk_conf , sclk_sel , 2 );
202
- break ;
203
- case UART_SCLK_XTAL :
204
- UART_LL_PCR_REG_SET (hw , sclk_conf , sclk_sel , 3 );
205
- break ;
206
- default :
207
- // Invalid UART clock source
208
- abort ();
197
+ case UART_SCLK_PLL_F48M :
198
+ UART_LL_PCR_REG_SET (hw , sclk_conf , sclk_sel , 1 );
199
+ break ;
200
+ case UART_SCLK_RTC :
201
+ UART_LL_PCR_REG_SET (hw , sclk_conf , sclk_sel , 2 );
202
+ break ;
203
+ case UART_SCLK_XTAL :
204
+ UART_LL_PCR_REG_SET (hw , sclk_conf , sclk_sel , 3 );
205
+ break ;
206
+ default :
207
+ // Invalid UART clock source
208
+ abort ();
209
209
}
210
210
}
211
211
@@ -220,16 +220,16 @@ FORCE_INLINE_ATTR void uart_ll_set_sclk(uart_dev_t *hw, soc_module_clk_t source_
220
220
FORCE_INLINE_ATTR void uart_ll_get_sclk (uart_dev_t * hw , soc_module_clk_t * source_clk )
221
221
{
222
222
switch (UART_LL_PCR_REG_GET (hw , sclk_conf , sclk_sel )) {
223
- default :
224
- case 1 :
225
- * source_clk = (soc_module_clk_t )UART_SCLK_PLL_F48M ;
226
- break ;
227
- case 2 :
228
- * source_clk = (soc_module_clk_t )UART_SCLK_RTC ;
229
- break ;
230
- case 3 :
231
- * source_clk = (soc_module_clk_t )UART_SCLK_XTAL ;
232
- break ;
223
+ default :
224
+ case 1 :
225
+ * source_clk = (soc_module_clk_t )UART_SCLK_PLL_F48M ;
226
+ break ;
227
+ case 2 :
228
+ * source_clk = (soc_module_clk_t )UART_SCLK_RTC ;
229
+ break ;
230
+ case 3 :
231
+ * source_clk = (soc_module_clk_t )UART_SCLK_XTAL ;
232
+ break ;
233
233
}
234
234
}
235
235
@@ -248,7 +248,9 @@ FORCE_INLINE_ATTR void uart_ll_set_baudrate(uart_dev_t *hw, uint32_t baud, uint3
248
248
const uint32_t max_div = BIT (12 ) - 1 ; // UART divider integer part only has 12 bits
249
249
uint32_t sclk_div = DIV_UP (sclk_freq , (uint64_t )max_div * baud );
250
250
251
- if (sclk_div == 0 ) abort ();
251
+ if (sclk_div == 0 ) {
252
+ abort ();
253
+ }
252
254
253
255
uint32_t clk_div = ((sclk_freq ) << 4 ) / (baud * sclk_div );
254
256
// The baud rate configuration register is divided into
@@ -844,22 +846,22 @@ FORCE_INLINE_ATTR void uart_ll_set_mode_irda(uart_dev_t *hw)
844
846
FORCE_INLINE_ATTR void uart_ll_set_mode (uart_dev_t * hw , uart_mode_t mode )
845
847
{
846
848
switch (mode ) {
847
- default :
848
- case UART_MODE_UART :
849
- uart_ll_set_mode_normal (hw );
850
- break ;
851
- case UART_MODE_RS485_COLLISION_DETECT :
852
- uart_ll_set_mode_collision_detect (hw );
853
- break ;
854
- case UART_MODE_RS485_APP_CTRL :
855
- uart_ll_set_mode_rs485_app_ctrl (hw );
856
- break ;
857
- case UART_MODE_RS485_HALF_DUPLEX :
858
- uart_ll_set_mode_rs485_half_duplex (hw );
859
- break ;
860
- case UART_MODE_IRDA :
861
- uart_ll_set_mode_irda (hw );
862
- break ;
849
+ default :
850
+ case UART_MODE_UART :
851
+ uart_ll_set_mode_normal (hw );
852
+ break ;
853
+ case UART_MODE_RS485_COLLISION_DETECT :
854
+ uart_ll_set_mode_collision_detect (hw );
855
+ break ;
856
+ case UART_MODE_RS485_APP_CTRL :
857
+ uart_ll_set_mode_rs485_app_ctrl (hw );
858
+ break ;
859
+ case UART_MODE_RS485_HALF_DUPLEX :
860
+ uart_ll_set_mode_rs485_half_duplex (hw );
861
+ break ;
862
+ case UART_MODE_IRDA :
863
+ uart_ll_set_mode_irda (hw );
864
+ break ;
863
865
}
864
866
}
865
867
@@ -957,7 +959,7 @@ FORCE_INLINE_ATTR void uart_ll_xon_force_on(uart_dev_t *hw, bool always_on)
957
959
{
958
960
hw -> swfc_conf0_sync .force_xon = 1 ;
959
961
uart_ll_update (hw );
960
- if (!always_on ) {
962
+ if (!always_on ) {
961
963
hw -> swfc_conf0_sync .force_xon = 0 ;
962
964
uart_ll_update (hw );
963
965
}
@@ -1003,7 +1005,7 @@ FORCE_INLINE_ATTR void uart_ll_inverse_signal(uart_dev_t *hw, uint32_t inv_mask)
1003
1005
FORCE_INLINE_ATTR void uart_ll_set_rx_tout (uart_dev_t * hw , uint16_t tout_thrd )
1004
1006
{
1005
1007
uint16_t tout_val = tout_thrd ;
1006
- if (tout_thrd > 0 ) {
1008
+ if (tout_thrd > 0 ) {
1007
1009
hw -> tout_conf_sync .rx_tout_thrhd = tout_val ;
1008
1010
hw -> tout_conf_sync .rx_tout_en = 1 ;
1009
1011
} else {
@@ -1022,7 +1024,7 @@ FORCE_INLINE_ATTR void uart_ll_set_rx_tout(uart_dev_t *hw, uint16_t tout_thrd)
1022
1024
FORCE_INLINE_ATTR uint16_t uart_ll_get_rx_tout_thr (uart_dev_t * hw )
1023
1025
{
1024
1026
uint16_t tout_thrd = 0 ;
1025
- if (hw -> tout_conf_sync .rx_tout_en > 0 ) {
1027
+ if (hw -> tout_conf_sync .rx_tout_en > 0 ) {
1026
1028
tout_thrd = hw -> tout_conf_sync .rx_tout_thrhd ;
1027
1029
}
1028
1030
return tout_thrd ;
0 commit comments