commit
e51aa3744e
@ -0,0 +1,8 @@
|
|||||||
|
/build
|
||||||
|
/debug
|
||||||
|
/dist
|
||||||
|
/.generated_files
|
||||||
|
device.h
|
||||||
|
keys.c
|
||||||
|
*.enc
|
||||||
|
*.unenc
|
||||||
@ -0,0 +1,539 @@
|
|||||||
|
//#############################################################################################################################################################################################################
|
||||||
|
#ifndef _INC_IDIBUS_DEFS_H_
|
||||||
|
#define _INC_IDIBUS_DEFS_H_
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#ifndef F_CPU
|
||||||
|
#define F_CPU 16000000UL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define MODBUS_CRC16_SIZE 2
|
||||||
|
#define CRC32_SIZE 4
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#define IDIBUS_BAUDRATE_DSW_CODE_19200B 0x00
|
||||||
|
#define IDIBUS_BAUDRATE_DSW_CODE_500K 0x01
|
||||||
|
#define IDIBUS_BAUDRATE_DSW_CODE_2400B 0x02
|
||||||
|
#define IDIBUS_BAUDRATE_DSW_CODE_9600B 0x03
|
||||||
|
#define IDIBUS_BAUDRATE_DSW_CODE_115200B 0x04
|
||||||
|
#define IDIBUS_BAUDRATE_DSW_CODE_250K 0x05
|
||||||
|
#define IDIBUS_BAUDRATE_DSW_CODE_1M 0x06
|
||||||
|
#define IDIBUS_BAUDRATE_DSW_CODE_10M 0x07
|
||||||
|
|
||||||
|
|
||||||
|
// Full timeout will be (InterframeTimeout + ResponseTimeout) for request(Write + Read) or InterframeTimeout for write(Write only)
|
||||||
|
#define IDIBUS_2400B_INTERFRAME_TIMEOUT_US 16042ULL //11 * 3.5 / Baudrate
|
||||||
|
#define IDIBUS_9600B_INTERFRAME_TIMEOUT_US 4011ULL
|
||||||
|
#define IDIBUS_19200B_INTERFRAME_TIMEOUT_US 2006ULL
|
||||||
|
#define IDIBUS_115200B_INTERFRAME_TIMEOUT_US 1750ULL
|
||||||
|
#define IDIBUS_250K_INTERFRAME_TIMEOUT_US 1750ULL
|
||||||
|
#define IDIBUS_500K_INTERFRAME_TIMEOUT_US 1750ULL
|
||||||
|
#define IDIBUS_1M_INTERFRAME_TIMEOUT_US 1750ULL
|
||||||
|
#define IDIBUS_10M_INTERFRAME_TIMEOUT_US 1750ULL
|
||||||
|
|
||||||
|
#define IDIBUS_2400B_ALARM_TIMEOUT_US 34375ULL //11 * 3.5 / Baudrate
|
||||||
|
#define IDIBUS_9600B_ALARM_TIMEOUT_US 8594ULL
|
||||||
|
#define IDIBUS_19200B_ALARM_TIMEOUT_US 4297ULL
|
||||||
|
#define IDIBUS_115200B_ALARM_TIMEOUT_US 1750ULL
|
||||||
|
#define IDIBUS_250K_ALARM_TIMEOUT_US 1750ULL
|
||||||
|
#define IDIBUS_500K_ALARM_TIMEOUT_US 1750ULL
|
||||||
|
#define IDIBUS_1M_ALARM_TIMEOUT_US 1750ULL
|
||||||
|
#define IDIBUS_10M_ALARM_TIMEOUT_US 1750ULL
|
||||||
|
|
||||||
|
#define IDIBUS_2400B_MASTER_RESPONSE_TIMEOUT_US (IDIBUS_2400B_INTERFRAME_TIMEOUT_US * 3 / 2 )
|
||||||
|
#define IDIBUS_9600B_MASTER_RESPONSE_TIMEOUT_US (IDIBUS_9600B_INTERFRAME_TIMEOUT_US * 3 / 2 )
|
||||||
|
#define IDIBUS_19200B_MASTER_RESPONSE_TIMEOUT_US (IDIBUS_19200B_INTERFRAME_TIMEOUT_US * 3 / 2 )
|
||||||
|
#define IDIBUS_115200B_MASTER_RESPONSE_TIMEOUT_US (IDIBUS_115200B_INTERFRAME_TIMEOUT_US * 3 / 2 )
|
||||||
|
#define IDIBUS_250K_MASTER_RESPONSE_TIMEOUT_US (IDIBUS_250K_INTERFRAME_TIMEOUT_US * 3 / 2 )
|
||||||
|
#define IDIBUS_500K_MASTER_RESPONSE_TIMEOUT_US (IDIBUS_500K_INTERFRAME_TIMEOUT_US * 3 / 2 )
|
||||||
|
#define IDIBUS_1M_MASTER_RESPONSE_TIMEOUT_US (IDIBUS_1M_INTERFRAME_TIMEOUT_US * 3 / 2 )
|
||||||
|
#define IDIBUS_10M_MASTER_RESPONSE_TIMEOUT_US (IDIBUS_10M_INTERFRAME_TIMEOUT_US * 3 / 2 )
|
||||||
|
|
||||||
|
#define IDIBUS_2400B_SLAVE_RESPONSE_TIMEOUT_US (IDIBUS_2400B_INTERFRAME_TIMEOUT_US )
|
||||||
|
#define IDIBUS_9600B_SLAVE_RESPONSE_TIMEOUT_US (IDIBUS_9600B_INTERFRAME_TIMEOUT_US )
|
||||||
|
#define IDIBUS_19200B_SLAVE_RESPONSE_TIMEOUT_US (IDIBUS_19200B_INTERFRAME_TIMEOUT_US )
|
||||||
|
#define IDIBUS_115200B_SLAVE_RESPONSE_TIMEOUT_US (IDIBUS_115200B_INTERFRAME_TIMEOUT_US)
|
||||||
|
#define IDIBUS_250K_SLAVE_RESPONSE_TIMEOUT_US (IDIBUS_250K_INTERFRAME_TIMEOUT_US )
|
||||||
|
#define IDIBUS_500K_SLAVE_RESPONSE_TIMEOUT_US (IDIBUS_500K_INTERFRAME_TIMEOUT_US )
|
||||||
|
#define IDIBUS_1M_SLAVE_RESPONSE_TIMEOUT_US (IDIBUS_1M_INTERFRAME_TIMEOUT_US )
|
||||||
|
#define IDIBUS_10M_SLAVE_RESPONSE_TIMEOUT_US (IDIBUS_10M_INTERFRAME_TIMEOUT_US )
|
||||||
|
|
||||||
|
|
||||||
|
enum IDIBUS_SERIAL_BAUDRATE {
|
||||||
|
IDIBUS_BAUDRATE_2400 = IDIBUS_BAUDRATE_DSW_CODE_2400B,
|
||||||
|
IDIBUS_BAUDRATE_9600 = IDIBUS_BAUDRATE_DSW_CODE_9600B,
|
||||||
|
IDIBUS_BAUDRATE_19200 = IDIBUS_BAUDRATE_DSW_CODE_19200B,
|
||||||
|
IDIBUS_BAUDRATE_115200 = IDIBUS_BAUDRATE_DSW_CODE_115200B,
|
||||||
|
IDIBUS_BAUDRATE_250K = IDIBUS_BAUDRATE_DSW_CODE_250K,
|
||||||
|
IDIBUS_BAUDRATE_500K = IDIBUS_BAUDRATE_DSW_CODE_500K,
|
||||||
|
IDIBUS_BAUDRATE_1M = IDIBUS_BAUDRATE_DSW_CODE_1M,
|
||||||
|
IDIBUS_BAUDRATE_10M = IDIBUS_BAUDRATE_DSW_CODE_10M
|
||||||
|
};
|
||||||
|
|
||||||
|
#define IDIBUS_LINK_LED_NO_MMES_TIMEOUT_0_SEC 60U
|
||||||
|
#define IDIBUS_LINK_LED_NO_MMES_TIMEOUT_0_MS ( IDIBUS_LINK_LED_NO_MMES_TIMEOUT_0_SEC * 1000U )
|
||||||
|
#define IDIBUS_LINK_LED_NO_MMES_TIMEOUT_1_SEC 15U
|
||||||
|
#define IDIBUS_LINK_LED_NO_MMES_TIMEOUT_1_MS ( IDIBUS_LINK_LED_NO_MMES_TIMEOUT_1_SEC * 1000U )
|
||||||
|
|
||||||
|
enum IDIBUS_RXTIMER_TIMEOUT_MODE {
|
||||||
|
IDIBUS_TIMER_MODE_RX_TIMEOUT = 0x00,
|
||||||
|
IDIBUS_TIMER_MODE_ALARM_TIMEOUT,
|
||||||
|
IDIBUS_TIMER_MODE_RESPONSE_TIMEOUT
|
||||||
|
};
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
#define IDISN_FIXP_Pos 1U //Internal padding
|
||||||
|
#define IDISN_FIXP_GS1_COUNTRY_Pos ( IDISN_FIXP_Pos + 0U)
|
||||||
|
#define IDISN_FIXP_GS1_COUNTRY_Length 3
|
||||||
|
#define IDISN_FIXP_GS1_COMPANY_Pos ( IDISN_FIXP_GS1_COUNTRY_Pos + IDISN_FIXP_GS1_COUNTRY_Length )
|
||||||
|
#define IDISN_FIXP_GS1_COMPANY_Length 6
|
||||||
|
#define IDISN_FIXP_MODULE_TYPE_Pos ( IDISN_FIXP_GS1_COMPANY_Pos + IDISN_FIXP_GS1_COMPANY_Length )
|
||||||
|
#define IDISN_FIXP_MODULE_TYPE_Length 3
|
||||||
|
#define IDISN_FIXP_HW_REV_Pos ( IDISN_FIXP_MODULE_TYPE_Pos + IDISN_FIXP_MODULE_TYPE_Length )
|
||||||
|
#define IDISN_FIXP_HW_REV_Length 2
|
||||||
|
#define IDISN_FIXP_SERIAL_Pos ( IDISN_FIXP_HW_REV_Pos + IDISN_FIXP_HW_REV_Length )
|
||||||
|
#define IDISN_FIXP_SERIAL_Length 7
|
||||||
|
#define IDISN_FIXP_MAC_Pos ( IDISN_FIXP_SERIAL_Pos + IDISN_FIXP_SERIAL_Length )
|
||||||
|
#define IDISN_FIXP_MAC_Length 6
|
||||||
|
#define IDISN_FIXP_SW_REV_Pos ( IDISN_FIXP_MAC_Pos + IDISN_FIXP_MAC_Length )
|
||||||
|
#define IDISN_FIXP_SW_REV_Length 2
|
||||||
|
#define IDISN_FIXP_LENGTH ( IDISN_FIXP_GS1_COUNTRY_Length + IDISN_FIXP_GS1_COMPANY_Length + IDISN_FIXP_MODULE_TYPE_Length + \
|
||||||
|
IDISN_FIXP_HW_REV_Length + IDISN_FIXP_SERIAL_Length + IDISN_FIXP_MAC_Length + IDISN_FIXP_SW_REV_Length )
|
||||||
|
|
||||||
|
#define IDISN_VARP_Pos 0 //IDISN_FIXP_LENGTH
|
||||||
|
#define IDISN_VARP_VERIF_DATE_Pos ( IDISN_VARP_Pos )
|
||||||
|
#define IDISN_VARP_VERIF_DATE_Length 4U
|
||||||
|
#define IDISN_VARP_EXPIR_DATE_Pos ( IDISN_VARP_VERIF_DATE_Pos + IDISN_VARP_VERIF_DATE_Length )
|
||||||
|
#define IDISN_VARP_EXPIR_DATE_Length 4U
|
||||||
|
#define IDISN_VARP_IPv4_Pos ( IDISN_VARP_EXPIR_DATE_Pos + IDISN_VARP_EXPIR_DATE_Length )
|
||||||
|
#define IDISN_VARP_IPv4_Length 4U
|
||||||
|
#define IDISN_VARP_IPv6_Pos ( IDISN_VARP_IPv4_Pos + IDISN_VARP_IPv4_Length )
|
||||||
|
#define IDISN_VARP_IPv6_Length 16U
|
||||||
|
#define IDISN_VARP_AES256_Pos ( IDISN_VARP_IPv6_Pos + IDISN_VARP_IPv6_Length )
|
||||||
|
#define IDISN_VARP_AES256_Length 32U
|
||||||
|
#define IDISN_VARP_LENGTH ( IDISN_VARP_VERIF_DATE_Length + IDISN_VARP_EXPIR_DATE_Length + \
|
||||||
|
IDISN_VARP_IPv4_Length + IDISN_VARP_IPv6_Length + IDISN_VARP_AES256_Length )
|
||||||
|
|
||||||
|
#define IDISN_FULL_LENGTH ( IDISN_FIXP_LENGTH + IDISN_VARP_LENGTH )
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
#define ISIBUS_MASTER_MAIN_ADDR 255U
|
||||||
|
#define ISIBUS_MASTER_SPARE_ADDR 254U
|
||||||
|
#define IDIBUS_SLAVE_ADDR_MIN 1U
|
||||||
|
#define IDIBUS_SLAVE_ADDR_MAX 229U
|
||||||
|
#define IDIBUS_DEVELOPER_ADDR_0 250U
|
||||||
|
#define IDIBUS_DEVELOPER_ADDR_1 251U
|
||||||
|
#define IDIBUS_DEVELOPER_ADDR_2 252U
|
||||||
|
#define IDIBUS_DEVELOPER_ADDR_3 253U
|
||||||
|
#define IDIBUS_GROUP_0_ADDR 230U
|
||||||
|
#define IDIBUS_GROUP_1_ADDR 231U
|
||||||
|
#define IDIBUS_GROUP_2_ADDR 232U
|
||||||
|
#define IDIBUS_GROUP_3_ADDR 233U
|
||||||
|
#define IDIBUS_GROUP_4_ADDR 234U
|
||||||
|
#define IDIBUS_GROUP_5_ADDR 235U
|
||||||
|
#define IDIBUS_GROUP_6_ADDR 236U
|
||||||
|
#define IDIBUS_GROUP_7_ADDR 237U
|
||||||
|
#define IDIBUS_GROUP_8_ADDR 238U
|
||||||
|
#define IDIBUS_GROUP_9_ADDR 239U
|
||||||
|
#define IDIBUS_GROUP_10_ADDR 240U
|
||||||
|
#define IDIBUS_GROUP_11_ADDR 241U
|
||||||
|
#define IDIBUS_GROUP_12_ADDR 242U
|
||||||
|
#define IDIBUS_GROUP_13_ADDR 243U
|
||||||
|
#define IDIBUS_GROUP_14_ADDR 244U
|
||||||
|
#define IDIBUS_GROUP_15_ADDR 245U
|
||||||
|
|
||||||
|
#define IDIBUS_GROUPS_NUMBER 16U
|
||||||
|
#define IDIBUS_GROUP_FIRST_NUMBER 0U
|
||||||
|
#define IDIBUS_GROUP_LAST_NUMBER 15U
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
#define IDIMMES_ADDR_Pos 00U
|
||||||
|
#define IDIMMES_MMPS_Pos 01U
|
||||||
|
#define IDIMMES_MMPS_LONG_MES_Pos 0U
|
||||||
|
#define IDIMMES_MMPS_LONG_MES_Msk 0x01U
|
||||||
|
#define IDIMMES_MMPS_MES_TYPE_Pos 1U
|
||||||
|
#define IDIMMES_MMPS_MES_TYPE_Msk 0x02U
|
||||||
|
#define IDIMMES_MMPS_MES_TYPE_MMES 0x00U
|
||||||
|
#define IDIMMES_MMPS_MES_TYPE_MMESG 0x01U
|
||||||
|
#define IDIMMES_MMPS_FAST_FUNC_Pos 2U
|
||||||
|
#define IDIMMES_MMPS_FAST_FUNC_Msk 0x3CU
|
||||||
|
#define IDIMMES_MMPS_ALARM_FRAME_Pos 6U
|
||||||
|
#define IDIMMES_MMPS_ALARM_FRAME_Msk 0x40U
|
||||||
|
#define IDIMMES_MMPS_ENCRYPTED_AES_Pos 7U
|
||||||
|
#define IDIMMES_MMPS_ENCRYPTED_AES_Msk 0x80U
|
||||||
|
#define IDIMMES_DEV_Pos 02U
|
||||||
|
#define IDIMMES_DEV_NUM_Pos 0U
|
||||||
|
#define IDIMMES_DEV_NUM_Msk 0x1FU
|
||||||
|
#define IDIMMES_DEV_ALLCH_Pos 5U
|
||||||
|
#define IDIMMES_DEV_ALLCH_Msk 0x20U
|
||||||
|
#define IDIMMES_CHNL_Pos 03U
|
||||||
|
#define IDIMMES_CHNL_NUM_Pos 0U
|
||||||
|
#define IDIMMES_CHNL_NUM_Msk 0x7FU
|
||||||
|
#define IDIMMES_CHNL_ALLSAME_Pos 7U
|
||||||
|
#define IDIMMES_CHNL_ALLSAME_Msk 0x80U
|
||||||
|
#define IDIMMES_DATA_FUNC_COM_DATA_Pos 04U
|
||||||
|
#define IDIMMES_MAX_HEADER_LENGTH (IDIMMES_DATA_FUNC_COM_DATA_Pos + 1)
|
||||||
|
#define IDIMMES_MAX_DATA_SIZE 256U
|
||||||
|
#define IDIMMES_MAX_MES_SIZE (IDIMMES_MAX_DATA_SIZE + IDIMMES_MAX_HEADER_LENGTH + MODBUS_CRC16_SIZE)
|
||||||
|
#define IDIMMES_MIN_MES_SIZE (IDIMMES_DATA_FUNC_COM_DATA_Pos + MODBUS_CRC16_SIZE)
|
||||||
|
|
||||||
|
#define IDIMMESG_DATA_COM_FUNC_Pos 02U
|
||||||
|
#define IDIMMESG_MAX_HEADER_LENGTH (IDIMMESG_DATA_COM_FUNC_Pos + 1)
|
||||||
|
#define IDIMMESG_MAX_DATA_SIZE IDIMMES_MAX_DATA_SIZE
|
||||||
|
#define IDIMMESG_MAX_MES_SIZE (IDIMMESG_MAX_DATA_SIZE + IDIMMESG_MAX_HEADER_LENGTH + MODBUS_CRC16_SIZE)
|
||||||
|
#define IDIMMESG_MODULE_MIN_MES_SIZE (IDIMMESG_DATA_COM_FUNC_Pos + 1 + MODBUS_CRC16_SIZE)
|
||||||
|
#define IDIMMESG_GROUP_MIN_MES_SIZE (IDIMMESG_DATA_COM_FUNC_Pos + MODBUS_CRC16_SIZE)
|
||||||
|
|
||||||
|
#define IDIMMES_LMES_MSIZE_Pos 0U
|
||||||
|
#define IDIMMES_LMES_BSIZE_Pos (IDIMMES_LMES_MSIZE_Pos + 4U)
|
||||||
|
#define IDIMMES_LMES_IDENTIFIER_LENGTH (IDIMMES_LMES_BSIZE_Pos + 1U)
|
||||||
|
#define IDIMMES_LMES_BSIZE_256B 0U
|
||||||
|
#define IDIMMES_LMES_BSIZE_1K 1U
|
||||||
|
#define IDIMMES_LMES_BSIZE_4K 2U
|
||||||
|
#define IDIMMES_LMES_BSIZE_8K 3U
|
||||||
|
#define IDIMMES_LMES_BSIZE_16K 4U
|
||||||
|
#define IDIMMES_LMES_BSIZE_32K 5U
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
#define IDISMES_ADDR_Pos 00U
|
||||||
|
#define IDISMES_SMPS_Pos 01U
|
||||||
|
#define IDISMES_SMPS_ERROR_BIT_Pos 0U
|
||||||
|
#define IDISMES_SMPS_LONG_MES_Pos 1U
|
||||||
|
#define IDISMES_SMPS_LONG_OP_Pos 2U
|
||||||
|
#define IDISMES_ERROR_Pos 02U
|
||||||
|
#define IDISMES_DATA_Pos 03U
|
||||||
|
#define IDISMES_MAX_DATA_SIZE 256U
|
||||||
|
#define IDISMES_MIN_MES_SIZE (IDISMES_DATA_Pos + MODBUS_CRC16_SIZE)
|
||||||
|
#define IDISMES_MAX_MES_SIZE (IDISMES_DATA_Pos + IDISMES_MAX_DATA_SIZE + MODBUS_CRC16_SIZE)
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
#define IDILONGOP_STATE_COMPLETE_NO_ERR 0x00U
|
||||||
|
#define IDILONGOP_STATE_IN_PROC 0x01U
|
||||||
|
#define IDILONGOP_STATE_COMPLETE_WITH_ERR 0x02U
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#define IDILONGOP_MES_DATA_LENGTH 5U
|
||||||
|
#define IDILONGOP_STATE_Pos 0U
|
||||||
|
#define IDILONGOP_REMAIN_TIME_Pos 1U
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
#define IDISTATUS_B0S_Pos 00U
|
||||||
|
#define IDISTATUS_B0S_ST_ERROR_Pos 0U
|
||||||
|
#define IDISTATUS_B0S_ST_STATE_Pos 1U
|
||||||
|
#define IDISTATUS_B0S_ST_STATE_Msk 0x07U
|
||||||
|
#define IDISTATUS_B0S_ST_STATE_StNoInit 0x00U
|
||||||
|
#define IDISTATUS_B0S_ST_STATE_StOperate 0x01U
|
||||||
|
#define IDISTATUS_B0S_ST_STATE_StFreeze 0x02U
|
||||||
|
#define IDISTATUS_B0S_ST_STATE_StVirtual 0x03U
|
||||||
|
#define IDISTATUS_B0S_ST_STATE_StFirmwareUpd 0x04U
|
||||||
|
#define IDISTATUS_B0S_ST_STATE_StReservedMaster 0x05U
|
||||||
|
#define IDISTATUS_B0S_ST_STATE_StBroken 0x06U
|
||||||
|
#define IDISTATUS_B0S_ST_STATE_StReserved0 0x07U
|
||||||
|
#define IDISTATUS_B0S_AES_SUPPORTED_Pos 4U
|
||||||
|
#define IDISTATUS_B0S_AES_INSTALLED_Pos 5U
|
||||||
|
#define IDISTATUS_B0S_SEND_ALARM_L0_Pos 6U
|
||||||
|
#define IDISTATUS_B0S_SEND_ALARM_L1_Pos 7U
|
||||||
|
|
||||||
|
#define IDISTATUS_B1S_Pos 01U
|
||||||
|
#define IDISTATUS_B1S_MODULE_TYPE_Pos 0U
|
||||||
|
#define IDISTATUS_B1S_MODULE_TYPE_Msk 0x03U
|
||||||
|
#define IDISTATUS_B1S_MODULE_TYPE_Master 0x00U
|
||||||
|
#define IDISTATUS_B1S_MODULE_TYPE_SpareMaster 0x01U
|
||||||
|
#define IDISTATUS_B1S_MODULE_TYPE_Slave 0x02U
|
||||||
|
#define IDISTATUS_B1S_MODULE_TYPE_Bridge 0x03U
|
||||||
|
#define IDISTATUS_B1S_BRIDGE_CONNECTED_Pos 2U
|
||||||
|
#define IDISTATUS_B1S_SELF_INIT_Pos 3U
|
||||||
|
#define IDISTATUS_B1S_TIMEOUT_LED_Pos 4U
|
||||||
|
#define IDISTATUS_B1S_NO_MMES_TIMEOUT_Pos 5U
|
||||||
|
#define IDISTATUS_B1S_CATCH_ALARM_L0_Pos 6U
|
||||||
|
#define IDISTATUS_B1S_CATCH_ALARM_L1_Pos 7U
|
||||||
|
|
||||||
|
#define IDISTATUS_SN_Pos 02U
|
||||||
|
#define IDISTATUS_LENGTH ( IDISTATUS_SN_Pos + IDISN_FULL_LENGTH )
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
#define IDIMMES_NOT_FAST_FUNC 0U
|
||||||
|
#define IDIMMES_MAX_FAST_FUNC_NUM 15U
|
||||||
|
#define IDIMMES_COM_START_NUM 220U
|
||||||
|
#define IDIMMES_COM_C_Init 220U
|
||||||
|
#define IDIMMES_COM_C_ShtDown 221U
|
||||||
|
#define IDIMMES_COM_C_Freeze 222U
|
||||||
|
#define IDIMMES_COM_C_Resume 223U
|
||||||
|
#define IDIMMES_COM_C_Dummy 224U
|
||||||
|
#define IDIMMES_COM_C_AssignGroup 225U
|
||||||
|
#define IDIMMES_COM_C_SetAlarmL12 226U
|
||||||
|
#define IDIMMES_COM_C_SetAlarmL 227U
|
||||||
|
#define IDIMMES_COM_C_Virtual 228U
|
||||||
|
#define IDIMMES_COM_C_SyncReadChnl 229U
|
||||||
|
#define IDIMMES_COM_C_SyncRead 230U
|
||||||
|
#define IDIMMES_COM_C_SyncDoChnl 231U
|
||||||
|
#define IDIMMES_COM_C_SyncDo 232U
|
||||||
|
#define IDIMMES_COM_C_SyncClear 233U
|
||||||
|
#define IDIMMES_COM_C_BurstReadCnt 234U
|
||||||
|
#define IDIMMES_COM_C_BurstReadTime 235U
|
||||||
|
#define IDIMMES_COM_C_SendTimeDate 236U
|
||||||
|
#define IDIMMES_COM_C_MkTimedMaster 237U
|
||||||
|
#define IDIMMES_COM_C_EnterBootloader 238U
|
||||||
|
//Skipped for historical reasons
|
||||||
|
#define IDIMMES_COM_C_ReadDevFullSN_MS 241U
|
||||||
|
#define IDIMMES_COM_C_WriteSnIPv4IPv6 242U
|
||||||
|
#define IDIMMES_COM_C_WriteSnVerifyDates 243U
|
||||||
|
#define IDIMMES_COM_C_WriteSnAES256 244U
|
||||||
|
#define IDIMMES_COM_C_SendLongMessage 245U
|
||||||
|
#define IDIMMES_COM_C_GetLondMessage 246U
|
||||||
|
#define IDIMMES_COM_C_DummyModule 247U
|
||||||
|
#define IDIMMES_COM_C_CheckModuleLongOp 248U
|
||||||
|
#define IDIMMES_COM_C_CheckChannelLongOp 249U
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
#define IDIER_MODBUS_NUM_START 1U
|
||||||
|
#define IDIER_MODBUS_NUM_END 9U
|
||||||
|
#define IDIER_MODULE_MASTER_NUM_START 10U
|
||||||
|
#define IDIER_MODULE_MASTER_NUM_END 32U
|
||||||
|
#define IDIER_MODULE_SLAVE_NUM_START 33U
|
||||||
|
#define IDIER_MODULE_SLAVE_NUM_END 71U
|
||||||
|
#define IDIER_MODULE_NUM_START IDIER_MODULE_MASTER_NUM_START
|
||||||
|
#define IDIER_MODULE_NUM_END IDIER_MODULE_SLAVE_NUM_END
|
||||||
|
#define IDIER_DEVICE_NUM_START 72U
|
||||||
|
#define IDIER_DEVICE_NUM_END 89U
|
||||||
|
|
||||||
|
#define IDIER_NOPE 0U
|
||||||
|
#define MODBUSER_WRONGFUNC 1U
|
||||||
|
#define MODBUSER_WRONGADDR 2U
|
||||||
|
#define MODBUSER_WRONGDATA 3U
|
||||||
|
#define MODBUSER_BROKE 4U
|
||||||
|
#define MODBUSER_LONGCOMMAND 5U
|
||||||
|
#define MODBUSER_BUSY 6U
|
||||||
|
#define MODBUSER_CANTDOFUNC 7U
|
||||||
|
#define MODBUSER_EXTMEMORYERROR 8U
|
||||||
|
#define MODBUSER_RESERVED 9U
|
||||||
|
#define IDIERMST_INVALID_ADDR_NUM 10U
|
||||||
|
#define IDIERMST_INVALID_DEV_NUM 11U
|
||||||
|
#define IDIERMST_INVALID_CHN_NUM 12U
|
||||||
|
#define IDIERMST_INVALID_FUNC_NUM 13U
|
||||||
|
#define IDIERMST_INVALID_TX_REQUEST_FORMAT 14U
|
||||||
|
#define IDIERMST_INVALID_TX_PARAM 15U
|
||||||
|
#define IDIERMST_TX_MES 16U
|
||||||
|
#define IDIERMST_RCV_TIMEOUT 17U
|
||||||
|
#define IDIERMST_MES_RX_INTEGRITY 18U
|
||||||
|
#define IDIERMST_CRC 19U
|
||||||
|
#define IDIERMST_MULTIPLE_CRC 20U
|
||||||
|
#define IDIERMST_INVALID_RX_REQUEST_FORMAT 21U
|
||||||
|
#define IDIERMST_INVALID_RX_PARAM 22U
|
||||||
|
#define IDIERMST_RESEVED_23 23U
|
||||||
|
#define IDIERMST_RESEVED_24 24U
|
||||||
|
#define IDIERMST_RESEVED_25 25U
|
||||||
|
#define IDIERMST_RESEVED_26 26U
|
||||||
|
#define IDIERMST_RESEVED_27 27U
|
||||||
|
#define IDIERMST_EXTRA_28 28U
|
||||||
|
#define IDIERMST_EXTRA_29 29U
|
||||||
|
#define IDIERMST_EXTRA_30 30U
|
||||||
|
#define IDIERMST_EXTRA_31 31U
|
||||||
|
#define IDIERMST_EXTRA_32 32U
|
||||||
|
#define IDIERSLV_RESEVED_33 33U
|
||||||
|
#define IDIERSLV_ENCRYPTION_NOT_SUPPORTED 34U
|
||||||
|
#define IDIERSLV_ENCRYPTION_NOT_INSTALLED 35U
|
||||||
|
#define IDIERSLV_JUMBO_NOT_SUPPORTED 36U
|
||||||
|
#define IDIERSLV_UNSUPPORTED_FUNC_NUM 37U
|
||||||
|
#define IDIERSLV_INVALID_RX_REQUEST_FORMAT 38U
|
||||||
|
#define IDIERSLV_INVALID_RX_PARAM 39U
|
||||||
|
#define IDIERSLV_IN_FREEZE 40U
|
||||||
|
#define IDIERSLV_RESERVED_41 41U
|
||||||
|
#define IDIERSLV_RESERVED_42 42U
|
||||||
|
#define IDIERSLV_RESERVED_43 43U
|
||||||
|
#define IDIERSLV_RESERVED_44 44U
|
||||||
|
#define IDIERSLV_RESERVED_45 45U
|
||||||
|
#define IDIERSLV_EXTRA_46 46U
|
||||||
|
#define IDIERSLV_EXTRA_47 47U
|
||||||
|
#define IDIERSLV_EXTRA_48 48U
|
||||||
|
#define IDIERSLV_EXTRA_49 49U
|
||||||
|
#define IDIERSLV_EXTRA_50 50U
|
||||||
|
#define IDIERSLV_BROKE 51U
|
||||||
|
#define IDIERSLV_NO_FIRMWARE 52U
|
||||||
|
#define IDIERSLV_NO_INIT 53U
|
||||||
|
#define IDIERSLV_OVERHEAT 54U
|
||||||
|
#define IDIERSLV_INP_VOLTAGE 55U
|
||||||
|
#define IDIERSLV_BRIDGE_OVERFLOW 56U
|
||||||
|
#define IDIERSLV_BRIDGE_NOT_CONF 57U
|
||||||
|
#define IDIERSLV_VERIF_DATE 58U
|
||||||
|
#define IDIERSLV_RTC 59U
|
||||||
|
#define IDIERSLV_LONG_OP_IN_PROC 60U
|
||||||
|
#define IDIERSLV_RESERVED_61 61U
|
||||||
|
#define IDIERSLV_RESERVED_62 62U
|
||||||
|
#define IDIERSLV_RESERVED_63 63U
|
||||||
|
#define IDIERSLV_RESERVED_64 64U
|
||||||
|
#define IDIERSLV_RESERVED_65 65U
|
||||||
|
#define IDIERSLV_RESERVED_66 66U
|
||||||
|
#define IDIERSLV_EXTRA_67 67U
|
||||||
|
#define IDIERSLV_EXTRA_68 68U
|
||||||
|
#define IDIERSLV_EXTRA_69 69U
|
||||||
|
#define IDIERSLV_EXTRA_70 70U
|
||||||
|
#define IDIERSLV_EXTRA_71 71U
|
||||||
|
#define IDIERDEV_INVALID_DEV_NUM 72U
|
||||||
|
#define IDIERDEV_INVALID_CHN_NUM 73U
|
||||||
|
#define IDIERDEV_INVALID_FUNC_NUM 74U
|
||||||
|
#define IDIERDEV_LONG_OP_IN_PROC 75U
|
||||||
|
#define IDIERDEV_RESERVED_76 76U
|
||||||
|
#define IDIERDEV_PARAM_LOW_ST_TIMEOUT 77U
|
||||||
|
#define IDIERDEV_PARAM_HIGH_ST_TIMEOUT 78U
|
||||||
|
#define IDIERDEV_PARAM_NOT_CHANGE_TIMEOUT 79U
|
||||||
|
#define IDIERDEV_RESERVED_80 80U
|
||||||
|
#define IDIERDEV_RESERVED_81 81U
|
||||||
|
#define IDIERDEV_RESERVED_82 82U
|
||||||
|
#define IDIERDEV_RESERVED_83 83U
|
||||||
|
#define IDIERDEV_RESERVED_84 84U
|
||||||
|
#define IDIERDEV_RESERVED_85 85U
|
||||||
|
#define IDIERDEV_RESERVED_86 86U
|
||||||
|
#define IDIERDEV_RESERVED_87 87U
|
||||||
|
#define IDIERDEV_RESERVED_88 88U
|
||||||
|
#define IDIERDEV_RESERVED_89 89U
|
||||||
|
|
||||||
|
#define IDIER_MULTIPLE_CRC_AVRBUF_SIZE 16U
|
||||||
|
#define IDIER_MULTIPLE_CRC_AVRBUF_THR 5U
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
#define IDIDATE_FORMAT_DAY_Pos 0U
|
||||||
|
#define IDIDATE_FORMAT_MONTH_Pos 1U
|
||||||
|
#define IDIDATE_FORMAT_CENTURY_Pos 2U
|
||||||
|
#define IDIDATE_FORMAT_YEAR99_Pos 3U
|
||||||
|
#define IDIDATE_FORMAT_LENGTH 4U
|
||||||
|
|
||||||
|
#define IDITIME_FORMAT_SECONDS_Pos 0U
|
||||||
|
#define IDITIME_FORMAT_MINUTES_Pos 1U
|
||||||
|
#define IDITIME_FORMAT_HOURS_Pos 2U
|
||||||
|
#define IDITIME_FORMAT_TIMEZONE_Pos 3U
|
||||||
|
#define IDITIME_FORMAT_LENGTH 4U
|
||||||
|
|
||||||
|
#define IDITIME_FORMAT_TIMEZONE_MIN (-12)
|
||||||
|
#define IDITIME_FORMAT_TIMEZONE_MAX 14
|
||||||
|
|
||||||
|
#define IDIMMES_C_DATETIME_TIME_Pos 0
|
||||||
|
#define IDIMMES_C_DATETIME_DATE_Pos (IDIMMES_C_DATETIME_TIME_Pos + IDIDATE_FORMAT_LENGTH)
|
||||||
|
#define IDIMMES_C_DATETIME_LENGTH (IDIDATE_FORMAT_LENGTH + IDITIME_FORMAT_LENGTH)
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
typedef struct {
|
||||||
|
struct {
|
||||||
|
uint8_t StError : 1;
|
||||||
|
uint8_t StState : 3;
|
||||||
|
uint8_t AesSupported : 1;
|
||||||
|
uint8_t AesInstalled : 1;
|
||||||
|
uint8_t SendAlarmL0 : 1;
|
||||||
|
uint8_t SendAlarmL1 : 1;
|
||||||
|
} B0S;
|
||||||
|
struct {
|
||||||
|
uint8_t ModuleType : 2;
|
||||||
|
uint8_t BridgeConnected : 1;
|
||||||
|
uint8_t SelfInit : 1;
|
||||||
|
uint8_t TimeoutLed : 1;
|
||||||
|
uint8_t NoMMESTimeout : 1;
|
||||||
|
uint8_t CatchAlarmL0 : 1;
|
||||||
|
uint8_t CatchAlarmL1 : 1;
|
||||||
|
} B1S;
|
||||||
|
} IDISTATUS_STATE_TYPE;
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
typedef struct {
|
||||||
|
IDISTATUS_STATE_TYPE STATE;
|
||||||
|
#ifdef __ATmega2560__
|
||||||
|
volatile uint_farptr_t SNfix;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __ATmega1280__
|
||||||
|
volatile uint_farptr_t SNfix;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __ATmega328PB__
|
||||||
|
const volatile uint8_t *SNfix;
|
||||||
|
#endif
|
||||||
|
const uint8_t *SNvar;
|
||||||
|
//uint8_t SN[IDISN_FULL_LENGTH];
|
||||||
|
} IDISTATUS_SLAVE_TYPE;
|
||||||
|
|
||||||
|
enum IDIBUS_MODULE_LONGOP_TYPES {
|
||||||
|
IDIBUS_LONGOP_NOPE = 0,
|
||||||
|
IDIBUS_LONGOP_VARSN_IP_WRITE,
|
||||||
|
IDIBUS_LONGOP_VARSN_VERIF_EXP_WRITE,
|
||||||
|
IDIBUS_LONGOP_VARSN_AES_WRITE,
|
||||||
|
IDIBUS_LONGOP_FMW_WRITE,
|
||||||
|
IDIBUS_LONGOP_INIT
|
||||||
|
};
|
||||||
|
typedef struct {
|
||||||
|
void (*SetNewBaudrate)(uint32_t);
|
||||||
|
void (*SendByteBuf)(uint8_t*, uint16_t);
|
||||||
|
void (*SendTxBuf)(uint16_t);
|
||||||
|
uint8_t (*IsNewRxMessage)(void);
|
||||||
|
uint8_t (*IsTxActive)(void);
|
||||||
|
uint8_t (*IsRxError)(void);
|
||||||
|
uint16_t (*getRxBufSize)(void);
|
||||||
|
void (*copyRxBuf)(uint8_t*, uint16_t, uint16_t);
|
||||||
|
uint8_t* (*getRxBuf)(void);
|
||||||
|
uint8_t* (*getTxBuf)(void);
|
||||||
|
void (*RxTransferRestart)(void);
|
||||||
|
} USART_INTERFACE_TYPE;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t ComFunc; //Êîìàíäà îòïðàâëåííàÿ ìàñòåðîì. Âûáèðàåòñÿ ïîëüçîâàòåì
|
||||||
|
uint8_t *InpData; //Óêàçàòåëü íà ïåðâûé áàéò ñîîáùåíèÿ
|
||||||
|
uint16_t InpDataLength; //Äëèíà ñîîáùåíèÿ, ïðèøåäåãî ñ êîìàíäîé
|
||||||
|
uint8_t *OutData;
|
||||||
|
uint16_t OutDataPos;
|
||||||
|
uint16_t OutDataLength;
|
||||||
|
uint16_t ErrorPos;
|
||||||
|
uint8_t ErrorState;
|
||||||
|
uint8_t OutLongMesState;
|
||||||
|
uint8_t LongOpState;
|
||||||
|
} idibus_farg_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct IDIBUS_CHANNEL_STR {
|
||||||
|
uint8_t BcastAddr;
|
||||||
|
uint8_t ChNum;
|
||||||
|
struct {
|
||||||
|
uint8_t Type;
|
||||||
|
uint8_t State;
|
||||||
|
uint32_t StartTimeInstanceMS;
|
||||||
|
uint32_t DurationMS;
|
||||||
|
} LONG_OP;
|
||||||
|
void (*CH_Func)(struct IDIBUS_CHANNEL_STR*, idibus_farg_t*);
|
||||||
|
} idibus_channel_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
idibus_channel_t *Channels;
|
||||||
|
uint8_t ChannelsCount;
|
||||||
|
} idibus_device_t;
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
typedef struct {
|
||||||
|
USART_INTERFACE_TYPE *USI;
|
||||||
|
idibus_device_t *Devices;
|
||||||
|
uint8_t DevicesCount;
|
||||||
|
IDISTATUS_SLAVE_TYPE STATUS;
|
||||||
|
uint8_t FreezeMemState;
|
||||||
|
uint8_t Error;
|
||||||
|
uint8_t c_InitAssignGroup;
|
||||||
|
struct {
|
||||||
|
uint8_t Type;
|
||||||
|
uint8_t Switch;
|
||||||
|
uint8_t State;
|
||||||
|
uint32_t StartTimeInstanceMS;
|
||||||
|
uint32_t DurationMS;
|
||||||
|
} LONG_OP;
|
||||||
|
} idibus_slave_module_t;
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#endif //_INC_IDIBUS_DEFS_H_
|
||||||
|
//#############################################################################################################################################################################################################
|
||||||
@ -0,0 +1,779 @@
|
|||||||
|
//#############################################################################################################################################################################################################
|
||||||
|
#include "IDIBUS_IMPL.h"
|
||||||
|
#include "EEMEM.h"
|
||||||
|
#include "SYSTEM.h"
|
||||||
|
#include "MEMORY.h"
|
||||||
|
#include "RSLink.h"
|
||||||
|
#include "USART1.h"
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
// At the request of the customer
|
||||||
|
volatile char IDUBUS_SPEC_FRAZE_RU[] = "ÍÅËÅÇÒÜ !!!";
|
||||||
|
volatile char IDUBUS_SPEC_FRAZE_EN[] = "HANDS OFF !!!";
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
static idibus_func_t custom_init = NULL;
|
||||||
|
static idibus_func_t custom_shutdown = NULL;
|
||||||
|
static idibus_func_t custom_freeze = NULL;
|
||||||
|
static idibus_func_t custom_resume = NULL;
|
||||||
|
|
||||||
|
static idibus_slave_module_t* IDIBUS_MODULE;
|
||||||
|
//Device description
|
||||||
|
|
||||||
|
void IdiBus_pass_module(idibus_slave_module_t* MODULE)
|
||||||
|
{
|
||||||
|
IDIBUS_MODULE = MODULE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void IdiBus_register_init(idibus_func_t callback)
|
||||||
|
{
|
||||||
|
custom_init = callback;
|
||||||
|
}
|
||||||
|
void IdiBus_register_shutdown(idibus_func_t callback)
|
||||||
|
{
|
||||||
|
custom_shutdown = callback;
|
||||||
|
}
|
||||||
|
void IdiBus_register_freeze(idibus_func_t callback)
|
||||||
|
{
|
||||||
|
custom_freeze = callback;
|
||||||
|
}
|
||||||
|
void IdiBus_register_resume(idibus_func_t callback)
|
||||||
|
{
|
||||||
|
custom_resume = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// EEPROM_Fast.h BLOCK
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint16_t EEPROM_ADDR;
|
||||||
|
uint8_t EEPROM_BUF[EEPROM_BUF_SIZE];
|
||||||
|
uint8_t EEPROM_BUF_COUNT;
|
||||||
|
|
||||||
|
ISR(EE_READY_vect)
|
||||||
|
{
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (EEPROM_BUF_COUNT == 0)
|
||||||
|
{
|
||||||
|
IDIBUS_MODULE->LONG_OP.State = IDILONGOP_STATE_COMPLETE_NO_ERR; //isThisSafe???!!!
|
||||||
|
IDIBUS_MODULE->LONG_OP.Switch = 0;
|
||||||
|
IDIBUS_MODULE->LONG_OP.Type = IDIBUS_LONGOP_NOPE;
|
||||||
|
EECR &= ~(1<<EERIE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EEAR = EEPROM_ADDR+EEPROM_BUF_COUNT-1;
|
||||||
|
EECR |= (1<<EERE);
|
||||||
|
uint8_t EEDRold = EEDR;
|
||||||
|
|
||||||
|
if (EEDRold == EEPROM_BUF[EEPROM_BUF_COUNT-1])
|
||||||
|
EEPROM_BUF_COUNT--;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
EEDR = EEPROM_BUF[EEPROM_BUF_COUNT-1];
|
||||||
|
EEPROM_BUF_COUNT--;
|
||||||
|
EECR |= (1<<EEMPE);
|
||||||
|
EECR |= (1<<EEPE);
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void EEPROM_WriteEepBuf(uint8_t count,uint16_t addr)
|
||||||
|
{
|
||||||
|
if (count > EEPROM_BUF_SIZE || count == 0)
|
||||||
|
{
|
||||||
|
IDIBUS_MODULE->LONG_OP.State = IDILONGOP_STATE_COMPLETE_WITH_ERR; //isThisSafe???!!!
|
||||||
|
IDIBUS_MODULE->LONG_OP.Switch = 0;
|
||||||
|
IDIBUS_MODULE->LONG_OP.Type = IDIBUS_LONGOP_NOPE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
EEPROM_BUF_COUNT = count;
|
||||||
|
EEPROM_ADDR = addr;
|
||||||
|
IDIBUS_MODULE->LONG_OP.Switch = 1;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (EEPROM_BUF_COUNT == 0)
|
||||||
|
{
|
||||||
|
IDIBUS_MODULE->LONG_OP.State = IDILONGOP_STATE_COMPLETE_NO_ERR; //isThisSafe???!!!
|
||||||
|
IDIBUS_MODULE->LONG_OP.Switch = 0;
|
||||||
|
IDIBUS_MODULE->LONG_OP.Type = IDIBUS_LONGOP_NOPE;
|
||||||
|
EECR &= ~(1<<EERIE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EEAR = EEPROM_ADDR+EEPROM_BUF_COUNT-1;
|
||||||
|
|
||||||
|
while(EECR&(1<<EEPE)); //Wait if we somehow doing write
|
||||||
|
EECR |= (1<<EERE);
|
||||||
|
uint8_t EEDRold = EEDR;
|
||||||
|
|
||||||
|
if (EEDRold == EEPROM_BUF[EEPROM_BUF_COUNT-1])
|
||||||
|
EEPROM_BUF_COUNT--;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cli();
|
||||||
|
EEDR = EEPROM_BUF[EEPROM_BUF_COUNT-1];
|
||||||
|
EEPROM_BUF_COUNT--;
|
||||||
|
EECR |= (1<<EERIE);
|
||||||
|
EECR |= (1<<EEMPE);
|
||||||
|
EECR |= (1<<EEPE);
|
||||||
|
sei();
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _LONG_ADDR_SPACE_
|
||||||
|
void IdiBus_ModuleInit(USART_INTERFACE_TYPE *USART_INTERFACE, uint_farptr_t PROGMEM_SN)
|
||||||
|
#else
|
||||||
|
void IdiBus_ModuleInit(USART_INTERFACE_TYPE *USART_INTERFACE, const volatile uint8_t *PROGMEM_SN)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if (IDUBUS_SPEC_FRAZE_RU[0]) {}
|
||||||
|
if (IDUBUS_SPEC_FRAZE_EN[0]) {}
|
||||||
|
|
||||||
|
IDIBUS_MODULE->USI = USART_INTERFACE;
|
||||||
|
IDIBUS_MODULE->FreezeMemState = IDISTATUS_B0S_ST_STATE_StOperate;
|
||||||
|
IDIBUS_MODULE->LONG_OP.Type = IDIBUS_LONGOP_NOPE;
|
||||||
|
IDIBUS_MODULE->LONG_OP.Switch = 0;
|
||||||
|
IDIBUS_MODULE->LONG_OP.State = IDILONGOP_STATE_COMPLETE_NO_ERR;
|
||||||
|
IDIBUS_MODULE->Error = IDIER_NOPE;
|
||||||
|
IDIBUS_MODULE->c_InitAssignGroup = IDIBUS_GROUP_0_ADDR;
|
||||||
|
|
||||||
|
// SN read ------------------------------------------------------------------------------------------------------>
|
||||||
|
IDIBUS_MODULE->STATUS.SNfix = PROGMEM_SN;
|
||||||
|
IDIBUS_MODULE->STATUS.SNvar = EEBLOCK.EEPROM_SN;
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint8_t InitAssignGroup = eeprom_read_byte(&EEBLOCK.EEPROM_IDIBUS_InitGroup);
|
||||||
|
|
||||||
|
if ( (InitAssignGroup > IDIBUS_GROUP_0_ADDR ) && (InitAssignGroup <= IDIBUS_GROUP_15_ADDR) )
|
||||||
|
{
|
||||||
|
for (uint8_t Dev = 0; Dev < IDIBUS_MODULE->DevicesCount; Dev++)
|
||||||
|
{
|
||||||
|
for (uint8_t Ch = 0; Ch<IDIBUS_MODULE->Devices[Dev].ChannelsCount; Ch++)
|
||||||
|
{
|
||||||
|
IDIBUS_MODULE->Devices[Dev].Channels[Ch].BcastAddr = InitAssignGroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
eeprom_write_byte(&EEBLOCK.EEPROM_IDIBUS_InitGroup, 0xFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
void IDIBUS_ModuleBackgroundHandler(void)
|
||||||
|
{
|
||||||
|
// Long Operation Routine ------------------------>
|
||||||
|
switch ( IDIBUS_MODULE->LONG_OP.Type )
|
||||||
|
{
|
||||||
|
case (IDIBUS_LONGOP_VARSN_IP_WRITE) :
|
||||||
|
{
|
||||||
|
if (IDIBUS_MODULE->LONG_OP.Switch == 0)
|
||||||
|
{
|
||||||
|
EEPROM_WriteEepBuf(IDISN_VARP_IPv4_Length+IDISN_VARP_IPv6_Length,EEBLOCK.EEPROM_SN[IDISN_VARP_IPv4_Pos]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case (IDIBUS_LONGOP_VARSN_VERIF_EXP_WRITE) :
|
||||||
|
{
|
||||||
|
if (IDIBUS_MODULE->LONG_OP.Switch == 0)
|
||||||
|
{
|
||||||
|
EEPROM_WriteEepBuf(IDISN_VARP_EXPIR_DATE_Length+IDISN_VARP_VERIF_DATE_Length,(int)&EEBLOCK.EEPROM_SN[IDISN_VARP_VERIF_DATE_Pos]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case (IDIBUS_LONGOP_VARSN_AES_WRITE) :
|
||||||
|
{
|
||||||
|
if (IDIBUS_MODULE->LONG_OP.Switch == 0)
|
||||||
|
{
|
||||||
|
EEPROM_WriteEepBuf(IDISN_VARP_AES256_Length,(int)&EEBLOCK.EEPROM_SN[IDISN_VARP_AES256_Pos]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case (IDIBUS_LONGOP_INIT) :
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( IDIBUS_MODULE->c_InitAssignGroup != IDIBUS_GROUP_0_ADDR )
|
||||||
|
eeprom_write_byte(&EEBLOCK.EEPROM_IDIBUS_InitGroup,IDIBUS_MODULE->c_InitAssignGroup);
|
||||||
|
|
||||||
|
uint8_t TimeoutMS = 200;
|
||||||
|
while ( (!eeprom_is_ready() || IDIBUS_MODULE->USI->IsTxActive()) && (TimeoutMS != 0) )
|
||||||
|
{
|
||||||
|
TimeoutMS--;
|
||||||
|
_delay_ms(1);
|
||||||
|
}
|
||||||
|
System_SWReboot();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default :
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error Handler Routine ------------------------>
|
||||||
|
if ( IDIBUS_MODULE->LONG_OP.State == IDILONGOP_STATE_IN_PROC )
|
||||||
|
{
|
||||||
|
if ( System_GetSysTickDifference(IDIBUS_MODULE->LONG_OP.StartTimeInstanceMS) > IDIBUS_MODULE->LONG_OP.DurationMS )
|
||||||
|
{
|
||||||
|
// Long Operation terminate function
|
||||||
|
IDIBUS_MODULE->LONG_OP.State = IDILONGOP_STATE_COMPLETE_WITH_ERR;
|
||||||
|
IDIBUS_MODULE->LONG_OP.Type = IDIBUS_LONGOP_NOPE;
|
||||||
|
IDIBUS_MODULE->LONG_OP.Switch = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
void IDIBUS_ModuleCommandHandler(idibus_farg_t *farg)
|
||||||
|
{
|
||||||
|
// If there is special command we don't care about any error in this place
|
||||||
|
if ( (farg->ComFunc != IDIMMES_COM_C_Init) && (farg->ComFunc != IDIMMES_COM_C_ShtDown) && (farg->ComFunc != IDIMMES_COM_C_SetAlarmL) )
|
||||||
|
{
|
||||||
|
// IF we somehow managed to come to the freeze state, we need to exit from freeze state
|
||||||
|
if ( IDIBUS_MODULE->STATUS.STATE.B0S.StState == IDISTATUS_B0S_ST_STATE_StFreeze )
|
||||||
|
{
|
||||||
|
if ( farg->ComFunc != IDIMMES_COM_C_Resume )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_IN_FREEZE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} // If not special command or freeze but long Operation and command not DummyModule
|
||||||
|
else if ( IDIBUS_MODULE->Error != IDIER_NOPE )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIBUS_MODULE->Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if ( IDIBUS_MODULE->LONG_OP.State == IDILONGOP_STATE_IN_PROC )
|
||||||
|
{
|
||||||
|
if ( farg->ComFunc != IDIMMES_COM_C_CheckModuleLongOp )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_LONG_OP_IN_PROC);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// There is no prohibited command if this place - just handle it
|
||||||
|
switch ( farg->ComFunc )
|
||||||
|
{
|
||||||
|
case (IDIMMES_COM_C_DummyModule) :
|
||||||
|
{
|
||||||
|
if ( farg->InpDataLength != 0 )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIER_NOPE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ( IDIMMES_COM_C_Init ) :
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( farg->InpDataLength > 1 )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
else if ( (farg->InpDataLength == 1) && (farg->InpData[0] > IDIBUS_GROUP_LAST_NUMBER) )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_PARAM);
|
||||||
|
}
|
||||||
|
//Some custom error???!!
|
||||||
|
//else if ( 0 /* CTRL_SelectedMode == _CTRL_MODE_MANUAL_ */ ) { IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIBUS_CUSTDEF_ERCODE_NO_ACCESS); }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Execute custom init
|
||||||
|
if (custom_init!=NULL) custom_init();
|
||||||
|
|
||||||
|
if ( farg->InpDataLength == 1 )
|
||||||
|
{
|
||||||
|
|
||||||
|
IDIBUS_MODULE->c_InitAssignGroup = (uint8_t)( farg->InpData[0] + IDIBUS_GROUP_0_ADDR );
|
||||||
|
}
|
||||||
|
//IDIBUS_MODULE->LONG_OP.Type = IDIBUS_LONGOP_INIT;
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIER_NOPE);
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ( IDIMMES_COM_C_ShtDown ) :
|
||||||
|
{
|
||||||
|
if ( farg->InpDataLength != 0 )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
//Some custom error???!!
|
||||||
|
//else if ( 0 /* CTRL_SelectedMode == _CTRL_MODE_MANUAL_ */ ) { IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIBUS_CUSTDEF_ERCODE_NO_ACCESS); }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (custom_shutdown!=NULL) custom_shutdown();
|
||||||
|
IDIBUS_MODULE->STATUS.STATE.B0S.StState = IDISTATUS_B0S_ST_STATE_StNoInit;
|
||||||
|
IDIBUS_MODULE->Error = IDIERSLV_NO_INIT;
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIER_NOPE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case (IDIMMES_COM_C_Freeze) :
|
||||||
|
{
|
||||||
|
if ( farg->InpDataLength != 0 )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (custom_freeze!= NULL) custom_freeze();
|
||||||
|
IDIBUS_MODULE->FreezeMemState = IDIBUS_MODULE->STATUS.STATE.B0S.StState;
|
||||||
|
IDIBUS_MODULE->STATUS.STATE.B0S.StState = IDISTATUS_B0S_ST_STATE_StFreeze;
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIER_NOPE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case (IDIMMES_COM_C_Resume) :
|
||||||
|
{
|
||||||
|
if ( farg->InpDataLength != 0 )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(custom_resume!=NULL) custom_resume();
|
||||||
|
IDIBUS_MODULE->STATUS.STATE.B0S.StState = (uint8_t)(IDIBUS_MODULE->FreezeMemState & 0x07U);
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIBUS_MODULE->Error);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case (IDIMMES_COM_C_ReadDevFullSN_MS) :
|
||||||
|
{
|
||||||
|
if ( farg->InpDataLength != 0 )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FLASH_DATABLOCK dataApp;
|
||||||
|
readDeviceData(&dataApp, locationInApp);
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, (uint8_t*)&dataApp,sizeof(dataApp),IDIER_NOPE);
|
||||||
|
/*
|
||||||
|
uint8_t ResponseLength = IDISN_FULL_LENGTH - IDISN_VARP_AES256_Length + 2;
|
||||||
|
uint8_t Response[ResponseLength];
|
||||||
|
Response[IDISTATUS_B0S_Pos] = (uint8_t) (
|
||||||
|
((uint8_t)IDIBUS_MODULE->STATUS.STATE.B0S.StError << IDISTATUS_B0S_ST_ERROR_Pos) |
|
||||||
|
((uint8_t)IDIBUS_MODULE->STATUS.STATE.B0S.StState << IDISTATUS_B0S_ST_STATE_Pos) |
|
||||||
|
((uint8_t)IDIBUS_MODULE->STATUS.STATE.B0S.AesSupported << IDISTATUS_B0S_AES_SUPPORTED_Pos) |
|
||||||
|
((uint8_t)IDIBUS_MODULE->STATUS.STATE.B0S.AesInstalled << IDISTATUS_B0S_AES_INSTALLED_Pos) |
|
||||||
|
((uint8_t)IDIBUS_MODULE->STATUS.STATE.B0S.SendAlarmL0 << IDISTATUS_B0S_SEND_ALARM_L0_Pos) |
|
||||||
|
((uint8_t)IDIBUS_MODULE->STATUS.STATE.B0S.SendAlarmL1 << IDISTATUS_B0S_SEND_ALARM_L1_Pos) |
|
||||||
|
((uint8_t)IDIBUS_MODULE->STATUS.STATE.B0S.StState << IDISTATUS_B0S_ST_STATE_Pos) );
|
||||||
|
Response[IDISTATUS_B1S_Pos] = (uint8_t) (
|
||||||
|
((uint8_t)IDIBUS_MODULE->STATUS.STATE.B1S.ModuleType << IDISTATUS_B1S_MODULE_TYPE_Pos) |
|
||||||
|
((uint8_t)IDIBUS_MODULE->STATUS.STATE.B1S.BridgeConnected << IDISTATUS_B1S_BRIDGE_CONNECTED_Pos ) |
|
||||||
|
((uint8_t)IDIBUS_MODULE->STATUS.STATE.B1S.SelfInit << IDISTATUS_B1S_SELF_INIT_Pos ) |
|
||||||
|
((uint8_t)IDIBUS_MODULE->STATUS.STATE.B1S.TimeoutLed << IDISTATUS_B1S_TIMEOUT_LED_Pos ) |
|
||||||
|
((uint8_t)IDIBUS_MODULE->STATUS.STATE.B1S.NoMMESTimeout << IDISTATUS_B1S_NO_MMES_TIMEOUT_Pos ) |
|
||||||
|
((uint8_t)IDIBUS_MODULE->STATUS.STATE.B1S.CatchAlarmL0 << IDISTATUS_B1S_CATCH_ALARM_L0_Pos ) |
|
||||||
|
((uint8_t)IDIBUS_MODULE->STATUS.STATE.B1S.CatchAlarmL1 << IDISTATUS_B1S_CATCH_ALARM_L1_Pos ) );
|
||||||
|
for (uint8_t pos=0; pos < IDISN_FIXP_LENGTH; pos++)
|
||||||
|
{
|
||||||
|
Response[IDISTATUS_SN_Pos+pos] = flash_read_byte((uint_farptr_t)IDIBUS_MODULE->STATUS.SNfix,IDISN_FIXP_Pos+pos);
|
||||||
|
}
|
||||||
|
for (uint8_t pos=0; pos < IDISN_VARP_LENGTH-IDISN_VARP_AES256_Length; pos++)
|
||||||
|
{
|
||||||
|
Response[IDISTATUS_SN_Pos+IDISN_FIXP_LENGTH+pos] = eeprom_read_byte(&IDIBUS_MODULE->STATUS.SNvar[pos]);
|
||||||
|
}
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, Response, ResponseLength, IDIER_NOPE);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case (IDIMMES_COM_C_CheckModuleLongOp) :
|
||||||
|
{
|
||||||
|
if ( farg->InpDataLength != 0 )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint8_t Response[IDILONGOP_MES_DATA_LENGTH];
|
||||||
|
Response[IDILONGOP_STATE_Pos] = IDIBUS_MODULE->LONG_OP.State;
|
||||||
|
uint32_t Countdown;
|
||||||
|
if ( IDIBUS_MODULE->LONG_OP.State == IDILONGOP_STATE_IN_PROC )
|
||||||
|
{
|
||||||
|
uint32_t TimeFromStart = System_GetSysTickDifference(IDIBUS_MODULE->LONG_OP.StartTimeInstanceMS);
|
||||||
|
if ( IDIBUS_MODULE->LONG_OP.DurationMS > TimeFromStart )
|
||||||
|
{
|
||||||
|
Countdown = IDIBUS_MODULE->LONG_OP.DurationMS - TimeFromStart;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Countdown = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Countdown = 0;
|
||||||
|
}
|
||||||
|
Response[IDILONGOP_REMAIN_TIME_Pos] = (uint8_t)(Countdown >> 24);
|
||||||
|
Response[IDILONGOP_REMAIN_TIME_Pos + 1] = (uint8_t)(Countdown >> 16);
|
||||||
|
Response[IDILONGOP_REMAIN_TIME_Pos + 2] = (uint8_t)(Countdown >> 8);
|
||||||
|
Response[IDILONGOP_REMAIN_TIME_Pos + 3] = (uint8_t)(Countdown);
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, Response, IDILONGOP_MES_DATA_LENGTH, IDIER_NOPE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case (IDIMMES_COM_C_SendTimeDate) :
|
||||||
|
{
|
||||||
|
if ( farg->InpDataLength != IDIMMES_C_DATETIME_LENGTH )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
( farg->InpData[IDIMMES_C_DATETIME_TIME_Pos + IDITIME_FORMAT_SECONDS_Pos] > 60U ) ||
|
||||||
|
( farg->InpData[IDIMMES_C_DATETIME_TIME_Pos + IDITIME_FORMAT_MINUTES_Pos] > 60U ) ||
|
||||||
|
( farg->InpData[IDIMMES_C_DATETIME_TIME_Pos + IDITIME_FORMAT_HOURS_Pos] > 23U ) ||
|
||||||
|
( (int8_t)farg->InpData[IDIMMES_C_DATETIME_TIME_Pos + IDITIME_FORMAT_TIMEZONE_Pos] > IDITIME_FORMAT_TIMEZONE_MAX ) ||
|
||||||
|
( (int8_t)farg->InpData[IDIMMES_C_DATETIME_TIME_Pos + IDITIME_FORMAT_TIMEZONE_Pos] < IDITIME_FORMAT_TIMEZONE_MIN ) ||
|
||||||
|
( farg->InpData[IDIMMES_C_DATETIME_DATE_Pos + IDIDATE_FORMAT_DAY_Pos] > 31 ) ||
|
||||||
|
( farg->InpData[IDIMMES_C_DATETIME_DATE_Pos + IDIDATE_FORMAT_DAY_Pos] == 0 ) ||
|
||||||
|
( farg->InpData[IDIMMES_C_DATETIME_DATE_Pos + IDIDATE_FORMAT_MONTH_Pos] > 31 ) ||
|
||||||
|
( farg->InpData[IDIMMES_C_DATETIME_DATE_Pos + IDIDATE_FORMAT_MONTH_Pos] == 0 ) ||
|
||||||
|
( farg->InpData[IDIMMES_C_DATETIME_DATE_Pos + IDIDATE_FORMAT_CENTURY_Pos] > 99 ) ||
|
||||||
|
( farg->InpData[IDIMMES_C_DATETIME_DATE_Pos + IDIDATE_FORMAT_YEAR99_Pos] > 99 )
|
||||||
|
)
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_PARAM);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIER_NOPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// LONG OPERATION FUNCS -------------------------------------------------------------->
|
||||||
|
case (IDIMMES_COM_C_WriteSnIPv4IPv6) :
|
||||||
|
{
|
||||||
|
if ( farg->InpDataLength != (IDISN_VARP_IPv4_Length + IDISN_VARP_IPv6_Length) )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memcpy(&EEPROM_BUF, farg->InpData, farg->InpDataLength);
|
||||||
|
IDIBUS_MODULE->LONG_OP.Type = IDIBUS_LONGOP_VARSN_IP_WRITE;
|
||||||
|
IDIBUS_MODULE->LONG_OP.Switch = 0;
|
||||||
|
IDIBUS_MODULE->LONG_OP.State = IDILONGOP_STATE_IN_PROC;
|
||||||
|
IDIBUS_MODULE->LONG_OP.StartTimeInstanceMS = System_GetTimeInstance();
|
||||||
|
IDIBUS_MODULE->LONG_OP.DurationMS = IDIBUS_LONGOP_VARSN_IP_WRITE_DURATION_MS;
|
||||||
|
farg->LongOpState = 1;
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIER_NOPE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case (IDIMMES_COM_C_WriteSnVerifyDates) :
|
||||||
|
{
|
||||||
|
if ( farg->InpDataLength != (IDIDATE_FORMAT_LENGTH * 2) )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
(farg->InpData[IDIDATE_FORMAT_DAY_Pos] == 0)||(farg->InpData[IDIDATE_FORMAT_DAY_Pos] > 31) ||
|
||||||
|
(farg->InpData[IDIDATE_FORMAT_MONTH_Pos] == 0 )||(farg->InpData[IDIDATE_FORMAT_MONTH_Pos] > 12) ||
|
||||||
|
(farg->InpData[IDIDATE_FORMAT_CENTURY_Pos] > 99 ) ||
|
||||||
|
(farg->InpData[IDIDATE_FORMAT_YEAR99_Pos] > 99) ||
|
||||||
|
(farg->InpData[IDIDATE_FORMAT_DAY_Pos+IDIDATE_FORMAT_LENGTH] == 0)||(farg->InpData[IDIDATE_FORMAT_DAY_Pos+IDIDATE_FORMAT_LENGTH] > 31) ||
|
||||||
|
(farg->InpData[IDIDATE_FORMAT_MONTH_Pos+IDIDATE_FORMAT_LENGTH] == 0 )||(farg->InpData[IDIDATE_FORMAT_MONTH_Pos+IDIDATE_FORMAT_LENGTH] > 12) ||
|
||||||
|
(farg->InpData[IDIDATE_FORMAT_CENTURY_Pos+IDIDATE_FORMAT_LENGTH] > 99 ) ||
|
||||||
|
(farg->InpData[IDIDATE_FORMAT_YEAR99_Pos+IDIDATE_FORMAT_LENGTH] > 99)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_PARAM);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//memcpy(&EEPROM_BUF, farg->InpData, (IDIDATE_FORMAT_LENGTH * 2));
|
||||||
|
memcpy(&EEPROM_BUF, farg->InpData, farg->InpDataLength);
|
||||||
|
IDIBUS_MODULE->LONG_OP.Type = IDIBUS_LONGOP_VARSN_VERIF_EXP_WRITE;
|
||||||
|
IDIBUS_MODULE->LONG_OP.Switch = 0;
|
||||||
|
IDIBUS_MODULE->LONG_OP.State = IDILONGOP_STATE_IN_PROC;
|
||||||
|
IDIBUS_MODULE->LONG_OP.StartTimeInstanceMS = System_GetTimeInstance();
|
||||||
|
IDIBUS_MODULE->LONG_OP.DurationMS = IDIBUS_LONGOP_VARSN_VERF_EXP_WRITE_DURATION_MS;
|
||||||
|
farg->LongOpState = 1;
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIER_NOPE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case (IDIMMES_COM_C_WriteSnAES256) :
|
||||||
|
{
|
||||||
|
if ( farg->InpDataLength != IDISN_VARP_AES256_Length )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//!!!memcpy(&IDIBUS_MODULE->STATUS.SN[IDISN_VARP_AES256_Pos], farg->InpData, farg->InpDataLength);
|
||||||
|
memcpy(&EEPROM_BUF, farg->InpData, farg->InpDataLength);
|
||||||
|
IDIBUS_MODULE->LONG_OP.Type = IDIBUS_LONGOP_VARSN_AES_WRITE;
|
||||||
|
IDIBUS_MODULE->LONG_OP.Switch = 0;
|
||||||
|
IDIBUS_MODULE->LONG_OP.State = IDILONGOP_STATE_IN_PROC;
|
||||||
|
IDIBUS_MODULE->LONG_OP.StartTimeInstanceMS = System_GetTimeInstance();
|
||||||
|
IDIBUS_MODULE->LONG_OP.DurationMS = IDIBUS_LONGOP_VARSN_AES_WRITE_DURATION_MS;
|
||||||
|
farg->LongOpState = 1;
|
||||||
|
IDIBUS_MODULE->STATUS.STATE.B0S.AesInstalled = 0;
|
||||||
|
for ( uint8_t I = 0; I < IDISN_VARP_AES256_Length; I++ )
|
||||||
|
{
|
||||||
|
if ( /*IDIBUS_MODULE->STATUS.SN[IDISN_VARP_AES256_Pos + I] != 0 */ 0 /* TODO */ )
|
||||||
|
{
|
||||||
|
IDIBUS_MODULE->STATUS.STATE.B0S.AesInstalled = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIER_NOPE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (IDIMMES_COM_C_EnterBootloader) :
|
||||||
|
{
|
||||||
|
const uint8_t packageSize = IDISN_FIXP_MODULE_TYPE_Length+IDISN_FIXP_HW_REV_Length+IDISN_FIXP_SERIAL_Length;
|
||||||
|
if ( farg->InpDataLength != packageSize)
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint8_t Check = 1;
|
||||||
|
/*
|
||||||
|
FLASH_DATABLOCK dataApp;
|
||||||
|
readDeviceData(&dataApp, locationInApp);
|
||||||
|
uint8_t* ptr = farg->InpData;
|
||||||
|
for (uint8_t i = 0;sizeof(dataApp.ModuleType);i++)
|
||||||
|
{
|
||||||
|
if(*ptr!=dataApp.ModuleType[i]) Check = 0;
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
for (uint8_t i = 0;sizeof(dataApp.HW_revision);i++)
|
||||||
|
{
|
||||||
|
if(*ptr!=dataApp.HW_revision[i]) Check = 0;
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
for (uint8_t i = 0;sizeof(dataApp.SN);i++)
|
||||||
|
{
|
||||||
|
if(*ptr!=dataApp.SN[i]) Check = 0;
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
PORTC = 0;
|
||||||
|
/*
|
||||||
|
for (uint8_t pos=0; pos < packageSize; pos++)
|
||||||
|
{
|
||||||
|
if (farg->InpData[pos] != flash_read_byte(IDIBUS_MODULE->STATUS.SNfix,IDISN_FIXP_MODULE_TYPE_Pos+pos))
|
||||||
|
Check = 0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (Check == 1)
|
||||||
|
{
|
||||||
|
//IDIBUS_MODULE->LONG_OP.Type = IDIBUS_LONGOP_INIT;
|
||||||
|
eeprom_busy_wait();
|
||||||
|
eeprom_write_byte(&EEBLOCK.BOOTFLAG, 0x21); //Magic BYTE???!?!??!
|
||||||
|
eeprom_busy_wait();
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIER_NOPE);
|
||||||
|
RSLink_SendSMES(farg);
|
||||||
|
while(IDIBUS_MODULE->USI->IsTxActive()) wdt_reset();
|
||||||
|
System_SWReboot();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg,NULL,0,IDIERSLV_INVALID_RX_PARAM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
default :
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_UNSUPPORTED_FUNC_NUM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void IDIBUS_ChannelBackgroundHandler (void)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Error Handler ------------------------>
|
||||||
|
for ( uint8_t Dev=0; Dev < IDIBUS_MODULE->DevicesCount; Dev++ )
|
||||||
|
{
|
||||||
|
for ( uint8_t Ch=0; Ch<IDIBUS_MODULE->Devices[Dev].ChannelsCount; Ch++ )
|
||||||
|
{
|
||||||
|
idibus_channel_t *CH = &IDIBUS_MODULE->Devices[Dev].Channels[Ch];
|
||||||
|
if ( CH->LONG_OP.State == IDILONGOP_STATE_IN_PROC )
|
||||||
|
{
|
||||||
|
if ( System_GetSysTickDifference(CH->LONG_OP.StartTimeInstanceMS) > CH->LONG_OP.DurationMS )
|
||||||
|
{
|
||||||
|
// Long Operation terminate function
|
||||||
|
CH->LONG_OP.State = IDILONGOP_STATE_COMPLETE_WITH_ERR;
|
||||||
|
CH->LONG_OP.Type = IDIBUS_LONGOP_NOPE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint8_t IDIBUS_CnannelStaticFunc(struct IDIBUS_CHANNEL_STR* CH, idibus_farg_t *farg)
|
||||||
|
{
|
||||||
|
if ( CH->LONG_OP.State == IDILONGOP_STATE_IN_PROC )
|
||||||
|
{
|
||||||
|
farg->LongOpState = 1;
|
||||||
|
if ( farg->ComFunc != IDIMMES_COM_C_CheckChannelLongOp )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERDEV_LONG_OP_IN_PROC);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( farg->ComFunc < IDIMMES_COM_START_NUM )
|
||||||
|
{
|
||||||
|
return 0; // If Not channel command
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (farg->ComFunc)
|
||||||
|
{
|
||||||
|
case (IDIMMES_COM_C_Dummy) :
|
||||||
|
{
|
||||||
|
if ( farg->InpDataLength != 0 )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIER_NOPE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case (IDIMMES_COM_C_AssignGroup) :
|
||||||
|
{
|
||||||
|
if ( (farg->InpDataLength != 1) || (farg->InpData[0] > IDIBUS_GROUP_LAST_NUMBER) )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CH->BcastAddr = (uint8_t)( farg->InpData[0] + IDIBUS_GROUP_0_ADDR );
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIER_NOPE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case (IDIMMES_COM_C_CheckChannelLongOp) :
|
||||||
|
{
|
||||||
|
if ( farg->InpDataLength != 0 )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint8_t Response[IDILONGOP_MES_DATA_LENGTH];
|
||||||
|
Response[IDILONGOP_STATE_Pos] = CH->LONG_OP.State;
|
||||||
|
uint32_t Countdown;
|
||||||
|
if ( CH->LONG_OP.State == IDILONGOP_STATE_IN_PROC )
|
||||||
|
{
|
||||||
|
uint32_t TimeFromStart = System_GetSysTickDifference( CH->LONG_OP.StartTimeInstanceMS );
|
||||||
|
if ( CH->LONG_OP.DurationMS > TimeFromStart )
|
||||||
|
{
|
||||||
|
Countdown = CH->LONG_OP.DurationMS - TimeFromStart;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Countdown = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Countdown = 0;
|
||||||
|
}
|
||||||
|
Response[IDILONGOP_REMAIN_TIME_Pos] = (uint8_t)(Countdown >> 24);
|
||||||
|
Response[IDILONGOP_REMAIN_TIME_Pos + 1] = (uint8_t)(Countdown >> 16);
|
||||||
|
Response[IDILONGOP_REMAIN_TIME_Pos + 2] = (uint8_t)(Countdown >> 8);
|
||||||
|
Response[IDILONGOP_REMAIN_TIME_Pos + 3] = (uint8_t)(Countdown);
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, Response, IDILONGOP_MES_DATA_LENGTH, IDIER_NOPE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default :
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_UNSUPPORTED_FUNC_NUM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
void IDIBUS_ResponseProtectedWrite(idibus_farg_t *farg, uint8_t *Data, uint16_t DataLength, uint8_t ErrorCode)
|
||||||
|
{
|
||||||
|
if (farg->OutData != NULL)
|
||||||
|
{
|
||||||
|
if ( ErrorCode != IDIER_NOPE )
|
||||||
|
{
|
||||||
|
IDIBUS_MODULE->STATUS.STATE.B0S.StError = 1;
|
||||||
|
farg->ErrorState = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IDIBUS_MODULE->STATUS.STATE.B0S.StError = 0;
|
||||||
|
}
|
||||||
|
farg->OutData[farg->ErrorPos] = ErrorCode;
|
||||||
|
farg->ErrorPos = (uint16_t)(farg->ErrorPos + 1);
|
||||||
|
farg->OutDataLength = (uint16_t)(farg->OutDataLength + 1);
|
||||||
|
|
||||||
|
if ( (DataLength != 0) && (Data != NULL) )
|
||||||
|
{
|
||||||
|
memcpy(&farg->OutData[farg->OutDataPos], Data, DataLength);
|
||||||
|
farg->OutDataPos = (uint16_t)( farg->OutDataPos + DataLength );
|
||||||
|
farg->OutDataLength = (uint16_t)(farg->OutDataLength + DataLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//=============================================================================================================================================================================================================
|
||||||
|
void IDIBUS_ServiceFunc (uint8_t *InpData, uint16_t InpDataLength, uint8_t *OutData, uint16_t *OutDataLength)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#############################################################################################################################################################################################################
|
||||||
@ -0,0 +1,85 @@
|
|||||||
|
//#############################################################################################################################################################################################################
|
||||||
|
#ifndef _INC_IDIBUS_IMPL_H_
|
||||||
|
#define _INC_IDIBUS_IMPL_H_
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
#ifndef F_CPU
|
||||||
|
#define F_CPU 16000000UL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
|
||||||
|
#include "../Required/USART_COM.h"
|
||||||
|
#include "../Required/SYSTEM.h"
|
||||||
|
|
||||||
|
#include "IDIBUS_DEFS.h"
|
||||||
|
#include "MODBUS_CRC.h"
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
#define IDIBUS_LONGOP_VARSN_IP_WRITE_DURATION_MS 200
|
||||||
|
#define IDIBUS_LONGOP_VARSN_VERF_EXP_WRITE_DURATION_MS 200
|
||||||
|
#define IDIBUS_LONGOP_VARSN_AES_WRITE_DURATION_MS 200
|
||||||
|
|
||||||
|
// EEPROM_FAST BLOCK
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#define EEPROM_BUF_SIZE 32
|
||||||
|
extern uint16_t EEPROM_ADDR;
|
||||||
|
extern uint8_t EEPROM_BUF[EEPROM_BUF_SIZE];
|
||||||
|
extern uint8_t EEPROM_BUF_COUNT;
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void EEPROM_WriteEepBuf(uint8_t count, uint16_t addr);
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#define IDIBUS_SYSTEM_SW_VERSION 0x3133U
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#ifdef _LONG_ADDR_SPACE_
|
||||||
|
void IdiBus_ModuleInit(USART_INTERFACE_TYPE *USART_INTERFACE, uint_farptr_t PROGMEM_SN);
|
||||||
|
#else
|
||||||
|
void IdiBus_ModuleInit(USART_INTERFACE_TYPE *USART_INTERFACE, const volatile uint8_t *PROGMEM_SN);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void IDIBUS_ModuleCommandHandler(idibus_farg_t *farg);
|
||||||
|
uint8_t IDIBUS_CnannelStaticFunc(struct IDIBUS_CHANNEL_STR* CH, idibus_farg_t *farg);
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void IDIBUS_ResponseProtectedWrite(idibus_farg_t *farg, uint8_t *Data, uint16_t DataLength, uint8_t ErrorCode);
|
||||||
|
void IDIBUS_ModuleBackgroundHandler(void);
|
||||||
|
void IDIBUS_ChannelBackgroundHandler(void);
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void IDIBUS_ServiceFunc(uint8_t *InpData, uint16_t InpDataLength, uint8_t *OutData, uint16_t *OutDataLength);
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void IdiBus_pass_module(idibus_slave_module_t* MODULE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Typedef for callback function
|
||||||
|
typedef void (*idibus_func_t)(void);
|
||||||
|
|
||||||
|
// Callback registration
|
||||||
|
void IdiBus_register_init(idibus_func_t callback);
|
||||||
|
void IdiBus_register_shutdown(idibus_func_t callback);
|
||||||
|
void IdiBus_register_freeze(idibus_func_t callback);
|
||||||
|
void IdiBus_register_resume(idibus_func_t callback);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#endif // #ifndef _INC_IDIBUS_IMPL_H_
|
||||||
|
//#############################################################################################################################################################################################################
|
||||||
|
|
||||||
@ -0,0 +1,504 @@
|
|||||||
|
//#############################################################################################################################################################################################################
|
||||||
|
#include "RSLink.h"
|
||||||
|
|
||||||
|
uint8_t mmes_buf[IDIMMES_MAX_MES_SIZE]; //RX buffer for copy
|
||||||
|
struct RSLINK_STRUCT RSLINK;
|
||||||
|
|
||||||
|
|
||||||
|
static rslink_func_pack_t rslink_hw =
|
||||||
|
{
|
||||||
|
.status_led_init = NULL,
|
||||||
|
.status_led_on = NULL,
|
||||||
|
.status_led_off = NULL,
|
||||||
|
.dips_init = NULL,
|
||||||
|
.disp_read_addr = NULL,
|
||||||
|
.disp_read_speed = NULL,
|
||||||
|
};
|
||||||
|
static idibus_slave_module_t* IDIBUS_MODULE;
|
||||||
|
//Device descriptor
|
||||||
|
|
||||||
|
void RSLlink_pass_module(idibus_slave_module_t* MODULE)
|
||||||
|
{
|
||||||
|
IDIBUS_MODULE = MODULE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RSLink_register_hw_functions(rslink_func_pack_t callback)
|
||||||
|
{
|
||||||
|
rslink_hw.dips_init = callback.dips_init;
|
||||||
|
rslink_hw.status_led_init = callback.status_led_init;
|
||||||
|
rslink_hw.status_led_on = callback.status_led_on;
|
||||||
|
rslink_hw.status_led_off = callback.status_led_off;
|
||||||
|
rslink_hw.disp_read_addr = callback.disp_read_addr;
|
||||||
|
rslink_hw.disp_read_speed = callback.disp_read_speed;
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void RSLink_Init(USART_INTERFACE_TYPE *USART_INTERFACE, USART_IDIBUS_ROUTINE_TYPE *USART_ID_INTERFACE)
|
||||||
|
{
|
||||||
|
RSLINK.USI=USART_INTERFACE; // USART POINTER INIT
|
||||||
|
RSLINK.USIID=USART_ID_INTERFACE;
|
||||||
|
RSLINK.NeedSpeedChangeFlag=0;
|
||||||
|
RSLINK.LastMMES_TimeInstance=System_GetTimeInstance();
|
||||||
|
rslink_hw.status_led_init(); // Init LEDs
|
||||||
|
rslink_hw.dips_init(); // Init DIP switches
|
||||||
|
RSLink_SpeedCheckAndUpdate(); // Set speed
|
||||||
|
RSLINK.USIID->SetIdiBusBoudrate(RSLINK.SpeedCode); // Set speed usart
|
||||||
|
RSLink_AddressCheckAndUpdate(); // Set adr
|
||||||
|
RSLINK.USI->RxTransferRestart(); // Restart RX
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint8_t RSLink_SpeedCheckAndUpdate(void)
|
||||||
|
{
|
||||||
|
uint8_t SpeedDSW_Code = rslink_hw.disp_read_speed();
|
||||||
|
if (RSLINK.SpeedCode != SpeedDSW_Code)
|
||||||
|
{
|
||||||
|
RSLINK.SpeedCode = SpeedDSW_Code;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void RSLink_AddressCheckAndUpdate(void)
|
||||||
|
{
|
||||||
|
RSLINK.Address = rslink_hw.disp_read_addr();
|
||||||
|
if ((RSLINK.Address>=IDIBUS_SLAVE_ADDR_MIN)&&(RSLINK.Address<=IDIBUS_SLAVE_ADDR_MAX))
|
||||||
|
{
|
||||||
|
RSLINK.Address_Error=0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RSLINK.Address_Error=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void RSLink_Handler(void)
|
||||||
|
{
|
||||||
|
// Address and Speed Change Check Routine =======================================
|
||||||
|
if ( (RSLINK.NeedSpeedChangeFlag == 1) || RSLink_SpeedCheckAndUpdate() )
|
||||||
|
{
|
||||||
|
if ( RSLINK.USI->IsTxActive() )
|
||||||
|
{
|
||||||
|
RSLINK.NeedSpeedChangeFlag = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RSLINK.USIID->SetIdiBusBoudrate(RSLINK.SpeedCode);
|
||||||
|
RSLINK.NeedSpeedChangeFlag = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RSLink_AddressCheckAndUpdate();
|
||||||
|
|
||||||
|
|
||||||
|
// Timeout Led Routine ==========================================================
|
||||||
|
if ( IDIBUS_MODULE->STATUS.STATE.B1S.TimeoutLed == 0 )
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
( (IDIBUS_MODULE->STATUS.STATE.B1S.NoMMESTimeout == 0) && (System_GetSysTickDifference( RSLINK.LastMMES_TimeInstance) >= IDIBUS_LINK_LED_NO_MMES_TIMEOUT_0_MS) ) ||
|
||||||
|
( (IDIBUS_MODULE->STATUS.STATE.B1S.NoMMESTimeout == 1) && (System_GetSysTickDifference( RSLINK.LastMMES_TimeInstance) >= IDIBUS_LINK_LED_NO_MMES_TIMEOUT_1_MS) )
|
||||||
|
)
|
||||||
|
{
|
||||||
|
IDIBUS_MODULE->STATUS.STATE.B1S.TimeoutLed=1;
|
||||||
|
rslink_hw.status_led_on();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rslink_hw.status_led_off();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Background Error Handler and Long Operations =================================
|
||||||
|
IDIBUS_ModuleBackgroundHandler();
|
||||||
|
IDIBUS_ChannelBackgroundHandler();
|
||||||
|
if ( RSLINK.USI->IsRxError() == 1)
|
||||||
|
{
|
||||||
|
RSLINK.USI->RxTransferRestart();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Check incorrect and Developers DIP Switch Address ---------------------------->
|
||||||
|
if ( RSLINK.Address_Error )
|
||||||
|
{
|
||||||
|
switch ( RSLINK.Address )
|
||||||
|
{
|
||||||
|
case ( IDIBUS_DEVELOPER_ADDR_0 ) :
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ( IDIBUS_DEVELOPER_ADDR_1 ) :
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ( IDIBUS_DEVELOPER_ADDR_2 ) :
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ( IDIBUS_DEVELOPER_ADDR_3 ) :
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default :
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
RSLINK.USI->RxTransferRestart();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
IdiBusProccessMessage();
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void IdiBusProccessMessage()
|
||||||
|
{
|
||||||
|
// Message Handling Routine =====================================================
|
||||||
|
if ( RSLINK.USI->IsNewRxMessage() == 0 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t RxMessageSize;
|
||||||
|
uint8_t *TxMesageBuf = RSLINK.USI->getTxBuf();
|
||||||
|
|
||||||
|
// Check normal Message --------------------------------------------------------->
|
||||||
|
|
||||||
|
// Check Message size
|
||||||
|
uint8_t RcvAddress;
|
||||||
|
RxMessageSize = RSLINK.USI->getRxBufSize();
|
||||||
|
if ( (RxMessageSize < (MODBUS_CRC16_SIZE+1) ) || (RxMessageSize > IDIMMES_MAX_MES_SIZE) )
|
||||||
|
{
|
||||||
|
RSLINK.USI->RxTransferRestart();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RSLINK.USI->copyRxBuf( &mmes_buf[IDIMMES_ADDR_Pos], IDIMMES_ADDR_Pos, 1 ); // Need for CRC
|
||||||
|
RcvAddress = mmes_buf[IDIMMES_ADDR_Pos];
|
||||||
|
}
|
||||||
|
|
||||||
|
// MMESG(Module) or MMES ------------->
|
||||||
|
if ( RcvAddress == RSLINK.Address )
|
||||||
|
{
|
||||||
|
// Check CRC, copy RxBuf and Restart Transfer
|
||||||
|
RSLINK.USI->copyRxBuf( &mmes_buf[IDIMMES_MMPS_Pos], IDIMMES_MMPS_Pos, (uint16_t)(RxMessageSize-1) );
|
||||||
|
RSLINK.USI->RxTransferRestart();
|
||||||
|
uint16_t CalculatedCRC = MODBUS_CRC16_T( mmes_buf, (uint16_t)(RxMessageSize-2) );
|
||||||
|
uint16_t ReceivedCRC = (uint16_t)( ((uint16_t)mmes_buf[RxMessageSize-2] << 8) | mmes_buf[RxMessageSize-1] );
|
||||||
|
if ( CalculatedCRC != ReceivedCRC )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
IDIBUS_MODULE->STATUS.STATE.B1S.TimeoutLed = 0;
|
||||||
|
RSLINK.LastMMES_TimeInstance = System_GetTimeInstance(); //FOR STM, (reset led)
|
||||||
|
|
||||||
|
idibus_farg_t FARG;
|
||||||
|
FARG.OutData = &TxMesageBuf[0]; //set RX addr
|
||||||
|
FARG.OutDataLength = IDISMES_ERROR_Pos; //Set length 2 (adr+cmd)
|
||||||
|
FARG.ErrorPos = IDISMES_ERROR_Pos; //set pos err
|
||||||
|
FARG.OutDataPos = IDISMES_ERROR_Pos + 1; //set pos data
|
||||||
|
FARG.ErrorState = 0;
|
||||||
|
FARG.OutLongMesState = 0;
|
||||||
|
if ( IDIBUS_MODULE->LONG_OP.State == IDILONGOP_STATE_IN_PROC )
|
||||||
|
{
|
||||||
|
FARG.LongOpState = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FARG.LongOpState = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Check if too short for MMESG message
|
||||||
|
if ( RxMessageSize < (IDIMMES_MMPS_Pos + 1 + MODBUS_CRC16_SIZE) )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(&FARG, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
RSLink_SendSMES(&FARG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get MMPS
|
||||||
|
uint8_t MMPS_FastFunc = (mmes_buf[IDIMMES_MMPS_Pos] & IDIMMES_MMPS_FAST_FUNC_Msk) >> IDIMMES_MMPS_FAST_FUNC_Pos;
|
||||||
|
uint8_t MMPS_MesType = (mmes_buf[IDIMMES_MMPS_Pos] & IDIMMES_MMPS_MES_TYPE_Msk) >> IDIMMES_MMPS_MES_TYPE_Pos;
|
||||||
|
uint8_t MMPS_LongMessage = mmes_buf[IDIMMES_MMPS_Pos] & IDIMMES_MMPS_LONG_MES_Msk;
|
||||||
|
uint8_t MMPS_AlarmFrame = mmes_buf[IDIMMES_MMPS_Pos] & IDIMMES_MMPS_ALARM_FRAME_Msk;
|
||||||
|
uint8_t MMPS_EncryptedAes = mmes_buf[IDIMMES_MMPS_Pos] & IDIMMES_MMPS_ENCRYPTED_AES_Msk;
|
||||||
|
if ( MMPS_AlarmFrame != 0 )
|
||||||
|
{
|
||||||
|
// Do Alarm
|
||||||
|
}
|
||||||
|
if ( MMPS_EncryptedAes != 0 )
|
||||||
|
{
|
||||||
|
if ( IDIBUS_MODULE->STATUS.STATE.B0S.AesSupported == 0 )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(&FARG, NULL, 0, IDIERSLV_ENCRYPTION_NOT_SUPPORTED);
|
||||||
|
RSLink_SendSMES(&FARG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if ( IDIBUS_MODULE->STATUS.STATE.B0S.AesInstalled == 0 )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(&FARG, NULL, 0, IDIERSLV_ENCRYPTION_NOT_INSTALLED);
|
||||||
|
RSLink_SendSMES(&FARG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Decrypt ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( MMPS_LongMessage != 0 )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(&FARG, NULL, 0, IDIERSLV_JUMBO_NOT_SUPPORTED);
|
||||||
|
RSLink_SendSMES(&FARG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// If Module Function
|
||||||
|
if ( MMPS_MesType == IDIMMES_MMPS_MES_TYPE_MMESG )
|
||||||
|
{
|
||||||
|
if ( (MMPS_FastFunc != 0) || (RxMessageSize < IDIMMESG_MODULE_MIN_MES_SIZE) )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(&FARG, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FARG.ComFunc = mmes_buf[IDIMMESG_DATA_COM_FUNC_Pos];
|
||||||
|
FARG.InpData = &mmes_buf[IDIMMESG_DATA_COM_FUNC_Pos + 1];
|
||||||
|
FARG.InpDataLength = (uint16_t)(RxMessageSize - (IDIMMESG_DATA_COM_FUNC_Pos + 1) - MODBUS_CRC16_SIZE);
|
||||||
|
IDIBUS_ModuleCommandHandler(&FARG);
|
||||||
|
|
||||||
|
}
|
||||||
|
RSLink_SendSMES(&FARG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// IF NOT Module Function
|
||||||
|
if ( IDIBUS_MODULE->STATUS.STATE.B0S.StState == IDISTATUS_B0S_ST_STATE_StFreeze )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(&FARG, NULL, 0, IDIERSLV_IN_FREEZE);
|
||||||
|
RSLink_SendSMES(&FARG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if ( IDIBUS_MODULE->Error != IDIER_NOPE )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(&FARG, NULL, 0, IDIBUS_MODULE->Error);
|
||||||
|
RSLink_SendSMES(&FARG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if ( IDIBUS_MODULE->LONG_OP.State == IDILONGOP_STATE_IN_PROC )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(&FARG, NULL, 0, IDIERSLV_LONG_OP_IN_PROC);
|
||||||
|
RSLink_SendSMES(&FARG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( MMPS_FastFunc == 0 )
|
||||||
|
{
|
||||||
|
if ( (RxMessageSize < (IDIMMES_MIN_MES_SIZE + 1)) || (mmes_buf[IDIMMES_DATA_FUNC_COM_DATA_Pos] <= IDIMMES_MAX_FAST_FUNC_NUM) ) //CHECK LEN ON MSG
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(&FARG, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
RSLink_SendSMES(&FARG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FARG.ComFunc = mmes_buf[IDIMMES_DATA_FUNC_COM_DATA_Pos];
|
||||||
|
FARG.InpData = &mmes_buf[IDIMMES_DATA_FUNC_COM_DATA_Pos + 1];
|
||||||
|
FARG.InpDataLength = (uint16_t)(RxMessageSize - (IDIMMES_DATA_FUNC_COM_DATA_Pos + 1) - MODBUS_CRC16_SIZE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( RxMessageSize < IDIMMES_MIN_MES_SIZE )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(&FARG, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
RSLink_SendSMES(&FARG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FARG.ComFunc = MMPS_FastFunc;
|
||||||
|
FARG.InpData = &mmes_buf[IDIMMES_DATA_FUNC_COM_DATA_Pos];
|
||||||
|
FARG.InpDataLength = (uint16_t)(RxMessageSize - IDIMMES_DATA_FUNC_COM_DATA_Pos - MODBUS_CRC16_SIZE);
|
||||||
|
}
|
||||||
|
// Channels command and funcs handling
|
||||||
|
uint8_t DeviceNum = (mmes_buf[IDIMMES_DEV_Pos] & IDIMMES_DEV_NUM_Msk) >> IDIMMES_DEV_NUM_Pos;
|
||||||
|
uint8_t AllChannels = mmes_buf[IDIMMES_DEV_Pos] & IDIMMES_DEV_ALLCH_Msk;
|
||||||
|
uint8_t ChannelNum = (mmes_buf[IDIMMES_CHNL_Pos] & IDIMMES_CHNL_NUM_Msk) >> IDIMMES_CHNL_NUM_Pos;
|
||||||
|
uint8_t ChannelAllSame = mmes_buf[IDIMMES_CHNL_Pos] & IDIMMES_CHNL_ALLSAME_Msk;
|
||||||
|
|
||||||
|
if ( DeviceNum >= IDIBUS_MODULE->DevicesCount )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(&FARG, NULL, 0, IDIERDEV_INVALID_DEV_NUM);
|
||||||
|
RSLink_SendSMES(&FARG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( (ChannelNum >= IDIBUS_MODULE->Devices[DeviceNum].ChannelsCount) && (AllChannels == 0) )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(&FARG, NULL, 0, IDIERDEV_INVALID_CHN_NUM);
|
||||||
|
RSLink_SendSMES(&FARG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( AllChannels != 0 )
|
||||||
|
{
|
||||||
|
uint8_t ChannelsCount = IDIBUS_MODULE->Devices[DeviceNum].ChannelsCount;
|
||||||
|
FARG.OutDataPos = (uint16_t)( FARG.OutDataPos + ChannelsCount - 1 ); // SMES = ADDR SMPS ERR1 ERR2 ERR3 DATA1 DATA2 DATA3 CRC
|
||||||
|
if ( ChannelAllSame == 0 )
|
||||||
|
{
|
||||||
|
uint16_t DataPortionLength = (uint16_t)( FARG.InpDataLength / ChannelsCount ); // If DataLength==0 -> OK (Byte count on one channel)
|
||||||
|
// SMES = ADDR SMPS ERR1 ERR2!=0 ERR3 DATA1 DATA3 CRC
|
||||||
|
if ( FARG.InpDataLength != (DataPortionLength * ChannelsCount) )
|
||||||
|
{
|
||||||
|
for (uint8_t I=0; I < ChannelsCount; I++ )
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(&FARG, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FARG.InpDataLength = DataPortionLength;
|
||||||
|
for (uint8_t I=0; I < ChannelsCount; I++ )
|
||||||
|
{
|
||||||
|
idibus_channel_t *CH = &IDIBUS_MODULE->Devices[DeviceNum].Channels[I];
|
||||||
|
CH->CH_Func( CH, &FARG );
|
||||||
|
FARG.InpData += DataPortionLength; //Pointer offset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (uint8_t I=0; I < IDIBUS_MODULE->Devices[DeviceNum].ChannelsCount; I++ )
|
||||||
|
{
|
||||||
|
idibus_channel_t *CH = &IDIBUS_MODULE->Devices[DeviceNum].Channels[I];
|
||||||
|
CH->CH_Func( CH, &FARG );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
idibus_channel_t *CH = &IDIBUS_MODULE->Devices[DeviceNum].Channels[ChannelNum];
|
||||||
|
CH->CH_Func( CH, &FARG );
|
||||||
|
}
|
||||||
|
RSLink_SendSMES(&FARG);
|
||||||
|
return;
|
||||||
|
} //if ( (RcvAddress == RSLINK.Address) && (RxMessageSize >= IDIMMES_MIN_MES_SIZE) )
|
||||||
|
|
||||||
|
|
||||||
|
// MMESG ------------->
|
||||||
|
// NO RESPONSE!!!
|
||||||
|
if ( (RcvAddress >= IDIBUS_GROUP_0_ADDR) && (RcvAddress <= IDIBUS_GROUP_15_ADDR) )
|
||||||
|
{
|
||||||
|
// Check CRC, copy RxBuf and Restart Transfer
|
||||||
|
RSLINK.USI->copyRxBuf( &mmes_buf[IDIMMES_MMPS_Pos], IDIMMES_MMPS_Pos, (uint16_t)(RxMessageSize-1) );
|
||||||
|
RSLINK.USI->RxTransferRestart();
|
||||||
|
uint16_t CalculatedCRC = MODBUS_CRC16_T( mmes_buf, (uint16_t)(RxMessageSize-2) );
|
||||||
|
uint16_t ReceivedCRC = (uint16_t)( ((uint16_t)mmes_buf[RxMessageSize-2] << 8) | mmes_buf[RxMessageSize-1] );
|
||||||
|
if ( CalculatedCRC != ReceivedCRC )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
IDIBUS_MODULE->STATUS.STATE.B1S.TimeoutLed = 0;
|
||||||
|
RSLINK.LastMMES_TimeInstance = System_GetTimeInstance();
|
||||||
|
|
||||||
|
idibus_farg_t FARG;
|
||||||
|
FARG.OutData = NULL;
|
||||||
|
|
||||||
|
// Check if too short for MMESG message
|
||||||
|
if ( RxMessageSize < (IDIMMES_MMPS_Pos + 1 + MODBUS_CRC16_SIZE) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get MMPS
|
||||||
|
uint8_t MMPS_FastFunc = (mmes_buf[IDIMMES_MMPS_Pos] & IDIMMES_MMPS_FAST_FUNC_Msk) >> IDIMMES_MMPS_FAST_FUNC_Pos;
|
||||||
|
uint8_t MMPS_MesType = (mmes_buf[IDIMMES_MMPS_Pos] & IDIMMES_MMPS_MES_TYPE_Msk) >> IDIMMES_MMPS_MES_TYPE_Pos;
|
||||||
|
uint8_t MMPS_LongMessage = mmes_buf[IDIMMES_MMPS_Pos] & IDIMMES_MMPS_LONG_MES_Msk;
|
||||||
|
uint8_t MMPS_AlarmFrame = mmes_buf[IDIMMES_MMPS_Pos] & IDIMMES_MMPS_ALARM_FRAME_Msk;
|
||||||
|
uint8_t MMPS_EncryptedAes = mmes_buf[IDIMMES_MMPS_Pos] & IDIMMES_MMPS_ENCRYPTED_AES_Msk;
|
||||||
|
if ( MMPS_AlarmFrame != 0 )
|
||||||
|
{
|
||||||
|
// Do Alarm
|
||||||
|
}
|
||||||
|
if ( MMPS_EncryptedAes != 0 )
|
||||||
|
{
|
||||||
|
if ( (IDIBUS_MODULE->STATUS.STATE.B0S.AesSupported == 0) || (IDIBUS_MODULE->STATUS.STATE.B0S.AesInstalled == 0) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Decrypt ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( MMPS_LongMessage != 0 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
( MMPS_MesType != IDIMMES_MMPS_MES_TYPE_MMESG ) ||
|
||||||
|
( IDIBUS_MODULE->STATUS.STATE.B0S.StState == IDISTATUS_B0S_ST_STATE_StFreeze ) || // There are no Module commands in group
|
||||||
|
( IDIBUS_MODULE->Error != IDIER_NOPE ) ||
|
||||||
|
( IDIBUS_MODULE->LONG_OP.State == IDILONGOP_STATE_IN_PROC )
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( MMPS_FastFunc == 0 )
|
||||||
|
{
|
||||||
|
if ( RxMessageSize < (IDIMMESG_GROUP_MIN_MES_SIZE + 1) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FARG.ComFunc = mmes_buf[IDIMMESG_DATA_COM_FUNC_Pos];
|
||||||
|
if ( FARG.ComFunc <= IDIMMES_MAX_FAST_FUNC_NUM )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FARG.InpData = &mmes_buf[IDIMMESG_DATA_COM_FUNC_Pos + 1];
|
||||||
|
FARG.InpDataLength = (uint16_t)(RxMessageSize - (IDIMMESG_DATA_COM_FUNC_Pos + 1) - MODBUS_CRC16_SIZE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( RxMessageSize < IDIMMESG_GROUP_MIN_MES_SIZE )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FARG.ComFunc = MMPS_FastFunc;
|
||||||
|
FARG.InpData = &mmes_buf[IDIMMESG_DATA_COM_FUNC_Pos];
|
||||||
|
FARG.InpDataLength = (uint16_t)(RxMessageSize - IDIMMESG_DATA_COM_FUNC_Pos - MODBUS_CRC16_SIZE);
|
||||||
|
}
|
||||||
|
for (uint8_t Dev = 0; Dev < IDIBUS_MODULE->DevicesCount; Dev++)
|
||||||
|
{
|
||||||
|
for (uint8_t Ch = 0; Ch<IDIBUS_MODULE->Devices[Dev].ChannelsCount; Ch++)
|
||||||
|
{
|
||||||
|
idibus_channel_t *CH = &IDIBUS_MODULE->Devices[Dev].Channels[Ch];
|
||||||
|
if ( (RcvAddress == IDIBUS_GROUP_0_ADDR) || (CH->BcastAddr == RcvAddress) )
|
||||||
|
{
|
||||||
|
CH->CH_Func(CH, &FARG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} //if ( ((RcvAddress >= IDIBUS_GROUP_0_ADDR) && (RcvAddress <= IDIBUS_GROUP_15_ADDR)) )
|
||||||
|
|
||||||
|
RSLINK.USI->RxTransferRestart(); // NOT MMES AND MMESG ------------->
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RSLink_SendSMES(idibus_farg_t *farg)
|
||||||
|
{
|
||||||
|
if ( (RSLINK.USIID->ResponseTimeoutComplete == 0) && (farg->OutDataLength > IDISMES_ERROR_Pos) )
|
||||||
|
{
|
||||||
|
farg->OutData[IDISMES_ADDR_Pos] = RSLINK.Address;
|
||||||
|
farg->OutData[IDISMES_SMPS_Pos] = 0;
|
||||||
|
if ( farg->ErrorState != 0 )
|
||||||
|
{
|
||||||
|
farg->OutData[IDISMES_SMPS_Pos] |= (1U << IDISMES_SMPS_ERROR_BIT_Pos);
|
||||||
|
}
|
||||||
|
if ( farg->OutLongMesState != 0 )
|
||||||
|
{
|
||||||
|
farg->OutData[IDISMES_SMPS_Pos] |= (1U << IDISMES_SMPS_LONG_MES_Pos);
|
||||||
|
}
|
||||||
|
if ( farg->LongOpState != 0 )
|
||||||
|
{
|
||||||
|
farg->OutData[IDISMES_SMPS_Pos] |= (1U << IDISMES_SMPS_LONG_OP_Pos);
|
||||||
|
}
|
||||||
|
uint16_t CRC16 = MODBUS_CRC16_T(&farg->OutData[0], farg->OutDataLength);
|
||||||
|
farg->OutData[farg->OutDataLength++] = (uint8_t)(CRC16 >> 8);
|
||||||
|
farg->OutData[farg->OutDataLength++] = (uint8_t) CRC16;
|
||||||
|
RSLINK.USI->SendTxBuf(farg->OutDataLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//#############################################################################################################################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
//#############################################################################################################################################################################################################
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
//#############################################################################################################################################################################################################
|
||||||
|
#ifndef _INC_RSLINK_H_
|
||||||
|
#define _INC_RSLINK_H_
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include "../Required/SYSTEM.h"
|
||||||
|
#include "IDIBUS_IMPL.h"
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
// DELAYS FOR LEDS status
|
||||||
|
#define RSLINK_LED_T1_DEFAULT_S 15UL
|
||||||
|
#define RSLINK_LED_T2_DEFAULT_S 60UL
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
struct RSLINK_STRUCT
|
||||||
|
{
|
||||||
|
USART_INTERFACE_TYPE *USI;
|
||||||
|
USART_IDIBUS_ROUTINE_TYPE *USIID;
|
||||||
|
uint8_t Address;
|
||||||
|
uint8_t Address_Error; // ????????????
|
||||||
|
uint8_t SpeedCode;
|
||||||
|
uint8_t NeedSpeedChangeFlag; // ???? ??? ????????? ????????
|
||||||
|
uint32_t LastMMES_TimeInstance; // ??? led
|
||||||
|
};
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
extern uint8_t mmes_buf[IDIMMES_MAX_MES_SIZE]; //RX buffer for copy
|
||||||
|
extern struct RSLINK_STRUCT RSLINK;
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void RSLink_Init(USART_INTERFACE_TYPE *USART_INTERFACE, USART_IDIBUS_ROUTINE_TYPE *USART_ID_INTERFACE);
|
||||||
|
uint8_t RSLink_SpeedCheckAndUpdate(void);
|
||||||
|
void RSLink_AddressCheckAndUpdate(void);
|
||||||
|
void RSLink_Handler(void);
|
||||||
|
void IdiBusProccessMessage();
|
||||||
|
void RSLink_SendSMES(idibus_farg_t *farg);
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Typedef for callback function
|
||||||
|
typedef uint8_t (*rslink_func_i_t)(void);
|
||||||
|
|
||||||
|
typedef void (*rslink_func_v_t)(void);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
rslink_func_v_t status_led_init;
|
||||||
|
rslink_func_v_t status_led_on;
|
||||||
|
rslink_func_v_t status_led_off;
|
||||||
|
rslink_func_v_t dips_init;
|
||||||
|
rslink_func_i_t disp_read_addr;
|
||||||
|
rslink_func_i_t disp_read_speed;
|
||||||
|
}rslink_func_pack_t;
|
||||||
|
|
||||||
|
// Callback registration
|
||||||
|
void RSLink_register_hw_functions(rslink_func_pack_t callback);
|
||||||
|
|
||||||
|
void RSLlink_pass_module(idibus_slave_module_t* MODULE);
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif // #ifndef _INC_RSLINK_H_
|
||||||
|
//#############################################################################################################################################################################################################
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
#ifndef _IDIBUS_SLAVE_H_
|
||||||
|
#define _IDIBUS_SLAVE_H_
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include "config.h"
|
||||||
|
#include "idibus_hw.h"
|
||||||
|
//=============================================================================
|
||||||
|
// DEVICE DEFINITIONS
|
||||||
|
// Add your devices here: ADC, Counter, 1wire, etc. Naming doesn't matter
|
||||||
|
// Share enums and defines with MASTER CODE
|
||||||
|
//=============================================================================
|
||||||
|
#define IDIBUS_XXX_NAME_CH_NUM 4
|
||||||
|
|
||||||
|
//Add commands to the slave
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
XXX_NAME_DUMMY_CMD,
|
||||||
|
XXX_NAME_GET_CMD,
|
||||||
|
XXX_NAME_SET_CMD,
|
||||||
|
XXX_NAME_STATUS_CMD,
|
||||||
|
};
|
||||||
|
//Enumerate all devices attached
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
XXX_NAME_DEV,
|
||||||
|
XXX_NAME_DEVICES_NUMBER
|
||||||
|
};
|
||||||
|
|
||||||
|
//Place custom ERR codes here
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
XXX_NAME_OK = 0,
|
||||||
|
XXX_NAME_NO_DATA, //No data from XXX
|
||||||
|
XXX_NAME_OUT_OF_BOUNDS, //Data is out of MIN/MAX
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t status;
|
||||||
|
//Place your custom struct for data here
|
||||||
|
uint8_t ch_data;
|
||||||
|
}XXX_NAME_channel_data_t;
|
||||||
|
|
||||||
|
extern XXX_NAME_channel_data_t XXX_NAME_channels_data[];
|
||||||
|
void SlaveInit();
|
||||||
|
void SlaveLoop();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef EEMEM_H_
|
||||||
|
#define EEMEM_H_
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
typedef struct{
|
||||||
|
uint8_t BOOTFLAG; //DoNotMove
|
||||||
|
uint8_t EEPROM_IDIBUS_InitGroup; //DoNotMove
|
||||||
|
uint8_t EEPROM_SN[IDISN_VARP_LENGTH]; //DoNotMove
|
||||||
|
|
||||||
|
//Add new things here
|
||||||
|
// ||
|
||||||
|
// ||
|
||||||
|
// \/
|
||||||
|
|
||||||
|
} EEPROM_DATABLOCKS;
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
__attribute__((__section__(".serialdata"))) EEPROM_DATABLOCKS EEBLOCK; //DYNAMIC PART
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* EEMEM_H_ */
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
#include "MEMORY.h"
|
||||||
|
#include "config.h"
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//const volatile FLASH_DATABLOCK STATIC_DATA_APP;
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
#ifndef MEMORY_H_
|
||||||
|
#define MEMORY_H_
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "IDIBUS_DEFS.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "MEMORY.h"
|
||||||
|
|
||||||
|
#define _APP_VERSION_
|
||||||
|
|
||||||
|
|
||||||
|
typedef volatile struct{
|
||||||
|
volatile uint8_t Padding;
|
||||||
|
volatile uint8_t GS1_country[IDISN_FIXP_GS1_COUNTRY_Length];
|
||||||
|
volatile uint8_t GS1_company[IDISN_FIXP_GS1_COMPANY_Length];
|
||||||
|
volatile uint8_t ModuleType[IDISN_FIXP_MODULE_TYPE_Length];
|
||||||
|
volatile uint8_t HW_revision[IDISN_FIXP_HW_REV_Length];
|
||||||
|
volatile uint8_t SN[IDISN_FIXP_SERIAL_Length];
|
||||||
|
volatile uint8_t MAC[IDISN_FIXP_MAC_Length];
|
||||||
|
volatile uint8_t SW[IDISN_FIXP_SW_REV_Length]; //SW Version (Bootloader/App)
|
||||||
|
volatile uint32_t AppCRC; //Only in APP
|
||||||
|
} FLASH_DATABLOCK;
|
||||||
|
//Universal data block
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* MEMORY_H_ */
|
||||||
@ -0,0 +1,78 @@
|
|||||||
|
//#############################################################################################################################################################################################################
|
||||||
|
#include "MODBUS_CRC.h"
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
const uint8_t MODBUS_auchCRCHi[256] PROGMEM= // Table of CRC values for high order byte
|
||||||
|
{
|
||||||
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
||||||
|
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||||
|
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||||
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
||||||
|
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||||
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
||||||
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
||||||
|
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||||
|
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||||
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
||||||
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
||||||
|
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||||
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
|
||||||
|
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||||
|
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
|
||||||
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40
|
||||||
|
};
|
||||||
|
const uint8_t MODBUS_auchCRCLo[256] PROGMEM= // Table of CRC values for low order byte
|
||||||
|
{
|
||||||
|
0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04,
|
||||||
|
0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, 0x08, 0xC8,
|
||||||
|
0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC,
|
||||||
|
0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3, 0x11, 0xD1, 0xD0, 0x10,
|
||||||
|
0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4,
|
||||||
|
0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38,
|
||||||
|
0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED, 0xEC, 0x2C,
|
||||||
|
0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26, 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0,
|
||||||
|
0xA0, 0x60, 0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4,
|
||||||
|
0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68,
|
||||||
|
0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C,
|
||||||
|
0xB4, 0x74, 0x75, 0xB5, 0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0,
|
||||||
|
0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54,
|
||||||
|
0x9C, 0x5C, 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98,
|
||||||
|
0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C,
|
||||||
|
0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83, 0x41, 0x81, 0x80, 0x40
|
||||||
|
};
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint16_t MODBUS_CRC16_T(uint8_t *MODBUS_puchMsg, uint16_t MODBUS_usDataLen)
|
||||||
|
{
|
||||||
|
uint8_t MODBUS_uchCRCHi=0xFF; // high byte of CRC initialized
|
||||||
|
uint8_t MODBUS_uchCRCLo=0xFF; // low byte of CRC initialized
|
||||||
|
uint8_t MODBUS_uIndex;
|
||||||
|
for (uint16_t I=0; I<MODBUS_usDataLen; I++)
|
||||||
|
{
|
||||||
|
MODBUS_uIndex=MODBUS_uchCRCLo^(*MODBUS_puchMsg++); // calculate the CRC
|
||||||
|
MODBUS_uchCRCLo=MODBUS_uchCRCHi^pgm_read_byte(&MODBUS_auchCRCHi[MODBUS_uIndex]);
|
||||||
|
MODBUS_uchCRCHi=pgm_read_byte(&MODBUS_auchCRCLo[MODBUS_uIndex]);
|
||||||
|
}
|
||||||
|
return (uint16_t)(((uint16_t)MODBUS_uchCRCHi<<8)|MODBUS_uchCRCLo);
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint16_t MODBUS_CRC16_S(uint8_t *MODBUS_puchMsg, uint16_t MODBUS_usDataLen)
|
||||||
|
{
|
||||||
|
uint16_t MODBUS_crc=0xFFFF;
|
||||||
|
for (uint16_t Mp=0; Mp<MODBUS_usDataLen; Mp++)
|
||||||
|
{
|
||||||
|
MODBUS_crc=(uint16_t)(MODBUS_crc^MODBUS_puchMsg[Mp]); // XOR byte into least sig. byte of crc
|
||||||
|
for (uint8_t Mi=8; Mi!=0; Mi--) // Loop over each bit
|
||||||
|
{
|
||||||
|
if ((MODBUS_crc&0x0001)!=0)
|
||||||
|
{
|
||||||
|
MODBUS_crc>>=1; // If the LSB is set Shift right and XOR 0xA001
|
||||||
|
MODBUS_crc^=0xA001;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MODBUS_crc>>=1; // Else LSB is not set Just shift right
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return MODBUS_crc;
|
||||||
|
}
|
||||||
|
//#############################################################################################################################################################################################################
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
//#############################################################################################################################################################################################################
|
||||||
|
#ifndef _INC_MODBUS_CRC_H_
|
||||||
|
#define _INC_MODBUS_CRC_H_
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#define MODBUS_CRC16_SIZE 2
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint16_t MODBUS_CRC16_T(uint8_t *MODBUS_puchMsg, uint16_t MODBUS_usDataLen);
|
||||||
|
uint16_t MODBUS_CRC16_S(uint8_t *MODBUS_buf, uint16_t MODBUS_len);
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif // #ifndef _INC_MODBUS_CRC_H_
|
||||||
|
//#############################################################################################################################################################################################################
|
||||||
@ -0,0 +1,84 @@
|
|||||||
|
//#############################################################################################################################################################################################################
|
||||||
|
#include "SYSTEM.h"
|
||||||
|
#include "config.h"
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
volatile uint32_t SystemSystickCounter;
|
||||||
|
|
||||||
|
uint32_t System_GetSysTick(void)
|
||||||
|
{
|
||||||
|
cli();
|
||||||
|
uint32_t SystemSysTick_Temp = SystemSystickCounter;
|
||||||
|
sei();
|
||||||
|
return SystemSysTick_Temp;
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint32_t HAL_GetTick(void) // redefine _weak HAL function For HAL Inits
|
||||||
|
{
|
||||||
|
cli();
|
||||||
|
uint32_t SystemSysTick_Temp = SystemSystickCounter;
|
||||||
|
sei();
|
||||||
|
return SystemSysTick_Temp;
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint32_t System_GetSysTickDifference(uint32_t TimeInstance)
|
||||||
|
{
|
||||||
|
cli();
|
||||||
|
uint32_t SystemSysTick_Temp = SystemSystickCounter;
|
||||||
|
sei();
|
||||||
|
if (TimeInstance<=SystemSysTick_Temp )
|
||||||
|
{
|
||||||
|
return (uint32_t)(SystemSysTick_Temp-TimeInstance);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (uint32_t)(0xFFFFFFFF-TimeInstance+SystemSysTick_Temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void System_SWReboot(void)
|
||||||
|
{
|
||||||
|
cli();
|
||||||
|
wdt_enable(WDTO_15MS);
|
||||||
|
while(1); //Dumb reset
|
||||||
|
}
|
||||||
|
//#############################################################################################################################################################################################################
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void System_InitSysTick(void)
|
||||||
|
{
|
||||||
|
SystemSystickCounter=0;
|
||||||
|
TCNT0=0xFF-250; // 1 ms
|
||||||
|
TCCR0B=0; // no clock
|
||||||
|
TIMSK0=0; // Overflow Interrupt Disable
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
ISR(TIMER0_OVF_vect) // 1ms timer0 interrupt
|
||||||
|
{
|
||||||
|
TCNT0=0xFF-250; // 1 ms
|
||||||
|
if (SystemSystickCounter==0xFFFFFFFF) SystemSystickCounter=0;
|
||||||
|
else SystemSystickCounter++;
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void System_SystickTimerStart(void)
|
||||||
|
{
|
||||||
|
SystemSystickCounter=0;
|
||||||
|
TCNT0=0xFF-250; // 1 ms
|
||||||
|
TCCR0B=3; // clkI/O/64 (from prescaller)
|
||||||
|
TIMSK0=1<<TOIE0; // Overflow Interrupt Enable
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void System_SystickTimerStop(void)
|
||||||
|
{
|
||||||
|
TCCR0B=0; // no clock
|
||||||
|
TIMSK0=0; // Overflow Interrupt Disable
|
||||||
|
}
|
||||||
|
void readDeviceData(FLASH_DATABLOCK* data, FLASH_ADDR_T addr) {
|
||||||
|
uint8_t* dst = (uint8_t*)data;
|
||||||
|
const FLASH_ADDR_T src = (addr*2);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < sizeof(FLASH_DATABLOCK); i++) {
|
||||||
|
dst[i] = pgm_read_byte_far(src + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//#############################################################################################################################################################################################################
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
//#############################################################################################################################################################################################################
|
||||||
|
#ifndef _INC_SYSTEM_H_
|
||||||
|
#define _INC_SYSTEM_H_
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "config.h"
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/wdt.h>
|
||||||
|
#include <avr/eeprom.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include "MEMORY.h"
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#ifdef _LONG_ADDR_SPACE_
|
||||||
|
#define flash_read_byte(x,y) pgm_read_byte_far(x+y)
|
||||||
|
#define flash_read_word(x,y) pgm_read_word_far(x+y)
|
||||||
|
#define flash_read_dword(x,y) pgm_read_dword_far(x+y)
|
||||||
|
#else
|
||||||
|
#define flash_read_byte(x,y) pgm_read_byte(x+y)
|
||||||
|
#define flash_read_word(x,y) pgm_read_word(x+y)
|
||||||
|
#define flash_read_dword(x,y) pgm_read_dword(x+y)
|
||||||
|
#endif
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#define System_GetTimeInstance() System_GetSysTick()
|
||||||
|
uint32_t System_GetSysTick(void);
|
||||||
|
uint32_t HAL_GetTick(void);
|
||||||
|
uint32_t System_GetSysTickDifference(uint32_t TimeInstance);
|
||||||
|
void System_SWReboot(void);
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
volatile extern uint32_t SystemSystickCounter;
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void System_InitSysTick(void);
|
||||||
|
void System_SystickTimerStart(void);
|
||||||
|
void System_SystickTimerStop(void);
|
||||||
|
|
||||||
|
void readDeviceData(FLASH_DATABLOCK* data, FLASH_ADDR_T addr);
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif // #ifndef _INC_SYSTEM_H_
|
||||||
|
//#############################################################################################################################################################################################################
|
||||||
@ -0,0 +1,231 @@
|
|||||||
|
#include "USART1.h"
|
||||||
|
|
||||||
|
USART_TypeDef USART1_ADR;
|
||||||
|
USART_HANDLER_TYPE USART1STR;
|
||||||
|
USART_INTERFACE_TYPE USART1_INTERFACE;
|
||||||
|
USART_IDIBUS_ROUTINE_TYPE USART1_IDIBUS;
|
||||||
|
|
||||||
|
uint8_t USART1_RX_BUF[USART1_BUF_SIZE]; // RX buffer
|
||||||
|
uint8_t USART1_TX_BUF[USART1_BUF_SIZE]; // TX buffer
|
||||||
|
// USARTs common settings : Speed and Timeouts
|
||||||
|
const uint16_t USART_UBRR[8] PROGMEM= { (F_CPU/8UL)/19200-1, (F_CPU/8UL)/500000-1,
|
||||||
|
(F_CPU/8UL)/2400-1, (F_CPU/8UL)/9600-1,
|
||||||
|
(F_CPU/8UL)/115200-1, (F_CPU/8UL)/250000-1,
|
||||||
|
(F_CPU/8UL)/1000000-1, /*(F_CPU/8UL)/10000000-1*/ 0
|
||||||
|
}; // Fosc=16MHz : 19.2k, 500k, 2.4k, 9.6k, 115.2k, 250k, 1M, 1M
|
||||||
|
const uint16_t USART_TIMEOUT[8] PROGMEM= { (IDIBUS_19200B_INTERFRAME_TIMEOUT_US/8*16), (IDIBUS_500K_INTERFRAME_TIMEOUT_US/8*16),
|
||||||
|
(IDIBUS_2400B_INTERFRAME_TIMEOUT_US/8*16), (IDIBUS_9600B_INTERFRAME_TIMEOUT_US/8*16),
|
||||||
|
(IDIBUS_115200B_INTERFRAME_TIMEOUT_US/8*16), (IDIBUS_250K_INTERFRAME_TIMEOUT_US/8*16),
|
||||||
|
(IDIBUS_1M_INTERFRAME_TIMEOUT_US/8*16), (IDIBUS_1M_INTERFRAME_TIMEOUT_US/8*16)
|
||||||
|
};
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
ISR(USART1_TX_vect)
|
||||||
|
{
|
||||||
|
if (USART1STR.TxSendedCount == USART1STR.TxBufCount)
|
||||||
|
{
|
||||||
|
*USART1STR.USART->UCRSB |= (1<<RXCIE1)|(1<<RXEN1);
|
||||||
|
*USART1STR.USART->UCRSB &= ~((1<<TXCIE1)|(1<<TXEN1));
|
||||||
|
USART1STR.TxSendedCount = 0;
|
||||||
|
USART1STR.TxBufCount = 0;
|
||||||
|
USART1STR.TxComplete = 1;
|
||||||
|
USART1_TX_DDR&=~(1<<USART1_TX_BIT);
|
||||||
|
USART1_TX_PORT|=1<<USART1_TX_BIT; // TXD -> Z
|
||||||
|
USART1_DRE_DDR&=~(1<<USART1_DRE_BIT);
|
||||||
|
USART1_DRE_PORT&=~(1<<USART1_DRE_BIT); // RDE -> 0
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*USART1STR.USART->UDR=USART1STR.TX_BUF[USART1STR.TxSendedCount];
|
||||||
|
USART1STR.TxSendedCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
ISR(USART1_RX_vect)
|
||||||
|
{
|
||||||
|
TIMSK3=0;
|
||||||
|
TCNT3=0; // Timeout Timer3 On, clkI/O/8 (From prescaller)
|
||||||
|
TCCR3B=2;
|
||||||
|
TIMSK3=1<<OCIE3A;
|
||||||
|
|
||||||
|
if (*USART1STR.USART->UCRSA & ((1<<FE1) | (1<<DOR1)) )
|
||||||
|
USART1STR.RxError = 1;
|
||||||
|
|
||||||
|
if (USART1STR.RxBufCount < USART1_BUF_SIZE)
|
||||||
|
{
|
||||||
|
USART1STR.RX_BUF[USART1STR.RxBufCount] = *USART1STR.USART->UDR;
|
||||||
|
USART1STR.RxBufCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
ISR(TIMER3_COMPA_vect)
|
||||||
|
{
|
||||||
|
TCCR3B=0;
|
||||||
|
TCNT3=0;
|
||||||
|
TIMSK3=0; // Timeout TIMER3 off
|
||||||
|
*USART1STR.USART->UCRSB&=~((1<<RXCIE1)|(1<<RXEN1)); // RX off
|
||||||
|
USART1STR.RxComplete = 1; // RX data ready
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void USART1_Init(void)
|
||||||
|
{
|
||||||
|
//USART1STR.USART = USART1_PERIPH_POINTER;
|
||||||
|
//USART1STR.DMATX = USART1_DMA_TX_STREAM;
|
||||||
|
USART1_ADR.UCRSA = &UCSR1A;
|
||||||
|
USART1_ADR.UCRSB = &UCSR1B;
|
||||||
|
USART1_ADR.UCRSC = &UCSR1C;
|
||||||
|
USART1_ADR.UDR = &UDR1;
|
||||||
|
USART1_ADR.UBRRL = &UBRR1L;
|
||||||
|
USART1_ADR.UBRRH = &UBRR1H;
|
||||||
|
|
||||||
|
USART1STR.USART = &USART1_ADR;
|
||||||
|
USART1STR.RX_BUF = USART1_RX_BUF;
|
||||||
|
USART1STR.TX_BUF = USART1_TX_BUF;
|
||||||
|
USART1STR.TxBufCount = 0;
|
||||||
|
USART1STR.TxSendedCount = 0;
|
||||||
|
USART1STR.RxBufCount = 0;
|
||||||
|
USART1STR.RxComplete = 0;
|
||||||
|
USART1STR.TxComplete = 1;
|
||||||
|
USART1STR.InterFrameTimeoutTicks = 0;
|
||||||
|
|
||||||
|
USART1_INTERFACE.SetNewBaudrate = USART1_SetBaudrate;
|
||||||
|
USART1_INTERFACE.SendTxBuf = USART1_SendTxBuf;
|
||||||
|
USART1_INTERFACE.SendByteBuf = USART1_SendByteBuf;
|
||||||
|
USART1_INTERFACE.IsNewRxMessage = USART1_IsNewRxMessage;
|
||||||
|
USART1_INTERFACE.IsTxActive = USART1_IsTxActive;
|
||||||
|
USART1_INTERFACE.IsRxError = USART1_IsRxError;
|
||||||
|
USART1_INTERFACE.getRxBufSize = USART1_getRxBufSize;
|
||||||
|
USART1_INTERFACE.copyRxBuf = USART1_copyRxBuf;
|
||||||
|
USART1_INTERFACE.getRxBuf = USART1_getRxBuf;
|
||||||
|
USART1_INTERFACE.getTxBuf = USART1_getTxBuf;
|
||||||
|
USART1_INTERFACE.RxTransferRestart = USART1_RxTransferRestart;
|
||||||
|
|
||||||
|
USART1_IDIBUS.SetIdiBusBoudrate = USART1_SetIdiBusBoudrate;
|
||||||
|
USART1_IDIBUS.RxAlarmFrameStart = USART1_RxAlarmFrameStart;
|
||||||
|
USART1_IDIBUS.ResponseTimeoutComplete = 0;
|
||||||
|
USART1_IDIBUS.AlarmTimeoutUS = 0;
|
||||||
|
USART1_IDIBUS.ResponseTimeoutUS = 0;
|
||||||
|
USART1_IDIBUS.TimerMode = IDIBUS_TIMER_MODE_RX_TIMEOUT;
|
||||||
|
|
||||||
|
USART1_TX_DDR&=~(1<<USART1_TX_BIT);
|
||||||
|
USART1_TX_PORT|=1<<USART1_TX_BIT; // TXD -> Z
|
||||||
|
USART1_RX_DDR&=~(1<<USART1_RX_BIT);
|
||||||
|
USART1_RX_PORT|=1<<USART1_RX_BIT; // RXD -> Z
|
||||||
|
USART1_DRE_DDR&=~(1<<USART1_DRE_BIT);
|
||||||
|
USART1_DRE_PORT&=~(1<<USART1_DRE_BIT); // RDE -> 0
|
||||||
|
|
||||||
|
*USART1STR.USART->UCRSA=(1<<U2X1);
|
||||||
|
*USART1STR.USART->UCRSB=(1<<RXCIE1)|(1<<RXEN1); // RX enable
|
||||||
|
*USART1STR.USART->UCRSC=(1<<UCSZ10)|(1<<UCSZ11)|(1<<USBS1); // 8 bit, 2 stop
|
||||||
|
TCCR3B=0;
|
||||||
|
TCNT3=0;
|
||||||
|
TIMSK3=0; // Timeout TIMER3 off
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void USART1_SetBaudrate(uint32_t Baudrate)
|
||||||
|
{
|
||||||
|
uint16_t UBRR = (F_CPU/16UL)/Baudrate-1;
|
||||||
|
*USART1STR.USART->UBRRL = (uint8_t)UBRR;
|
||||||
|
*USART1STR.USART->UBRRH = (uint8_t)(UBRR>>8);
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint8_t USART1_IsNewRxMessage(void)
|
||||||
|
{
|
||||||
|
return USART1STR.RxComplete;
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint8_t USART1_IsRxError(void)
|
||||||
|
{
|
||||||
|
return USART1STR.RxError;
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint16_t USART1_getRxBufSize(void)
|
||||||
|
{
|
||||||
|
return USART1STR.RxBufCount;
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint8_t *USART1_getRxBuf(void)
|
||||||
|
{
|
||||||
|
return &USART1STR.RX_BUF[0];
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint8_t *USART1_getTxBuf(void)
|
||||||
|
{
|
||||||
|
return &USART1STR.TX_BUF[0];
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void USART1_copyRxBuf(uint8_t *Dst, uint16_t StartPos, uint16_t Count)
|
||||||
|
{
|
||||||
|
memcpy(Dst, &USART1STR.RX_BUF[StartPos], Count);
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint8_t USART1_IsTxActive(void)
|
||||||
|
{
|
||||||
|
if (USART1STR.TxComplete) return 0;
|
||||||
|
else return 1;
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void USART1_SetIdiBusBoudrate(enum IDIBUS_SERIAL_BAUDRATE BoudrateCode)
|
||||||
|
{
|
||||||
|
uint16_t UBRR = pgm_read_word(&USART_UBRR[BoudrateCode]);
|
||||||
|
*USART1STR.USART->UBRRL = (uint8_t)UBRR;
|
||||||
|
*USART1STR.USART->UBRRH = (uint8_t)(UBRR>>8);
|
||||||
|
USART1STR.InterFrameTimeoutTicks = pgm_read_word(&USART_TIMEOUT[BoudrateCode]);
|
||||||
|
OCR3A = USART1STR.InterFrameTimeoutTicks;
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void USART1_SendByteBuf(uint8_t *Buf, uint16_t Count)
|
||||||
|
{
|
||||||
|
if ( (!USART1STR.TxComplete) || (Count == 0) || (Count > USART1_BUF_SIZE) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memcpy(USART1STR.TX_BUF, Buf, Count);
|
||||||
|
USART1_TX_DDR|=1<<USART1_TX_BIT;
|
||||||
|
USART1_TX_PORT|=1<<USART1_TX_BIT; // TXD -> out
|
||||||
|
USART1_DRE_DDR|=1<<USART1_DRE_BIT;
|
||||||
|
USART1_DRE_PORT|=1<<USART1_DRE_BIT;
|
||||||
|
USART1STR.TxComplete = 0;
|
||||||
|
USART1STR.TxBufCount = Count;
|
||||||
|
USART1STR.TxSendedCount = 1;
|
||||||
|
*USART1STR.USART->UCRSB&=~((1<<RXCIE1)|(1<<RXEN1)); // RX off
|
||||||
|
*USART1STR.USART->UCRSB|=(1<<TXCIE1)|(1<<TXEN1);
|
||||||
|
*USART1STR.USART->UDR = USART1STR.TX_BUF[0];
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void USART1_SendTxBuf(uint16_t Count)
|
||||||
|
{
|
||||||
|
if ( (!USART1STR.TxComplete) || (Count == 0) || (Count > USART1_BUF_SIZE) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
USART1_TX_DDR|=1<<USART1_TX_BIT;
|
||||||
|
USART1_TX_PORT|=1<<USART1_TX_BIT; // TXD -> out
|
||||||
|
USART1_DRE_DDR|=1<<USART1_DRE_BIT;
|
||||||
|
USART1_DRE_PORT|=1<<USART1_DRE_BIT;
|
||||||
|
USART1STR.TxComplete = 0;
|
||||||
|
USART1STR.TxBufCount = Count;
|
||||||
|
USART1STR.TxSendedCount = 1;
|
||||||
|
*USART1STR.USART->UCRSB&=~((1<<RXCIE1)|(1<<RXEN1)); // RX off
|
||||||
|
*USART1STR.USART->UCRSB|=(1<<TXCIE1)|(1<<TXEN1);
|
||||||
|
*USART1STR.USART->UDR = USART1STR.TX_BUF[0];
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void USART1_RxTransferRestart(void)
|
||||||
|
{
|
||||||
|
//USART1_RX_TIMER_STOP(); //We are already doing this in IRQ
|
||||||
|
//(void) USART1STR.USART->SR;
|
||||||
|
//(void) USART1STR.USART->DR;
|
||||||
|
*USART1STR.USART->UCRSB|=(1<<RXCIE1)|(1<<RXEN1);
|
||||||
|
USART1STR.RxBufCount = 0;
|
||||||
|
USART1STR.RxComplete = 0;
|
||||||
|
USART1STR.RxError = 0;
|
||||||
|
USART1_IDIBUS.TimerMode = IDIBUS_TIMER_MODE_RX_TIMEOUT;
|
||||||
|
//USART1_RX_TIMER_SET_TIMEOUT(USART1STR.InterFrameTimeoutUS);
|
||||||
|
//OCR3A = USART1STR.InterFrameTimeoutTicks; //Not necessary but why not
|
||||||
|
//USART1STR.USART->CR1 |= (1U<<USART_CR1_RE_Pos);
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void USART1_RxAlarmFrameStart(void)
|
||||||
|
{
|
||||||
|
//Sometimes there will be something
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
#ifndef USART1_H_
|
||||||
|
#define USART1_H_
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "USART_COM.h"
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
extern USART_TypeDef USART1_ADR;
|
||||||
|
extern USART_HANDLER_TYPE USART1STR;
|
||||||
|
extern USART_INTERFACE_TYPE USART1_INTERFACE;
|
||||||
|
extern USART_IDIBUS_ROUTINE_TYPE USART1_IDIBUS;
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#define USART1_BUF_SIZE IDIMMES_MAX_MES_SIZE + 1 // Buffer size
|
||||||
|
extern uint8_t USART1_RX_BUF[USART1_BUF_SIZE]; // RX buffer
|
||||||
|
extern uint8_t USART1_TX_BUF[USART1_BUF_SIZE]; // TX buffer
|
||||||
|
|
||||||
|
void USART1_Init(void);
|
||||||
|
void USART1_SetBaudrate(uint32_t Boudrate);
|
||||||
|
|
||||||
|
//inline void USART1_IRQN_HANDLER(void);
|
||||||
|
//inline void USART1_RX_TIMER_HANDLER(void);
|
||||||
|
|
||||||
|
void USART1_SendByteBuf(uint8_t *Buf, uint16_t Count);
|
||||||
|
void USART1_SendTxBuf(uint16_t Count);
|
||||||
|
uint8_t USART1_IsTxActive(void);
|
||||||
|
uint8_t USART1_IsNewRxMessage(void);
|
||||||
|
uint8_t USART1_IsRxError(void);
|
||||||
|
uint16_t USART1_getRxBufSize(void);
|
||||||
|
void USART1_copyRxBuf(uint8_t *Dst, uint16_t StartPos, uint16_t Count);
|
||||||
|
uint8_t *USART1_getRxBuf(void);
|
||||||
|
uint8_t *USART1_getTxBuf(void);
|
||||||
|
void USART1_RxTransferRestart(void);
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void USART1_SetIdiBusBoudrate(enum IDIBUS_SERIAL_BAUDRATE BoudrateCode);
|
||||||
|
void USART1_RxAlarmFrameStart(void);
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* USART1_H_ */
|
||||||
@ -0,0 +1,72 @@
|
|||||||
|
//#############################################################################################################################################################################################################
|
||||||
|
#ifndef _INC_USART_COM_H_
|
||||||
|
#define _INC_USART_COM_H_
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//#include "stm32f4xx.h"
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <string.h>
|
||||||
|
//#include "SYSTEM.h"
|
||||||
|
//#include "CUST_GPIO.h"
|
||||||
|
//#include "TIMERS.h"
|
||||||
|
#include "IDIBUS_DEFS.h"
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#ifdef __ATmega328PB__ //Maybe move this
|
||||||
|
#include "m328pb_defs.h"
|
||||||
|
#endif // #ifdef _CPU_ATMEGA328PB_
|
||||||
|
#ifdef __ATmega1280__
|
||||||
|
#include "m2560_defs.h"
|
||||||
|
#endif // _CPU_ATMEGA2560_
|
||||||
|
#ifdef __ATmega2560__
|
||||||
|
#include "m2560_defs.h"
|
||||||
|
#endif // _CPU_ATMEGA2560_
|
||||||
|
#ifdef __ATmega128__
|
||||||
|
#include "m128_defs.h"
|
||||||
|
#endif // _CPU_ATMEGA2560_
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
typedef struct {
|
||||||
|
volatile uint8_t *UCRSA;
|
||||||
|
volatile uint8_t *UCRSB;
|
||||||
|
volatile uint8_t *UCRSC;
|
||||||
|
volatile uint8_t *UBRRL;
|
||||||
|
volatile uint8_t *UBRRH;
|
||||||
|
volatile uint8_t *UDR;
|
||||||
|
} USART_TypeDef;
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
typedef struct {
|
||||||
|
USART_TypeDef *USART;
|
||||||
|
//DMA_Stream_TypeDef *DMATX;
|
||||||
|
|
||||||
|
uint8_t *TX_BUF;
|
||||||
|
uint8_t *RX_BUF;
|
||||||
|
uint16_t TxBufCount;
|
||||||
|
//uint16_t TxPacketSize;
|
||||||
|
uint16_t TxSendedCount;
|
||||||
|
uint16_t RxBufCount;
|
||||||
|
|
||||||
|
volatile uint8_t TxComplete;
|
||||||
|
uint8_t RxError;
|
||||||
|
uint8_t RxComplete;
|
||||||
|
|
||||||
|
uint16_t InterFrameTimeoutTicks; //Currently there are ticks for timer
|
||||||
|
} USART_HANDLER_TYPE;
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
typedef struct {
|
||||||
|
uint8_t TimerMode;
|
||||||
|
uint16_t ResponseTimeoutUS;
|
||||||
|
uint16_t AlarmTimeoutUS;
|
||||||
|
volatile uint8_t ResponseTimeoutComplete;
|
||||||
|
void (*SetIdiBusBoudrate)(enum IDIBUS_SERIAL_BAUDRATE);
|
||||||
|
void (*RxAlarmFrameStart)(void);
|
||||||
|
} USART_IDIBUS_ROUTINE_TYPE;
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif //_INC_USART_COM_H_
|
||||||
|
//#############################################################################################################################################################################################################
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
// USARTCUSTOM (FOR 2560)
|
||||||
|
#define USART2_TX_DDR DDRH
|
||||||
|
#define USART2_TX_PORT PORTH
|
||||||
|
#define USART2_TX_BIT 1
|
||||||
|
#define USART2_RX_DDR DDRH
|
||||||
|
#define USART2_RX_PORT PORTH
|
||||||
|
#define USART2_RX_BIT 0
|
||||||
|
// USARTCUSTOM (FOR 2560)
|
||||||
|
#define USART1_TX_DDR DDRD
|
||||||
|
#define USART1_TX_PORT PORTD
|
||||||
|
#define USART1_TX_BIT 3
|
||||||
|
#define USART1_RX_DDR DDRD
|
||||||
|
#define USART1_RX_PORT PORTD
|
||||||
|
#define USART1_RX_BIT 2
|
||||||
|
#define USART1_DRE_DDR DDRD
|
||||||
|
#define USART1_DRE_PORT PORTD
|
||||||
|
#define USART1_DRE_BIT 4
|
||||||
|
// USARTCUSTOM (FOR 2560)
|
||||||
|
#define USART0_TX_DDR DDRE
|
||||||
|
#define USART0_TX_PORT PORTE
|
||||||
|
#define USART0_TX_BIT 1
|
||||||
|
#define USART0_RX_DDR DDRE
|
||||||
|
#define USART0_RX_PORT PORTE
|
||||||
|
#define USART0_RX_BIT 0
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
// USARTCUSTOM (FOR 128)
|
||||||
|
#define USART1_TX_DDR DDRD
|
||||||
|
#define USART1_TX_PORT PORTD
|
||||||
|
#define USART1_TX_BIT 3
|
||||||
|
#define USART1_RX_DDR DDRD
|
||||||
|
#define USART1_RX_PORT PORTD
|
||||||
|
#define USART1_RX_BIT 2
|
||||||
|
#define USART1_DRE_DDR DDRD
|
||||||
|
#define USART1_DRE_PORT PORTD
|
||||||
|
#define USART1_DRE_BIT 4
|
||||||
|
// USARTCUSTOM (FOR 128)
|
||||||
|
#define USART0_TX_DDR DDRE
|
||||||
|
#define USART0_TX_PORT PORTE
|
||||||
|
#define USART0_TX_BIT 1
|
||||||
|
#define USART0_RX_DDR DDRE
|
||||||
|
#define USART0_RX_PORT PORTE
|
||||||
|
#define USART0_RX_BIT 0
|
||||||
|
|
||||||
|
// EEPROM compatibility with newer MCUs
|
||||||
|
#define EEMPE EEMWE
|
||||||
|
#define EEPE EEWE
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
// USARTCUSTOM (FOR 2560)
|
||||||
|
#define USART2_TX_DDR DDRH
|
||||||
|
#define USART2_TX_PORT PORTH
|
||||||
|
#define USART2_TX_BIT 1
|
||||||
|
#define USART2_RX_DDR DDRH
|
||||||
|
#define USART2_RX_PORT PORTH
|
||||||
|
#define USART2_RX_BIT 0
|
||||||
|
// USARTCUSTOM (FOR 2560)
|
||||||
|
#define USART1_TX_DDR DDRD
|
||||||
|
#define USART1_TX_PORT PORTD
|
||||||
|
#define USART1_TX_BIT 3
|
||||||
|
#define USART1_RX_DDR DDRD
|
||||||
|
#define USART1_RX_PORT PORTD
|
||||||
|
#define USART1_RX_BIT 2
|
||||||
|
#define USART1_DRE_DDR DDRD
|
||||||
|
#define USART1_DRE_PORT PORTD
|
||||||
|
#define USART1_DRE_BIT 4
|
||||||
|
// USARTCUSTOM (FOR 2560)
|
||||||
|
#define USART0_TX_DDR DDRE
|
||||||
|
#define USART0_TX_PORT PORTE
|
||||||
|
#define USART0_TX_BIT 1
|
||||||
|
#define USART0_RX_DDR DDRE
|
||||||
|
#define USART0_RX_PORT PORTE
|
||||||
|
#define USART0_RX_BIT 0
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
//USART CUSTOM (FOR 328pb)
|
||||||
|
#define USART0_TX_DDR DDRD
|
||||||
|
#define USART0_TX_PORT PORTD
|
||||||
|
#define USART0_TX_BIT 1
|
||||||
|
#define USART0_RX_DDR DDRD
|
||||||
|
#define USART0_RX_PORT PORTD
|
||||||
|
#define USART0_RX_BIT 0
|
||||||
|
|
||||||
|
//USART CUSTOM (FOR 328pb)
|
||||||
|
#define USART1_TX_DDR DDRB
|
||||||
|
#define USART1_TX_PORT PORTB
|
||||||
|
#define USART1_TX_BIT 3
|
||||||
|
#define USART1_RX_DDR DDRB
|
||||||
|
#define USART1_RX_PORT PORTB
|
||||||
|
#define USART1_RX_BIT 4
|
||||||
|
#define USART1_DRE_DDR DDRB
|
||||||
|
#define USART1_DRE_PORT PORTB
|
||||||
|
#define USART1_DRE_BIT 5
|
||||||
|
|
||||||
@ -0,0 +1,81 @@
|
|||||||
|
#ifndef CONFIG_H_
|
||||||
|
#define CONFIG_H_
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
//Consfigure project
|
||||||
|
|
||||||
|
//#define _NO_BOOTLOADER_
|
||||||
|
#define _DEBUG_
|
||||||
|
|
||||||
|
//Choose one
|
||||||
|
//#define _SLAVE_MODULE_
|
||||||
|
#define _SLAVE_EXT_
|
||||||
|
//#define _CUSTOM_TYPE_
|
||||||
|
|
||||||
|
//After this see idibus_hw.h to change PIN definition
|
||||||
|
|
||||||
|
//Done!
|
||||||
|
|
||||||
|
|
||||||
|
//For 328pb
|
||||||
|
#ifdef __ATmega328PB__
|
||||||
|
|
||||||
|
#define PAGE_SIZE 128UL
|
||||||
|
#define PAGE_SIZE_BIT 7
|
||||||
|
|
||||||
|
//DONT FORGET TO CHANGE LINKER OPTIONS!!!!
|
||||||
|
#define locationInBoot (0x3FE8UL) //CAREFUL ONLY 48 byte in size for data
|
||||||
|
#define locationInApp (0x37C0UL)
|
||||||
|
|
||||||
|
#define SRAM_size 2048UL
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//For 2560
|
||||||
|
#ifdef __ATmega2560__
|
||||||
|
|
||||||
|
#define _LONG_ADDR_SPACE_
|
||||||
|
#define _FAT_CRC_
|
||||||
|
|
||||||
|
#define PAGE_SIZE 256ULL
|
||||||
|
#define PAGE_SIZE_BIT 8
|
||||||
|
|
||||||
|
//Settings in the linker
|
||||||
|
#define locationInBoot (0x1FF80ULL)
|
||||||
|
#define locationInApp (0x1EF80ULL)
|
||||||
|
|
||||||
|
#define SRAM_size 8192UL
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//For 1280
|
||||||
|
#ifdef __ATmega1280__
|
||||||
|
|
||||||
|
#define _LONG_ADDR_SPACE_
|
||||||
|
#define _FAT_CRC_
|
||||||
|
|
||||||
|
#define PAGE_SIZE 256ULL
|
||||||
|
#define PAGE_SIZE_BIT 8
|
||||||
|
|
||||||
|
//Settings in the linker
|
||||||
|
#define locationInBoot (0x0FF80ULL)
|
||||||
|
#define locationInApp (0x0EF80ULL)
|
||||||
|
|
||||||
|
|
||||||
|
#define SRAM_size 8192UL
|
||||||
|
|
||||||
|
#endif
|
||||||
|
//COMMON Define
|
||||||
|
#define PAGE_COUNT (((locationInApp<<1)/PAGE_SIZE)+1)
|
||||||
|
|
||||||
|
#ifdef _LONG_ADDR_SPACE_
|
||||||
|
#define FLASH_ADDR_T uint_farptr_t
|
||||||
|
#else
|
||||||
|
#define FLASH_ADDR_T uint16_t
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* CONFIG_H_ */
|
||||||
@ -0,0 +1,220 @@
|
|||||||
|
//#############################################################################
|
||||||
|
// idibus_custom.h implementation
|
||||||
|
//#############################################################################
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "IdiBusSlave.h"
|
||||||
|
#include "idibus_hw.h"
|
||||||
|
|
||||||
|
#include "USART1.h"
|
||||||
|
#include "SYSTEM.h"
|
||||||
|
|
||||||
|
#include "IDIBUS_IMPL.h"
|
||||||
|
#include "RSLink.h"
|
||||||
|
#include "MEMORY.h"
|
||||||
|
|
||||||
|
// ÍÅ ÈÑÏÎËÜÇÓÉÒÅ ÎÁÙÈÅ ÏÅÐÅÌÅÍÍÛÅ ÄËß ÑÂßÇÈ ÊÎÌÏîÍÅÍÒΠÌÅÆÄÓ ÑÎÁÎÉ ÏÎÆÀË+ÉÑÒÀ
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
// IMPLEMENTATION SECTION
|
||||||
|
//=============================================================================
|
||||||
|
/*
|
||||||
|
* Define your specific logic for slave module
|
||||||
|
* Required:
|
||||||
|
* Init
|
||||||
|
* Shutdown
|
||||||
|
* And any other custom functions for your needs
|
||||||
|
*/
|
||||||
|
//Make prototypes for channel handlers
|
||||||
|
static void IDIBUS_XXX_NAME_ChannelHandler(idibus_channel_t* CH, idibus_farg_t* farg);
|
||||||
|
|
||||||
|
//Enumerate channels and assign functions to them
|
||||||
|
static idibus_channel_t IDIBUS_XXX_NAME_Channels[IDIBUS_XXX_NAME_CH_NUM] =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
.ChNum = 0,
|
||||||
|
.CH_Func = IDIBUS_XXX_NAME_ChannelHandler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.ChNum = 1,
|
||||||
|
.CH_Func = IDIBUS_XXX_NAME_ChannelHandler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.ChNum = 2,
|
||||||
|
.CH_Func = IDIBUS_XXX_NAME_ChannelHandler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.ChNum = 3,
|
||||||
|
.CH_Func = IDIBUS_XXX_NAME_ChannelHandler,
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//List all devices and their channels
|
||||||
|
static idibus_device_t IDIBUS_Devices[XXX_NAME_DEVICES_NUMBER] =
|
||||||
|
{
|
||||||
|
{IDIBUS_XXX_NAME_Channels, IDIBUS_XXX_NAME_CH_NUM},
|
||||||
|
};
|
||||||
|
//Common module configuration
|
||||||
|
//Change on your own risk;
|
||||||
|
static idibus_slave_module_t IDIBUS_MODULE =
|
||||||
|
{
|
||||||
|
.Devices = IDIBUS_Devices,
|
||||||
|
.DevicesCount = XXX_NAME_DEVICES_NUMBER,
|
||||||
|
.STATUS.STATE.B0S.StError = 0,
|
||||||
|
.STATUS.STATE.B0S.StState = IDISTATUS_B0S_ST_STATE_StOperate,
|
||||||
|
.STATUS.STATE.B0S.AesSupported = 0,
|
||||||
|
.STATUS.STATE.B0S.AesInstalled = 0,
|
||||||
|
.STATUS.STATE.B0S.SendAlarmL0 = 0,
|
||||||
|
.STATUS.STATE.B0S.SendAlarmL1 = 0,
|
||||||
|
|
||||||
|
.STATUS.STATE.B1S.ModuleType = IDISTATUS_B1S_MODULE_TYPE_Slave,
|
||||||
|
.STATUS.STATE.B1S.BridgeConnected = 0,
|
||||||
|
.STATUS.STATE.B1S.SelfInit = 1,
|
||||||
|
.STATUS.STATE.B1S.TimeoutLed = 1,
|
||||||
|
.STATUS.STATE.B1S.NoMMESTimeout = 0,
|
||||||
|
.STATUS.STATE.B1S.CatchAlarmL0 = 0,
|
||||||
|
.STATUS.STATE.B1S.CatchAlarmL1 = 0,
|
||||||
|
};
|
||||||
|
#define IDIBUS_READ_VAR(farg, DATA){\
|
||||||
|
if (farg->InpDataLength != 0)\
|
||||||
|
{\
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);\
|
||||||
|
}\
|
||||||
|
else\
|
||||||
|
{\
|
||||||
|
uint8_t ResponseData[sizeof(DATA)] = {0};\
|
||||||
|
memcpy(ResponseData, &DATA, sizeof(DATA));\
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, ResponseData, sizeof(ResponseData), IDIER_NOPE);\
|
||||||
|
}\
|
||||||
|
}
|
||||||
|
#define IDIBUS_WRITE_VAR(farg, DATA){\
|
||||||
|
if (farg->InpDataLength == sizeof(DATA))\
|
||||||
|
{\
|
||||||
|
memcpy(&DATA, farg->InpData, sizeof(DATA));\
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIER_NOPE);\
|
||||||
|
}\
|
||||||
|
else\
|
||||||
|
{\
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_INVALID_RX_REQUEST_FORMAT);\
|
||||||
|
}\
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Channel Handler
|
||||||
|
// This sequence is for a single channel CH->ChNum
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//memcpy(to, from, num);
|
||||||
|
static void IDIBUS_XXX_NAME_ChannelHandler(idibus_channel_t* CH, idibus_farg_t* farg)
|
||||||
|
{
|
||||||
|
//Check for msg and operations
|
||||||
|
if (IDIBUS_CnannelStaticFunc(CH, farg) != 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//Catch channel error
|
||||||
|
if (CH->ChNum >= IDIBUS_XXX_NAME_CH_NUM)
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERDEV_INVALID_CHN_NUM);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* After all checks proccess the command
|
||||||
|
* This sequence is for a single channel CH->ChNum
|
||||||
|
* Use farg->ComFunc to define command
|
||||||
|
* Use farg->InpData and farg->InpDataLength to read recieved data
|
||||||
|
* Two types of command is used READ and WRITE
|
||||||
|
* For ecxlusive actions write your own handler
|
||||||
|
*/
|
||||||
|
switch (farg->ComFunc)
|
||||||
|
{
|
||||||
|
case (XXX_NAME_STATUS_CMD):
|
||||||
|
{
|
||||||
|
IDIBUS_READ_VAR(farg, XXX_NAME_channels_data[CH->ChNum].status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (XXX_NAME_GET_CMD):
|
||||||
|
{
|
||||||
|
IDIBUS_READ_VAR(farg, XXX_NAME_channels_data[CH->ChNum].ch_data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case (XXX_NAME_SET_CMD):
|
||||||
|
{
|
||||||
|
IDIBUS_WRITE_VAR(farg, XXX_NAME_channels_data[CH->ChNum].ch_data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
IDIBUS_ResponseProtectedWrite(farg, NULL, 0, IDIERSLV_UNSUPPORTED_FUNC_NUM);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Custom Initialization
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
static void IDIBUS_Init() //Idibus only init!
|
||||||
|
{
|
||||||
|
for (uint8_t dev = 0; dev < XXX_NAME_DEVICES_NUMBER; dev ++)
|
||||||
|
{
|
||||||
|
for (uint8_t I = 0; I < IDIBUS_MODULE.Devices[dev].ChannelsCount; I++)
|
||||||
|
{
|
||||||
|
IDIBUS_MODULE.Devices[dev].Channels[I].ChNum = I;
|
||||||
|
IDIBUS_MODULE.Devices[dev].Channels[I].LONG_OP.Type = 0;
|
||||||
|
IDIBUS_MODULE.Devices[dev].Channels[I].LONG_OP.State =
|
||||||
|
IDILONGOP_STATE_COMPLETE_NO_ERR;
|
||||||
|
IDIBUS_MODULE.Devices[dev].Channels[I].BcastAddr =
|
||||||
|
IDIBUS_GROUP_0_ADDR;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// IdiBus Initialization
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void IdiBusSlaveInit()
|
||||||
|
{
|
||||||
|
// Idibus dedicated hardware init
|
||||||
|
System_InitSysTick();
|
||||||
|
System_SystickTimerStart();
|
||||||
|
USART1_Init();
|
||||||
|
|
||||||
|
RSLink_StatusLedInit();
|
||||||
|
|
||||||
|
wdt_reset();
|
||||||
|
//Rslink hardware registration
|
||||||
|
rslink_func_pack_t rslink_hw =
|
||||||
|
{
|
||||||
|
.dips_init = RSLink_DipsInit,
|
||||||
|
.disp_read_addr = RSLink_AddrDecode,
|
||||||
|
.disp_read_speed = RSLink_SpeedDecode,
|
||||||
|
.status_led_init = RSLink_StatusLedInit,
|
||||||
|
.status_led_off = RSLink_StatusLedSetOff,
|
||||||
|
.status_led_on = RSLink_StatusLedSetOn,
|
||||||
|
};
|
||||||
|
//Register hardware and configuration
|
||||||
|
RSLink_register_hw_functions(rslink_hw);
|
||||||
|
IDIBUS_Init();
|
||||||
|
//Executes on c_Init
|
||||||
|
//IdiBus_register_init();
|
||||||
|
//Executes on c_Shutdown
|
||||||
|
//IdiBus_register_shutdown();
|
||||||
|
|
||||||
|
wdt_reset();
|
||||||
|
//Do a complete init of IdiBus
|
||||||
|
RSLlink_pass_module(&IDIBUS_MODULE);
|
||||||
|
IdiBus_pass_module(&IDIBUS_MODULE);
|
||||||
|
#ifdef _LONG_ADDR_SPACE_
|
||||||
|
IdiBus_ModuleInit(&USART1_INTERFACE, (uint_farptr_t)(locationInApp*2));
|
||||||
|
#else
|
||||||
|
IdiBus_ModuleInit(&USART1_INTERFACE, (uint8_t*)(locationInApp*2));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
RSLink_Init(&USART1_INTERFACE, &USART1_IDIBUS);
|
||||||
|
wdt_reset();
|
||||||
|
}
|
||||||
@ -0,0 +1,107 @@
|
|||||||
|
#include "idibus_hw.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
// RSLINK MCU SPECIFIC FUNCTIONS SECTION
|
||||||
|
// This example is typical Idibus_Ext with shift register
|
||||||
|
//=============================================================================
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Status LED functions
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void RSLink_StatusLedInit(void) // Status led Init
|
||||||
|
{
|
||||||
|
RSLINK_LED_DDR|=1<<RSLINK_LED_BIT;
|
||||||
|
RSLINK_LED_PORT&=~(1<<RSLINK_LED_BIT);
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void RSLink_StatusLedSetOn(void) // Status led On
|
||||||
|
{
|
||||||
|
RSLINK_LED_PORT|=1<<RSLINK_LED_BIT;
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void RSLink_StatusLedSetOff(void) // Status led Off
|
||||||
|
{
|
||||||
|
RSLINK_LED_PORT&=~(1<<RSLINK_LED_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _SLAVE_MODULE_
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
// FOR 328pb
|
||||||
|
void RSLink_DipsInit(void) // Dip switch Adders, Speed, Bus Type Init
|
||||||
|
{
|
||||||
|
RSLINK_ADDR_DDR&=~(RSLINK_ADDR_MASK);
|
||||||
|
RSLINK_ADDR_PORT&=~(RSLINK_ADDR_MASK);
|
||||||
|
RSLINK_SPEED_DDR&=~(RSLINK_SPEED_MASK);
|
||||||
|
RSLINK_SPEED_PORT&=~(RSLINK_SPEED_MASK);
|
||||||
|
}
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
uint8_t RSLink_SpeedDecode(void)
|
||||||
|
{
|
||||||
|
return (RSLINK_SPEED_PIN)&RSLINK_SPEED_MASK;
|
||||||
|
}
|
||||||
|
uint8_t RSLink_AddrDecode(void)
|
||||||
|
{
|
||||||
|
return RSLINK_ADDR_PIN&RSLINK_ADDR_MASK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _SLAVE_EXT_
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// DIP switch functions (FOR 328pb)
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void RSLink_DipsInit(void) // Dip switch Adders, Speed, Bus Type Init
|
||||||
|
{
|
||||||
|
// Clock, output -> 1
|
||||||
|
RSLINK_DIPS_CP_DDR |= (1 << RSLINK_DIPS_CP_BIT);
|
||||||
|
RSLINK_DIPS_CP_PORT |= (1 << RSLINK_DIPS_CP_BIT);
|
||||||
|
|
||||||
|
// Latch, output -> 1
|
||||||
|
RSLINK_DIPS_nPL_DDR |= (1 << RSLINK_DIPS_nPL_BIT);
|
||||||
|
RSLINK_DIPS_nPL_PORT |= (1 << RSLINK_DIPS_nPL_BIT);
|
||||||
|
|
||||||
|
// Data, input
|
||||||
|
RSLINK_DIPS_Q7_DDR &= ~(1 << RSLINK_DIPS_Q7_BIT);
|
||||||
|
RSLINK_DIPS_Q7_PORT &= ~(1 << RSLINK_DIPS_Q7_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
static uint16_t RSLink_DipsRead(void) // Dip switch Adders, Speed, Bus Type Read
|
||||||
|
{
|
||||||
|
// RESULT = [ADDR7...0][XXXX][TYPE][SS2...0]
|
||||||
|
RSLINK_DIPS_nPL_PORT &= ~(1 << RSLINK_DIPS_nPL_BIT);
|
||||||
|
|
||||||
|
uint16_t STATE = 0;
|
||||||
|
RSLINK_DIPS_nPL_PORT |= (1 << RSLINK_DIPS_nPL_BIT);
|
||||||
|
|
||||||
|
for (uint8_t I = 0; I < 16; I++)
|
||||||
|
{
|
||||||
|
STATE = STATE << 1;
|
||||||
|
RSLINK_DIPS_CP_PORT &= ~(1 << RSLINK_DIPS_CP_BIT);
|
||||||
|
|
||||||
|
if ((RSLINK_DIPS_Q7_PIN & (1 << RSLINK_DIPS_Q7_BIT)) != 0)
|
||||||
|
{
|
||||||
|
STATE |= 0x0001;
|
||||||
|
}
|
||||||
|
|
||||||
|
RSLINK_DIPS_CP_PORT |= (1 << RSLINK_DIPS_CP_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
return STATE & 0xFF0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
uint8_t RSLink_SpeedDecode()
|
||||||
|
{
|
||||||
|
return (uint8_t)(RSLink_DipsRead() & 0x07);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t RSLink_AddrDecode()
|
||||||
|
{
|
||||||
|
return (uint8_t)(RSLink_DipsRead() >> 8);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _CUSTOM_TYPE_
|
||||||
|
//Define custom type here
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* File: idibus_hw.h
|
||||||
|
* Author: Michail
|
||||||
|
*
|
||||||
|
* Created on 20 ÿíâàðÿ 2026 ã., 16:12
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef IDIBUS_HW_H
|
||||||
|
#define IDIBUS_HW_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
#include "config.h"
|
||||||
|
//=============================================================================
|
||||||
|
// RSLINK SECTION
|
||||||
|
// Define specific macros for MCU
|
||||||
|
// Currently supports Ext with shift register and modules with address
|
||||||
|
// and speed on two different ports
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Status LED
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#define RSLINK_LED_DDR DDRB
|
||||||
|
#define RSLINK_LED_PORT PORTB
|
||||||
|
#define RSLINK_LED_PIN PINB
|
||||||
|
#define RSLINK_LED_BIT 0
|
||||||
|
|
||||||
|
#ifdef _SLAVE_EXT_
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// DIP switch - Address, Speed, Bus Type
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#define RSLINK_DIPS_CP_PORT PORTD
|
||||||
|
#define RSLINK_DIPS_CP_DDR DDRD
|
||||||
|
#define RSLINK_DIPS_CP_PIN PIND
|
||||||
|
#define RSLINK_DIPS_CP_BIT 7
|
||||||
|
|
||||||
|
#define RSLINK_DIPS_nPL_PORT PORTD
|
||||||
|
#define RSLINK_DIPS_nPL_DDR DDRD
|
||||||
|
#define RSLINK_DIPS_nPL_PIN PIND
|
||||||
|
#define RSLINK_DIPS_nPL_BIT 6
|
||||||
|
|
||||||
|
#define RSLINK_DIPS_Q7_PORT PORTD
|
||||||
|
#define RSLINK_DIPS_Q7_DDR DDRD
|
||||||
|
#define RSLINK_DIPS_Q7_PIN PIND
|
||||||
|
#define RSLINK_DIPS_Q7_BIT 5
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _SLAVE_MODULE_
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Dip switch Adders, Speed, Bus Type
|
||||||
|
#define RSLINK_ADDR_DDR DDRA
|
||||||
|
#define RSLINK_ADDR_PORT PORTA
|
||||||
|
#define RSLINK_ADDR_PIN PINA
|
||||||
|
#define RSLINK_ADDR_MASK 0xFF
|
||||||
|
|
||||||
|
#define RSLINK_SPEED_DDR DDRL
|
||||||
|
#define RSLINK_SPEED_PORT PORTL
|
||||||
|
#define RSLINK_SPEED_PIN PINL
|
||||||
|
#define RSLINK_SPEED_MASK 0b111
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _CUSTOM_TYPE_
|
||||||
|
//Define custom type here
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void RSLink_StatusLedInit(void);
|
||||||
|
void RSLink_StatusLedSetOn(void);
|
||||||
|
void RSLink_StatusLedSetOff(void);
|
||||||
|
|
||||||
|
void RSLink_DipsInit(void);
|
||||||
|
uint8_t RSLink_SpeedDecode(void);
|
||||||
|
uint8_t RSLink_AddrDecode(void);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* IDIBUS_HW_H */
|
||||||
|
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// File to configure device
|
||||||
|
#include "config.h" // <-------Look here first!----------------------
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/wdt.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "IdiBusSlave.h"
|
||||||
|
#include "RSLink.h"
|
||||||
|
#include "IdiBusSlave.h"
|
||||||
|
|
||||||
|
#ifdef _NO_BOOTLOADER_
|
||||||
|
FUSES=
|
||||||
|
{
|
||||||
|
.extended=0xFC,
|
||||||
|
.high = 0x01,
|
||||||
|
.low = 0xE0
|
||||||
|
}; // Fuses + Lock programming
|
||||||
|
LOCKBITS=0xFF;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
extern void IdiBusSlaveInit(void);
|
||||||
|
//##############################################################################
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
cli(); // INTR OFF
|
||||||
|
// Enable wdt
|
||||||
|
wdt_enable(WDTO_2S);
|
||||||
|
wdt_reset();
|
||||||
|
IdiBusSlaveInit(); // See idibus_custom.c file
|
||||||
|
sei(); // INTR ON
|
||||||
|
SlaveInit();
|
||||||
|
wdt_reset();
|
||||||
|
//Init done!
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
SlaveLoop();
|
||||||
|
RSLink_Handler();
|
||||||
|
wdt_reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//##############################################################################
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
#include "IdiBusSlave.h"
|
||||||
|
#include "IDIBUS_IMPL.h"
|
||||||
|
|
||||||
|
//Structure that holds module's data
|
||||||
|
XXX_NAME_channel_data_t XXX_NAME_channels_data[IDIBUS_XXX_NAME_CH_NUM];
|
||||||
|
|
||||||
|
static void custom_init()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
static void custom_shutdown()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
static void custom_freeze()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
static void custom_resume()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void SlaveInit()//Intr is ON
|
||||||
|
{
|
||||||
|
//Hardware init
|
||||||
|
//...
|
||||||
|
//You can register custom c_Init or c_Shutdown here via IdiBus_register_xxx
|
||||||
|
IdiBus_register_init(custom_init);
|
||||||
|
IdiBus_register_shutdown(custom_shutdown);
|
||||||
|
IdiBus_register_freeze(custom_freeze);
|
||||||
|
IdiBus_register_resume(custom_resume);
|
||||||
|
}
|
||||||
|
void SlaveLoop()
|
||||||
|
{
|
||||||
|
//Read any data that can change in channels data
|
||||||
|
//...
|
||||||
|
//Do some app logic
|
||||||
|
//..
|
||||||
|
//Update channel data
|
||||||
|
//Exit
|
||||||
|
}
|
||||||
@ -0,0 +1,113 @@
|
|||||||
|
#
|
||||||
|
# There exist several targets which are by default empty and which can be
|
||||||
|
# used for execution of your targets. These targets are usually executed
|
||||||
|
# before and after some main targets. They are:
|
||||||
|
#
|
||||||
|
# .build-pre: called before 'build' target
|
||||||
|
# .build-post: called after 'build' target
|
||||||
|
# .clean-pre: called before 'clean' target
|
||||||
|
# .clean-post: called after 'clean' target
|
||||||
|
# .clobber-pre: called before 'clobber' target
|
||||||
|
# .clobber-post: called after 'clobber' target
|
||||||
|
# .all-pre: called before 'all' target
|
||||||
|
# .all-post: called after 'all' target
|
||||||
|
# .help-pre: called before 'help' target
|
||||||
|
# .help-post: called after 'help' target
|
||||||
|
#
|
||||||
|
# Targets beginning with '.' are not intended to be called on their own.
|
||||||
|
#
|
||||||
|
# Main targets can be executed directly, and they are:
|
||||||
|
#
|
||||||
|
# build build a specific configuration
|
||||||
|
# clean remove built files from a configuration
|
||||||
|
# clobber remove all built files
|
||||||
|
# all build all configurations
|
||||||
|
# help print help mesage
|
||||||
|
#
|
||||||
|
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
|
||||||
|
# .help-impl are implemented in nbproject/makefile-impl.mk.
|
||||||
|
#
|
||||||
|
# Available make variables:
|
||||||
|
#
|
||||||
|
# CND_BASEDIR base directory for relative paths
|
||||||
|
# CND_DISTDIR default top distribution directory (build artifacts)
|
||||||
|
# CND_BUILDDIR default top build directory (object files, ...)
|
||||||
|
# CONF name of current configuration
|
||||||
|
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
|
||||||
|
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
|
||||||
|
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
|
||||||
|
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
|
||||||
|
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
|
||||||
|
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
|
||||||
|
#
|
||||||
|
# NOCDDL
|
||||||
|
|
||||||
|
|
||||||
|
# Environment
|
||||||
|
MKDIR=mkdir
|
||||||
|
CP=cp
|
||||||
|
CCADMIN=CCadmin
|
||||||
|
RANLIB=ranlib
|
||||||
|
|
||||||
|
|
||||||
|
# build
|
||||||
|
build: .build-post
|
||||||
|
|
||||||
|
.build-pre:
|
||||||
|
# Add your pre 'build' code here...
|
||||||
|
|
||||||
|
.build-post: .build-impl
|
||||||
|
# Add your post 'build' code here...
|
||||||
|
|
||||||
|
|
||||||
|
# clean
|
||||||
|
clean: .clean-post
|
||||||
|
|
||||||
|
.clean-pre:
|
||||||
|
# Add your pre 'clean' code here...
|
||||||
|
# WARNING: the IDE does not call this target since it takes a long time to
|
||||||
|
# simply run make. Instead, the IDE removes the configuration directories
|
||||||
|
# under build and dist directly without calling make.
|
||||||
|
# This target is left here so people can do a clean when running a clean
|
||||||
|
# outside the IDE.
|
||||||
|
|
||||||
|
.clean-post: .clean-impl
|
||||||
|
# Add your post 'clean' code here...
|
||||||
|
|
||||||
|
|
||||||
|
# clobber
|
||||||
|
clobber: .clobber-post
|
||||||
|
|
||||||
|
.clobber-pre:
|
||||||
|
# Add your pre 'clobber' code here...
|
||||||
|
|
||||||
|
.clobber-post: .clobber-impl
|
||||||
|
# Add your post 'clobber' code here...
|
||||||
|
|
||||||
|
|
||||||
|
# all
|
||||||
|
all: .all-post
|
||||||
|
|
||||||
|
.all-pre:
|
||||||
|
# Add your pre 'all' code here...
|
||||||
|
|
||||||
|
.all-post: .all-impl
|
||||||
|
# Add your post 'all' code here...
|
||||||
|
|
||||||
|
|
||||||
|
# help
|
||||||
|
help: .help-post
|
||||||
|
|
||||||
|
.help-pre:
|
||||||
|
# Add your pre 'help' code here...
|
||||||
|
|
||||||
|
.help-post: .help-impl
|
||||||
|
# Add your post 'help' code here...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# include project implementation makefile
|
||||||
|
include nbproject/Makefile-impl.mk
|
||||||
|
|
||||||
|
# include project make variables
|
||||||
|
include nbproject/Makefile-variables.mk
|
||||||
@ -0,0 +1,301 @@
|
|||||||
|
#
|
||||||
|
# Generated Makefile - do not edit!
|
||||||
|
#
|
||||||
|
# Edit the Makefile in the project folder instead (../Makefile). Each target
|
||||||
|
# has a -pre and a -post target defined where you can add customized code.
|
||||||
|
#
|
||||||
|
# This makefile implements configuration specific macros and targets.
|
||||||
|
|
||||||
|
|
||||||
|
# Include project Makefile
|
||||||
|
ifeq "${IGNORE_LOCAL}" "TRUE"
|
||||||
|
# do not include local makefile. User is passing all local related variables already
|
||||||
|
else
|
||||||
|
include Makefile
|
||||||
|
# Include makefile containing local settings
|
||||||
|
ifeq "$(wildcard nbproject/Makefile-local-default.mk)" "nbproject/Makefile-local-default.mk"
|
||||||
|
include nbproject/Makefile-local-default.mk
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Environment
|
||||||
|
MKDIR=gnumkdir -p
|
||||||
|
RM=rm -f
|
||||||
|
MV=mv
|
||||||
|
CP=cp
|
||||||
|
|
||||||
|
# Macros
|
||||||
|
CND_CONF=default
|
||||||
|
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
|
||||||
|
IMAGE_TYPE=debug
|
||||||
|
OUTPUT_SUFFIX=elf
|
||||||
|
DEBUGGABLE_SUFFIX=elf
|
||||||
|
FINAL_IMAGE=${DISTDIR}/IdiBusSlaveTemplate.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
|
||||||
|
else
|
||||||
|
IMAGE_TYPE=production
|
||||||
|
OUTPUT_SUFFIX=hex
|
||||||
|
DEBUGGABLE_SUFFIX=elf
|
||||||
|
FINAL_IMAGE=${DISTDIR}/IdiBusSlaveTemplate.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(COMPARE_BUILD), true)
|
||||||
|
COMPARISON_BUILD=
|
||||||
|
else
|
||||||
|
COMPARISON_BUILD=
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Object Directory
|
||||||
|
OBJECTDIR=build/${CND_CONF}/${IMAGE_TYPE}
|
||||||
|
|
||||||
|
# Distribution Directory
|
||||||
|
DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE}
|
||||||
|
|
||||||
|
# Source Files Quoted if spaced
|
||||||
|
SOURCEFILES_QUOTED_IF_SPACED=IdiBusCore/IdiBus/IDIBUS_IMPL.c IdiBusCore/IdiBus/RSLink.c IdiBusCore/Required/MEMORY.c IdiBusCore/Required/MODBUS_CRC.c IdiBusCore/Required/SYSTEM.c IdiBusCore/Required/USART1.c IdiBusCore/idibus_custom.c IdiBusCore/idibus_hw.c IdiBusCore/main.c IdiBusSlave.cpp
|
||||||
|
|
||||||
|
# Object Files Quoted if spaced
|
||||||
|
OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o ${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o ${OBJECTDIR}/IdiBusCore/Required/MEMORY.o ${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o ${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o ${OBJECTDIR}/IdiBusCore/Required/USART1.o ${OBJECTDIR}/IdiBusCore/idibus_custom.o ${OBJECTDIR}/IdiBusCore/idibus_hw.o ${OBJECTDIR}/IdiBusCore/main.o ${OBJECTDIR}/IdiBusSlave.o
|
||||||
|
POSSIBLE_DEPFILES=${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o.d ${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o.d ${OBJECTDIR}/IdiBusCore/Required/MEMORY.o.d ${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o.d ${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o.d ${OBJECTDIR}/IdiBusCore/Required/USART1.o.d ${OBJECTDIR}/IdiBusCore/idibus_custom.o.d ${OBJECTDIR}/IdiBusCore/idibus_hw.o.d ${OBJECTDIR}/IdiBusCore/main.o.d ${OBJECTDIR}/IdiBusSlave.o.d
|
||||||
|
|
||||||
|
# Object Files
|
||||||
|
OBJECTFILES=${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o ${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o ${OBJECTDIR}/IdiBusCore/Required/MEMORY.o ${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o ${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o ${OBJECTDIR}/IdiBusCore/Required/USART1.o ${OBJECTDIR}/IdiBusCore/idibus_custom.o ${OBJECTDIR}/IdiBusCore/idibus_hw.o ${OBJECTDIR}/IdiBusCore/main.o ${OBJECTDIR}/IdiBusSlave.o
|
||||||
|
|
||||||
|
# Source Files
|
||||||
|
SOURCEFILES=IdiBusCore/IdiBus/IDIBUS_IMPL.c IdiBusCore/IdiBus/RSLink.c IdiBusCore/Required/MEMORY.c IdiBusCore/Required/MODBUS_CRC.c IdiBusCore/Required/SYSTEM.c IdiBusCore/Required/USART1.c IdiBusCore/idibus_custom.c IdiBusCore/idibus_hw.c IdiBusCore/main.c IdiBusSlave.cpp
|
||||||
|
|
||||||
|
# Pack Options
|
||||||
|
PACK_COMPILER_OPTIONS=-I "${DFP_DIR}/include"
|
||||||
|
PACK_COMMON_OPTIONS=-B "${DFP_DIR}/gcc/dev/atmega328pb"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CFLAGS=
|
||||||
|
ASFLAGS=
|
||||||
|
LDLIBSOPTIONS=
|
||||||
|
|
||||||
|
############# Tool locations ##########################################
|
||||||
|
# If you copy a project from one host to another, the path where the #
|
||||||
|
# compiler is installed may be different. #
|
||||||
|
# If you open this project with MPLAB X in the new host, this #
|
||||||
|
# makefile will be regenerated and the paths will be corrected. #
|
||||||
|
#######################################################################
|
||||||
|
# fixDeps replaces a bunch of sed/cat/printf statements that slow down the build
|
||||||
|
FIXDEPS=fixDeps
|
||||||
|
|
||||||
|
# The following macros may be used in the pre and post step lines
|
||||||
|
_/_=\\
|
||||||
|
ShExtension=.bat
|
||||||
|
Device=ATmega328PB
|
||||||
|
ProjectDir="P:\IdiBus\Atmega\IdiBusSlaveTemplate"
|
||||||
|
ProjectName=IdiBusSlaveTemplate
|
||||||
|
ConfName=default
|
||||||
|
ImagePath="dist\default\${IMAGE_TYPE}\IdiBusSlaveTemplate.${IMAGE_TYPE}.${OUTPUT_SUFFIX}"
|
||||||
|
ImageDir="dist\default\${IMAGE_TYPE}"
|
||||||
|
ImageName="IdiBusSlaveTemplate.${IMAGE_TYPE}.${OUTPUT_SUFFIX}"
|
||||||
|
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
|
||||||
|
IsDebug="true"
|
||||||
|
else
|
||||||
|
IsDebug="false"
|
||||||
|
endif
|
||||||
|
MDFUHostPath="C:\Users\Michail\AppData\Roaming\mplab_ide\dev\v6.25\bin\windows\pymdfu-bin.exe"
|
||||||
|
PYFWImageBuilderPath="C:\Users\Michail\AppData\Roaming\mplab_ide\dev\v6.25\bin\windows\pyfwimagebuilder-bin.exe"
|
||||||
|
|
||||||
|
.build-conf: ${BUILD_SUBPROJECTS}
|
||||||
|
ifneq ($(INFORMATION_MESSAGE), )
|
||||||
|
@echo $(INFORMATION_MESSAGE)
|
||||||
|
endif
|
||||||
|
${MAKE} -f nbproject/Makefile-default.mk ${DISTDIR}/IdiBusSlaveTemplate.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
|
||||||
|
@echo "--------------------------------------"
|
||||||
|
@echo "User defined post-build step: [IdiBusFPT.exe --cli -o="${ProjectDir}" -n="${ProjectName}" -k="${ProjectDir}\keys.c" -d="${ProjectDir}\device.h" -m="${Device}" -x="${ProjectDir}\dist\default\production\${ProjectName}.production.hex"]"
|
||||||
|
@IdiBusFPT.exe --cli -o="${ProjectDir}" -n="${ProjectName}" -k="${ProjectDir}\keys.c" -d="${ProjectDir}\device.h" -m="${Device}" -x="${ProjectDir}\dist\default\production\${ProjectName}.production.hex"
|
||||||
|
@echo "--------------------------------------"
|
||||||
|
|
||||||
|
MP_PROCESSOR_OPTION=ATmega328PB
|
||||||
|
# ------------------------------------------------------------------------------------
|
||||||
|
# Rules for buildStep: assemble
|
||||||
|
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
|
||||||
|
else
|
||||||
|
endif
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------------
|
||||||
|
# Rules for buildStep: assembleWithPreprocess
|
||||||
|
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
|
||||||
|
else
|
||||||
|
endif
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------------
|
||||||
|
# Rules for buildStep: compile
|
||||||
|
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
|
||||||
|
${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o: IdiBusCore/IdiBus/IDIBUS_IMPL.c .generated_files/flags/default/e9a38142752595870859f111653c5e1ce9c519 .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore/IdiBus"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -g -DDEBUG -gdwarf-2 -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o.d" -MT "${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o.d" -MT ${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o -o ${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o IdiBusCore/IdiBus/IDIBUS_IMPL.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o: IdiBusCore/IdiBus/RSLink.c .generated_files/flags/default/66c7d382ea20b9b3a9f082eb9b239ccaface02f6 .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore/IdiBus"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -g -DDEBUG -gdwarf-2 -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o.d" -MT "${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o.d" -MT ${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o -o ${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o IdiBusCore/IdiBus/RSLink.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
${OBJECTDIR}/IdiBusCore/Required/MEMORY.o: IdiBusCore/Required/MEMORY.c .generated_files/flags/default/964fce023a3f7804f660718ae9275c73cb8f8c1e .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore/Required"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/Required/MEMORY.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/Required/MEMORY.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -g -DDEBUG -gdwarf-2 -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/Required/MEMORY.o.d" -MT "${OBJECTDIR}/IdiBusCore/Required/MEMORY.o.d" -MT ${OBJECTDIR}/IdiBusCore/Required/MEMORY.o -o ${OBJECTDIR}/IdiBusCore/Required/MEMORY.o IdiBusCore/Required/MEMORY.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o: IdiBusCore/Required/MODBUS_CRC.c .generated_files/flags/default/28e0ec1c4f16eabb5b730b5a3acecfd4ebb17293 .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore/Required"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -g -DDEBUG -gdwarf-2 -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o.d" -MT "${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o.d" -MT ${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o -o ${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o IdiBusCore/Required/MODBUS_CRC.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o: IdiBusCore/Required/SYSTEM.c .generated_files/flags/default/d212dba77d21ed2d462fec63f1625f7fbbde4e50 .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore/Required"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -g -DDEBUG -gdwarf-2 -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o.d" -MT "${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o.d" -MT ${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o -o ${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o IdiBusCore/Required/SYSTEM.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
${OBJECTDIR}/IdiBusCore/Required/USART1.o: IdiBusCore/Required/USART1.c .generated_files/flags/default/f8adb936d6f3ea2a7c935ef712ef89bd9e0bac37 .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore/Required"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/Required/USART1.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/Required/USART1.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -g -DDEBUG -gdwarf-2 -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/Required/USART1.o.d" -MT "${OBJECTDIR}/IdiBusCore/Required/USART1.o.d" -MT ${OBJECTDIR}/IdiBusCore/Required/USART1.o -o ${OBJECTDIR}/IdiBusCore/Required/USART1.o IdiBusCore/Required/USART1.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
${OBJECTDIR}/IdiBusCore/idibus_custom.o: IdiBusCore/idibus_custom.c .generated_files/flags/default/df0490719c3ac1a00c3f18b21d31aa0a93fe1218 .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/idibus_custom.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/idibus_custom.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -g -DDEBUG -gdwarf-2 -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/idibus_custom.o.d" -MT "${OBJECTDIR}/IdiBusCore/idibus_custom.o.d" -MT ${OBJECTDIR}/IdiBusCore/idibus_custom.o -o ${OBJECTDIR}/IdiBusCore/idibus_custom.o IdiBusCore/idibus_custom.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
${OBJECTDIR}/IdiBusCore/idibus_hw.o: IdiBusCore/idibus_hw.c .generated_files/flags/default/e00edf63a3a14c1226c0a168de271ccec64d797d .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/idibus_hw.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/idibus_hw.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -g -DDEBUG -gdwarf-2 -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/idibus_hw.o.d" -MT "${OBJECTDIR}/IdiBusCore/idibus_hw.o.d" -MT ${OBJECTDIR}/IdiBusCore/idibus_hw.o -o ${OBJECTDIR}/IdiBusCore/idibus_hw.o IdiBusCore/idibus_hw.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
${OBJECTDIR}/IdiBusCore/main.o: IdiBusCore/main.c .generated_files/flags/default/ab29b2ee9938ed03700d7711a6d436d9aea08c5f .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/main.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/main.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -g -DDEBUG -gdwarf-2 -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/main.o.d" -MT "${OBJECTDIR}/IdiBusCore/main.o.d" -MT ${OBJECTDIR}/IdiBusCore/main.o -o ${OBJECTDIR}/IdiBusCore/main.o IdiBusCore/main.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
else
|
||||||
|
${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o: IdiBusCore/IdiBus/IDIBUS_IMPL.c .generated_files/flags/default/deac40c0a281ab1f83c2152316fe46fde8f57998 .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore/IdiBus"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o.d" -MT "${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o.d" -MT ${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o -o ${OBJECTDIR}/IdiBusCore/IdiBus/IDIBUS_IMPL.o IdiBusCore/IdiBus/IDIBUS_IMPL.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o: IdiBusCore/IdiBus/RSLink.c .generated_files/flags/default/e9746ae4988c79472d420f21711f1dfc42ae2b92 .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore/IdiBus"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o.d" -MT "${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o.d" -MT ${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o -o ${OBJECTDIR}/IdiBusCore/IdiBus/RSLink.o IdiBusCore/IdiBus/RSLink.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
${OBJECTDIR}/IdiBusCore/Required/MEMORY.o: IdiBusCore/Required/MEMORY.c .generated_files/flags/default/4b65c3af6242de005622917f3b6ee9841f75295a .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore/Required"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/Required/MEMORY.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/Required/MEMORY.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/Required/MEMORY.o.d" -MT "${OBJECTDIR}/IdiBusCore/Required/MEMORY.o.d" -MT ${OBJECTDIR}/IdiBusCore/Required/MEMORY.o -o ${OBJECTDIR}/IdiBusCore/Required/MEMORY.o IdiBusCore/Required/MEMORY.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o: IdiBusCore/Required/MODBUS_CRC.c .generated_files/flags/default/bb2a0aa9e48cf7d1572a4d94591b1b608a567b79 .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore/Required"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o.d" -MT "${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o.d" -MT ${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o -o ${OBJECTDIR}/IdiBusCore/Required/MODBUS_CRC.o IdiBusCore/Required/MODBUS_CRC.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o: IdiBusCore/Required/SYSTEM.c .generated_files/flags/default/30a7af11612c4825529cde3610ffd270273de1d .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore/Required"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o.d" -MT "${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o.d" -MT ${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o -o ${OBJECTDIR}/IdiBusCore/Required/SYSTEM.o IdiBusCore/Required/SYSTEM.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
${OBJECTDIR}/IdiBusCore/Required/USART1.o: IdiBusCore/Required/USART1.c .generated_files/flags/default/e20dd54c9c3e9366b7e35fbede409b0e575dc648 .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore/Required"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/Required/USART1.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/Required/USART1.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/Required/USART1.o.d" -MT "${OBJECTDIR}/IdiBusCore/Required/USART1.o.d" -MT ${OBJECTDIR}/IdiBusCore/Required/USART1.o -o ${OBJECTDIR}/IdiBusCore/Required/USART1.o IdiBusCore/Required/USART1.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
${OBJECTDIR}/IdiBusCore/idibus_custom.o: IdiBusCore/idibus_custom.c .generated_files/flags/default/c3d42a8848cfe26e389c6f774eeaf6abeccfac8e .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/idibus_custom.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/idibus_custom.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/idibus_custom.o.d" -MT "${OBJECTDIR}/IdiBusCore/idibus_custom.o.d" -MT ${OBJECTDIR}/IdiBusCore/idibus_custom.o -o ${OBJECTDIR}/IdiBusCore/idibus_custom.o IdiBusCore/idibus_custom.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
${OBJECTDIR}/IdiBusCore/idibus_hw.o: IdiBusCore/idibus_hw.c .generated_files/flags/default/d5b34525c4a66132f29addca6aba3792d3300f55 .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/idibus_hw.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/idibus_hw.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/idibus_hw.o.d" -MT "${OBJECTDIR}/IdiBusCore/idibus_hw.o.d" -MT ${OBJECTDIR}/IdiBusCore/idibus_hw.o -o ${OBJECTDIR}/IdiBusCore/idibus_hw.o IdiBusCore/idibus_hw.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
${OBJECTDIR}/IdiBusCore/main.o: IdiBusCore/main.c .generated_files/flags/default/6b86ad118a826c8373ddd5d6f367cc4f4dfaaa2 .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}/IdiBusCore"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/main.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusCore/main.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -x c -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusCore/main.o.d" -MT "${OBJECTDIR}/IdiBusCore/main.o.d" -MT ${OBJECTDIR}/IdiBusCore/main.o -o ${OBJECTDIR}/IdiBusCore/main.o IdiBusCore/main.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------------
|
||||||
|
# Rules for buildStep: compileCPP
|
||||||
|
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
|
||||||
|
${OBJECTDIR}/IdiBusSlave.o: IdiBusSlave.cpp .generated_files/flags/default/2f96a12a4d5605dd7d4b5320fe366ca7335deefc .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusSlave.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusSlave.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -g -DDEBUG -gdwarf-2 -x c++ -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusSlave.o.d" -MT "${OBJECTDIR}/IdiBusSlave.o.d" -MT ${OBJECTDIR}/IdiBusSlave.o -o ${OBJECTDIR}/IdiBusSlave.o IdiBusSlave.cpp -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
else
|
||||||
|
${OBJECTDIR}/IdiBusSlave.o: IdiBusSlave.cpp .generated_files/flags/default/c1972d05bd292e9c5488c0069d0a205bff09c5d .generated_files/flags/default/da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||||
|
@${MKDIR} "${OBJECTDIR}"
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusSlave.o.d
|
||||||
|
@${RM} ${OBJECTDIR}/IdiBusSlave.o
|
||||||
|
${MP_CPPC} $(MP_EXTRA_CC_PRE) -mmcu=atmega328pb ${PACK_COMPILER_OPTIONS} ${PACK_COMMON_OPTIONS} -x c++ -c -D__$(MP_PROCESSOR_OPTION)__ -I"IdiBusCore" -I"IdiBusCore/IdiBus" -I"IdiBusCore/Required" -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -MD -MP -MF "${OBJECTDIR}/IdiBusSlave.o.d" -MT "${OBJECTDIR}/IdiBusSlave.o.d" -MT ${OBJECTDIR}/IdiBusSlave.o -o ${OBJECTDIR}/IdiBusSlave.o IdiBusSlave.cpp -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD)
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------------
|
||||||
|
# Rules for buildStep: link
|
||||||
|
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
|
||||||
|
${DISTDIR}/IdiBusSlaveTemplate.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk
|
||||||
|
@${MKDIR} ${DISTDIR}
|
||||||
|
${MP_CPPC} $(MP_EXTRA_LD_PRE) -mmcu=atmega328pb ${PACK_COMMON_OPTIONS} -gdwarf-2 -D__$(MP_PROCESSOR_OPTION)__ -Wl,-Map="${DISTDIR}\IdiBusSlaveTemplate.${IMAGE_TYPE}.map" -Wl,-section-start=.serialdata=0x810000 -Wl,-section-start=.eeprom=0x810040 -o ${DISTDIR}/IdiBusSlaveTemplate.${IMAGE_TYPE}.${OUTPUT_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -Wl,--defsym=__MPLAB_BUILD=1$(MP_EXTRA_LD_POST)$(MP_LINKER_FILE_OPTION),--defsym=__ICD2RAM=1,--defsym=__MPLAB_DEBUG=1,--defsym=__DEBUG=1 -Wl,--gc-sections -Wl,--start-group -Wl,-lm -Wl,--end-group
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
else
|
||||||
|
${DISTDIR}/IdiBusSlaveTemplate.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk
|
||||||
|
@${MKDIR} ${DISTDIR}
|
||||||
|
${MP_CPPC} $(MP_EXTRA_LD_PRE) -mmcu=atmega328pb ${PACK_COMMON_OPTIONS} -D__$(MP_PROCESSOR_OPTION)__ -Wl,-Map="${DISTDIR}\IdiBusSlaveTemplate.${IMAGE_TYPE}.map" -Wl,-section-start=.serialdata=0x810000 -Wl,-section-start=.eeprom=0x810040 -o ${DISTDIR}/IdiBusSlaveTemplate.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -Wl,--defsym=__MPLAB_BUILD=1$(MP_EXTRA_LD_POST)$(MP_LINKER_FILE_OPTION) -Wl,--gc-sections -Wl,--start-group -Wl,-lm -Wl,--end-group
|
||||||
|
${MP_CC_DIR}\\avr-objcopy -O ihex "${DISTDIR}/IdiBusSlaveTemplate.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX}" "${DISTDIR}/IdiBusSlaveTemplate.${IMAGE_TYPE}.hex"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# Subprojects
|
||||||
|
.build-subprojects:
|
||||||
|
|
||||||
|
|
||||||
|
# Subprojects
|
||||||
|
.clean-subprojects:
|
||||||
|
|
||||||
|
# Clean Targets
|
||||||
|
.clean-conf: ${CLEAN_SUBPROJECTS}
|
||||||
|
${RM} -r ${OBJECTDIR}
|
||||||
|
${RM} -r ${DISTDIR}
|
||||||
|
|
||||||
|
# Enable dependency checking
|
||||||
|
.dep.inc: .depcheck-impl
|
||||||
|
|
||||||
|
DEPFILES=$(wildcard ${POSSIBLE_DEPFILES})
|
||||||
|
ifneq (${DEPFILES},)
|
||||||
|
include ${DEPFILES}
|
||||||
|
endif
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
#
|
||||||
|
#Wed May 13 12:30:51 MSK 2026
|
||||||
|
default.languagetoolchain.version=14.2.0
|
||||||
|
default.Pack.dfplocation=C\:\\Users\\Michail\\.mchp_packs\\Microchip\\ATmega_DFP\\3.5.296
|
||||||
|
default.com-microchip-mplab-nbide-toolchain-avr-AVRLanguageToolchain.md5=7077cb0f7d3286937e616ce3e96e957a
|
||||||
|
conf.ids=default
|
||||||
|
default.languagetoolchain.dir=C\:\\Users\\Michail\\AVR\\cooler_tool\\bin
|
||||||
|
host.id=j20m-9n47-m
|
||||||
|
default.platformTool.md5=null
|
||||||
|
configurations-xml=815e4f33c4f6d31852ae21c189ccfa12
|
||||||
|
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=6cd85c1014597ae4d039afea70fe46c5
|
||||||
|
proj.dir=P\:\\IdiBus\\Atmega\\IdiBusSlaveTemplate
|
||||||
|
host.platform=windows
|
||||||
@ -0,0 +1,69 @@
|
|||||||
|
#
|
||||||
|
# Generated Makefile - do not edit!
|
||||||
|
#
|
||||||
|
# Edit the Makefile in the project folder instead (../Makefile). Each target
|
||||||
|
# has a pre- and a post- target defined where you can add customization code.
|
||||||
|
#
|
||||||
|
# This makefile implements macros and targets common to all configurations.
|
||||||
|
#
|
||||||
|
# NOCDDL
|
||||||
|
|
||||||
|
|
||||||
|
# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
|
||||||
|
# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
|
||||||
|
# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
|
||||||
|
# and .clean-reqprojects-conf unless SUB has the value 'no'
|
||||||
|
SUB_no=NO
|
||||||
|
SUBPROJECTS=${SUB_${SUB}}
|
||||||
|
BUILD_SUBPROJECTS_=.build-subprojects
|
||||||
|
BUILD_SUBPROJECTS_NO=
|
||||||
|
BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
|
||||||
|
CLEAN_SUBPROJECTS_=.clean-subprojects
|
||||||
|
CLEAN_SUBPROJECTS_NO=
|
||||||
|
CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
|
||||||
|
|
||||||
|
|
||||||
|
# Project Name
|
||||||
|
PROJECTNAME=IdiBusSlaveTemplate
|
||||||
|
|
||||||
|
# Active Configuration
|
||||||
|
DEFAULTCONF=default
|
||||||
|
CONF=${DEFAULTCONF}
|
||||||
|
|
||||||
|
# All Configurations
|
||||||
|
ALLCONFS=default
|
||||||
|
|
||||||
|
|
||||||
|
# build
|
||||||
|
.build-impl: .build-pre
|
||||||
|
${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf
|
||||||
|
|
||||||
|
|
||||||
|
# clean
|
||||||
|
.clean-impl: .clean-pre
|
||||||
|
${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf
|
||||||
|
|
||||||
|
# clobber
|
||||||
|
.clobber-impl: .clobber-pre .depcheck-impl
|
||||||
|
${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default clean
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# all
|
||||||
|
.all-impl: .all-pre .depcheck-impl
|
||||||
|
${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default build
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# dependency checking support
|
||||||
|
.depcheck-impl:
|
||||||
|
# @echo "# This code depends on make tool being used" >.dep.inc
|
||||||
|
# @if [ -n "${MAKE_VERSION}" ]; then \
|
||||||
|
# echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \
|
||||||
|
# echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
|
||||||
|
# echo "include \$${DEPFILES}" >>.dep.inc; \
|
||||||
|
# echo "endif" >>.dep.inc; \
|
||||||
|
# else \
|
||||||
|
# echo ".KEEP_STATE:" >>.dep.inc; \
|
||||||
|
# echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
|
||||||
|
# fi
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
#
|
||||||
|
# Generated Makefile - do not edit!
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# This file contains information about the location of compilers and other tools.
|
||||||
|
# If you commmit this file into your revision control server, you will be able to
|
||||||
|
# to checkout the project and build it from the command line with make. However,
|
||||||
|
# if more than one person works on the same project, then this file might show
|
||||||
|
# conflicts since different users are bound to have compilers in different places.
|
||||||
|
# In that case you might choose to not commit this file and let MPLAB X recreate this file
|
||||||
|
# for each user. The disadvantage of not commiting this file is that you must run MPLAB X at
|
||||||
|
# least once so the file gets created and the project can be built. Finally, you can also
|
||||||
|
# avoid using this file at all if you are only building from the command line with make.
|
||||||
|
# You can invoke make with the values of the macros:
|
||||||
|
# $ makeMP_CC="/opt/microchip/mplabc30/v3.30c/bin/pic30-gcc" ...
|
||||||
|
#
|
||||||
|
SHELL=cmd.exe
|
||||||
|
PATH_TO_IDE_BIN=C:/Program Files/Microchip/MPLABX/v6.25/mplab_platform/platform/../mplab_ide/modules/../../bin/
|
||||||
|
# Adding MPLAB X bin directory to path.
|
||||||
|
PATH:=C:/Program Files/Microchip/MPLABX/v6.25/mplab_platform/platform/../mplab_ide/modules/../../bin/:$(PATH)
|
||||||
|
# Path to java used to run MPLAB X when this makefile was created
|
||||||
|
MP_JAVA_PATH="C:\Program Files\Microchip\MPLABX\v6.25\sys\java\zulu8.80.0.17-ca-fx-jre8.0.422-win_x64/bin/"
|
||||||
|
OS_CURRENT="$(shell uname -s)"
|
||||||
|
MP_CC="C:\Users\Michail\AVR\cooler_tool\bin\avr-gcc.exe"
|
||||||
|
MP_CPPC="C:\Users\Michail\AVR\cooler_tool\bin\avr-g++.exe"
|
||||||
|
# MP_BC is not defined
|
||||||
|
MP_AS="C:\Users\Michail\AVR\cooler_tool\bin\avr-as.exe"
|
||||||
|
MP_LD="C:\Users\Michail\AVR\cooler_tool\bin\avr-ld.exe"
|
||||||
|
MP_AR="C:\Users\Michail\AVR\cooler_tool\bin\avr-gcc-ar.exe"
|
||||||
|
DEP_GEN=${MP_JAVA_PATH}java -jar "C:/Program Files/Microchip/MPLABX/v6.25/mplab_platform/platform/../mplab_ide/modules/../../bin/extractobjectdependencies.jar"
|
||||||
|
MP_CC_DIR="C:\Users\Michail\AVR\cooler_tool\bin"
|
||||||
|
MP_CPPC_DIR="C:\Users\Michail\AVR\cooler_tool\bin"
|
||||||
|
# MP_BC_DIR is not defined
|
||||||
|
MP_AS_DIR="C:\Users\Michail\AVR\cooler_tool\bin"
|
||||||
|
MP_LD_DIR="C:\Users\Michail\AVR\cooler_tool\bin"
|
||||||
|
MP_AR_DIR="C:\Users\Michail\AVR\cooler_tool\bin"
|
||||||
|
DFP_DIR=C:/Users/Michail/.mchp_packs/Microchip/ATmega_DFP/3.5.296
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
#
|
||||||
|
# Generated - do not edit!
|
||||||
|
#
|
||||||
|
# NOCDDL
|
||||||
|
#
|
||||||
|
CND_BASEDIR=`pwd`
|
||||||
|
# default configuration
|
||||||
|
CND_ARTIFACT_DIR_default=dist/default/production
|
||||||
|
CND_ARTIFACT_NAME_default=IdiBusSlaveTemplate.production.hex
|
||||||
|
CND_ARTIFACT_PATH_default=dist/default/production/IdiBusSlaveTemplate.production.hex
|
||||||
@ -0,0 +1,326 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configurationDescriptor version="65">
|
||||||
|
<logicalFolder name="root" displayName="root" projectFiles="true">
|
||||||
|
<logicalFolder name="HeaderFiles"
|
||||||
|
displayName="Header Files"
|
||||||
|
projectFiles="true">
|
||||||
|
<logicalFolder name="IdiBusCore" displayName="IdiBusCore" projectFiles="true">
|
||||||
|
<logicalFolder name="IdiBus" displayName="IdiBus" projectFiles="true">
|
||||||
|
<itemPath>IdiBusCore/IdiBus/IDIBUS_DEFS.h</itemPath>
|
||||||
|
<itemPath>IdiBusCore/IdiBus/IDIBUS_IMPL.h</itemPath>
|
||||||
|
<itemPath>IdiBusCore/IdiBus/RSLink.h</itemPath>
|
||||||
|
</logicalFolder>
|
||||||
|
<logicalFolder name="Required" displayName="Required" projectFiles="true">
|
||||||
|
<itemPath>IdiBusCore/Required/EEMEM.h</itemPath>
|
||||||
|
<itemPath>IdiBusCore/Required/m1280_defs.h</itemPath>
|
||||||
|
<itemPath>IdiBusCore/Required/m128_defs.h</itemPath>
|
||||||
|
<itemPath>IdiBusCore/Required/m2560_defs.h</itemPath>
|
||||||
|
<itemPath>IdiBusCore/Required/m328pb_defs.h</itemPath>
|
||||||
|
<itemPath>IdiBusCore/Required/MEMORY.h</itemPath>
|
||||||
|
<itemPath>IdiBusCore/Required/MODBUS_CRC.h</itemPath>
|
||||||
|
<itemPath>IdiBusCore/Required/SYSTEM.h</itemPath>
|
||||||
|
<itemPath>IdiBusCore/Required/USART1.h</itemPath>
|
||||||
|
<itemPath>IdiBusCore/Required/USART_COM.h</itemPath>
|
||||||
|
</logicalFolder>
|
||||||
|
<itemPath>IdiBusCore/config.h</itemPath>
|
||||||
|
<itemPath>IdiBusCore/IdiBusSlave.h</itemPath>
|
||||||
|
<itemPath>IdiBusCore/idibus_hw.h</itemPath>
|
||||||
|
</logicalFolder>
|
||||||
|
</logicalFolder>
|
||||||
|
<logicalFolder name="ExternalFiles"
|
||||||
|
displayName="Important Files"
|
||||||
|
projectFiles="true">
|
||||||
|
<itemPath>Makefile</itemPath>
|
||||||
|
</logicalFolder>
|
||||||
|
<logicalFolder name="LinkerScript"
|
||||||
|
displayName="Linker Files"
|
||||||
|
projectFiles="true">
|
||||||
|
</logicalFolder>
|
||||||
|
<logicalFolder name="SourceFiles"
|
||||||
|
displayName="Source Files"
|
||||||
|
projectFiles="true">
|
||||||
|
<logicalFolder name="IdiBusCore" displayName="IdiBusCore" projectFiles="true">
|
||||||
|
<logicalFolder name="IdiBus" displayName="IdiBus" projectFiles="true">
|
||||||
|
<itemPath>IdiBusCore/IdiBus/IDIBUS_IMPL.c</itemPath>
|
||||||
|
<itemPath>IdiBusCore/IdiBus/RSLink.c</itemPath>
|
||||||
|
</logicalFolder>
|
||||||
|
<logicalFolder name="Required" displayName="Required" projectFiles="true">
|
||||||
|
<itemPath>IdiBusCore/Required/MEMORY.c</itemPath>
|
||||||
|
<itemPath>IdiBusCore/Required/MODBUS_CRC.c</itemPath>
|
||||||
|
<itemPath>IdiBusCore/Required/SYSTEM.c</itemPath>
|
||||||
|
<itemPath>IdiBusCore/Required/USART1.c</itemPath>
|
||||||
|
</logicalFolder>
|
||||||
|
<itemPath>IdiBusCore/idibus_custom.c</itemPath>
|
||||||
|
<itemPath>IdiBusCore/idibus_hw.c</itemPath>
|
||||||
|
<itemPath>IdiBusCore/main.c</itemPath>
|
||||||
|
</logicalFolder>
|
||||||
|
<itemPath>IdiBusSlave.cpp</itemPath>
|
||||||
|
</logicalFolder>
|
||||||
|
</logicalFolder>
|
||||||
|
<sourceRootList>
|
||||||
|
<Elem>.</Elem>
|
||||||
|
</sourceRootList>
|
||||||
|
<projectmakefile>Makefile</projectmakefile>
|
||||||
|
<confs>
|
||||||
|
<conf name="default" type="2">
|
||||||
|
<toolsSet>
|
||||||
|
<developmentServer>localhost</developmentServer>
|
||||||
|
<targetDevice>ATmega328PB</targetDevice>
|
||||||
|
<targetHeader></targetHeader>
|
||||||
|
<targetPluginBoard></targetPluginBoard>
|
||||||
|
<platformTool>noID</platformTool>
|
||||||
|
<languageToolchain>AVR</languageToolchain>
|
||||||
|
<languageToolchainVersion>14.2.0</languageToolchainVersion>
|
||||||
|
<platform>3</platform>
|
||||||
|
</toolsSet>
|
||||||
|
<packs>
|
||||||
|
<pack name="ATmega_DFP" vendor="Microchip" version="3.5.296"/>
|
||||||
|
</packs>
|
||||||
|
<ScriptingSettings>
|
||||||
|
</ScriptingSettings>
|
||||||
|
<compileType>
|
||||||
|
<linkerTool>
|
||||||
|
<linkerLibItems>
|
||||||
|
</linkerLibItems>
|
||||||
|
</linkerTool>
|
||||||
|
<archiverTool>
|
||||||
|
</archiverTool>
|
||||||
|
<loading>
|
||||||
|
<makeArtifact PL="../IdibusBootloader2560.X"
|
||||||
|
CT="1"
|
||||||
|
CN="default"
|
||||||
|
AC="true"
|
||||||
|
BL="false"
|
||||||
|
WD="../IdibusBootloader2560.X"
|
||||||
|
BC="${MAKE} -f Makefile CONF=default"
|
||||||
|
DBC="${MAKE} -f Makefile CONF=default TYPE_IMAGE=DEBUG_RUN"
|
||||||
|
CC="rm -rf "build/default" "dist/default""
|
||||||
|
OP="dist/default/production/IdibusBootloader2560.X.production.hex"
|
||||||
|
DOP="dist/default/debug/IdibusBootloader2560.X.debug.elf"
|
||||||
|
FL="dist/default/production/IdibusBootloader2560.X.production.hex"
|
||||||
|
PD="dist/default/production/IdibusBootloader2560.X.production.elf"
|
||||||
|
DD="dist/default/debug/IdibusBootloader2560.X.debug.elf">
|
||||||
|
</makeArtifact>
|
||||||
|
<useAlternateLoadableFile>false</useAlternateLoadableFile>
|
||||||
|
<parseOnProdLoad>true</parseOnProdLoad>
|
||||||
|
<alternateLoadableFile></alternateLoadableFile>
|
||||||
|
</loading>
|
||||||
|
<subordinates>
|
||||||
|
</subordinates>
|
||||||
|
</compileType>
|
||||||
|
<makeCustomizationType>
|
||||||
|
<makeCustomizationPreStepEnabled>false</makeCustomizationPreStepEnabled>
|
||||||
|
<makeUseCleanTarget>false</makeUseCleanTarget>
|
||||||
|
<makeCustomizationPreStep></makeCustomizationPreStep>
|
||||||
|
<makeCustomizationPostStepEnabled>true</makeCustomizationPostStepEnabled>
|
||||||
|
<makeCustomizationPostStep>IdiBusFPT.exe --cli -o="${ProjectDir}" -n="${ProjectName}" -k="${ProjectDir}\keys.c" -d="${ProjectDir}\device.h" -m="${Device}" -x="${ProjectDir}\dist\default\production\${ProjectName}.production.hex"</makeCustomizationPostStep>
|
||||||
|
<makeCustomizationPutChecksumInUserID>false</makeCustomizationPutChecksumInUserID>
|
||||||
|
<makeCustomizationEnableLongLines>false</makeCustomizationEnableLongLines>
|
||||||
|
<makeCustomizationNormalizeHexFile>false</makeCustomizationNormalizeHexFile>
|
||||||
|
</makeCustomizationType>
|
||||||
|
<AVR-AR>
|
||||||
|
<property key="archiver-flags" value="-r"/>
|
||||||
|
</AVR-AR>
|
||||||
|
<AVR-AS>
|
||||||
|
<property key="announce-version" value="false"/>
|
||||||
|
<property key="include-paths" value=""/>
|
||||||
|
<property key="suppress-warnings" value="false"/>
|
||||||
|
</AVR-AS>
|
||||||
|
<AVR-AS-PRE>
|
||||||
|
<property key="announce-version" value="false"/>
|
||||||
|
<property key="include-paths" value=""/>
|
||||||
|
<property key="preprocessor-macros" value=""/>
|
||||||
|
<property key="preprocessor-macros-undefined" value=""/>
|
||||||
|
<property key="suppress-warnings" value="false"/>
|
||||||
|
</AVR-AS-PRE>
|
||||||
|
<AVR-CPP>
|
||||||
|
<property key="additional-warnings" value="true"/>
|
||||||
|
<property key="call-prologues" value="false"/>
|
||||||
|
<property key="default-bitfield-type" value="true"/>
|
||||||
|
<property key="default-char-type" value="true"/>
|
||||||
|
<property key="extra-include-directories" value=""/>
|
||||||
|
<property key="garbage-collect-data" value="true"/>
|
||||||
|
<property key="garbage-collect-functions" value="true"/>
|
||||||
|
<property key="inhibit-all" value="false"/>
|
||||||
|
<property key="make-warnings-into-errors" value="false"/>
|
||||||
|
<property key="no-interrupts" value="false"/>
|
||||||
|
<property key="no-system-directories" value="false"/>
|
||||||
|
<property key="optimization-level" value="-O1"/>
|
||||||
|
<property key="pack-struct" value="true"/>
|
||||||
|
<property key="preprocess-only" value="false"/>
|
||||||
|
<property key="preprocessor-macros" value=""/>
|
||||||
|
<property key="preprocessor-macros-undefined" value=""/>
|
||||||
|
<property key="save-temps" value="false"/>
|
||||||
|
<property key="short-calls" value="false"/>
|
||||||
|
<property key="short-enums" value="true"/>
|
||||||
|
<property key="strict-ansi" value="false"/>
|
||||||
|
<property key="strict-ansi-errors" value="false"/>
|
||||||
|
<property key="support-ansi" value="false"/>
|
||||||
|
<property key="syntax-only" value="false"/>
|
||||||
|
<property key="undefined-identifier" value="false"/>
|
||||||
|
<property key="verbose" value="false"/>
|
||||||
|
</AVR-CPP>
|
||||||
|
<AVR-GCC>
|
||||||
|
<property key="additional-warnings" value="true"/>
|
||||||
|
<property key="call-prologues" value="false"/>
|
||||||
|
<property key="default-bitfield-type" value="true"/>
|
||||||
|
<property key="default-char-type" value="true"/>
|
||||||
|
<property key="extra-include-directories" value=""/>
|
||||||
|
<property key="extra-warnings" value="false"/>
|
||||||
|
<property key="garbage-collect-data" value="true"/>
|
||||||
|
<property key="garbage-collect-functions" value="true"/>
|
||||||
|
<property key="inhibit-all" value="false"/>
|
||||||
|
<property key="make-warnings-into-errors" value="false"/>
|
||||||
|
<property key="no-interrupts" value="false"/>
|
||||||
|
<property key="no-system-directories" value="false"/>
|
||||||
|
<property key="optimization-level" value="-O1"/>
|
||||||
|
<property key="pack-struct" value="true"/>
|
||||||
|
<property key="preprocessor-macros" value=""/>
|
||||||
|
<property key="preprocessor-macros-undefined" value=""/>
|
||||||
|
<property key="save-temps" value="false"/>
|
||||||
|
<property key="short-calls" value="false"/>
|
||||||
|
<property key="short-enums" value="true"/>
|
||||||
|
<property key="strict-ansi" value="false"/>
|
||||||
|
<property key="strict-ansi-errors" value="false"/>
|
||||||
|
<property key="support-ansi" value="false"/>
|
||||||
|
<property key="syntax-only" value="false"/>
|
||||||
|
<property key="undefined-identifier" value="false"/>
|
||||||
|
<property key="verbose" value="false"/>
|
||||||
|
</AVR-GCC>
|
||||||
|
<AVR-Global>
|
||||||
|
<property key="common-include-directories"
|
||||||
|
value="IdiBusCore;IdiBusCore\IdiBus;IdiBusCore\Required"/>
|
||||||
|
<property key="eep" value="false"/>
|
||||||
|
<property key="external-ram-check" value="false"/>
|
||||||
|
<property key="hex" value="true"/>
|
||||||
|
<property key="lss" value="false"/>
|
||||||
|
<property key="omit-pack-options" value="false"/>
|
||||||
|
<property key="relax-branches" value="false"/>
|
||||||
|
<property key="srec" value="false"/>
|
||||||
|
<property key="user-pack-device-support" value=""/>
|
||||||
|
<property key="user-pack-include" value=""/>
|
||||||
|
<property key="usersig" value="false"/>
|
||||||
|
</AVR-Global>
|
||||||
|
<AVR-LD>
|
||||||
|
<property key="eeprom-segment" value=".serialdata=0x0;.eeprom=0x40"/>
|
||||||
|
<property key="exclude-standard-libraries" value="false"/>
|
||||||
|
<property key="extra-lib-directories" value=""/>
|
||||||
|
<property key="flash-segment" value=""/>
|
||||||
|
<property key="generate-map-file" value="true"/>
|
||||||
|
<property key="initial-stack-address" value=""/>
|
||||||
|
<property key="input-libraries" value="libm"/>
|
||||||
|
<property key="no-default-libs" value="false"/>
|
||||||
|
<property key="no-shared-libraries" value="false"/>
|
||||||
|
<property key="no-startup-files" value="false"/>
|
||||||
|
<property key="omit-symbol-information" value="false"/>
|
||||||
|
<property key="other-options" value=""/>
|
||||||
|
<property key="remove-unused-sections" value="true"/>
|
||||||
|
<property key="rodata-writable" value="false"/>
|
||||||
|
<property key="sram-segment" value=""/>
|
||||||
|
<property key="v-printf" value="false"/>
|
||||||
|
</AVR-LD>
|
||||||
|
<Tool>
|
||||||
|
<property key="AutoSelectMemRanges" value="auto"/>
|
||||||
|
<property key="ToolFirmwareFilePath"
|
||||||
|
value="Press to browse for a specific firmware version"/>
|
||||||
|
<property key="ToolFirmwareOption.UpdateOptions"
|
||||||
|
value="ToolFirmwareOption.UseLatest"/>
|
||||||
|
<property key="ToolFirmwareToolPack"
|
||||||
|
value="Press to select which tool pack to use"/>
|
||||||
|
<property key="communication.interface" value="isp"/>
|
||||||
|
<property key="communication.interface.jtag" value="2wire"/>
|
||||||
|
<property key="communication.speed" value="0,5"/>
|
||||||
|
<property key="debugoptions.debug-startup" value="Use system settings"/>
|
||||||
|
<property key="debugoptions.reset-behaviour" value="Use system settings"/>
|
||||||
|
<property key="debugoptions.simultaneous.debug" value="false"/>
|
||||||
|
<property key="debugoptions.useswbreakpoints" value="false"/>
|
||||||
|
<property key="event.recorder.debugger.behavior" value="Running"/>
|
||||||
|
<property key="event.recorder.enabled" value="false"/>
|
||||||
|
<property key="event.recorder.scvd.files" value=""/>
|
||||||
|
<property key="freeze.timers" value="false"/>
|
||||||
|
<property key="lastid" value=""/>
|
||||||
|
<property key="memories.aux" value="false"/>
|
||||||
|
<property key="memories.bootflash" value="true"/>
|
||||||
|
<property key="memories.configurationmemory" value="true"/>
|
||||||
|
<property key="memories.configurationmemory2" value="true"/>
|
||||||
|
<property key="memories.dataflash" value="true"/>
|
||||||
|
<property key="memories.eeprom" value="true"/>
|
||||||
|
<property key="memories.exclude.configurationmemory" value="true"/>
|
||||||
|
<property key="memories.flashdata" value="true"/>
|
||||||
|
<property key="memories.id" value="true"/>
|
||||||
|
<property key="memories.instruction.ram.ranges"
|
||||||
|
value="${memories.instruction.ram.ranges}"/>
|
||||||
|
<property key="memories.programmemory" value="true"/>
|
||||||
|
<property key="memories.programmemory.ranges" value="0-1ffff"/>
|
||||||
|
<property key="programoptions.donoteraseauxmem" value="false"/>
|
||||||
|
<property key="programoptions.eraseb4program" value="true"/>
|
||||||
|
<property key="programoptions.pgmentry.voltage" value="low"/>
|
||||||
|
<property key="programoptions.pgmspeed" value="Med"/>
|
||||||
|
<property key="programoptions.preservedataflash" value="false"/>
|
||||||
|
<property key="programoptions.preservedataflash.ranges" value="0-fff"/>
|
||||||
|
<property key="programoptions.preserveeeprom" value="false"/>
|
||||||
|
<property key="programoptions.preserveeeprom.ranges" value=""/>
|
||||||
|
<property key="programoptions.preserveprogram.ranges" value=""/>
|
||||||
|
<property key="programoptions.preserveprogramrange" value="false"/>
|
||||||
|
<property key="programoptions.programcalmem" value="false"/>
|
||||||
|
<property key="programoptions.programuserotp" value="false"/>
|
||||||
|
<property key="programoptions.testmodeentrymethod" value="VDDFirst"/>
|
||||||
|
<property key="toolpack.updateoptions"
|
||||||
|
value="toolpack.updateoptions.uselatestoolpack"/>
|
||||||
|
<property key="toolpack.updateoptions.packversion"
|
||||||
|
value="Press to select which tool pack to use"/>
|
||||||
|
</Tool>
|
||||||
|
<snap>
|
||||||
|
<property key="AutoSelectMemRanges" value="auto"/>
|
||||||
|
<property key="ToolFirmwareFilePath"
|
||||||
|
value="Press to browse for a specific firmware version"/>
|
||||||
|
<property key="ToolFirmwareOption.UpdateOptions"
|
||||||
|
value="ToolFirmwareOption.UseLatest"/>
|
||||||
|
<property key="ToolFirmwareToolPack"
|
||||||
|
value="Press to select which tool pack to use"/>
|
||||||
|
<property key="communication.interface" value="isp"/>
|
||||||
|
<property key="communication.interface.jtag" value="2wire"/>
|
||||||
|
<property key="communication.speed" value="0,5"/>
|
||||||
|
<property key="debugoptions.debug-startup" value="Use system settings"/>
|
||||||
|
<property key="debugoptions.reset-behaviour" value="Use system settings"/>
|
||||||
|
<property key="debugoptions.simultaneous.debug" value="false"/>
|
||||||
|
<property key="debugoptions.useswbreakpoints" value="false"/>
|
||||||
|
<property key="event.recorder.debugger.behavior" value="Running"/>
|
||||||
|
<property key="event.recorder.enabled" value="false"/>
|
||||||
|
<property key="event.recorder.scvd.files" value=""/>
|
||||||
|
<property key="freeze.timers" value="false"/>
|
||||||
|
<property key="lastid" value=""/>
|
||||||
|
<property key="memories.aux" value="false"/>
|
||||||
|
<property key="memories.bootflash" value="true"/>
|
||||||
|
<property key="memories.configurationmemory" value="true"/>
|
||||||
|
<property key="memories.configurationmemory2" value="true"/>
|
||||||
|
<property key="memories.dataflash" value="true"/>
|
||||||
|
<property key="memories.eeprom" value="true"/>
|
||||||
|
<property key="memories.exclude.configurationmemory" value="true"/>
|
||||||
|
<property key="memories.flashdata" value="true"/>
|
||||||
|
<property key="memories.id" value="true"/>
|
||||||
|
<property key="memories.instruction.ram.ranges"
|
||||||
|
value="${memories.instruction.ram.ranges}"/>
|
||||||
|
<property key="memories.programmemory" value="true"/>
|
||||||
|
<property key="memories.programmemory.ranges" value="0-1ffff"/>
|
||||||
|
<property key="programoptions.donoteraseauxmem" value="false"/>
|
||||||
|
<property key="programoptions.eraseb4program" value="true"/>
|
||||||
|
<property key="programoptions.pgmentry.voltage" value="low"/>
|
||||||
|
<property key="programoptions.pgmspeed" value="Med"/>
|
||||||
|
<property key="programoptions.preservedataflash" value="false"/>
|
||||||
|
<property key="programoptions.preservedataflash.ranges" value="0-fff"/>
|
||||||
|
<property key="programoptions.preserveeeprom" value="false"/>
|
||||||
|
<property key="programoptions.preserveeeprom.ranges" value=""/>
|
||||||
|
<property key="programoptions.preserveprogram.ranges" value=""/>
|
||||||
|
<property key="programoptions.preserveprogramrange" value="false"/>
|
||||||
|
<property key="programoptions.programcalmem" value="false"/>
|
||||||
|
<property key="programoptions.programuserotp" value="false"/>
|
||||||
|
<property key="programoptions.testmodeentrymethod" value="VDDFirst"/>
|
||||||
|
<property key="toolpack.updateoptions"
|
||||||
|
value="toolpack.updateoptions.uselatestoolpack"/>
|
||||||
|
<property key="toolpack.updateoptions.packversion"
|
||||||
|
value="Press to select which tool pack to use"/>
|
||||||
|
</snap>
|
||||||
|
</conf>
|
||||||
|
</confs>
|
||||||
|
</configurationDescriptor>
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configurationDescriptor version="65">
|
||||||
|
<projectmakefile>Makefile</projectmakefile>
|
||||||
|
<defaultConf>0</defaultConf>
|
||||||
|
<confs>
|
||||||
|
<conf name="default" type="2">
|
||||||
|
<platformToolSN>noToolString</platformToolSN>
|
||||||
|
<languageToolchainDir>C:\Users\Michail\AVR\cooler_tool\bin</languageToolchainDir>
|
||||||
|
<mdbdebugger version="1">
|
||||||
|
<placeholder1>place holder 1</placeholder1>
|
||||||
|
<placeholder2>place holder 2</placeholder2>
|
||||||
|
</mdbdebugger>
|
||||||
|
<runprofile version="6">
|
||||||
|
<args></args>
|
||||||
|
<rundir></rundir>
|
||||||
|
<buildfirst>true</buildfirst>
|
||||||
|
<console-type>0</console-type>
|
||||||
|
<terminal-type>0</terminal-type>
|
||||||
|
<remove-instrumentation>0</remove-instrumentation>
|
||||||
|
<environment>
|
||||||
|
</environment>
|
||||||
|
</runprofile>
|
||||||
|
</conf>
|
||||||
|
</confs>
|
||||||
|
</configurationDescriptor>
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||||
|
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||||
|
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||||
|
<group/>
|
||||||
|
</open-files>
|
||||||
|
</project-private>
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
|
<type>com.microchip.mplab.nbide.embedded.makeproject</type>
|
||||||
|
<configuration>
|
||||||
|
<data xmlns="http://www.netbeans.org/ns/make-project/1">
|
||||||
|
<name>IdiBusSlaveTemplate</name>
|
||||||
|
<creation-uuid>ba3551bc-e288-4eb1-944a-64a3b567ee1c</creation-uuid>
|
||||||
|
<make-project-type>0</make-project-type>
|
||||||
|
<sourceEncoding>ISO-8859-1</sourceEncoding>
|
||||||
|
<make-dep-projects>
|
||||||
|
<make-dep-project>../IdibusBootloader2560.X</make-dep-project>
|
||||||
|
</make-dep-projects>
|
||||||
|
<sourceRootList>
|
||||||
|
<sourceRootElem>.</sourceRootElem>
|
||||||
|
</sourceRootList>
|
||||||
|
<confList>
|
||||||
|
<confElem>
|
||||||
|
<name>default</name>
|
||||||
|
<type>2</type>
|
||||||
|
</confElem>
|
||||||
|
</confList>
|
||||||
|
<formatting>
|
||||||
|
<project-formatting-style>false</project-formatting-style>
|
||||||
|
</formatting>
|
||||||
|
</data>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
||||||
Loading…
Reference in new issue