mirror of
https://gitea.ecohim.ru:3000/RS485_BSV/RS485_BSV_fw.git
synced 2025-08-04 15:37:06 +03:00
Migrated to a new HAL version; FW now works; Adress is 38, board type is 12
This commit is contained in:
37
Core/Inc/modbus_logic.h
Normal file
37
Core/Inc/modbus_logic.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* modbus_logic.h
|
||||
*
|
||||
* Created on: Jul 25, 2024
|
||||
* Author: User
|
||||
*/
|
||||
|
||||
#ifndef INC_MODBUS_LOGIC_H_
|
||||
#define INC_MODBUS_LOGIC_H_
|
||||
#include <stdint.h>
|
||||
|
||||
#define BOARD_ADRESS 38 //BSV Module 1
|
||||
//#define BOARD_ADRESS 39 //BSV Module 2
|
||||
|
||||
#define BUS_IDLE_TIME 3
|
||||
|
||||
#define MODBUS_PROTOCOL_VERSION (1)
|
||||
#define MODBUS_HEADER_SIZE (13)
|
||||
#define BUFFERS_SIZE (100 + 9)
|
||||
#define MAX_REGS_PER_QUERY (32)
|
||||
#define ADDRESS_UNDEFINED (0xff)
|
||||
|
||||
enum recv_state {RECV_IDLE, RECV_READ_HEADER, RECV_READ_DATA, RECV_READ_COMPLETE, RECV_ERROR};
|
||||
enum send_state {SEND_IDLE, SEND_BUSY};
|
||||
|
||||
#define TXEN_ON HAL_GPIO_WritePin(TXEN_GPIO_Port, TXEN_Pin, GPIO_PIN_SET)
|
||||
#define TXEN_OFF HAL_GPIO_WritePin(TXEN_GPIO_Port, TXEN_Pin, GPIO_PIN_RESET)
|
||||
|
||||
void UART_RxCpltCallback(void);
|
||||
void UART_TxCpltCallback(void);
|
||||
void process_incoming_packet();
|
||||
void modbus_loop_iterate();
|
||||
uint8_t read_register(uint16_t address, uint16_t* value);
|
||||
uint8_t write_register(uint16_t address, uint16_t value);
|
||||
|
||||
|
||||
#endif /* INC_MODBUS_LOGIC_H_ */
|
Reference in New Issue
Block a user