Master Thesis
V1.0
Research and Design of Sensor Node for NMSD Treatment
|
UART communication with BLE. More...
#include <uart.h>
#include "em_usart.h"
#include "pinout.h"
#include "em_cmu.h"
#include "em_gpio.h"
#include "ble.h"
#include <stdint.h>
#include "em_device.h"
#include "em_chip.h"
#include "em_emu.h"
#include "bsp.h"
#include "debug_dbprint.h"
Go to the source code of this file.
Data Structures | |
struct | circularBuffer |
Macros | |
#define | BUFFERSIZE 256 |
Functions | |
void | uart_Init () |
UART init. More... | |
uint8_t | uartGetChar () |
uartGetChar function More... | |
void | uartPutChar (uint8_t ch) |
uartPutChar function More... | |
void | uartPutData (uint8_t *dataPtr, uint32_t dataLen) |
uartPutData function More... | |
uint32_t | uartGetData (uint8_t *dataPtr, uint32_t dataLen) |
uartGetData function More... | |
void | USART1_RX_IRQHandler (void) |
UART1 RX IRQ Handler. More... | |
void | USART1_TX_IRQHandler (void) |
UART1 TX IRQ Handler. More... | |
Variables | |
volatile struct circularBuffer | rxBuf |
volatile struct circularBuffer | txBuf = { {0}, 0, 0, 0, false } |
void uart_Init | ( | ) |
UART init.
Inspired by Silabs demo code
Definition at line 57 of file uart.c.
References BLE_PIN_RX, BLE_PIN_TX, BLE_PORT, and BLE_USART.
Referenced by BLE_Init().
uint8_t uartGetChar | ( | ) |
uartGetChar function
Note that if there are no pending characters in the receive buffer, this function will hang until a character is received.
Definition at line 94 of file uart.c.
References BUFFERSIZE, circularBuffer::data, circularBuffer::pendingBytes, circularBuffer::rdI, and rxBuf.
uint32_t uartGetData | ( | uint8_t * | dataPtr, |
uint32_t | dataLen | ||
) |
uartGetData function
Definition at line 185 of file uart.c.
References BUFFERSIZE, circularBuffer::data, circularBuffer::pendingBytes, circularBuffer::rdI, and rxBuf.
Referenced by BLE_readData().
void uartPutChar | ( | uint8_t | ch | ) |
uartPutChar function
Definition at line 121 of file uart.c.
References BLE_USART, BUFFERSIZE, circularBuffer::data, circularBuffer::pendingBytes, txBuf, and circularBuffer::wrI.
void uartPutData | ( | uint8_t * | dataPtr, |
uint32_t | dataLen | ||
) |
uartPutData function
Definition at line 148 of file uart.c.
References BLE_USART, BUFFERSIZE, circularBuffer::data, circularBuffer::pendingBytes, txBuf, and circularBuffer::wrI.
Referenced by BLE_sendData(), and BLE_set_output_power().
void USART1_RX_IRQHandler | ( | void | ) |
UART1 RX IRQ Handler.
Set up the interrupt prior to use
Note that this function handles overflows in a very simple way.
Definition at line 223 of file uart.c.
References BLE_USART, BUFFERSIZE, circularBuffer::data, circularBuffer::overflow, circularBuffer::pendingBytes, rxBuf, and circularBuffer::wrI.
void USART1_TX_IRQHandler | ( | void | ) |
UART1 TX IRQ Handler.
Set up the interrupt prior to use
Definition at line 250 of file uart.c.
References BLE_USART, BUFFERSIZE, circularBuffer::data, circularBuffer::pendingBytes, circularBuffer::rdI, and txBuf.
volatile struct circularBuffer rxBuf |
Referenced by uartGetChar(), uartGetData(), and USART1_RX_IRQHandler().
volatile struct circularBuffer txBuf = { {0}, 0, 0, 0, false } |
Referenced by uartPutChar(), uartPutData(), and USART1_TX_IRQHandler().