Skip to content

Commit b505d10

Browse files
committed
buffer support update
1 parent 9d177d0 commit b505d10

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

source/usart.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
/* Private define ------------------------------------------------------------*/
2626
/* Private macro -------------------------------------------------------------*/
2727
/* Private variables ---------------------------------------------------------*/
28+
#if USART_BUFFER_STACK == ENABLE
29+
circularBuffer_st * m_cb_rx_svptr;
30+
#endif
2831
/* Private function prototypes -----------------------------------------------*/
2932
/* Private functions ---------------------------------------------------------*/
3033

@@ -41,3 +44,20 @@ USART_Read()
4144
while ( BIT_IsClear(UCSR0A, RXC0) );
4245
return (REG_Read(UDR0));
4346
}
47+
48+
#if USART_BUFFER_STACK == ENABLE
49+
50+
void
51+
USART_BufferLink(circularBuffer_st * cirbuf_svptr)
52+
{
53+
m_cb_rx_svptr = cirbuf_svptr;
54+
}
55+
56+
void
57+
USART_BufferEngin()
58+
{
59+
uint8_t read_byte_u8 = REG_Read(UDR0);
60+
CIRCULAR_BUFFER_Write(m_cb_rx_svptr, read_byte_u8);
61+
}
62+
63+
#endif

source/usart.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
/* Includes ------------------------------------------------------------------*/
3636
#include "mcu.h"
3737

38+
#if USART_BUFFER_STACK == ENABLE
39+
#include "circular-buffer.h"
40+
#endif
41+
3842
#if defined(USART_PRINTF_REDIRECT)
3943
#include "print.h"
4044
#endif
@@ -59,6 +63,15 @@ USART_Write(uint8_t ch);
5963
uint8_t
6064
USART_Read();
6165

66+
#if USART_BUFFER_STACK == ENABLE
67+
68+
void
69+
USART_BufferLink(circularBuffer_st * cirbuf_svptr);
70+
71+
void
72+
USART_BufferEngin();
73+
74+
#endif
6275

6376
#ifdef __cplusplus
6477
}

0 commit comments

Comments
 (0)