![]() |
The foxBMS secondary mcu API documentation
|
Headers for the driver for the UART. More...
#include "uart_cfg.h"
Go to the source code of this file.
Macros | |
#define | RXBUF_LENGTH 0x100 /* 256 Byte */ |
#define | TXBUF_LENGTH 0x300 /* 768 Byte */ |
#define | ACK_SYMBOL 0x06 |
#define | NAK_SYMBOL 0x15 |
#define | STX_SYMBOL 0x02 |
#define | ETX_SYMBOL 0x03 |
#define | UART_COM_RECEIVEBUFFER_LENGTH 100 |
Functions | |
void | UART_Init (void) |
UART_Init provides initialization of the UART module. More... | |
void | HAL_UART_CustomIRQHandler (UART_HandleTypeDef *huart) |
HAL_UART_CustomIRQHandler is responsible for handling all requests. More... | |
void | UART_vWrite (const uint8_t *source) |
UART_vWrite provides an interface to send data. More... | |
void | UART_vWrite_intbuf (const uint8_t *source, uint16_t length) |
UART_vWrite provides an interface to send data. More... | |
__attribute__ ((weak)) void UART_IntTx(UART_HandleTypeDef *huart) | |
Variables | |
char | uart_com_receivedbyte [UART_COM_RECEIVEBUFFER_LENGTH] |
uint8_t | uart_com_receive_slot |
Headers for the driver for the UART.
BSD 3-Clause License Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:
″This product uses parts of foxBMS®″
″This product includes parts of foxBMS®″
″This product is derived from foxBMS®″
#define ACK_SYMBOL 0x06 |
#define ETX_SYMBOL 0x03 |
#define NAK_SYMBOL 0x15 |
#define RXBUF_LENGTH 0x100 /* 256 Byte */ |
#define STX_SYMBOL 0x02 |
#define TXBUF_LENGTH 0x300 /* 768 Byte */ |
#define UART_COM_RECEIVEBUFFER_LENGTH 100 |
__attribute__ | ( | (weak) | ) |
void HAL_UART_CustomIRQHandler | ( | UART_HandleTypeDef * | huart | ) |
HAL_UART_CustomIRQHandler is responsible for handling all requests.
This custom interrupt handler does all the handling for sending/receiving data, reset and error handling. In case of send/receive a subfunction is called which handles further processing.
void UART_Init | ( | void | ) |
UART_Init provides initialization of the UART module.
It needs to be called during startup, send/receive will only work after initialization is completed. This function configures parameters of the UART interface and enables the needed interrupts.
Available baudrate is dependent on Sysclock.
void UART_vWrite | ( | const uint8_t * | source | ) |
UART_vWrite provides an interface to send data.
---------------------— IMPORTANT!!!! -----------------------------— Make sure that this function is not interrupted by the operating system during its execution.
This function copies data from input buffer to transmit ringbuffer and processes this data in case it's not already busy transmitting data. The copying will stop as soon as an ASCII NULL character is detected. To avoid data corruption caused by simultaneous accesses some kind of critical section is used.
void UART_vWrite_intbuf | ( | const uint8_t * | source, |
uint16_t | length | ||
) |
UART_vWrite provides an interface to send data.
---------------------— IMPORTANT!!!! -----------------------------— Make sure that this function is not interrupted by the operating system during its execution.
This function copies data from input buffer to transmit ringbuffer and processes this data in case it's not already busy transmitting data. To avoid data corruption caused by simultaneous accesses some kind of critical section is used. The difference between UART_vWrite(const uint8_t *source) and this function is, that this one does not stop at an ASCII_NULL character. Therefore writing of non ASCII characters is possible without having to worry that the data might represent an ASCII NULL character.
uint8_t uart_com_receive_slot |
char uart_com_receivedbyte[UART_COM_RECEIVEBUFFER_LENGTH] |