//Modbus relay card firmware Revision 0.1
//This firmware is designed for an AtMega328 running at 8MHz.
//The fuse bits should be set to 0xFF 0xD5 0xE2.

#ifndef MODBUS_RELAY_BOARD_V_1_H_
#define MODBUS_RELAY_BOARD_V_1_H_

#include <avr/io.h>
#include <avr/interrupt.h>
#include "Board_IO.h"
#include "Helper.h"
#include "USART_Control.h"
#include "EEPROM.h"
#include "Modbus.h"

//Modbus callback functions.
void do_read_coils(Mb_rx_struct *rx_struct, Mb_tx_struct *tx_struct);           //Read coils.
void do_write_single_coil(Mb_rx_struct *rx_struct, Mb_tx_struct *tx_struct);    //Write single coil.

//Array of callback function pointers. NULL for unsupported functions.
void (*modbus_callback_functions[MB_FUNC_ARRAY_LENGTH])(Mb_rx_struct *rx_struct, Mb_tx_struct *tx_struct) =
{
    do_read_coils,                      //Read coils.
    NULL,                               //Read discrete inputs.
    NULL,                               //Read holding registers.
    NULL,                               //Read input registers.
    do_write_single_coil,               //Write single coil.
    NULL,                               //Write single register.
    NULL,                               //Read exception status.
    NULL,                               //Diagnostic. Placeholder only, should always be NULL.
    NULL,                               //Get com event counter. Placeholder only, should always be NULL.
    NULL,                               //Get com event log. Placeholder only, should always be NULL.
    NULL,                               //Program controller.
    NULL,                               //Poll.
    NULL,                               //Write multiple coils.
    NULL,                               //Write multiple registers.
    NULL,                               //Report server ID.
    NULL,                               //Read file record.
    NULL,                               //Write file record.
    NULL,                               //Mask write register.
    NULL,                               //Read write multi regs.
    NULL,                               //Read FIFO queue.
    NULL                                //Read device ID.
};

#endif //MODBUS_RELAY_BOARD_V_1_H_