/* 
 * File:   modbus_Private.h
 * Author: chang
 *
 * Created on July 25, 2024, 1:37 PM
 */

#ifndef MODBUS_USER_H
#define	MODBUS_USER_H

#ifdef	__cplusplus
extern "C" {
#endif

#include "modbus.h"   

 #define MODBUS_FC_READ_USER_INPUT_REG (modbus->FC_user_read)
 #define MODBUS_FC_READ_USER1_HOLDING_REG (modbus->FC_user1_readHolding) 
 #define MODBUS_FC_READ_USER2_HOLDING_REG (modbus->FC_user2_readHolding) 
 #define MODBUS_FC_WRITE_USER1_REG (modbus->FC_user1_write) 
 #define MODBUS_FC_WRITE_USER2_REG (modbus->FC_user2_write)
 
 void MODBUS_Slave_User_init(ModbusSlave_t * modbus, uint8_t FC_user_read_a, uint8_t FC_user1_readHolding1_a, uint8_t FC_user2_readHolding1_a,
                       uint8_t FC_user1_write_a, uint8_t FC_user2_write_a, 
                       uint16_t * memory_rw_user1,uint16_t memory_rw_user1_size,uint16_t memory_rw_user1_minAddr,
                       uint16_t *memory_r_user, uint16_t memory_r_user_size, uint16_t memory_r_user_minAddr,
                       uint16_t * memory_rw_user2,uint16_t memory_rw_user2_size, uint16_t memory_rw_user2_minAddr );  
 void MODBUS_Master_private_init(ModbusMaster_t * modbus, uint8_t FC_user_read_a, uint8_t FC_user1_readHolding1_a, uint8_t FC_user2_readHolding1_a,
                       uint8_t FC_user1_write_a, uint8_t FC_user2_write_a);   
  
 /*
#define SET_BREAKPOINT(EnterCondition, ExitCondition, mb) \
        while(EnterCondition) \
        {  \
            MODBUS_Slave_Poll(&mb); \
            if (ExitCondition)      \
            {                       \
                break;              \
            }\                          
        }  */
 
#define SET_BREAKPOINT(EnterCondition, ExitCondition, mb) \
while(EnterCondition) \
{  \
    MODBUS_Slave_Poll(&mb); \
    if (ExitCondition) break; \
}  

#ifdef	__cplusplus
}
#endif

#endif	/* MODBUS_PRIVATE_H */

