42 #ifndef DS2485_H_INCLUDED 43 #define DS2485_H_INCLUDED 55 #define DS2485_I2C_7BIT_ADDRESS 0x40U 56 #define DS2485_I2C_CLOCKRATE 1000000U
59 #define DFC_WRITE_MEMORY 0x96; 60 #define DFC_READ_MEMORY 0x44; 61 #define DFC_READ_STATUS 0xAA; 62 #define DFC_SET_I2C_ADDRESS 0x75; 63 #define DFC_SET_PAGE_PROTECTION 0xC3; 64 #define DFC_READ_ONE_WIRE_PORT_CONFIG 0x52; 65 #define DFC_WRITE_ONE_WIRE_PORT_CONFIG 0x99; 66 #define DFC_MASTER_RESET 0x62; 67 #define DFC_ONE_WIRE_SCRIPT 0x88; 68 #define DFC_ONE_WIRE_BLOCK 0xAB; 69 #define DFC_ONE_WIRE_READ_BLOCK 0x50; 70 #define DFC_ONE_WIRE_WRITE_BLOCK 0x68; 71 #define DFC_ONE_WIRE_SEARCH 0x11; 72 #define DFC_FULL_COMMAND_SEQUENCE 0x57; 73 #define DFC_COMPUTE_CRC16 0xCC; 76 #define RB_SUCCESS 0 // No Failure 77 #define RB_ALREADY_PROTECTED -100 // Command failed because the protection for the page has already been set 78 #define RB_INVALID_PARAMETER -101 // Invalid input or parameter 79 #define RB_SET_ADDRESS_FAIL -102 // Command failed because I2C address has already been set 80 #define RB_MASTER_RESET_FAIL -103 // Master reset fail 81 #define RB_COMMS_FAIL -104 // Communication failure 82 #define RB_NO_PRESENCE -105 // 1-Wire presence pulse not detected 83 #define RB_NO_MATCH_WRITES -106 // Non-matching 1-Wire writes 84 #define RB_NOT_DETECTED -107 // Device not detected in search 85 #define RB_INCORRECT_CRC -108 // CRC16 incorrect 86 #define RB_INVALID_LENGTH -109 // Invalid length of data (0) 87 #define RB_LENGTH_MISMATCH -110 // Length byte does not match actual length of data (Rx Length Byte will be 0) 88 #define RB_WRITE_PROTECTED -111 // The command failed because destination page is protected (WP) 89 #define RB_UNKNOWN -112 // Unknown error 106 } DS2485_memory_page_T;
113 } DS2485_status_outputs_T;
117 WRITE_PROTECTION = 0x02,
118 NONE_PROTECTION = 0x20,
119 } DS2485_page_protection_T;
123 MASTER_CONFIGURATION,
124 STANDARD_SPEED_tRSTL,
127 STANDARD_SPEED_tRSTH,
132 OVERDRIVE_SPEED_tRSTL,
133 OVERDRIVE_SPEED_tMSI,
134 OVERDRIVE_SPEED_tMSP,
135 OVERDRIVE_SPEED_tRSTH,
136 OVERDRIVE_SPEED_tW0L,
137 OVERDRIVE_SPEED_tW1L,
138 OVERDRIVE_SPEED_tMSR,
139 OVERDRIVE_SPEED_tREC,
144 } DS2485_configuration_register_address_T;
404 } DS2485_full_command_sequence_delays_msecs_T;
407 int DS2485_WriteMemory(DS2485_memory_page_T pgNumber,
const uint8_t *pgData);
408 int DS2485_ReadMemory(DS2485_memory_page_T pgNumber, uint8_t *pgData);
409 int DS2485_ReadStatus(DS2485_status_outputs_T output, uint8_t *status);
410 int DS2485_SetI2cAddress(uint8_t newAddress);
411 int DS2485_SetPageProtection(DS2485_memory_page_T pgNumber, DS2485_page_protection_T protection);
412 int DS2485_ReadOneWirePortConfig(DS2485_configuration_register_address_T reg, uint8_t *regData);
413 int DS2485_WriteOneWirePortConfig(DS2485_configuration_register_address_T reg,
const uint8_t *regData);
414 int DS2485_MasterReset(
void);
415 int DS2485_OneWireScript(
const uint8_t *script, uint8_t script_length,
double accumulativeOneWireTime, uint8_t commandsCount, uint8_t *scriptResponse, uint8_t scriptResponse_length);
416 int DS2485_OneWireBlock(
const uint8_t *blockData,
int blockData_Length, uint8_t *ow_data,
bool ow_reset,
bool ignore,
bool spu,
bool pe);
417 int DS2485_OneWireWriteBlock(
const uint8_t *writeData,
int writeData_Length,
bool ow_reset,
bool ignore,
bool spu);
418 int DS2485_OneWireReadBlock(uint8_t *readData, uint8_t bytes);
419 int DS2485_OneWireSearch(uint8_t *romId, uint8_t code,
bool ow_reset,
bool ignore,
bool search_rst,
bool *flag);
420 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);
421 int DS2485_ComputeCrc16(
const uint8_t *crcData,
int crcData_Length, uint8_t *crc16);
424 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)
Definition: DS2485_port_maxim.c:63