feat(set-protocol): добавь порт F407 для DevBoard_V1
This commit is contained in:
60
c/set-protocol/include/pcan_modbus_server.h
Normal file
60
c/set-protocol/include/pcan_modbus_server.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @file pcan_modbus_server.h
|
||||
* @brief Modbus register windows transported in one classic ProtoCAN frame.
|
||||
*/
|
||||
#ifndef PCAN_MODBUS_SERVER_H
|
||||
#define PCAN_MODBUS_SERVER_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "pcan_frame.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PCAN_MODBUS_COIL = 0x4U,
|
||||
PCAN_MODBUS_DISCRETE = 0x5U,
|
||||
PCAN_MODBUS_HOLDING = 0x6U,
|
||||
PCAN_MODBUS_INPUT = 0x7U
|
||||
} pcan_modbus_bank_t;
|
||||
|
||||
typedef bool (*pcan_modbus_read_fn)(void *user, pcan_modbus_bank_t bank,
|
||||
uint16_t address, uint16_t *value);
|
||||
typedef bool (*pcan_modbus_write_fn)(void *user, pcan_modbus_bank_t bank,
|
||||
uint16_t address, uint16_t value);
|
||||
|
||||
typedef struct {
|
||||
uint8_t device_type;
|
||||
uint8_t device_id;
|
||||
pcan_modbus_read_fn read;
|
||||
pcan_modbus_write_fn write;
|
||||
void *user;
|
||||
uint32_t requests;
|
||||
uint32_t responses;
|
||||
uint32_t rejected;
|
||||
} pcan_modbus_server_t;
|
||||
|
||||
typedef enum {
|
||||
PCAN_MODBUS_NOT_FOR_US = 0,
|
||||
PCAN_MODBUS_HANDLED_NO_RESPONSE,
|
||||
PCAN_MODBUS_RESPONSE
|
||||
} pcan_modbus_result_t;
|
||||
|
||||
bool pcan_modbus_server_init(pcan_modbus_server_t *server,
|
||||
uint8_t device_type, uint8_t device_id,
|
||||
pcan_modbus_read_fn read,
|
||||
pcan_modbus_write_fn write, void *user);
|
||||
|
||||
/** Zero DLC reads; data writes COIL/HOLDING. Register words are little-endian. */
|
||||
pcan_modbus_result_t pcan_modbus_server_handle(pcan_modbus_server_t *server,
|
||||
const pcan_frame_t *request,
|
||||
pcan_frame_t *response);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PCAN_MODBUS_SERVER_H */
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "pcan_gas.h"
|
||||
#include "pcan_id.h"
|
||||
#include "pcan_link.h"
|
||||
#include "pcan_modbus_server.h"
|
||||
#include "pcan_ring.h"
|
||||
|
||||
#endif /* PROTOCAN_TRANSPORT_H */
|
||||
|
||||
Reference in New Issue
Block a user