46 #ifndef DS2485_H_INCLUDED 47 #define DS2485_H_INCLUDED 59 #define DS2485_I2C_7BIT_ADDRESS 0x40U 60 #define DS2485_I2C_CLOCKRATE 1000000U
63 #define DFC_WRITE_MEMORY 0x96; 64 #define DFC_READ_MEMORY 0x44; 65 #define DFC_READ_STATUS 0xAA; 66 #define DFC_SET_I2C_ADDRESS 0x75; 67 #define DFC_SET_PAGE_PROTECTION 0xC3; 68 #define DFC_READ_ONE_WIRE_PORT_CONFIG 0x52; 69 #define DFC_WRITE_ONE_WIRE_PORT_CONFIG 0x99; 70 #define DFC_MASTER_RESET 0x62; 71 #define DFC_ONE_WIRE_SCRIPT 0x88; 72 #define DFC_ONE_WIRE_BLOCK 0xAB; 73 #define DFC_ONE_WIRE_READ_BLOCK 0x50; 74 #define DFC_ONE_WIRE_WRITE_BLOCK 0x68; 75 #define DFC_ONE_WIRE_SEARCH 0x11; 76 #define DFC_FULL_COMMAND_SEQUENCE 0x57; 77 #define DFC_COMPUTE_CRC16 0xCC; 80 #define RB_SUCCESS 0 // No Failure 81 #define RB_ALREADY_PROTECTED -100 // Command failed because the protection for the page has already been set 82 #define RB_INVALID_PARAMETER -101 // Invalid input or parameter 83 #define RB_SET_ADDRESS_FAIL -102 // Command failed because I2C address has already been set 84 #define RB_MASTER_RESET_FAIL -103 // Master reset fail 85 #define RB_COMMS_FAIL -104 // Communication failure 86 #define RB_NO_PRESENCE -105 // 1-Wire presence pulse not detected 87 #define RB_NO_MATCH_WRITES -106 // Non-matching 1-Wire writes 88 #define RB_NOT_DETECTED -107 // Device not detected in search 89 #define RB_INCORRECT_CRC -108 // CRC16 incorrect 90 #define RB_INVALID_LENGTH -109 // Invalid length of data (0) 91 #define RB_LENGTH_MISMATCH -110 // Length byte does not match actual length of data (Rx Length Byte will be 0) 92 #define RB_WRITE_PROTECTED -111 // The command failed because destination page is protected (WP) 93 #define RB_UNKNOWN -112 // Unknown error 110 } DS2485_memory_page_T;
117 } DS2485_status_outputs_T;
121 WRITE_PROTECTION = 0x02,
122 NONE_PROTECTION = 0x20,
123 } DS2485_page_protection_T;
127 MASTER_CONFIGURATION,
128 STANDARD_SPEED_tRSTL,
131 STANDARD_SPEED_tRSTH,
136 OVERDRIVE_SPEED_tRSTL,
137 OVERDRIVE_SPEED_tMSI,
138 OVERDRIVE_SPEED_tMSP,
139 OVERDRIVE_SPEED_tRSTH,
140 OVERDRIVE_SPEED_tW0L,
141 OVERDRIVE_SPEED_tW1L,
142 OVERDRIVE_SPEED_tMSR,
143 OVERDRIVE_SPEED_tREC,
148 } DS2485_configuration_register_address_T;
408 } DS2485_full_command_sequence_delays_msecs_T;
411 int DS2485_WriteMemory(DS2485_memory_page_T pgNumber,
const uint8_t *pgData);
412 int DS2485_ReadMemory(DS2485_memory_page_T pgNumber, uint8_t *pgData);
413 int DS2485_ReadStatus(DS2485_status_outputs_T output, uint8_t *status);
414 int DS2485_SetI2cAddress(uint8_t newAddress);
415 int DS2485_SetPageProtection(DS2485_memory_page_T pgNumber, DS2485_page_protection_T protection);
416 int DS2485_ReadOneWirePortConfig(DS2485_configuration_register_address_T reg, uint8_t *regData);
417 int DS2485_WriteOneWirePortConfig(DS2485_configuration_register_address_T reg,
const uint8_t *regData);
418 int DS2485_MasterReset(
void);
419 int DS2485_OneWireScript(
const uint8_t *script, uint8_t script_length,
double accumulativeOneWireTime, uint8_t commandsCount, uint8_t *scriptResponse, uint8_t scriptResponse_length);
420 int DS2485_OneWireBlock(
const uint8_t *blockData,
int blockData_Length, uint8_t *ow_data,
bool ow_reset,
bool ignore,
bool spu,
bool pe);
421 int DS2485_OneWireWriteBlock(
const uint8_t *writeData,
int writeData_Length,
bool ow_reset,
bool ignore,
bool spu);
422 int DS2485_OneWireReadBlock(uint8_t *readData, uint8_t bytes);
423 int DS2485_OneWireSearch(uint8_t *romId, uint8_t code,
bool ow_reset,
bool ignore,
bool search_rst,
bool *flag);
424 int DS2485_FullCommandSequence(
const uint8_t *owData,
int owData_Length, uint8_t *rom_id, DS2485_full_command_sequence_delays_msecs_T ow_delay_msecs, uint8_t *ow_rslt_data, uint8_t ow_rslt_len);
425 int DS2485_ComputeCrc16(
const uint8_t *crcData,
int crcData_Length, uint8_t *crc16);
428 int DS2485_ExecuteCommand(
const uint8_t *packet,
int packetSize,
int delay_uSec, uint8_t *response,
int responseSize);
int DS2485_ExecuteCommand(const uint8_t *packet, int packetSize, int delay_uSec, uint8_t *response, int responseSize)
Platform-specific I2C command interface implemented in DS2485_port_xxxx.c Returns 'error' (0 if compl...