Перенос на новую организацию GONEC
This commit is contained in:
commit
7d8eaae9dd
|
|
@ -0,0 +1,20 @@
|
||||||
|
//
|
||||||
|
// Created by cfif on 03.10.22.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef MODULE_SERIALPORTHALFDUPLEXIO_H
|
||||||
|
#define MODULE_SERIALPORTHALFDUPLEXIO_H
|
||||||
|
#include "stdint.h"
|
||||||
|
#include "SerialPortIO.h"
|
||||||
|
#include "GpioPin.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
tSerialPortIO *serialPortIo;
|
||||||
|
tGpioPin *transmitePin;
|
||||||
|
tGpioPin *recivePin;
|
||||||
|
} tSerialPortHalfDuplex;
|
||||||
|
|
||||||
|
tSerialPortHalfDuplex vSerialPortHalfDuplexInit(tSerialPortIO *serialPortIo, tGpioPin *transmitePin, tGpioPin *recivePin);
|
||||||
|
tSerialPortIO vSerialPortHalfDuplexGetIo(tSerialPortHalfDuplex *serialPortHalfDuplex);
|
||||||
|
|
||||||
|
#endif //MODULE_SERIALPORTHALFDUPLEXIO_H
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
//
|
||||||
|
// Created by cfif on 03.10.22.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "SerialPortHalfDuplexIO.h"
|
||||||
|
#include "SystemDelayInterface.h"
|
||||||
|
|
||||||
|
static uint16_t vSerialPortHalfDuplexReceive(tSerialPortHalfDuplex *io, uint8_t *data, uint16_t size,
|
||||||
|
uint32_t timeout) {
|
||||||
|
|
||||||
|
// tSerialPortHalfDuplex *serialPortHalfDuplex = (void *) io;
|
||||||
|
|
||||||
|
GpioPinSet(io->transmitePin, false);
|
||||||
|
GpioPinSet(io->recivePin, true);
|
||||||
|
|
||||||
|
uint16_t result = io->serialPortIo->receive(io->serialPortIo->env, data, size, timeout);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
static uint16_t vSerialPortHalfDuplexTransmit(tSerialPortIO *io, uint8_t *data, uint16_t size, uint32_t timeout) {
|
||||||
|
|
||||||
|
tSerialPortHalfDuplex *serialPortHalfDuplex = io->env;
|
||||||
|
|
||||||
|
GpioPinSet(serialPortHalfDuplex->transmitePin, true);
|
||||||
|
GpioPinSet(serialPortHalfDuplex->recivePin, false);
|
||||||
|
uint16_t result = serialPortHalfDuplex->serialPortIo->transmit(serialPortHalfDuplex->serialPortIo->env, data, size, timeout);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
static uint16_t vSerialPortHalfDuplexTransmit(tSerialPortHalfDuplex *io, uint8_t *data, uint16_t size, uint32_t timeout) {
|
||||||
|
|
||||||
|
// tSerialPortHalfDuplex *serialPortHalfDuplex = (void *) io;
|
||||||
|
|
||||||
|
GpioPinSet(io->recivePin, false);
|
||||||
|
GpioPinSet(io->transmitePin, true);
|
||||||
|
|
||||||
|
uint16_t result = io->serialPortIo->transmit(io->serialPortIo->env, data, size, timeout);
|
||||||
|
|
||||||
|
SystemDelayMs(5);
|
||||||
|
|
||||||
|
GpioPinSet(io->transmitePin, false);
|
||||||
|
GpioPinSet(io->recivePin, true);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
tSerialPortHalfDuplex vSerialPortHalfDuplexInit(
|
||||||
|
tSerialPortIO *serialPortIo, tGpioPin *transmitePin, tGpioPin *recivePin
|
||||||
|
) {
|
||||||
|
tSerialPortHalfDuplex port = {
|
||||||
|
.serialPortIo = serialPortIo,
|
||||||
|
.transmitePin = transmitePin,
|
||||||
|
.recivePin = recivePin
|
||||||
|
};
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
tSerialPortIO vSerialPortHalfDuplexGetIo(tSerialPortHalfDuplex *serialPortHalfDuplex) {
|
||||||
|
|
||||||
|
tSerialPortIO io = {
|
||||||
|
.env = serialPortHalfDuplex,
|
||||||
|
.receive = (SerialPortIOTransaction) vSerialPortHalfDuplexReceive,
|
||||||
|
.transmit = (SerialPortIOTransaction) vSerialPortHalfDuplexTransmit
|
||||||
|
};
|
||||||
|
return io;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"dep": [
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"provider": "GONEC",
|
||||||
|
"repo": "SerialPortInterface"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cmake": {
|
||||||
|
"inc_dirs": [
|
||||||
|
"Inc"
|
||||||
|
],
|
||||||
|
"srcs": [
|
||||||
|
"Src/**.c"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue