Skip to content

Commit 8600c9f

Browse files
authored
Add files via upload
1 parent d2f0f41 commit 8600c9f

File tree

3 files changed

+5
-37
lines changed

3 files changed

+5
-37
lines changed

atc.c

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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
3431
void 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
//####################################################################################################
7669
void 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
//####################################################################################################
9381
void 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
//####################################################################################################
126104
void atc_search(atc_t *atc)

atc.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
*/
1111

1212
/*
13-
* Version: 3.0.3
13+
* Version: 3.0.2
1414
*
1515
* History:
1616
*
17-
* (3.0.3): Added check for HAL && LL.
1817
* (3.0.2): Clear answer buffer before use.
1918
* (3.0.1): Change some defines.
2019
* (3.0.0): Rewrite again. Support NONE-RTOS, RTOS V1 and RTOS V2.
@@ -46,15 +45,10 @@ typedef struct
4645
char *search[_ATC_SEARCH_MAX];
4746
char *searchCmd[_ATC_SEARCH_CMD_MAX];
4847
uint8_t searchIndex;
49-
uint8_t tmp;
5048
char name[8];
5149

5250
bool lock;
53-
#ifdef HAL_MODULE_ENABLED
54-
UART_HandleTypeDef *usart;
55-
#elif
5651
USART_TypeDef *usart;
57-
#endif
5852
void (*found)(char *foundStr);
5953

6054
} atc_t;
@@ -66,11 +60,7 @@ typedef struct
6660
* USARTx: selected USART
6761
* found: atc found function. auto called after found strings you added before. do not use atc_command function into this
6862
*/
69-
#ifdef HAL_MODULE_ENABLED
70-
void atc_init(atc_t *atc, const char *name, UART_HandleTypeDef *USARTx, void *found);
71-
#elif
7263
void atc_init(atc_t *atc, const char *name, USART_TypeDef *USARTx, void *found);
73-
#endif
7464
//###############################################################################################################
7565
/*
7666
* put in usart rx interrupt

atcConfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#define _ATCCONFIG_H_
44

55
#define _ATC_DEBUG 0 // use printf debug
6-
#define _ATC_RTOS 0 // 0: no rtos 1: cmsis_os v1 2: cmsis_os v2
7-
#define _ATC_RXSIZE 1024 // at-command rx buffer size
6+
#define _ATC_RTOS 1 // 0: no rtos 1: cmsis_os v1 2: cmsis_os v2
7+
#define _ATC_RXSIZE 1500 // at-command rx buffer size
88
#define _ATC_SEARCH_CMD_MAX 5 // maximum of answer in at-command
99
#define _ATC_SEARCH_MAX 10 // maximum of always search in buffer
1010
#define _ATC_RXTIMEOUT_MS 50 // rx timeout to get new packet

0 commit comments

Comments
 (0)