Files
MSE-SoftwEng/pico-sensor/McuLib/src/McuUart485.h
2025-05-06 13:07:01 +00:00

92 lines
2.2 KiB
C

/*
* Copyright (c) 2020-2022, Erich Styger
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef MCUUART485_H_
#define MCUUART485_H_
#include "McuUart485config.h"
#include "McuShell.h"
#include "McuRTOS.h"
#ifdef __cplusplus
extern "C" {
#endif
#if McuUart485_CONFIG_USE_RS_485
/*! buffers for the RS-485 shell parser */
extern uint8_t McuUart485_DefaultShellBuffer[McuShell_DEFAULT_SHELL_BUFFER_SIZE]; /* default buffer which can be used by the application */
/*! The shell standard I/O handler to send/receive shell commands over the bus*/
extern McuShell_ConstStdIOType McuUart485_stdio;
/*!
* \brief Sending a string to the bus
* \param data string to be sent
*/
void McuUart485_SendString(unsigned char *data);
/*!
* \brief Send a binary data block to the bus
* \param data Data to be sent
* \param dataSize Size of data in bytes
*/
void McuUart485_SendBlock(unsigned char *data, size_t dataSize);
/*!
* \brief Clear the response queue.
*/
void McuUart485_ClearResponseQueue(void);
/*!
* \brief Clear the Rx queue.
*/
void McuUart485_ClearRxQueue(void);
/*!
* \brief Return a byte from the response queue
* \param data Pointer to where to store the queue element
* \param ticksToWait Number of RTOS ticks to wait for a queue element
* \return ERR_OK if element received, ERR_FAILED otherwise
*/
uint8_t McuUart485_GetRxQueueByte(unsigned char *data, TickType_t ticksToWait);
/*!
* \brief Pull (dequeue) a character from the response queue
* \return Error code, or ERR_OK
*/
uint8_t McuUart485_GetResponseQueueChar(void);
/*!
* \brief Pull (dequeue) a character from the rx queue
* \return Error code, or ERR_OK
*/
uint8_t McuUart485_GetRxQueueChar(void);
/*!
* \brief Shell command line parser
* \param cmd command to be parsed
* \param handled if command was recognized
* \param io I/O handler
* \return Error code, or ERR_OK
*/
uint8_t McuUart485_ParseCommand(const unsigned char *cmd, bool *handled, const McuShell_StdIOType *io);
/*! \brief Module de-initialization */
void McuUart485_Deinit(void);
/*! \brief Module initialization */
void McuUart485_Init(void);
#endif /* #if McuUart485_CONFIG_USE_RS_485 */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* MCUUART485_H_ */