@@ -28,22 +28,15 @@ void atc_free(void *ptr)
2828#endif
2929}
3030//####################################################################################################
31- #ifdef HAL_MODULE_ENABLED
32- void atc_init (atc_t * atc , const char * name , UART_HandleTypeDef * USARTx , void * found )
33- #elif
3431void atc_init (atc_t * atc , const char * name , USART_TypeDef * USARTx , void * found )
35- #endif
3632{
3733 if (atc -> inited == true)
3834 return ;
3935 memset (atc , 0 , sizeof (atc_t ));
4036 strncpy (atc -> name , name , sizeof (atc -> name ) - 1 );
4137 atc -> usart = USARTx ;
4238 atc -> found = found ;
43- #ifdef HAL_MODULE_ENABLED
44- #elif
4539 LL_USART_EnableIT_RXNE (atc -> usart );
46- #endif
4740 atc -> inited = true;
4841 atc_printf ("\r\n[%s] inited.\r\n" , atc -> name );
4942}
@@ -75,10 +68,6 @@ void atc_unlock(atc_t *atc)
7568//####################################################################################################
7669void atc_transmit (atc_t * atc , uint8_t * data , uint16_t len )
7770{
78- #ifdef HAL_MODULE_ENABLED
79- HAL_UART_Transmit_IT (atc -> usart ,data ,len );
80- atc_delay (1 );
81- #elif
8271 for (uint16_t i = 0 ; i < len ; i ++ )
8372 {
8473 while (!LL_USART_IsActiveFlag_TXE (atc -> usart ))
@@ -87,26 +76,16 @@ void atc_transmit(atc_t *atc, uint8_t *data, uint16_t len)
8776 }
8877 while (!LL_USART_IsActiveFlag_TC (atc -> usart ))
8978 atc_delay (1 );
90- #endif
9179}
9280//####################################################################################################
9381void atc_rxCallback (atc_t * atc )
9482{
95- #ifdef HAL_MODULE_ENABLED
96- if (atc -> rxIndex < _ATC_RXSIZE - 1 )
97- {
98- atc -> rxBuffer [atc -> rxIndex ] = atc -> tmp ;
99- atc -> rxIndex ++ ;
100- }
101- atc -> rxTime = HAL_GetTick ();
102- HAL_UART_Receive_IT (atc -> usart , & atc -> tmp , 1 );
103- #elif
10483 if (LL_USART_IsActiveFlag_RXNE (atc -> usart ))
10584 {
106- atc -> tmp = LL_USART_ReceiveData8 (atc -> usart );
85+ uint8_t tmp = LL_USART_ReceiveData8 (atc -> usart );
10786 if (atc -> rxIndex < _ATC_RXSIZE - 1 )
10887 {
109- atc -> rxBuffer [atc -> rxIndex ] = atc -> tmp ;
88+ atc -> rxBuffer [atc -> rxIndex ] = tmp ;
11089 atc -> rxIndex ++ ;
11190 }
11291 atc -> rxTime = HAL_GetTick ();
@@ -120,7 +99,6 @@ void atc_rxCallback(atc_t *atc)
12099// LL_USART_ClearFlag_ORE(atc->usart);
121100// if (LL_USART_IsActiveFlag_NE(atc->usart))
122101// LL_USART_ClearFlag_NE(atc->usart);
123- #endif
124102}
125103//####################################################################################################
126104void atc_search (atc_t * atc )
0 commit comments