Handles Serial driver functionalities.
Copyright (c) 2017-2018 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
#include <string.h>
#include "ble_utils.h"
#include "serial_drv.h"
#include "conf_serialdrv.h"
#include "serial_fifo.h"
#include "platform.h"
Macros | |
#define | ioport_set_pin_peripheral_mode(pin, mode) |
Set peripheral mode for one single IOPORT pin. More... | |
Functions | |
void | ble_pdc_send_data (uint8_t *buf, uint16_t len) |
static void | ble_pdc_serial_drv_send (uint8_t *data, uint16_t len) |
static void | ble_pdc_uart_handler (void) |
void | BLE_UART_Handler (void) |
static uint8_t | configure_primary_uart (uint32_t bus_baudrate) |
uint8_t | configure_serial_drv (uint32_t bus_baudrate) |
Initializes the Serial IO Module. More... | |
void | configure_usart_after_patch (uint32_t bus_baudrate) |
static void | pdc_update_rx_transfer (void) |
void | platform_configure_sleep_manager (void) |
void | platform_enter_critical_section (void) |
void | platform_leave_critical_section (void) |
void | platform_pdc_process_rxdata (uint8_t *buf, uint16_t len) |
void | platform_restore_from_sleep (void) |
uint32_t | platform_serial_drv_tx_status (void) |
void | platform_set_ble_rts_high (void) |
void | platform_set_ble_rts_low (void) |
void | platform_set_hostsleep (void) |
uint16_t | serial_drive_rx_data_count (void) |
uint16_t | serial_drv_send (uint8_t *data, uint16_t len) |
Transmits data via UART. More... | |
static uint32_t | usart_clear_tx_empty (Usart *p_usart) |
static uint32_t | usart_is_rx_buffer_overrun (Usart *p_usart) |
static uint32_t | usart_is_rx_timeout (Usart *p_usart) |
Variables | |
static volatile uint16_t | ble_txbyte_count = 0 |
Pdc * | ble_usart_pdc |
pdc_packet_t | ble_usart_rx_pkt |
volatile bool | ble_usart_tx_cmpl = true |
pdc_packet_t | ble_usart_tx_pkt |
enum sleepmgr_mode | current_sleep_mode = SLEEPMGR_ACTIVE |
volatile uint16_t | dma_buf_index |
uint16_t | g_txdata |
uint8_t | pdc_rx_buffer [BLE_MAX_RX_PAYLOAD_SIZE] |
volatile bool | pdc_uart_enabled = false |
#define ioport_set_pin_peripheral_mode | ( | pin, | |
mode | |||
) |
Set peripheral mode for one single IOPORT pin.
It will configure port mode and disable pin mode (but enable peripheral).
pin | IOPORT pin to configure |
mode | Mode masks to configure for the specified pin (IOPORT Modes) |
Referenced by configure_primary_uart().
void ble_pdc_send_data | ( | uint8_t * | buf, |
uint16_t | len | ||
) |
References BLE_UART, ble_usart_pdc, pdc_tx_init(), pdc_packet::ul_addr, pdc_packet::ul_size, and usart_enable_interrupt().
Referenced by ble_pdc_serial_drv_send().
|
inlinestatic |
References ble_pdc_send_data(), and ble_usart_tx_cmpl.
Referenced by serial_drv_send().
|
inlinestatic |
References BLE_UART, ble_usart_pdc, ble_usart_tx_cmpl, dma_buf_index, pdc_read_rx_counter(), pdc_update_rx_transfer(), platform_dma_process_rxdata(), SERIAL_DRV_RX_CB, pdc_packet::ul_addr, pdc_packet::ul_size, usart_clear_tx_empty(), usart_disable_interrupt(), usart_is_rx_buf_full(), usart_is_rx_buffer_overrun(), usart_is_rx_timeout(), usart_is_tx_empty(), usart_reset_status(), and usart_start_rx_timeout().
Referenced by BLE_UART_Handler().
void BLE_UART_Handler | ( | void | ) |
References ble_pdc_uart_handler().
|
inlinestatic |
References sam_usart_opt_t::baudrate, BLE_MAX_RX_PAYLOAD_SIZE, BLE_UART, BLE_UART_ID, BLE_UART_IRQn, ble_usart_pdc, dma_buf_index, gpio_configure_pin, IOPORT_MODE_PULLUP, ioport_set_pin_peripheral_mode, pdc_enable_transfer(), pdc_rx_buffer, pdc_rx_init(), pdc_uart_enabled, PIO_DEFAULT, PIO_PERIPH_A, PIO_PULLUP, RX_TIMEOUT_VALUE, STATUS_OK, sysclk_enable_peripheral_clock(), sysclk_get_peripheral_hz(), pdc_packet::ul_addr, pdc_packet::ul_size, usart_enable_interrupt(), usart_enable_rx(), usart_enable_tx(), usart_get_pdc_base(), usart_init_hw_handshaking(), usart_init_rs232(), usart_reset(), usart_set_rx_timeout(), usart_set_sleepwalking(), and usart_start_rx_timeout().
Referenced by configure_serial_drv(), and configure_usart_after_patch().
uint8_t configure_serial_drv | ( | uint32_t | ) |
Initializes the Serial IO Module.
References configure_primary_uart(), and STATUS_OK.
Referenced by platform_configure_primary_uart(), and platform_init().
void configure_usart_after_patch | ( | uint32_t | bus_baudrate | ) |
References configure_primary_uart().
Referenced by platform_configure_hw_fc_uart().
|
inlinestatic |
References BLE_MAX_RX_PAYLOAD_SIZE, ble_usart_pdc, dma_buf_index, pdc_rx_buffer, pdc_rx_init(), pdc_packet::ul_addr, and pdc_packet::ul_size.
Referenced by ble_pdc_uart_handler().
void platform_configure_sleep_manager | ( | void | ) |
References current_sleep_mode, sleepmgr_init(), and sleepmgr_lock_mode().
Referenced by platform_init().
void platform_enter_critical_section | ( | void | ) |
References Disable_global_interrupt.
Referenced by platform_start_timer(), and platform_stop_timer().
void platform_leave_critical_section | ( | void | ) |
References Enable_global_interrupt.
Referenced by platform_start_timer(), and platform_stop_timer().
void platform_pdc_process_rxdata | ( | uint8_t * | buf, |
uint16_t | len | ||
) |
void platform_restore_from_sleep | ( | void | ) |
References current_sleep_mode, SLEEPMGR_ACTIVE, sleepmgr_lock_mode(), and sleepmgr_unlock_mode().
Referenced by platform_enter_sleep().
uint32_t platform_serial_drv_tx_status | ( | void | ) |
References ble_usart_tx_cmpl.
void platform_set_ble_rts_high | ( | void | ) |
References BLE_UART, and usart_drive_RTS_pin_low().
Referenced by platform_enter_sleep().
void platform_set_ble_rts_low | ( | void | ) |
References BLE_UART, and usart_drive_RTS_pin_high().
Referenced by platform_enter_sleep().
void platform_set_hostsleep | ( | void | ) |
References current_sleep_mode, sleepmgr_enter_sleep(), sleepmgr_lock_mode(), SLEEPMGR_SLEEP_WFI, and sleepmgr_unlock_mode().
Referenced by platform_enter_sleep().
uint16_t serial_drive_rx_data_count | ( | void | ) |
References ble_usart_pdc, dma_buf_index, pdc_read_rx_counter(), and pdc_packet::ul_size.
Referenced by platform_enter_sleep(), and platform_gpio_set().
uint16_t serial_drv_send | ( | uint8_t * | data, |
uint16_t | len | ||
) |
Transmits data via UART.
data | Pointer to the buffer where the data to be transmitted is present |
length | Number of bytes to be transmitted |
References ble_pdc_serial_drv_send(), pdc_uart_enabled, and STATUS_OK.
Referenced by platform_send_sync().
|
inlinestatic |
Referenced by ble_pdc_uart_handler().
|
inlinestatic |
Referenced by ble_pdc_uart_handler().
|
inlinestatic |
Referenced by ble_pdc_uart_handler().
|
static |
Pdc* ble_usart_pdc |
pdc_packet_t ble_usart_rx_pkt |
Referenced by ble_pdc_serial_drv_send(), ble_pdc_uart_handler(), and platform_serial_drv_tx_status().
pdc_packet_t ble_usart_tx_pkt |
enum sleepmgr_mode current_sleep_mode = SLEEPMGR_ACTIVE |
Referenced by platform_configure_sleep_manager(), platform_restore_from_sleep(), and platform_set_hostsleep().
volatile uint16_t dma_buf_index |
Referenced by ble_pdc_uart_handler(), configure_primary_uart(), pdc_update_rx_transfer(), and serial_drive_rx_data_count().
uint16_t g_txdata |
uint8_t pdc_rx_buffer[BLE_MAX_RX_PAYLOAD_SIZE] |
Referenced by configure_primary_uart(), and pdc_update_rx_transfer().
Referenced by configure_primary_uart(), and serial_drv_send().