1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

OP-1275 - add ChangeBaud to PIOS_COM_MSG

This commit is contained in:
Alessio Morale 2014-09-07 21:51:11 +02:00
parent 20273e77aa
commit 984a7a675c
2 changed files with 25 additions and 0 deletions

View File

@ -176,6 +176,30 @@ uint16_t PIOS_COM_MSG_Receive(uint32_t com_id, uint8_t *msg, uint16_t msg_len)
return 0;
}
/**
* Change the port speed without re-initializing
* \param[in] port COM port
* \param[in] baud Requested baud rate
* \return -1 if port not available
* \return 0 on success
*/
int32_t PIOS_COM_MSG_ChangeBaud(uint32_t com_id, uint32_t baud)
{
struct pios_com_msg_dev *com_dev = (struct pios_com_msg_dev *)com_id;
if (!com_dev) {
/* Undefined COM port for this board (see pios_board.c) */
return -1;
}
/* Invoke the driver function if it exists */
if (com_dev->driver->set_baud) {
com_dev->driver->set_baud(com_dev->lower_id, baud);
}
return 0;
}
#endif /* PIOS_INCLUDE_COM_MSG */
/**

View File

@ -34,6 +34,7 @@
#include <stdint.h> /* uint*_t */
/* Public Functions */
extern int32_t PIOS_COM_MSG_ChangeBaud(uint32_t com_id, uint32_t baud);
extern int32_t PIOS_COM_MSG_Send(uint32_t com_id, const uint8_t *msg, uint16_t msg_len);
extern uint16_t PIOS_COM_MSG_Receive(uint32_t com_id, uint8_t *buf, uint16_t buf_len);