Browse Source

串口支持一次性传输多个byte

master
zhaohe 1 year ago
parent
commit
1cc538fc71
  1. 2
      components/libraries/log/src/nrf_log_backend_uart.c
  2. 5
      components/libraries/uart/app_uart.c
  3. 5
      components/libraries/uart/app_uart.h
  4. 8
      components/libraries/uart/app_uart_fifo.c

2
components/libraries/log/src/nrf_log_backend_uart.c

@ -45,7 +45,7 @@
#include "nrf_drv_uart.h" #include "nrf_drv_uart.h"
#include "app_error.h" #include "app_error.h"
nrf_drv_uart_t m_uart = NRF_DRV_UART_INSTANCE(0);
nrf_drv_uart_t m_uart = NRF_DRV_UART_INSTANCE(1);
static uint8_t m_string_buff[NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE]; static uint8_t m_string_buff[NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE];
static volatile bool m_xfer_done; static volatile bool m_xfer_done;

5
components/libraries/uart/app_uart.c

@ -43,7 +43,7 @@
#include "nrf_drv_uart.h" #include "nrf_drv_uart.h"
#include "nrf_assert.h" #include "nrf_assert.h"
static uint8_t tx_buffer[1];
static uint8_t tx_buffer[256];
static uint8_t rx_buffer[1]; static uint8_t rx_buffer[1];
static volatile bool rx_done; static volatile bool rx_done;
static app_uart_event_handler_t m_event_handler; /**< Event handler function. */ static app_uart_event_handler_t m_event_handler; /**< Event handler function. */
@ -151,6 +151,9 @@ uint32_t app_uart_put(uint8_t byte)
} }
} }
uint32_t app_uart_flush(void) uint32_t app_uart_flush(void)
{ {
return NRF_SUCCESS; return NRF_SUCCESS;

5
components/libraries/uart/app_uart.h

@ -252,6 +252,11 @@ uint32_t app_uart_flush(void);
uint32_t app_uart_close(void); uint32_t app_uart_close(void);
uint32_t app_uart_put_bytes(
uint8_t const * p_data,
uint8_t length);
#ifdef __cplusplus #ifdef __cplusplus
} }

8
components/libraries/uart/app_uart_fifo.c

@ -243,6 +243,14 @@ uint32_t app_uart_put(uint8_t byte)
return err_code; return err_code;
} }
uint32_t app_uart_put_bytes(
uint8_t const * p_data,
uint8_t length){
return nrf_drv_uart_tx(&app_uart_inst, p_data, length);
}
uint32_t app_uart_close(void) uint32_t app_uart_close(void)
{ {

Loading…
Cancel
Save