* Relocated subreposiroty and added ESP-classes, problem with systick.h persists * added test to main * Clean directory by moving MQTT related classes to their own folders in /src /inc * Relocated subreposiroty and added ESP-classes, problem with systick.h persists * added test to main * rm MQTT test func Co-authored-by: Vasily Davydov <vasilydavydovmail@yahoo.com>
50 lines
904 B
C++
50 lines
904 B
C++
/*
|
|
* serial_port.cpp
|
|
*
|
|
* Created on: 25.8.2021
|
|
* Author: keijo
|
|
*/
|
|
#include "../inc/Modbus/Uart.h"
|
|
#include "serial_port.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
static LpcUart *EspUart;
|
|
|
|
void serial_init(void *ctx)
|
|
{
|
|
LpcPinMap none = {-1, -1}; // unused pin has negative values in it
|
|
LpcPinMap txpin_esp = { 0, 8 }; // transmit pin
|
|
LpcPinMap rxpin_esp = { 1, 6 }; // receive pin
|
|
LpcUartConfig cfg = { LPC_USART2, 115200, UART_CFG_DATALEN_8 | UART_CFG_PARITY_NONE | UART_CFG_STOPLEN_1, false, txpin_esp, rxpin_esp, none, none };
|
|
|
|
EspUart = new LpcUart(cfg);
|
|
|
|
}
|
|
|
|
void serial_write_buf(void *ctx, const char *buf, int len)
|
|
{
|
|
EspUart->write(buf, len);
|
|
}
|
|
|
|
void serial_write_str(void *ctx, const char *s)
|
|
{
|
|
EspUart->write(s);
|
|
}
|
|
|
|
int serial_get_char(void *ctx, char *p)
|
|
{
|
|
return EspUart->read(*p);
|
|
}
|
|
|
|
int serial_peek(void *ctx)
|
|
{
|
|
return EspUart->peek();
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|