Signed-off-by: huhui <huhui@sharkgulf.com>
@@ -41,7 +41,7 @@
#define SHARK_UART1_rx_dma_clk RCU_DMA
// ================================================================================
-#define ENABLE_RX_DMA 0
+#define ENABLE_RX_DMA 1
static u8 shark_uart0_tx_cache[SHARK_UART_TX_MEM_SIZE];
#if UART_NUM==2
@@ -8,6 +8,7 @@ static int circle_get_read_space(c_buffer_t *cbuff);
void circle_buffer_init(c_buffer_t *cbuff, uint8_t *buffer, int16_t max_len){
cbuff->buffer = buffer;
cbuff->buffer_len = max_len;
+ circle_reset(cbuff);
}
void circle_reset(c_buffer_t *cbuff){
@@ -19,7 +19,13 @@ typedef struct {
//used by dma
static __inline__ void circle_update_write_position(c_buffer_t *cbuff, int pos){
- cbuff->w_pos = pos;
+ if (pos != 0) {
+ if (pos == cbuff->buffer_len) {
+ cbuff->w_pos = 0;
+ }else {
+ cbuff->w_pos = pos;
+ }
static __inline__ int circle_get_read_position(c_buffer_t *cbuff){